Real-Time Measurement and Control

Showing results for 
Search instead for 
Did you mean: 

Is CompactRio best solution for me?

Go to solution



You're more than welcome, we're happy to help.


To answer your question, you are correct that the 9403 is a bidirectional module and it is possible to set line direction on a line by line basis.  That means that you should be able to generate 16 PWM outputs and monitor 16 PWM inputs with the one module.  What is the period of the PWM signals you are interested in?


Just note that you will have to program the FPGA if you want to generate PWM / measure PWM inputs with the 9403.  The scan interface speciality digital functionality is not supported on the 9403 at this time.


Let me know if you have any other questions.


0 Kudos
Message 11 of 22



Thank you again for following up on my project. Please excuse my ignorance in this, but I am not sure how to determine exact requirements of PWM period that you asked me about. In my design, I will have a PWM Joystick which will control proportional hydraulic valves. The valves will control hydraulic motors (motion) and cylinders (grip). If I understand this technology correctly, the output of Joystick will be connected to the input of RIO module and the module will amplify/filter the signal and send correct output to the valves. Is the PWM period dependant of Joystick characteristics or is it determined by the demand of application (ie how precisely and smoothly we want to control valves)?

Again, I greatly apprecate your help. I do know a lot about mechanics/hydraulics and software applications, but when it comes to modern automation, I am still learning.



0 Kudos
Message 12 of 22

Hello Milen,


This article should help answer some of your questions and actually explains how to write a good part of the code you're going to need.


Briefly, PWM works with a fixed period.  The idea is that for any given period the signal will be high for some part of it and low for the rest.  The amount of time the signal is high as a percentage of the total period is refered to as the duty cycle.  The duty cycle is the part of the PWM signal that is changed to change the meaning of the signal (hence the name, Pulse Width Modulation).  For example a 30% duty cycle and a 1kHz PWM frequency (1000 us period) would mean that the signal is high for the first 300 us and low for the remaining 700 us.  This pattern will repeat until the duty cycle is changed.  Your joystick may be able to operate at a range of PWM periods, but you'll need to look at the manual to see what to expect.


The reasons I asked about the period you were dealing with is a speed issue.  As you can see in the article linked above the way to determine the duty cycle of an incoming pulse is to monitor for the rising and falling edges of the signal in the FPGA code.  With the 9403 you can only check the signal ever 7 us, so you can see that there is always going to be some error in your measurement.  With the 9403 the worst case is going to be 7 us + some setup and hold time.  Similarly when you drive the output signal you can expect it to take 7 us to respond.  You need to decide if this error is acceptable for your application or if you require faster sampling.  How bad it is depends a lot on the time periods invovled.  The longer the period the less signifigant the issue.  NI has modules with 1 us and 100 ns sample times as well. 


You need to think along similar lines for the encoder.  Encoder processing also works by monitoring for edges on digital lines.  With encoders it is less how quickly you detect the edge, although this does affect how up to date your position data is, but it is more that if you happen to miss an edge (as in the signal goes high and then low again without ever being sampled) then position data is lost.

Message Edited by speleato on 02-05-2009 01:09 PM
0 Kudos
Message 13 of 22

Hi Speleato,


This was a great explanation. I think I understand this PWM business better now - higher the frequency, better the control. PWM ideally is square wave, bit in reality it will have raising and falling curves (delays), so higher frequency will make more of the signal count and les lost info. Basically, the accuracy will mostly depend upon the processing power of RIO and accompanying module. In that case, I think I should go with the fastest modules. This brings a question - do I have a double probem here? The module input is the signal from the Joystick and the output is the same signal amplified and sent to the valves. Is there maybe some slicker solution for this (ie dedicated Joystick controller)? Attached is controller that they sugges for their Joystick, but it looks much inferior in processing power than RIO modules. Please let me know whit you think if you find some time to check attached controller.


Thanks a lot. 

0 Kudos
Message 14 of 22



You are correct that using a module that can sample at a higher frequency will give a better indication of what the output of the joystick is and will let you generate a more accurate output signal.  The reason for this is not so much that PWM signals are not perfectly square (which incidentally is true) but more because it shortens the interval between IO updates.  If I understand what you wrote, I'd like to clarify that I was referring to the the sample rate here and not how quickly the signals can change state.  For the 9403 output signals stabilize in a few hundred nanoseconds.


I've put together a simple (and admitedly rather crude) timing diagram that illustrates what I'm talking about here.  What you can see is that the system samples the waveform at Sample 1 and again after a time interval t, at Sample 2.  At sample 1 the signal is high and even though the signal goes low shortly after sample 1 the system has no idea until it samples again.  All we really know is that at some point between Samples 1 and 2 there was a falling edge.  The duration of t is equivalent to the sample rate of the module.  Increasing the sample rate, decreases t and will give you a better idea of when that edge happened.  Measuring PWM signals is all about measuring the time between edges so this has a direct effect on how well you know the true duty cycle of the signal.


Where the PWM period comes in is that it determines how wide the pulse will be in real terms.  With a 1Hz PWM a 50% duty cycle signal will have a 5000 us wide pulse.  In that case a worst case error of 7 us is basically inconsequential in all but the most demanding applications.  On the other hand if you are doing 10kHz PWM a 50% duty cycle signal only has a 50 us wide pulse and 7 us is quite significant.  You'll need to decide what is acceptable based on the error you can tolerate and the signals you are dealing with.  Unfortunetly all of our faster modules are also lower channel count so you'll need to balance that too.


I took a quick look at that controller but before I can really comment I'd like to know a bit more about what you intend to do.  Why are you passing the PWM signal through the cRIO, do you need to use the joystick information for additional processing or is it truely just fowarded to the valves?  Also what kind of levels do you need to amplify the signal to for the valves


Do you have data sheets for the valves and joystick you intend to use?


Message Edited by speleato on 02-05-2009 04:36 PM
0 Kudos
Message 15 of 22
My mistake, the pulse in the 1Hz case would be 500,000 us wide.  If anything then 7 us is even more insignificant.
0 Kudos
Message 16 of 22



Joystick will just control valves, no other functions in the system, but cannot drive coils directly. That is why we need to amplify signal from the joystick trhrough the PWM controller. Attached are datasheets of Joystick and one of the valves I will be using. I hope it will give you a clue regarding PWM required. 

Download All
0 Kudos
Message 17 of 22

Hello Milen,


Thank you for the datasheets, I think I understand better now the application you have in mind.


The joystick datasheet states that the joystick outputs a 500 Hz PWM signal from ~20% to an ~80% duty cycle depending on the position of the joystick.  Any number of modules can be used to read this signal.  I'd probably recommend at least a 1 us module for good control.


The valves appear to allow fluid to flow in a manner proportional the current applied to the solenoid coil.  In this case PWM is used to generate a variable current signal from a constant voltage source.  The coil acts like a low pass filter and smooths out the signal.  The flow vs. current graph shows flow values for currents as high as 1.2 amps


The 9474 is the best option you have as it can supply up to 1A but as I understand the graph in the data sheet correctly it will fall short of fully opening the valve.  The 9505 can supply 8A of continous current but it is only one channel per module and you need 16 channels so many controllers and modules will be required. 


With all that in mind, and given the fact that you don't need to monitor the joystick in your software, I'd suggest looking at controllers designed for the valves.  I noticed the data sheet refers to a page in the Electronics catalog with recommended controllers so you may want to look at that.  My guess is that the controllers will take a control signal of some sort and will output a current to the valves based on this control signal  If you have access to that pdf, feel free to post it and I'll take a look at it.


For the control signal you may be able to connect the joystick directly to the controller or you may need to change the signal to another format.  If you need to convert the control signal, you can revisit using the CompactRIO in this part of the system.


I do still CompactRIO is a good choice for the rest of your system.  That is, reading the load cell, the encoder, operating the dump valve, logging data etc.



0 Kudos
Message 18 of 22



Attached is controller that the manufacturer makes for the joystick / valves. It has 72 inputs and 26 outputs and also various communications capabilities. My concern is whether it is fast enough (I would guess it is) but more importantly whether it could br incorporated in Labview (does Labview have drivers for it?). It is not because I need to software-control joystick and valves, but because the original software and programmiing are very complicated and cumbersome. Please let me know your opinion.


Thanks a lot
0 Kudos
Message 19 of 22

Hi Speleato,


Attached is technical reference for ECU controller. It has lot of information.



0 Kudos
Message 20 of 22