Hi all,
I'm trying to interface a single ended encoder for an MPG handle.
I understand that a "mux" statement must be used in my init.c file. 4 questions:
1 Can I modify the mux statement to include only one encoder multiplexed to one set of pins on jp6. I think I would need something like:
// Mux encoder inputs from KFLOP JP7 & JP5 to JP4 and JP6
FPGAW(ENC_NOISE_FILTER_ADD) = ENC_7_JP6 + ENC_NOISE_FILTER_DEFAULT_VAL;
if this is correct, which pins on jp6 would i use for MPG phase A and B?
2 How can I test if this is working, not sure how to assign a dro to simply look and see if the single ended MPG incoder is working?
3 Does the mux statement belong in the setup portion of the C program or loop?
4 I think I have to also include a statement in the C to invoke the MPG to start counting, again "setup" or "loop"?
MPG and MUX definitions
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2786
- Joined: Mon Dec 04, 2017 1:49 am
Re: MPG and MUX definitions
Hi Dennis,
To use JP6 code:
When JP4 or JP6 are used the 4 AB encoder inputs occupy the first 8 inputs on the connector in logical order.
For JP6 encoder #4 would have its A signal on IO26 Pin5 and IO27 Pin6
If you wish to use connector JP4 instead of JP7 or JP6 instead of JP5 you can use the mux.I understand that a "mux" statement must be used in my init.c file. 4 questions:
No. There isn't the option to move individual encoder inputs. The only options are to move all 4 encoder inputs from JP7 to JP4 and/or all 4 encoder inputs from JP5 to JP6. Note because encoder signals are inputs, pins can still be used as general purpose IO if the encoder channels are not needed.Can I modify the mux statement to include only one encoder multiplexed to one set of pins on jp6. I think I would need something like:
// Mux encoder inputs from KFLOP JP7 & JP5 to JP4 and JP6
FPGAW(ENC_NOISE_FILTER_ADD) = ENC_7_JP6 + ENC_NOISE_FILTER_DEFAULT_VAL;
if this is correct, which pins on jp6 would i use for MPG phase A and B?
To use JP6 code:
Code: Select all
// Mux encoder inputs from KFLOP JP5 to JP6
FPGAW(ENC_NOISE_FILTER_ADD) = ENC_4_7_JP6 + ENC_NOISE_FILTER_DEFAULT_VAL;
For JP6 encoder #4 would have its A signal on IO26 Pin5 and IO27 Pin6
Configure an axis to have Input mode encoder and configure the Input Channel 0 to the Encoder Input Channel (4). After KFLOP is configured the Encoder count can be viewed on the KMotion.exe Axis Screen. You might also check that IO26 and 27 toggle on KMotion's Digital IO Screen when the encoder is moving.How can I test if this is working, not sure how to assign a dro to simply look and see if the single ended MPG incoder is working?
The setup portion3 Does the mux statement belong in the setup portion of the C program or loop?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 3
- Joined: Fri Nov 24, 2023 3:12 pm
Re: MPG and MUX definitions
Thanks for the response Tom,
My reason to want to move only one enxoder to JP6, the lathe I'm working on will eventually have 6 axis of coordinated movement using differential. I want to start the retro simple at first, two axis. I want to reserve every differential input I have for the other axis to be added in the future.
I'm guessing I will need to purchase a differential MPG encoder to work with the Kanalog board or purchase an off the shelf converter.
Is there any way to fake a single end signal without having to purchase additional hardware? Pull up, Pull down, capacitor, If I move the single ended mpg handle, it it will count, but only after hitting reset (init.c) and this includes moving an axis motor with differentiall output, that's connected properly. To be more clear, I have one axis motor connected to JP1 channel 0 (encoder only), and when I turn the motor shaft the DRO doesn't count live changes, but will wait for the reset to register the counts, just like the single ended mpg I have connected to JP2 channel 7.
I may be expecting the wrong response, I have only used kflop\kanalog with mach 3 interface and don't really know if the motor shaft movement without being commanded, will actually live change the DRO without a commanded position.
Thanks in advance, as always I appreciate all of your help.
Dennis
My reason to want to move only one enxoder to JP6, the lathe I'm working on will eventually have 6 axis of coordinated movement using differential. I want to start the retro simple at first, two axis. I want to reserve every differential input I have for the other axis to be added in the future.
I'm guessing I will need to purchase a differential MPG encoder to work with the Kanalog board or purchase an off the shelf converter.
Is there any way to fake a single end signal without having to purchase additional hardware? Pull up, Pull down, capacitor, If I move the single ended mpg handle, it it will count, but only after hitting reset (init.c) and this includes moving an axis motor with differentiall output, that's connected properly. To be more clear, I have one axis motor connected to JP1 channel 0 (encoder only), and when I turn the motor shaft the DRO doesn't count live changes, but will wait for the reset to register the counts, just like the single ended mpg I have connected to JP2 channel 7.
I may be expecting the wrong response, I have only used kflop\kanalog with mach 3 interface and don't really know if the motor shaft movement without being commanded, will actually live change the DRO without a commanded position.
Thanks in advance, as always I appreciate all of your help.
Dennis
- TomKerekes
- Posts: 2786
- Joined: Mon Dec 04, 2017 1:49 am
Re: MPG and MUX definitions
I think those would be the best solutions. Converters are inexpensive such as this.I'm guessing I will need to purchase a differential MPG encoder to work with the Kanalog board or purchase an off the shelf converter.
You could use an inverter. Or a differential line driverIs there any way to fake a single end signal without having to purchase additional hardware? Pull up, Pull down, capacitor

I'm not sure I understand. Are you looking at KMotionCNC DROs? Or KMotion Axis Screen? For an axis to count encoder pulses it must be configured as Input Mode Encoder and the correct encoder channel specified.If I move the single ended mpg handle, it it will count, but only after hitting reset (init.c) and this includes moving an axis motor with differentiall output, that's connected properly. To be more clear, I have one axis motor connected to JP1 channel 0 (encoder only), and when I turn the motor shaft the DRO doesn't count live changes, but will wait for the reset to register the counts, just like the single ended mpg I have connected to JP2 channel 7.
For KMotionCNC to display encoder positions it must be configured to display Encoder position rather than commanded Destination. (Blue DRO). See here.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.