# Jrk G2 21v3 controller and pololu 4.4:1 metal gearmotor: frequency feedback settings

Hi

I am trying to control a Pololu 4.4:1 metal Gearmotor (https://www.pololu.com/product/2281) with the Jrk G2 21v3. I am using frequency feedback as I need speed control.

The first thing I try to do is to calculate the pulse frequency tachymeter on the motor. The motors speed at 6V is 1300 RPM, and it has a gear ratio of 4.4. Therefore, the motor shaft turns at 95 Hz:

1300 x 4.4 / 60 = 95

The encoder gives 48 pulses per revolution. However, the JRK only uses one channel of the encoder, and on this page https://www.pololu.com/product/2281, it says: using just a single edge of one channel results in 12 counts per revolution of the motor shaft. So, the pulse frequency is

95 x 12 = 1140

As this is smaller than 5 Khz, the manual states I should use pulse timing and not pulse timing.

In JrkGui, I select the following settings:

• Measurement type: Pulse timing
• Pulse timing clock: 45 Mhz
• Polarity: High
• Timeout: 100
• Samples: 5
• Divider: 64

Now for my questions:

• Is my calculation of the pulse frequency correct?
• The GUI tells me that the upper-frequency range I can measure is 1.43 kHz. Which should cover the range I require (up to 1140 Hz). Is that correct?
• What does it mean that the lowest frequency I can measure is 35 Hz? Is this the lowest speed of the motor that can be controlled?
• How do I calculate the number of rotations of my motor as a function of the target (0-4095)? Can I assume that the range [-1.43Khz, 1.43kHz] is mapped on to the range [0,4095]?

Hello.

It sounds like you are on the right track and following the instructions in the “Setting up frequency feedback” section of the Jrk G2 user’s guide. Your calculations for the frequency range of your tachometer feedback look correct:

1300 \frac{rev}{min} × 4.4 × \frac{1 min}{60 sec} × 12 \frac{tick}{rev} = 1144 \frac{tick}{sec}

I suspect you have a typo in your pulse timing clock setting, since 45 MHz is not an option. Following the instructions listed in the “Setting up frequency feedback” section I mentioned above for configuring the “Pulse timing clock” and “Frequency divider” settings, you should have a Pulse timing clock of 3 MHz and a divider of 32. This results in a frequency measurement range of 35 Hz to 1.43 kHz. The upper limit is higher than the maximum frequency from your tachometer, so you should be good there. The lower limit is the slowest tachometer frequency that the controller can measure with those settings. You can find a detailed explanation of where that limitation comes from in the “Pulse timing clock” entry of that same “Setting up frequency feedback” section of the user’s guide.

If you followed the instructions to uncheck the “Invert feedback direction” box and click the “Reset to full range” button to effectively turn off feedback scaling, the Set Target value will correspond to the desired feedback value. Note that this value does not correspond to a number of rotations, but to a rotational speed. The way the Jrk G2 calculates the feedback value is described in the following paragraph from the “Setting up frequency feedback” section of the guide:

The Jrk will measure a pulse width (or average together multiple pulse widths) in units of the pulse timing clock ticks, and it will be a number between 0 and 65535 (0xFFFF). To convert this pulse width to a frequency, it will take 2 raised to the power of 26 (0x4000000, or 67,108,864) and then divide it by the pulse width. It will then divide this reading by the “Frequency divider” setting, which is a power of two between 1 and 32768. Finally, it adds or subtracts the reading from 2048 in order to set the “Feedback” variable, which is constrained to be within 0 to 4095.

Brandon

Hi Brandon

I am still struggling to understand how the pulse frequency is related to the feedback value. I have tried to convert this paragraph into an equation that relates pulse frequency and the feedback value, but my result seems nonsense.

Could you please provide an explicit equation that relates the feedback value to the pulse frequency?

The Jrk will measure a pulse width (or average together multiple pulse widths) in units of the pulse timing clock ticks, and it will be a number between 0 and 65535 (0xFFFF). To convert this pulse width to a frequency, it will take 2 raised to the power of 26 (0x4000000, or 67,108,864) and then divide it by the pulse width. It will then divide this reading by the “Frequency divider” setting, which is a power of two between 1 and 32768. Finally, it adds or subtracts the reading from 2048 in order to set the “Feedback” variable, which is constrained to be within 0 to 4095.

Hello.

If you simplify the calculation by making the assumption that the duty cycle of the tachometer feedback is 50%, the equation works out to:

Feedback = 2048 \pm \frac{2^{27}\cdot(\text{tachometer frequency})}{(\text{pulse timing clock frequency})(\text{frequency divider})}

Brandon

Thank you for this. Quick question though, should it be 2^{27} or 2^{26}? In the text, it says 2^{26}, but in your equation, you say 2^{27}.

Also, when I use the equation above, the GUI says that ‘the motor is running at maximum duty cycle’ at feedback values lower than the one that would correspond to 1144 Hz tachometer frequency.

The equation above tells me that the feedback value for a tachometer frequency corresponds to 3683. However, the GUI says that the motor is running at the maximum duty cycle for a feedback value of about 3400.

Is this to be expected or does this imply there is an error in my equations somewhere?

The equation Brandon posted is correct. The extra factor of 2 comes from the assumption that the duty cycle is 50%.

You have not provided enough information for us to tell what is going wrong. If you want help troubleshooting, please say what tachometer frequency you are trying to achieve and provide a screenshot of the Status tab of the Jrk G2 Configuration Utility while the system is in the state you described. Please also provide the settings file for your Jrk so we can see how you have configured it. You can save a settings file from the “File” menu of the Jrk G2 Configuration Utility. Please also tell us what power supply you are using, and any other relevant details about how you set up your system.

–David