LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can real-time control digital outputs directly?

I am trying to control some digital outputs on a 9474 module and a and a cRIO-9022 Chassis.

 

I was trying to drag and drop the module outputs in the FPGA section of the project onto a real time block diagram, but the output doesn't seem to be valid.

 

Can I only control digital outputs via FPGA VIs?

 

I didn't want to wait 20 minutes for the FPGA to compile so that is why I wanted to use real time.

 

 Just wondered if there was any way to directly control the digital module outputs from real-time VIs.

0 Kudos
Message 1 of 8
(3,335 Views)

Hi David,

 

did you configure your project/cRIO to use the ScanEngine?

If you would you could control those DO channels using (kind of) shared variables provided by the ScanEngine…

 

Hint: search for "crio scan engine" to find relevant articles provided by NI…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(3,323 Views)

All of the C Series modules are connected to the FPGA chip, which is why you must use the FPGA to communicate with them. When moving to FPGA, it is generally better to try and design your FPGA VI first so that you can minimise the number of compilations you need to do - some of the simulation tools can help with testing your FPGA VI before you need to compile it.

 

Or, as GerdW has mentioned - you can use the Scan Engine (or hybrid mode which allows some modules to use FPGA and some modules to use Scan Engine) which is basically puts some pre-compiled code onto the FPGA which takes the input/outputs of the C Series modules and puts them into shared variables which you can then read in RT. The downside is that it is much slower than using an FPGA VI and you cannot implement any custom logic without the FPGA.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 8
(3,311 Views)

Just a follow up question on this, will DAQmx code work on a cRIO if I use it in real-time mode? Or does real-time have a DAQmx equivilent? I have found the way I program FPGAs to be quite different to the way cDAQs are coded.

 

The difference with PWM modulation on a cDAQ and FPGA were quite big. Despite FPGAs being supposedly a lot quicker, I found I couldn't get 2,000Hz PWM with FPGA using a delay and shift registers (the recommended way) but could easily get 2,000Hz  with a cDAQ using the DAQmx method recommended.

 

I am using the same module in both instances, a digital module 9474 using the CTR output for PWM. I wondered if there is a way to use this witha  cRIO rather than trying to hardcode a PWM into the FPGA.

0 Kudos
Message 4 of 8
(3,241 Views)

Hi David,

 

will DAQmx code work on a cRIO if I use it in real-time mode?

No.

 

Or does real-time have a DAQmx equivilent?

No, not really.

You have a ScanEngine instead.

 

I have found the way I program FPGAs to be quite different to the way cDAQs are coded.

Yes.

 

I found I couldn't get 2,000Hz PWM with FPGA using a delay and shift registers (the recommended way) but could easily get 2,000Hz  with a cDAQ using the DAQmx method recommended.

 Then you made something wrong…

 

I am using the same module in both instances, a digital module 9474 using the CTR output for PWM. I wondered if there is a way to use this witha  cRIO rather than trying to hardcode a PWM into the FPGA.

Are we talking about 2Hz or about 2kHz?
For 2Hz you could use the RT part with the ScanEngine: just toggle a DO (with some minimal jitter).
For 2kHz you should use the FPGA to get a PWM output with very high accuracy (with a clock of 40MHz)!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(3,234 Views)

2kHz. For some reason it starts to look really deformed on the oscilloscope at anything over 500Hz. I was surprised as I always thought FPGAs could perform a lot better than cDAQs. Yet my cDAQ can give me 2kHz PWM no problem using the DAQmx feature with the ctr output. I wasn't sure if the digital modules have a built in PWM that I could also use with a cRIO rathre than coding one in.

 

PWM is fairly simple to code so I dont know why it doesn't work. I dont even have a varied duty cycle, its literally just delaying a while loop ever n seconds and alternating between 1 and 0 using an inverter and shift register. I can't see how I coudl have coded this to work up to 500Hz but then start to deform.

0 Kudos
Message 6 of 8
(3,222 Views)

Hi David,

 

I can't see how I coudl have coded this to work up to 500Hz but then start to deform.

We neither as you don't attach any code here…

 

I don't have problems to create PWM signals with 10µs resolution using a 9403 module!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(3,212 Views)
I posted in your original thread about the problems you were having with generating a PWM signal - I also mentioned that you can use the 9474 in scan engine mode with a PWM output.

http://forums.ni.com/t5/LabVIEW/Can-anyone-spot-the-error-in-this-code/m-p/3247075#M945994

LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 8 of 8
(3,202 Views)