View Full Version : Servo Help
12-09-2010, 06:12 PM
Since March I have been trying to develop a proper code for the servos. Recently I have been watching Labview tutorials from the FRC Mastery Tip Jar videos (http://www.lvmastery.com/tipjar) and have learned a great deal about clusters and creating codes via a typedef - in fact that is where I have gotten the idea to link up my objects and such. I have created a project and inside the begin VI i have created a separate typedef from the MatchInfo.ctl (for debugging purposes) and put a servo dev type into this cluster. I then linked it to the Teleop Vi where I used a unbundle by name to access this servo and then developed a code that would set the angles based on inputs from the controller. When I run this code nothing happens and all I get is an error that tells me that there is an improper refnum get. Must I use the refnum get and set for the latest Labview projects? Also, I am only trying to run one servo, not two so I don't need a splitter (if any clarity on this could be issued that would be great) and I have assumed that the black wire (i have black,red,yellow) is negative and have plugged it into the proper port on the PWM channel. If any one could help me on getting these darn things to work that would be helpful. Thanks
12-09-2010, 06:29 PM
I'd recommend probing the inputs to the Get. I suspect that the value assigned in begin isn't really being read, and that an empty string or default string is being used.
As for the rest, the code and wiring are pretty independent. You could test the wiring with simpler code, perhaps an example. Once you don't get an error when the code runs, you may be able to use that to determine if the wiring is correct.
12-09-2010, 06:51 PM
For the wiring you don't need a PWM splitter. You can plug the servo directly into a PWM output on the sidecar or add a straight extender cable.
For a servo you do need a jumper on the pair of pins directly beside the PWM output you've chosen to use. Jumping those pins passes 6v power though to the center PWM output pin and that is where the servo gets the power to move from.
I like using the simple servo example code Greg's team provided for testing that the servo is correctly wired up. You'll find it from the LabVIEW Startup Screen under more examples in the lower right.
12-09-2010, 06:55 PM
Ok. I think that this might work. So I'm guessing it's not a good idea to wire all of the devices to a typedef via bunddling with out setting the refnum first. Also, do these jumpers come with the Kit of Parts? If not what do they look like? I'll give this a shot and report my findings thanks! (ps. is there any way to test this without deploying onto the robot?)
12-09-2010, 09:59 PM
4 Jumpers came in the kit, in one of the small plastic bags mixed in with other electrical parts, probably with the Wago connectors. They are tiny and either white or black. You'll see the same jumpers already on your Jags in the limit switch slots, although they're unobtrusive, recessed into the Jag case and hard to notice.
Here is the KOP description and the picture (http://www.chiefdelphi.com/forums/attachment.php?attachmentid=8333&d=1263845559)
You can test and work out basic concepts such as generic use of typedefs on your PC by writing your own test programs under My Computer, but if your program uses anything from the WPI Robotics Library then you'll have to have the cRIO to test it.
12-10-2010, 06:23 AM
To further answer the question about deploying and testing. If you are testing the logic value of something algorithmic, you can write a quick VI to run on the PC. To do this, you can choose File >> New and if the lower left corner says the VI is targeted to the cRIO, right click on it and set it to My Computer. At that point, you can do math, strings, loops, and anything that doesn't do robot I/O.
There are also two ways of running on the robot. The way to debug is to simply press the run button on the VI. Typically in the framework, that is the RobotMain VI.
Later, when things are relatively bug-free, you Build the project and Set it as Startup, and reboot the cRIO.
I'd suggest going through the steps of a deployment tutorial if you haven't done it before.
12-10-2010, 06:26 PM
to Leod: Thanks for the advice on the Jumpers! The servos work perfectly now thank you so much.
to McKaskle: Thank you on your advice for running the VI"s separately. I also have another question. Instead of wiring separate refnums to each device that I open in the Begin.vi, could I instead add all the devices to a cluster and wire that to my teleop or whatever state that I am programming? Would this be essentially the same as opening a device-like a solenoid, setting it, and then closing it on the same DeviceRef wire that I opened it on as in a Basic Robot Main.vi ? Here is what I did:
http://www.chiefdelphi.com/forums/C:/Users/Boy/Pictures/deviceref.jpg Teleop: http://www.chiefdelphi.com/forums/C:/Users/Boys/Pictures/devicerefs.jpghttp://www.chiefdelphi.com/forums/attachment.php?attachmentid=9487&stc=1&d=1292027289
12-10-2010, 09:24 PM
The framework shows one way to pass data between the open, updates, and close. There are in fact many ways that will work, and if you understand how to make clusters and use parameters, then you are set.
12-10-2010, 09:50 PM
If i send you the full project could you tell me if there is an error? Every time I run the code I get errors dealling with Refnums on the Servo Get angle and Set angle.
12-11-2010, 06:37 AM
If you post a zip, someone can almost certainly spot the issue. If you want to debug it yourself, use probes and the run button.
12-16-2010, 07:15 PM
I think I found the problem but thanks for the advice!
vBulletin® v3.6.4, Copyright ©2000-2015, Jelsoft Enterprises Ltd.