Quadrature decoding to produce pulse + direction
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
30 Jul 2024 17:44 #306428
by frogandspanner
Quadrature decoding to produce pulse + direction was created by frogandspanner
I am building an MPG control for a Chinese 920 lathe I am converting to CNC. I want the controls to have the same intuitive feel as the original manual lathe, with the option of overriding to use full CNC, so will be fitting an MPG where the standard controls would be. I have the prototype setup working, using _encoder_ to decode the quadrature encoding (it is strange the the decoder component is called "encoder"). This produces a count, but I'd also like quadrature decoded to pulse + direction for further processing.
Is there any way of doing that with standard HAL components?
Is there any way of doing that with standard HAL components?
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 18657
- Thank you received: 6266
30 Jul 2024 18:51 #306430
by tommylight
Replied by tommylight on topic Quadrature decoding to produce pulse + direction
Hmmmm why?
LinuxCNC can use any encoder as MPG, so no need to convert anything, even on parallel port it works.
LinuxCNC can use any encoder as MPG, so no need to convert anything, even on parallel port it works.
Please Log in or Create an account to join the conversation.
30 Jul 2024 19:13 #306432
by PCW
Replied by PCW on topic Quadrature decoding to produce pulse + direction
Yes, basically LinuxCNCs motion component already does this with the MPG count.
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Aug 2024 09:45 #306706
by frogandspanner
Replied by frogandspanner on topic Quadrature decoding to produce pulse + direction
I don't want the count - I want pulse + direction so I can combine decoded pulses from the quadrature encoder/MPG with pulses from other sources.
Please Log in or Create an account to join the conversation.
02 Aug 2024 13:02 #306728
by PCW
Replied by PCW on topic Quadrature decoding to produce pulse + direction
In any case LinuxCNC uses a count for jogging
You could combine MPGs by adding counts in hal
You could combine MPGs by adding counts in hal
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Aug 2024 13:07 #306729
by frogandspanner
Replied by frogandspanner on topic Quadrature decoding to produce pulse + direction
That's what I currently do, but I wish to extend this to apply different scales at different time to the combined streams of pulses to produce the count.
For example, I wish to have a switch that reduces the MPG count:pulse ratio, then revert to the original ratio. I also wish to combine that count with another count (which may have a similar scaling switch).
For example, I wish to have a switch that reduces the MPG count:pulse ratio, then revert to the original ratio. I also wish to combine that count with another count (which may have a similar scaling switch).
Please Log in or Create an account to join the conversation.
02 Aug 2024 13:18 #306731
by PCW
Replied by PCW on topic Quadrature decoding to produce pulse + direction
You can scale the individual counts
take a look at
scaled_s32_sums.comp
(this may only be in master)
take a look at
scaled_s32_sums.comp
(this may only be in master)
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Aug 2024 13:27 #306733
by frogandspanner
Replied by frogandspanner on topic Quadrature decoding to produce pulse + direction
But does that apply to the counts, or the counts since a certain condition/time/bit being set?
If it applies to *all* counts then it doesn't do what I want as if I am rotating my MPG, then set the bit that changes scale it would apply to the accumulated, but I want it to apply only after the bit has been set.
If it applies to *all* counts then it doesn't do what I want as if I am rotating my MPG, then set the bit that changes scale it would apply to the accumulated, but I want it to apply only after the bit has been set.
Please Log in or Create an account to join the conversation.
02 Aug 2024 13:56 #306734
by PCW
Replied by PCW on topic Quadrature decoding to produce pulse + direction
Typically the scaling would be done by setting the jog increments.
Please Log in or Create an account to join the conversation.
02 Aug 2024 14:02 #306737
by Mecanix
shadowcode.io/quadrature-decoder-verilog/
Better yet, use flags!!
Replied by Mecanix on topic Quadrature decoding to produce pulse + direction
Potential rewrite/custom solution required. See 'old/new states' for inspiration.but I want it to apply only after the bit has been set.
shadowcode.io/quadrature-decoder-verilog/
Better yet, use flags!!
Please Log in or Create an account to join the conversation.
Time to create page: 0.699 seconds