Talon SRX driving a motor with a quadrature encoder wired directly into the Talon.
Assuming the begin.vi has the Talon Set Ref wired to the digital quad encoder and is ID’d and is wired to the Config Encoder CPR…
Will the following autonomous.vi drive the motor 200 pulses followed by 100 pulses? Our robot is bagged so I can’t test.
CHANGE MODE is used to set the target and control mode registers. See section 3.3 in Talon SRX Software Reference Manual.
SET SENSOR POS is used to the set the current position register. Typically this is used to zero your sensor. See section 13 in Talon SRX Software Reference Manual.
You typically want to SET SENSOR POS once to zero your sensor, and use CHANGE MODE to periodically change the target position.
The units are in native sensors units, or in decimal rotations, depending on sensor selection and API calls. See section 17.2 for details.
You example might work if it only fires once (since it resets the position register), but you are much better off following our documented example.
Section 12.8. Motion Magic Closed-Loop Walkthrough documents the procedure. Use the LabVIEW github example instead of the Java one.
If you don’t have access to a robot, try to get a small setup with a roboRIO or HERO Robot Controller. The tuning math/procedure is language agnostic.
If you have a gearbox with a sensor, you could start testing/learning now.
So if I change the Talon Set Sensor Pos block to another Talon Change Mode block, will the motor drive one direction until the sensor reads 200 and then drive the other direction until the sensor reads 100?
What I’m trying to figure out is if the Talon finishes one Change Mode block/call before starting the next one. We are a rookie team so we don’t have any other controllers available this year.
I don’t think any particular VI in FRC blocks in the fashion you are describing. Not without sequence structures or similar.
Think about it this way, if you want to drive at percentVoltage V1 for T1 seconds, and then drive at V2 for T2 seconds, you need to wire the correct program flow to request V1 *until *T1, then request V2 *until *T2.
Learning how to begin an action, determine when it’s complete, and move to the next step is part of learning the programming interface. Example docs…
Personally I prefer state machines, but there are many ways to accomplish this. This is covered in many places.
Once you understand how to do that, then using motion magic is no different than the timed examle. Request Trgt1 *until *Target1-is-reached, then request Trgt2 *until *Target2-is-reached.
Thank you Ozrien!
That is exactly the information I was lacking.