Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

myRIO C Language Programming

Hello Everybody,

 

 

I would like to know if anyone uses the C language to develop applications for myRIO board. I have read the tutorials and samples in the National website but they are very simple and don't bring very much information.

 

I usually use ARM microcontroler to develop my applications and when I need to sample a signal I generate a timer interrupt and read the ADC value. Can I uses the same approach with myRIO?

 

 

Thanks

0 Kudos
Message 1 of 4
(6,886 Views)

Hey danieloak,

 

The method you described (generate an interrupt and read ADC register) is generally used in 'bare-metal' programming (programming a micrcontroller with no operating system).  The method you described does not apply to myRIO since it is running an operating system (NI Linux Real-Time).  It may help to think about developing applications for myRIO more like developing for a  Linux desktop.  

 

When developing an application for myRIO using the C API you'll need to open a reference to the FPGA, and then you can read and write to the FPGA registers to read and generate IO signals.

 

Let us know if you have any specific questions on how this works.

 

Thanks!

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 2 of 4
(6,871 Views)

Hi Sam K,

 

First of all thanks for the quick answer.

 

 

My question is how can I configure the myRIO ADC to sample some signal at a specific sampling rate to perform operations like filtering? I need to use Labview to generate the FPGA code that sample and filter the signal and, through C API, uses this pre computed value in my C application running on linux? 

 

Thanks

 

Daniel

 

0 Kudos
Message 3 of 4
(6,867 Views)

Hey Daniel,

 

You have a couple options. 

 

If you don't want to create your own FPGA code you can use the myRIO  'default personality'.  In your C application you can open an FPGA reference using the default personality then use the C API to read from the ADC register, buffer it in program memory and then use C libraries to filter the data.  This method is simple but much slower than the following method.

 

The other option is to do exactly what you said.  Use LabVIEW FPGA to create a custom bitfile that samples at your desired rate and buffers and filters the data in FPGA.  You can then use the C API to read from the output register containing the filtered data you create in LabVIEW FPGA.

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 4 of 4
(6,862 Views)