LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulation Interface Toolkit - Error transfering small values

Hi all,
 
I have a quite big problem that looks like a bug in the SIT and I'd like to know if i do something wrong... When my Simulink model contains a value that has five digits or more after the dot (ex. 0.000001), the numeric control that is mapped to this value gets a wrong value at the initialization. I think that this has something to do with the fact that the data is transferred as strings between Matlab and Labview.
 
ex :
 
Matlab initial value : 0.000001
gets transferred as 1e-06 (in string format)
then is converted back to a numeric value in Labview, but Labview ignores the engineering format part, I get 1.
 
When I link such a value to a string control in Labview, I get the correct value (1E-06).
 
Any idea? What's more, any workaround?
 
Attached is a small VI with a small model that demonstrates the problem.
 
Thanks a lot,
 
Alex
Download All
0 Kudos
Message 1 of 9
(3,173 Views)
I cant check this VI for you as I am missing all of the SIT VIs.  But it sounds like a conversion issue between the string and the LabVIEW control.  How are you converting the string to a number currently?  Since you are getting an incorrect value (I could be wrong on this) it sounds like you should replace the string to number conversion VI you are currently using with a Fract/Exp String To Number VI found on the String >> String/Number Conversion palette.
 
LabVIEW help blurb:
Interprets the characters 0 through 9, plus, minus, e, E, and the decimal point (usually period) in string starting at offset as a floating-point number in engineering notation, exponential, or fractional format and returns it in number.
0 Kudos
Message 2 of 9
(3,167 Views)
Hi Chaos,
 
Thanks for the suggestion, I also think that the problem is related to that.
 
Unfortunately, this conversion doesn't take place in my code... The SIT read server, a VI provided with the toolkit, takes care of that and its source code is locked.
 
That's why I'm asking if anyone experimented this problem.
 
Thanks anyway,
 
Alex
0 Kudos
Message 3 of 9
(3,153 Views)
Hi There:

So the good news is that I think we can definitely work around the issue.

First I would like to make sure that you have set the right digits of precision when you were trying get the data from Matlab in to a numeric control. If you have, then the next thing I would do would be to right click on the control and setting the format to Floating Point rather than Automatic Formatting which is the default.

Next, if this does not work, we can follow the suggestions given by Chaos. Since you have the correct value in a string control in LabVIEW you can very much use the Fract/Exp Strin to Number VI. Again, when you get your number out you will need to change the formatting to Floating Point.

Thanks,

Jaideep
0 Kudos
Message 4 of 9
(3,137 Views)

Hi Jaideep,

Thanks for your answer. Unfortunately, I tried to change the numeric control to floating point format and to increase its digits of precision with no results. The value 0.00001, which should be displayed properly in a floating point control with 6 digits of precision, still gets converted to 1.000000. I really think that the value is converted to an exp/fractionnal string on Matlab's side but is not converted properly back to a floating point value on Labview's side. The exponential part seems to get dropped in the process.

You're right that I can acquire the value from Matlab as a string and convert it to a number later, but I have quite a few variables to transfer from Matlab (over 150) and adding these conversions would be quite a big headache.

This behavior seems odd to me, and I'd like to understand why it happens so...

Thanks again,

Alex

 

0 Kudos
Message 5 of 9
(3,134 Views)
Hello Alex,
 
I have verified that the behavior you are describing has been fixed in our new SIT 3.0 version that was released in November.  We are investigating if there is an easy workaround for you to implement in SIT 2.x.  What specific version of SIT are you using.   I will post what we find concerning that on here ASAP.
 
Thank you for posting this question and I apologize for any inconvenience,
Gretchen Edelmon
Simulation Interface Toolkit R&D
Message 6 of 9
(3,117 Views)

Hi Gretchen,

Thanks a lot for your help. We use SIT 2.0 (i guess, it was bundled with LV 7.1, any way verify?). I applied the 2.0.3 patch...

Let me know if you need any other information.

Thanks again,

Alex

0 Kudos
Message 7 of 9
(3,108 Views)
Hi Alex:

I am trying to work on this issue currently and will get back to you as soon as I have found something.

Best Regards,

Jaideep
0 Kudos
Message 8 of 9
(3,078 Views)

Hi guys,

Did you find a workaround regarding the bug that occurs when we transfer small values from Matlab to Labview? Your help would be greatly appreciated on that issue.

Thanks,

Alex

0 Kudos
Message 9 of 9
(3,006 Views)