Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

analog input-output PWM for servo with crio

Hello everybody,

First of all, I am new to labview, compactrio, etc... But I searched on the forum and didn't find an answer to this question. 

For a school project, we have to built a 'compactrio controlled RC car'. 

In a standard RC car, the user of the car sends the signal with a transmitter to the receiver. The receiver demodulates the signal of the transmitter and sends a PWM signal to the servos(brake, steering)/engines with 3 wires (-,+ and signal). The PWM signal has a frequency of 50Hz (20ms) and a duty cycle between 1 (servo to the left) and 2ms (servo to the right). 1,5ms is neutral.

In this RC car project, we want to send the signal of the receiver to the compactrio and from the compactrio to the servo. For this, we have a crio 9074 chassis, a NI 9205 analog input module and a NI 9264 analog output module. For a first test, we only connected one servo. Connection is as folows: 'signal' from receiver to the AI0, '-' from receiver to the COM of the 9205 module, 'signal' from servo to the AO0 and '-' from servo to the COM of the 9264 module. 

In labview, we thought it was as simple as connecting input with output in a timed loop. We used the real time, scan mode and created a .vi on the compactrio (with just a timed loop and a connection between AI0 and AO0). When we compare input with output, the output seems to be too slow. The output pulses are wider than the input pulses. When we change the duty cycle of the input signal with the controller (transmitter), the width of the output signal doesn't change but sometimes shows multiple pulses instead. What is the problem here?

In a next step, we tried to create an analog PWM output signal based on an example in labview (pwm2.vi). Is this correct? The servo doesn't react as we want, but we don't know if this is due to a problem in the labview code, or due to the timing of the pwm (time high and time low, real frequency of PWM signal send out by receiver is not exacty 50Hz but 53Hz). 
 
Thank you for your help.

0 Kudos
Message 1 of 2
(7,241 Views)

Hi JP

 

The PWM example you downloaded is correct, but it is meant to run on the FPGA of the cRIO system, not on the real-time controller.

 

Using the cRIO in Scan mode in combination with an analog output module in this case will never allow you to create a proper PWM signal. The cRIO Scan engine does not support update rates > 1 kHz, meaning that you have a maximum update rate of 1ms on your output (so also the pulse width will vary with with minimum 1ms).

 

In general, what you want in this case is a high speed digital output module such as the NI 9401. This kind of module will allow you to get an accurate and TTL compatible digital output signal, which is what a servo requests in general. With a digital module you can also configure the scan mode to output a PWM on the module, while you only have to write to duty cycle to the I/O variable.

 

If you don't have access to a digital module, you can still try with the analog output module. In this case however you will have to go through programming the FPGA to achieve the maximum 25 kS/s update rate of the analog output module. It will probably work, but will be a little bit thougher...

 

Good luck!

Best Regards

Michiel
Applications Engineer
NI Belgium
Message 2 of 2
(7,216 Views)