SoMachine Basic INT_TO_REAL

onkalolo

Member
Join Date
Jun 2015
Location
UK
Posts
3
Hey guys,

I'm trying to basically get an analogue input (4-20mA) to become a real/float between 0 and 10.

Currently to my knowledge that involves moving the IW to an MW, and then using the "INT_TO_REAL" function to change that MW to an MF.

However, the INT_TO_REAL function just consistently outputs 0. If i increase the scaling of my IW to something like 0-10,000 (rather than 0-10), the function outputs a long decimal followed by "E-42" or similar.

All I want is my analogue to become a real, scaled between 0 and 10 as before. I do note that perhaps I need to scale the IW between a high number to get the resolution required - but then how do I decide that my real/float is between 0 and 10?

Cheers in advance.
 
I guess I'm not familiar with variable declaration in SoMachine Basic, but since it seems to not use the IEC standard INT and REAL types and instead use controller specific types MW and MF, it may be that the floating point data is stored differently in the MF type and the IEC standard conversion functions simply won't work.

Also, you should really do all your scaling after it is a floating point number or you're just truncating resolution. I would do the 4-20mA as 0 to 32767 or even -32767 to 32767, convert that to floating point, then divide.
 
Thanks for replies guys, I've actually emailed my project to Schneider who offered to take a look at it for me.

Will take a look at that .pdf, and fair point CapinWinky I will likely do that if I ever get this float.. floating!
 
TEMPERATURE_ENTRE := INT_TO_REAL (Temperature_IN);
TEMPERATURE_ENTRE := TEMPERATURE_ENTRE / 100;

(* Result with decimal point
Temperature_IN = %IW3... 3921
Out = 39.21 *)
That work for me
 
Last edited:
use scale or the oscat library from oscat.de
remember the Input Word is not from 0 to 32565 but will be something like from 4 to 4000 depending on the input type.
then use scaling to make it a real and engineer value.
 
Hi Onkalolo. I realise this is an old post, but came across it searching for exactly the same answers you were. Did you resolve this issue? I am trying to do the same thing, but using the input from a PT100 temperature sensor
 

Similar Topics

Hi all, I've been trying to develop modbus rtu program between uv balasts and plc ı'have 6 slave balast.I am reading fault run voltages etc...
Replies
0
Views
1,188
hello eveyrone I want to make an application with M221 PLC in SOMACHINE BASIC program. I request your valuable help. I have a 50 ms pulse...
Replies
1
Views
1,594
Hi Guys, I'm using M221(TM221CE24R) PLC and SoMachine Basic from Schneider and having a bit of problem. 1. I can't able to read the data from...
Replies
1
Views
1,738
Hello, I am new to plc programming. I am trying to program a flow meter (E&H promag 50) in somachine basic to achieve the following: 1...
Replies
5
Views
2,393
I downloaded SoMachine Basic, I'm looking to maybe use an M241 in an upcoming project. It seems that the basic vs, doesn't offer Tag based...
Replies
2
Views
3,032
Back
Top Bottom