Real-Time Measurement and Control

Showing results for 
Search instead for 
Did you mean: 

cRio 9014, controlling digital output signal (9476) based on analog signal (9221) using FPGA - control aspect

Hi Rob,


Just posting this question again.


I am doing another project in which i am reading analog data using cRio 9014, may be frequency and some other things, but based on analog signals (temperature in this case) I have to control a digital output signal or inother words turn ON or OFF a heating source. I have done lots of acquiring stuff but have not done the control element. We have digitial output 9476 module we can use. Can you please show me some place to look for an example to build such a program using FPGA?


I will appreciate a lot.





Hey Ajay,


Might be best to open a new thread on this unrelated topic, but you have a pretty straightforward control need. You could do something as simple as:


while loop(

(read analog temperature = temp)

if(temp < setpoint)

    dig channel 0 = TRUE


    do nothing



I know this is text pseudocode, but with your experience you should be able to convert that pretty easy to G with a while loop, less than symbol, and a case structure. The control gets more complicated if you want to add PID control, hysteresis(would be a good idea), or pulse width modulation of the heater element, but those topics are very specific to application needs and cannot easily be answered on forums.



To bring this back around to the GPS question, one will be starting out with something simple such as

while loop(

read current position(x, y)

compare (x,y) to (desired x, desired y)

Turn motors on or off as needed at calculated power and direction (ie, if we only have to go a short distance, no need to turn motor to 100% power or you will overshoot)


This is greatly simplified since it assumes a cartesian coordinate system with a motor for X and a motor for Y, however we all know most robots do not have that, they have a direction they are pointing and it takes a certain distance to get to the correct facing direction. For example, if I have to drive straight north, and I am facing West, I am going to have to move a little west as I turn before I am facing north. Most robotics also integrate encoders on the wheels to approximate distance travelled and to make a better closed-loop control system. I say approximate because there is always minor slip in wheels.

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video





Thank you very much, its always a pleasure taking to you.


I believe this while loop sits in the and then pass this true or False back to FPGA part of the program? is that right.


Appreciate your help.



0 Kudos
Message 1 of 3

Hello Ajay,


Thanks for starting a new thread for this new topic.  I wanted to go ahead and answer your question, and Rob can chime in if he has some other info for you.


You can run your control loop either in the Host VI or on the FPGA directly - there are pros and cons to each approach.  You will have faster and more deterministic control if you do it on the FPGA, but it will use more of your FPGA space and some algorithms are easier to implement on the Real-time host.


For the simple control that Rob suggested, I would just do it in your FPGA VI.  You can still send the data back to the host for logging and monitoring, but this way the communication delay won't slow down your control.


You can find some good FPGA control examples in our IPNet (  There's a good reference design for PID control there if you need to use PID.

For something simple like Rob suggested, take a look at the Switch VI included in the LabVIEW FPGA module -


Morgan S

Applications Engineer

National Instruments

0 Kudos
Message 2 of 3

Hi Morgan,


Thanks very much, I think I got it, will come back and let you know very soon.


Appreciate it.



0 Kudos
Message 3 of 3