LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Myrio Problem between FPGA and RT

Hello,

 

in my current peoject, I need to acquire a frequency, between 200-3000 kHz, acquire the temperatures in four points on the board and control the temperature through a PID system.The frequency and the temperature should be acuired each 1 sec, or faster.

 

In order to read the temperatures a MAX31865, wich is a resistance-to-digital converter optimized for RTDs taht use an SPI comunication, has been interfaced to a myRIO.

For simplicity I have developed the communication program using the low level SPI comunication VI present in the myRIO toolkit, combinig with low level Digital I/O VI presnt n the same toolkit, and the system work perfectly.

 

After that I focused on the acquisition of the frequency,and I realized that due to the its range(200-3000Hz) it needed of FPGA programmation, so I realized (also with help of som web example) a working FPGA VI's.
he last step was to combine the two working VI's in ne project, and at this point I fund som problems.
I created a new FPGA project for myRIO 1900, I added the FPGA VI for the frequency and In the RT I created a VI taht used the RTD reading and control VI, adding the related part for the frequency.

I complile everithing without errors, but when I run the RT VI I'm able to correctly read the frequency, but not the temperatures.
Adding a probe on the temperature chain I obtain this error:

"

Error -61202 occurred at niLvFpga_Open_myRIO-1900.vi:700001

Possible reason(s):

LabVIEW FPGA: LabVIEW could not perform the operation because an FPGA VI reference to another VI is currently open. You must close the currently open FPGA VI reference before attempting to perform this operation"

 

Can some one Help me?

My be to solve the problem I shuld program the SPI comunication in the FPGA, but I don't know how to do it.

 The Hardware and Software utlized are:

Windows 10

Labview 2019 32bit

myRIO-1900

MAX31865

 

 

Thanks

David

0 Kudos
Message 1 of 5
(1,008 Views)

The problem you are having is created when you create your Project -- you can choose a Project using the functions that come as part of the myRIO Software Toolkit (including the functions that implement SPI) or a Project that lets you develop your own (single) FPGA application.  The first option actually loads FPGA code that all those functions call to "do the dirty work".  When you create your own FPGA (custom) application, you replace the underlying FPGA code that runs the myRIO Toolkit.

 

If you think about it, the SPI routines accept calls to do various things and accomplish them by manipulating MOSI, MISO, SCLK, and SS line (which, in the myRIO Toolkit, are assigned to specific DIO lines and operate according to the parameters of the way you configure the SPI protocol.

 

But, yes, the alternative is to write a single FPGA routine that both handles your custom FPGA application and also allows you to create your own set of commands that "do the same thing as SPI" using the four DIO lines that you choose for MISO, MOSI, SCLK, and SS.

 

With this freedom, you can be more innovative.  I've seen some FPGA code that used a DIO Port Expander to route MOSI signals to a subset of 16 SPI chips (including all of them at once) by manipulating their SS lines, then sent a single SCLK and MOSI signals that activates just the SPI chips that were "selected", and using 16 DIO lines for MISOs (one per "channel") allowing the myRIO to handle not 2 SPI devices (doing potentially different things) but 16 SPI devices (doing the same thing).  Looked like magic to me, but I was assured that it actually worked.

 

As I see it, the big problem you have is the requirement for a superfast A/D system.  Since SPI is a serial protocol, if you want to sample a 12-bit A/D at 1 MHz, you need to MISO your data at 12 MHz, which requires an SCLK of 24 MHz.  That's seems to me to be pretty fast -- you might want to see if there's an A/D system that can plug into the PC (over USB or TCP/IP) that can let the Host acquire the A/D while the myRIO does everything else.

 

Bob Schor

0 Kudos
Message 2 of 5
(965 Views)

Hi Bob,


many thancks for your fast answere.


First of all I have to correct a mistake in my previsu post,in fact I need to acquire a frequency between 200-3000Hz( and not 200-3000Khz as incorrectly indicated), so I don't need a superfast A/D, and sorry for my mistake again.


So if I well understud there is no way to create a project in wich functions of the myRIO Software Toolkit, and my own FPGA could coexist, neigther if i start from a blanck project and i add myRIO later?


As you understood I have 4 SPI A/D converter to control trugh the same MOSI, MISO, SCLK, and different CS, and if you have some FPGA code to do this it will be very usefull, as well as you have some simple FPGA code for SPI comunication from Wich I can start to create my personal code.


Ciao
David

0 Kudos
Message 3 of 5
(920 Views)

David,

 

     Now I'm confused.  In your initial Post, you mentioned using SPI to communicate with a MAX 31865 using SPI, and also to take several channels of A/D at very high sampling rates.  Your followup says that the sampling rates are more modest (up to 3 kHz), but now you are talking about using SPI to address these chips, as well.  And you are hoping to do all of this with custom FPGA code, rather than use the functions provided by the myRIO Software Toolkit that give you routines for accessing the myRIO A/D converters (if memory serves, there are four single-ended converters on the A and B connectors, 0-5 V), as well as two SPI channels (with dedicated digital lines for MOSI, MISO, SCLK, and CS).

 

     Why don't you start by using the Toolkit?  Don't try to do everything all at once!  I'd suggest starting with the A/D routines, as this is conceptually easier (and there might even be Example Code available, I haven't checked recently).  SPI takes a little more work (because you need to understand how SPI works, and understand the Chip you are SPI-ing on, if you'll forgive the phrase).

 

     I'm guessing that you are relatively new to LabVIEW and to LabVIEW Real-Time.  If that is the case, it's even more reasonable to "start small" and leave the custom FPGA stuff for when you've got a year (or a decade) of experience under your belt.

 

Bob Schor

0 Kudos
Message 4 of 5
(897 Views)

Hi Bob,

maybe maybe I was not clear in my first post, I'll try to clarify my needed.

 

In my project I have to acquire 4 RTD's, to do this I use 4 MAX31865 connected to my myRIO-1900( see Temperature acquisition.jpeg), and as you know the MAX31865 use the SPI protocol to comunicate.
At the same time,I have to acquire a square wave( 0-5) V with a frequency range between 200 - 3000 Hz.

 

As I said I started from the RTD's Acquisition using myRIO toolikit, and I wrote a fully functional VI's( See Attached READ RTD.zip).

 

Then  I moved on to the development of the code for the square wave acquisition.
Because of the frequency range of the wave (200-3000Hz) I realised that with the myrio Toolkit it was not possible to acquire at an adequate speed, so I switched to FPGA programming, again obtaining a working code (See attached Frequency.zip).
The problems occured when I tried to merge the two codes into a single project, which resulted in the error I described in the first post.

 

I hope I have clarified my needs and difficulties.

 

Thank you
David

 

0 Kudos
Message 5 of 5
(876 Views)