FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Opening a new motor reference in Advanced Project

Having gotten our new control system up and running, I am running through the examples and project templates.  I am finding no problems with the Basic Framework, adding motors and sensors.  However, I seem to have no luck in the Advanced Framework.  The RobotData Global seems to have an array of motor refs.  In Teleop.vi, I place the open and setspeed vi's in place with appropriate constants to set the pwm ref.  However, the new motor does not react as programmed?

I am obviously missing a simple but critical item here!  I would appreciate your assistance.

0 Kudos
Message 1 of 5
(6,371 Views)

The motor array in the RobotData cluster is from the RobotDrive Device Reference. You shouldn't access those directly, use the RobotDrive VIs.

The important thing to realize is that the telop vi is called once each time a new packet is received from the driver station. Thus you are opening the motor reference every new packet (50hz). I bet if you look at the ErrorDisplay VI, there will be a lot of errors about reopening the same hardware.

You have a couple of options of where to put the open motor. You could stick it in Begin.vi, and modify the RobotData cluster to contain the device reference for the new motor. You could open it in the the init state of the telop vi, and modify the RobotData cluster to contain the device reference (see how the joystick is done in telop). Or, you could open the motor in init, then use feedback node to keep the reference around for the next time telop is called.

There are instructions for modifying the cluster in the Using the FRC Framework document. We've chosen to do all the opening in Begin.vi, so the device references are availible everywhere.

0 Kudos
Message 2 of 5
(910 Views)

But if I want to use a motor for something other than a drive motor, I presume I use a Open Motor vi, right? Do I put a refernce to that motor in the RobotData.ctl?

0 Kudos
Message 3 of 5
(910 Views)

Yes, you do need to use the open motor vi for additional motors.

The RobotData.ctl is a typedef. When you add device references there, you basically save space for the device reference. Then you need to hook up the device reference in the RobotData cluster with the output from the open motor vi.

I've attached our current RobotData.ctl and Begin.vi so you can see how we did it. I apologize that it isn't very clean.

0 Kudos
Message 4 of 5
(910 Views)

Thank you!

0 Kudos
Message 5 of 5
(910 Views)