Conversion To Float


Recommended Posts

Posted

Dear Support,

 

I am using OPC between the PLC and Daq.

I have an analog output to control the valve.

This channel is a REAL Value in PLC. But I could not convert word to integer in my OPC. 

So, I think I need to convert it in Daq Scada.

 

How can I convert the normal set to REAL Value?

For Example:

20- 16xxx

30-16xxx

 

Thanks in advance,

Sadyr

Posted

I'm not really sure what you are trying to do.  OPC isn't a protocol like modbus where you can just translate in bytes from integers to floats.  Also, DAQFactory should be able to set a real (i.e. float) value over OPC with no translation.

Posted

Dear Guru,

 

When there is a connection via OPC there is no many choices like to write float or real.

 

When I write without OPC with DF Quickmod SCAN, it is ok.

But, via the OPC, how can I convert my setpoint in DF, forexample 50 C to 16968?

 

I have too many tags, so not to confuse I do not want to write with sequence.

Is it possible to use some conversion on channel or before setting the channel? 

 

Thanks in advance.

 

 

 

post-120-0-55501900-1416570796_thumb.png

post-120-0-45941600-1416570809_thumb.png

Posted

The OPC server should have an option to specify float or real.

 

Anyhow, the Conversion you want is:

 

(from.Float(Value))[0][3] * 256 + (from.Float(Value))[0][2]

 

 

 

That will convert 50 to 16968, and other integers to part of the float.  You can then apply that conversion to any channel.

 

Note that this will only work on integers because you are ignoring the decimal part of the float and only updating 2 of the 4 bytes.  Likewise, you will be limited by the range of values available.  This may or may not be a problem.  This is not the best solution really, but if it works for you, there it is.

Archived

This topic is now archived and is closed to further replies.