LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Servo Control on a cRIO-9074 and NI 9403

Hi all,

 

I am currently in possession of a cRIO-9074, as well as a NI-9403 DIO module. My objective is to generate a basic square-wave PWM to control a servo which takes in PWM cycles from 900 to 2400 microseconds. Trying to do this with the 9403, I have run headlong into the well-documented issues of Windows not really being able to time anything faster than 1kHz. When I use a looped sequence I can't push the frequency higher than 50Hz, and when I use various hacks involving quotient-remainder operations on ticks, the frequency is extremely inconsistent. I am aware that dedicated NI servo modules exist in that directly address control applications, but I would like to avoid spending on them until I'm absolutely sure there are no workarounds.

 

My question is this - given all that I have tried thus far, is there any way that I can use the 9403, the ethernet port on the crio-9074, and/or any cheap (< USD 50) third-party modules / solutions to generate a PWM signal of the required frequency? Or is buying a dedicated servo module really my only recourse?

 

Thanks in advance.

0 Kudos
Message 1 of 9
(1,560 Views)

I should that switching to Linux to exploit their real-time functions is not an option for my particular application

0 Kudos
Message 2 of 9
(1,559 Views)

Hi ds97,

 


@ds97 wrote:

I am currently in possession of a cRIO-9074, as well as a NI-9403 DIO module.


That is a very old cRIO, using either Pharlap or VxWorks as OS. It is not able to run Linux or Windows…

 


@ds97 wrote:

My objective is to generate a basic square-wave PWM to control a servo which takes in PWM cycles from 900 to 2400 microseconds. Trying to do this with the 9403, I have run headlong into the well-documented issues of Windows not really being able to time anything faster than 1kHz.


Again: that cRIO has nothing to do with Windows at all!

When using the ScanEngine you might try to set the 9403 module into the PWM generation mode. (I'm not sure that specific 9403 module is supported for that purpose in the ScanEngine.) AFAIK the ScanEngine supports PWM generation at 1kHz, but my memory fades as I used the ScanEngine only once about 10 years ago…

 

You might also use LabVIEW-FPGA to program the 9403 module in the FPGA hardware, here you can easily create a PWM signal with your requirements!

 


@ds97 wrote:

My question is this - given all that I have tried thus far, is there any way that I can use the 9403, the ethernet port on the crio-9074, and/or any cheap (< USD 50) third-party modules / solutions to generate a PWM signal of the required frequency? Or is buying a dedicated servo module really my only recourse?


The way to use that all with your cRIO+9403 is to install LabVIEW + LabVIEW-Realtime + LabVIEW-FPGA, using a LabVIEW version which supports that old cRIO. (I think LV2019 or older, but not LV2020+)

 

When you want a cheap solution you should use a small Arduino (or similar) for about 10US$, those are able to create such PWM signals…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 9
(1,553 Views)

Just a few additions to Gerds reply:

 

yes, cRIO-9074 is quite old, the RT-OS on this system is VxWorks.

 

To get any use of this cRIO, you need the RT-module and the FPGA-module for LabVIEW, as Gerd said. Latest version that supports this cRIO is LabVIEW 2019 SP1.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 4 of 9
(1,526 Views)

Hi GerdW,

 

I think I was insufficiently clear regarding the Windows part, what I mean is that I'm currently using Labview on Windows with all the add-ons (including Real-Time and FPGA) in order to program the 9074. I'm honestly not sure if I'm doing things correctly, but the 9074 seems to accept the VI's I've been writing for it thus far. If the 9074 itself isn't subject to any limitations imposed by the Labview software that writes to it, then I'm honestly at a loss as to why my attempts at creating a PWM VI are producing such inconsistent waveforms. Of note is that I'm also running a real-time analog-input data-gathering loop on the same VI (separate AI module), could that be the cause?

 

Regarding the ScanEngine solution you mentioned, I'll look into it and see if that works, thanks for it!

 

As for the FPGA option, I tried doing that when I started out, but LabView couldn't even detect my 9074 when I followed Vaneet's tutorial series on Youtube and scanned for the device.

 

Lastly I was actually thinking of using the Arduino as it has been floated several times on the forum on this purpose, but another requirement that I failed to mention in the original post is that I need to record any user-commanded changes to the PWM signal in a manner that is synchronised with the data-gathering loop. If there's a way to have the Arduino feed this data to the 9074 in a manner that is synchronised to the 9074's clock I'd be all for it! It's just that try as I might I can't seem to find any method of doing this online, just various ways to work on Arduino in Labview.

 

Thanks for the help thus far!

0 Kudos
Message 5 of 9
(1,523 Views)

Hi JensG69,

 

Thanks for the reply! I actually have the RT and FPGA modules already installed on LabView 2019 SP1, but I'm honestly not sure if the VIs that I have created are currently using them. Whenever I try to follow FPGA or RT youtube tutorials, they're usually not filmed with the 9074 in mind, so as I detailed in my reply to GerdW they're of limited usefulness.

 

I'm at a point currently where I can have the cRIO-9074 perform basic datalogging and simple arithmetic-only VIs, but this PWM problem is completely intractable with the tools I have.

 

Thanks for the help thus far!

0 Kudos
Message 6 of 9
(1,520 Views)

Regarding the last part about requiring synchronisation, let me just elaborate by stating my use case. Basically I'm trying to generate this PWM square wave in order to control a servo that actuates a plant. The plant's response (recorded by the analog input modules I've mentioned earlier) will be time-delayed somewhat, and I want to measure this time-delay. So ultimately the ideal output from the Arduino / 9074 combination would be a CSV containing the analog input data with timestamps, and the commanded servo duty cycle at each of those timestamps.

0 Kudos
Message 7 of 9
(1,518 Views)

Are you running your VIs interactively from Windows?

By which I mean, do you have VIs in the cRIO Target, and then you're opening this VI on Windows (as if to edit) and then clicking Run?

 

If so, you might take a look at creating an application and running it at startup, and setting up a slower messaging loop for communication with the Windows PC.

 

I'm not familiar with the VxWorks systems, so if this isn't relevant, hopefully GerdW or JensG69 will correct me.


GCentral
0 Kudos
Message 8 of 9
(1,506 Views)

Hi ds,

 


@ds97 wrote:

I think I was insufficiently clear regarding the Windows part, what I mean is that I'm currently using Labview on Windows with all the add-ons (including Real-Time and FPGA) in order to program the 9074. I'm honestly not sure if I'm doing things correctly, but the 9074 seems to accept the VI's I've been writing for it thus far. If the 9074 itself isn't subject to any limitations imposed by the Labview software that writes to it, then I'm honestly at a loss as to why my attempts at creating a PWM VI are producing such inconsistent waveforms. Of note is that I'm also running a real-time analog-input data-gathering loop on the same VI (separate AI module), could that be the cause?

 

Regarding the ScanEngine solution you mentioned, I'll look into it and see if that works, thanks for it!

 

As for the FPGA option, I tried doing that when I started out, but LabView couldn't even detect my 9074 when I followed Vaneet's tutorial series on Youtube and scanned for the device.


Until now you failed in attaching your VI/project so we cannot tell you what you (maybe) made wrong in creating that PWM signal. (When you have problems with code then you should attach code, not just some text describing the code…)

 

I don't know that "Vaneet" and I don't know why you look for tutorials on Youtube when there are knowledge base articles and tutorials at NI.com. That being said: you "detect" the FPGA target within your LabVIEW project when adding the cRIO as target into the project…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(1,501 Views)