Jump to content

decimal places


gazza29

Recommended Posts

hi

what is the best way to use a math's functions. I need to convert an output put off my linearize function to a percent so i can show the tank contents in litres  at the moment its 13 but need to convert this to a percentage 

my tank level is 21000 x 13% will give my tank contents so i need to convert that 13

also what am i going wrong with the timer below it wont energize

thanks,

Gary  

image.png

image.png

Link to comment
Share on other sites

  • MVP 2023
59 minutes ago, gazza29 said:

my tank level is 21000 x 13% will give my tank contents so i need to convert that 13

You need to convert a 13% tank level to gallons? One way is to multiply 21000 times 13, then divide by 100. That's the normal way percentages work.

Another way would be to have a second linearization function that outputs gallons instead of percentage.

1 hour ago, gazza29 said:

also what am i going wrong with the timer below it wont energize

Is your timer in a subroutine that is being called by the Main Routine? Edit: I see that it is in the Main Routine.

It's not possible to see if you have the tag names correct (i.e. is the timer output bit the same tag that's energizing the coil). If that is all correct, do one or both of these:

1) Place an INC function just after the Timer function and see that it actually increments. If not,

2) Place a test bit in parallel with the Negative Transition contact in front of the Timer function and activate it manually while online.

This should help point you to the problem.

Link to comment
Share on other sites

  • MVP 2023

I would re-do your first linearization function.  I don't know what your comfort level with algebra is, but it is common for people to have problems visualizing what this block is doing.  It is literally a PLC version of the y=mx+b line equation.

 

Where did you get the values you have in the input parameters of the block?

They should be these-

a: - channel on I/O module

b: A/D counts at 4 mA

😄 Minimum scaled value at 4 mA

d: A/D counts at 20 mA

e: Maximum scaled value at 20 mA

If you don't know the A/D count minimum and maximums you can get them off the datasheet or post your part numbers.

Sometimes it's helpful for me to draw a little graph to pluck those numbers off. 

 

Joe T.

Link to comment
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...