LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with data sharing between fpga and Simulink via SIT

When I connect an indicator of the FPGA via the SIT manager to a simulink input and then connect that value back to a labview host vi I get strange values on the host VI.
 The FPGA simulink connection is made via the Hardware I/O tab in the SIT manager.
The NI FPGA is checked and finaly the connection is made via the "Configure FBGA..." button.
 
The connection between simulink and the host vi is done via the tab mappings.
where in simulink the input port is connected to a gain block (multiply with 1) and this gain block is then conneted to the host via via SIT mappings
 
 All variables, indicator etc are of type I16 ( as well in  labview as in simulink)
 
 When I run the FPGA standalone the value of the indicator which is connected to simulink is around 90000.
When I run the FPGA bitfile via the host VI  the value is varying som where between -10 and 10.
The -10 to 10 indicates that some where a value is to high for a signed integer, This must be somewhere inside the SIT code, because all other variables and indicator are of type I16 as I metioned before.
 
 How Can I solve this problem
 
I amusing
matlab 6.5.1
labview 8.5
and SIT 4.0
 
Regards
Frank
0 Kudos
Message 1 of 21
(3,876 Views)

Hello Frank,

There is some scaling that is applied to the I16 datatype.  We assume the full range of the I16 corresponds to the range -10 to +10V, which matches the data returned from an analog input.  So if the value of the I16 is -32767 we scale that to be a -10 V, -16384 is -5V, 0 is 0V, and 32767 we scale it to be +10V.  This scaling is applied to any indicator or control that we read or write from the FPGA VI that is an I16.because this matches the data returned from the FPGA analog inputs.  This was intended to match the data to this range in a logical way.

To avoid the scaling I recommend using the Fixed-Point datatype (which was recently added to the LabVIEW environment) rather than the I16 in your FPGA VI.  You can configure the datatype to be signed and have 16 bit word length and integer word length.  This will give you the same range as the I16 and no scaling will be applied.

Let us know if you have any more questions about this.

Regards,
Angela M
Product Support Engineer

Message 2 of 21
(3,856 Views)

Thank you Angela,

That makes it more clear to me, but still I have a problem with it.

When I make a contstant (I16) in the FPGA with for example the value 4000, and connect this via the SIT manager to the the Simulink DLL.   I get nothing else than zero (or I get nothing?).

But I will try the sugestion off you with the fixed-point data type.

 

Thank you verry much

Frank

0 Kudos
Message 3 of 21
(3,841 Views)

Angela,

The work around with the fixpiont type did not work,  but thanks to your reply, I now  know that I have to convert it in simulink.

With the kwonledge of the conversion to Volts, I looked again at the values in simulink (comming from the FPGA), but I see that some of them are converted to volt but some of them are not.

So there are some values wich are not or incorrect converted. How is this possible.

All values output in the FPGA are I16 and the input values in simulink are now double.

Regards

Frank

 

0 Kudos
Message 4 of 21
(3,817 Views)
Hello Frank,
What kind of target are you using (cRIO)?  If the value coming from the FPGA is of type I16, then SIT will apply some scaling, but if it is fixed point, then SIT will not apply any scaling.  The scaling that SIT applies assumes a -10 to 10 V range, so if your target has a different range, then the scaling would be inaccurate.
 
As you've mentioned, you can account for the scaling values in the model itself, but if the bitfile is appropriately defined and compiled with a fixed point datatype there should not be a need.
 
So please post back a little more information about what you changed and what exactly you are seeing in terms of scaling and we can provide a little more guidance.
 
Thank you,
Angela M
Product Support Engineer
0 Kudos
Message 5 of 21
(3,813 Views)
Angela
 I am using a PCI 7813R on a labview RT system
 
When I tried the fixpoint solution I just changed the I16 indicators to FXP indicators. It still showed the scaled values (volts) in simulink DLL.
I did not use type converssion before the FXP indicators, perhaps that is the cause of still showing the scaling to volts.
 
In the SIT Harware IO tab I connected several indicators from the FPGA to the simulink DLL model, some of them show correct values( in volts) other had complete incorrect values in simulink.
See the attsched files of labview and simulink (this pictures show the I16 indicator, I changed the FXP indicators back to I16)
Even constan values from the FPGAappear as  0 in simulink model, see attachement.
 
Regards
Frank
Download All
0 Kudos
Message 6 of 21
(3,780 Views)
Hello Frank,
It is not clear why some values would be returned properly and others not.  When you say some are correct and others are not, how are the values incorrect, are they scaled or just completely nonsense?  As I've mentioned before, no scaling will be added by SIT in the driver VI if the values are a fixed point number.  Can you do some probing in your driver VI to see what the values returned from the FPGA are?  When you say the values are wrong in simulink, how are you seeing this?  Does your model dll pass the input value directly back out to the driver VI?
 
I hope this helps, please post back if there is still any confusion about this.
 
Regards,
Angela M
Product Support Engineer
 
0 Kudos
Message 7 of 21
(3,743 Views)

Angela,

 The values are complete nonsense.

 I read the values in the simulink model back via the SIT manager into a windows vi, so I can see them.

I will try to read the values of the FPGA in the driver vi ( I do not know how to, but I will find out)

Regards

Frank

0 Kudos
Message 8 of 21
(3,714 Views)

Hello Frank,

If you have a support contract you can call in and talk with one of our applications engineers, they will be able to help you with your troubleshooting and probing in the driver VI.  You can find the contact information but clicking Contact NI in the bar at the top of any ni.com webpage.

Regards,
Angela M
Product Support Engineer

0 Kudos
Message 9 of 21
(3,706 Views)

Angela,

 I have support and and they know about the problem, but I did not get any answer yet (It is to complicated)

I looked in the driver and the values are the same as in simulink ( some are correct and some are nonsens or 0).

I have in total about 350 connections to simulink, is this perhaps the problem (65 inputs and 295 outputs) and can this then be solved by using  array's or cluster.

What is the total maximun possible connections to simulink,

Regards

Frank

0 Kudos
Message 10 of 21
(3,678 Views)