Quadrature decoding to produce pulse + direction

More
30 Jul 2024 17:44 #306428 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?

 

Please Log in or Create an account to join the conversation.

More
30 Jul 2024 18:51 #306430 by tommylight
Hmmmm why?
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.

More
30 Jul 2024 19:13 #306432 by PCW
Yes, basically LinuxCNCs motion component already does this with the MPG count.

Please Log in or Create an account to join the conversation.

More
02 Aug 2024 09:45 #306706 by frogandspanner
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.

More
02 Aug 2024 13:02 #306728 by PCW
In any case LinuxCNC uses a count for jogging

You could combine MPGs by adding counts in hal

Please Log in or Create an account to join the conversation.

More
02 Aug 2024 13:07 #306729 by frogandspanner
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).

Please Log in or Create an account to join the conversation.

More
02 Aug 2024 13:18 #306731 by PCW
You can scale the individual counts
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.

More
02 Aug 2024 13:27 #306733 by frogandspanner
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.

Please Log in or Create an account to join the conversation.

More
02 Aug 2024 13:56 #306734 by PCW
Typically the scaling would be done by setting the jog increments.

Please Log in or Create an account to join the conversation.

More
02 Aug 2024 14:02 #306737 by Mecanix

but I want it to apply only after the bit has been set.

Potential rewrite/custom solution required. See 'old/new states' for inspiration.
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
Powered by Kunena Forum