Jump to content
David S

Integer value from analog input to real value

Recommended Posts

Hello, I am new to PLC programming, and I´ve been assigned this task at USP-070-B10 with UIS-WCB1, using Unilogic 1.23.25:

I have an analog angle measuring sensor, which gives current of 0-20mA( 0mA is for -45°,20mA is for 45°) , which transfers into integer value from 0 to 16383 in INT16, I need:
    1) transfer the integer value to value in degrees
    2) display the value in degrees on the HMI field
    3) compare the value with user written value in another HMI field, and perform actions according to the comparation

I am stuck at the first part, transferring the integer value to degrees. I tried the linearize function, which suggest in help that can be used to convert analog input values. But when trying to compile and send project to the PLC, displayed error suggested, that the input value and output value have to be in the same data type.

Thus I wanted to try the INT to REAL operator, which I probably did not get, how to set up, because when online the value converted into real does not change with the value on the analog input and stays on 0. Furthemore when I want to linearize the converted value of REAL data type into degrees in REAL datatype, the same error displays, that the input value and output value have to be in the same data type, when this is no longer true.

I would appreciate any guidelines to setting up my task.
 

linearize.jpg

inttoreal.jpg

Share this post


Link to post
Share on other sites

Why are you wanting to use REAL in this application? You can have multiple decimal places of precision using integers. For example, if you want two decimal places of precision in your project, linearize from -4500 to +4500. This will give you an implied two decimal places. You can then display it with the two decimal places on screen and use the number in calculations and other manipulations, remembering that the value is 100 times the actual value.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...