5.2. Setting up analog feedback
This section explains how to connect an analog feedback signal to the Jrk G2 and configure the Jrk G2 to do position control. Please note that this is different from setting up an analog control signal, which is documented in Section 6.4.
Connecting analog feedback
If you have not done so already, you should follow the instructions in Section 4.3 to configure and test your motor. Next, with the system unpowered, connect your analog feedback signal to the Jrk as described below.
If you are using a potentiometer to generate the analog feedback signal, then you should connect the potentiometer’s wiper to FBA. You should connect the other two ends of the feedback potentiometer to the power pins that are in line with FBA: on the Jrk G2 18v27 and 24v21, the pins are AUX and GND, while on the other Jrk G2 versions the pins are AUX and POT−.
Connecting analog voltage feedback to the Jrk G2.
If you are using something other than a potentiometer to generate the analog feedback signal, make sure that the ground node of that device is connected to a GND pin of the Jrk, and that the signal from that device is connected to the FBA pin. The Jrk can only accept signals between 0 V and 5 V with respect to GND; signals outside of this range could damage the Jrk.
Configuring and calibrating analog feedback
Now connect your Jrk to your computer via USB. In the Jrk G2 Configuration Utility, go to the “Feedback tab” and set the “Feedback mode” to “Analog voltage”.
If you are powering a feedback potentiometer from the AUX pin, you should check the “Detect disconnect with power pin (AUX)” checkbox. This causes the Jrk to drive AUX low periodically to help detect whether the feedback potentiometer has been disconnected.
Go to the “Errors” tab and set the “Feedback disconnect” error to “Enabled and latched”. Click the “Apply settings” button.
Turn on motor power.
In the “Scaling” box of the “Feedback” tab, click “Learn…” to start the feedback setup wizard.
Steps 1 and 2 of the feedback setup wizard helps you configure the direction of your motor and the direction of your feedback. These steps ensure that a positive duty cycle corresponds to the motor moving in the direction that you consider to be forward in your system, and that this forward movement also causes the Jrk’s “Scaled feedback” variable to increase.
Step 3 of the feedback setup wizard lets you set the range of your feedback.
If possible, the range you enter in step 3 should be at least a little larger than the range of motion that you actually plan on using. Raw feedback values within this range get mapped to “Scaled feedback” values from 0 to 4095. Raw feedback values outside of the range will be mapped to a “Scaled feedback” value of either 0 or 4095, depending on whether they are below or above the range. The Jrk’s PID algorithm does not look at the raw feedback variable: it compares the “Scaled feedback” to the “Target” and drives the motor in attempt to eliminate the difference between those two, also known as the “Error”. If you set the “Target” to 0 or 4095 but something pulls your system outside of the feedback range entered in step 3, the “Scaled feedback” variable will not change so the Jrk will not know it should drive the motor to get the system back within the desired range.
Once you have finished the wizard, the new settings should be applied to the Jrk.
Testing basic feedback
At this point, the Jrk is almost ready to do position control. Go to the “PID” tab and enter a “Proportional coefficient” of 1, while leaving the other two coefficients set to zero. This will probably drive your motor at its maximum duty cycle, so make sure that this and other motor parameters are configured correctly. Click “Apply settings”.
Use the target slider at the bottom of the window to send various target values to your Jrk, and see how it behaves. The red dot on the slider shows the “Scaled feedback” value.
If you did everything correctly, your feedback system should now be active, approximately following the target value.
Troubleshooting basic feedback
If the steps above do not result in a working position feedback system, these tips can help you figure out what is wrong and get the system working.
First of all, look in the “Errors” tab and look at the status message at the bottom of the Jrk G2 Configuration Utility. These messages might tell you why things are not working.
It is possible that you did not do one of the steps of the Feedback wizard correctly. You might consider trying the wizard again and carefully reading each instruction.
To troubleshoot effectively, you should know a little bit about how the Jrk’s PID algorithm works.
- During each PID update period (which is 10 ms by default), the Jrk measures the analog voltage on the FBA pin and uses that to set the (raw) “Feedback” variable, which you can see in the Status tab of the Jrk Configuration Utility. A value of 0 should represent 0 V, while a value of 4092 represents approximately 5 V.
- The Jrk scales the raw feedback value using the scaling settings from the “Feedback” tab in order to compute the “Scaled feedback” value, which is also a number between 0 and 4095. Raw feedback values above the “Maximum” feedback value get mapped to a “Scaled feedback” value of 4095 (if the feedback direction is not inverted) or 0 (if the feedback direction is inverted. Raw feedback values below the “Minimum” feedback value get mapped to a “Scaled feedback” value of 0 (if the feedback direction is not inverted) or 4095 (if the feedback direction is inverted).
- The Jrk’s PID algorithm calculates the “Scaled Feedback” minus the “Target” (which is called the Error), multiplies it by the proportional coefficient, then multiplies by −1, and assigns that value to the “Duty cycle target” variable (assuming the derivative and integral coefficients are zero). A “Duty cycle target” of −600 represents full speed reverse while a “Duty cycle target” of 600 represents full speed forward, but the target can be outside of this range. A proportional coefficient of 1 means that the “Target” and “Scaled feedback” have to differ by 600 counts before the Jrk will drive the motor at full speed.
- The Jrk applies max duty cycle, max acceleration, and other motor limits to the “Duty cycle target” to produce the “Duty cycle” variable between −600 (full speed reverse) and 600 (full speed forward).
- The Jrk drives the motor at the specified duty cycle. The direction of the motor is determined by the sign of the “Duty cycle” variable and the “Invert motor direction” setting, which was determined in step 1 of the feedback setup wizard.
The “Status” tab displays the “Feedback”, “Scaled feedback”, “Target”, “Error”, “Duty cycle target”, and “Duty cycle” variables so you can see what is happening at each step of this process and figure out exactly where things are going wrong:
- Measure the analog voltage on the FBA pin with respect to GND and make sure it accurately reflects the position of your system.
- Compare those measurements to the “Feedback” variable, and make sure it accurately reflects the voltage on the FBA pin as described above.
- Make sure that the “Scaled feedback” values goes to roughly 4095 at your system’s extreme forward position (according to your definition of forward for your system), and goes to roughly 0 at your system’s extreme reverse position. If not, the feedback scaling settings should probably be adjusted.
- Make sure that the “Duty cycle target” is equal to the “Target” minus the “Scaled feedback” (assuming your proportional coefficient is 1 and the other coefficients are 0).
- Make sure that the “Duty cycle” responds properly to changes in the “Duty cycle target”. If the “Duty cycle” is not being calculated properly, check the limits in the “Motor” tab.
- Make sure that the “Duty cycle” goes below −150 (−25%) or above 150 (25%) when you try to drive the motor, or else you might not be applying enough power to actually move the motor.
- Make sure that when the motor is moving, a positive duty cycle corresponds to forward movement (according to your definition of forward for your system), while a negative duty cycle corresponds to reverse movement. If this is not the case, you should toggle the “Invert motor direction” checkbox in the “Motor” tab or retry the feedback setup wizard.
- Make sure that when the motor is moving with a positive duty cycle, the scaled feedback value is increasing, and that when the motor is moving with a negative duty cycle, the scaled feedback value is decreasing. If this is not the case, you should toggle the “Invert feedback direction” checkbox in the “Feedback” tab or retry the feedback setup wizard.
Tuning the PID coefficients
After getting a basic feedback system working, you might want to tune it for better performance. You should first increase your “Max. duty cycle”, and other limits to reasonable values for high-performance operation of your system. Tuning the PID coefficients might also be worthwhile. We are working on adding more information about tuning the PID coefficients to this section. In the meantime, you might find the “Tuning the PID constants” subsection of the Setting Up Your System section in the orignal user’s guide for the original Jrk controllers to be helpful, even though it was written for a different product.