HomeMicroSmart FC6A

A powerful micro PLC with the features of a PAC making it an ideal fit for demanding applications.

How to convert word to floating point Messages in this topic - RSS

Barry
Barry
Posts: 175

6/16/2019
HI

I have a word value in the form 9999 that represents a real world value of 99.99

How do I convert this word to a floating value to display its true Y axis value correctly on a line chart?

Barry
0 link
Shane
Shane
Moderator
Posts: 273

6/18/2019
First perform a CVDT on the word register to make it a float. You'll end up with 9999.0

Second perform a DIV by 100 to end up with 99.99

Be sure to skip every other data register because when you make it a float the value will take two registers. For example, D0000 is your word register, make D0002 your float register after the CVDT. Then DIV D0002 by 100 and use D0004 for your scaled float. Don't use D0003 or D0005 for anything else or you'll corrupt your register values.
0 link
Barry
Barry
Posts: 175

6/18/2019
Hi Shane, that's what I thought but it doesn't seem to want to work for me, I think it must be finger trouble!
0 link
Shane
Shane
Moderator
Posts: 273

25 days ago
If you have a simple sample program you want to post with it not working perhaps we/I can have a look and see what may be wrong.
0 link
Barry
Barry
Posts: 175

22 days ago
Shane wrote:
If you have a simple sample program you want to post with it not working perhaps we/I can have a look and see what may be wrong.
Thanks Shane, forgot to change the data type in the CVDT from 'word to word' to 'word to float'! DUH!
0 link
Shane
Shane
Moderator
Posts: 273

21 days ago
Excellent, glad you figured it out.
0 link
JDemsey
JDemsey
Posts: 10

7 days ago
I would also like to do conversions like this in a script. I have a Modbus temperature coming in as a word which is 10 times the value, so 234 represents 23.4 deg F. I would like to convert this in a script with a statement like:

[Test_DegF] = ( [Test_degC] / 10 )* (9/5) + 32 ;

This compiles with no errors, but only computes to 32.0. Should convert to 74.12. The script is setup as as a Float script.
0 link
JDemsey
JDemsey
Posts: 10

7 days ago
I would love some examples of useful scripts especially for the FC6A, but I think they should be for most any of the IDEC devices.
0 link
Shane
Shane
Moderator
Posts: 273

2 days ago
Are you saying the result of the script is always 32.0 regardless of the "Test_degC" value?
0 link
JDemsey
JDemsey
Posts: 10

5 hours ago
Yes. And IDEC help said it was due to the Test_DegC being a word and not a Float. After converting it in ladder with CVDT I was able to get the Script to work. I was not able to get it to work in Script with asword or asfloat.
0 link




Powered by Jitbit Forum 8.2.0.0 © 2006-2013 Jitbit Software