04-23-2009 10:59 AM
Hi all,
I'm using a PCI-6221 to generate two pulse trains to control two servos. The servos I'm using are Futabo servos and work off a 1.5 millsecond high pulse, followed by a 20 millisecond low signal. The position of the servo is defined by expanding or reducing the high pulse by 0.5 milliseconds-1 millisecond is fully left, 2 milliseconds is fully right. I can generate one channel quite easily using my code below, but I am now trying to expand this to control two servos. When I simply copy and paste my code, Instead of getting a constant pulse on the two output channels, the code gives me three high pulses on one channel, followed by three on the other, causing havoc with the servos. I know I should be able to generate two pulse trains using this card, they aren't finite, they are user halted. I've tried all sorts of codings, using case structures, loops and timed sequences, but I always get the same (rather odd) oscilloscope readings. I am fairly sure the card is ok, as the channels work fine independantly.
Thanks for your help in advance!
Ed.
04-28-2009 12:09 PM
Ed,
If you just copy and paste you will end up with two differenct counter tasks that fight each other. You need to create a single task that contains both counters.
04-28-2009 01:30 PM
Hey Ed,
You're right, with continuous pulse trains you shouldn't have a problem and usually if the HW is bad counters won't work at all. I'm not sure that I understand the issue though - do the channels just stop generating? If you can grab a screenshot or draw up a timing diagram it would help, I usually end up at a whiteboard when talking about counters. With two counters in parallel, they will start at different times unless you use a start trigger - is this causing the problems? Can you include your completed code so we can test it out?
thanks,
Andrew S
04-29-2009 02:40 AM
04-29-2009 02:41 AM
04-29-2009 08:41 AM
Ed,
You have gaps in the pulse train because you are doing all the task overhead inside the loop. You are creating, starting and clearing the task every iteration of the loop. Code needs to look more like the first vi you posted that had the overhead stuff outside the while loop.