- Interactive Q & A - Interactive Q & A (
-   LIVE PLC Questions And Answers (
-   -   Micro 820 structured text real/multiply/time (

Bryan_Mitchell March 6th, 2018 04:25 PM

Micro 820 structured text real/multiply/time
Hello all,

I am wanting to convert a real value from a panel view to minutes,
I can get it to work in ladder logic but I am hoping to demonstrate function block to students.

hoping for a sample instruction.
Thanks in advance.

Geoff White March 6th, 2018 07:50 PM

Welcome to the forum.

The first step is to describe what you are trying to do in such a way that we can understand it without guessing.

Bryan_Mitchell March 6th, 2018 08:02 PM

I am sending a "real" value from my panel view into the PLC to be able to adjust the the time a pump cycles.

I have achieved this function it ladder logic, with the exception of the time still being in milliseconds. I forgot structure text long ago(Don't use it you lose it).
I am hoping to get an example of the text to convert a "real" integer into seconds(* 1000) then to min(*60) then convert that to a global variable to assign to a timer set value.
Thanks for the reply!

Bryan_Mitchell March 6th, 2018 08:13 PM

That real value coming in from the panel view is a global variable as well.

Geoff White March 6th, 2018 08:46 PM

"Real" to me means non-integer or floating point. Are you talking about engineering units? The timer preset will be in ms. What units are you using on the HMI?
The conversion you specified is backwards for minutes to ms. Wouldn't you just multiply by 60000? Convert to DINT with ANY_TO_DINT.

Bryan_Mitchell March 6th, 2018 08:48 PM

I'll need to check on that first thing in the morning.

damica1 March 7th, 2018 07:06 AM

Geoff White is suggesting what I also think would be your best solution. Convert real to "Dint" then use the function block "Dint to Time" which can be downloaded from "Rockwell's" support site?

The "Dint to Time" has an example of how to use this function block by "Structured Text" if I remember correctly!

Bryan_Mitchell March 7th, 2018 10:49 AM

3 Attachment(s)
Ok guys, sorry for the wait.
I am going to screenshot a couple of things that I think will help you guys see what I am talking about!
The pump control screen is where I want to be able to adjust the time for how long the pump stays on, and how long between cycles.
The global variable screenshot is how I am sending the value from my HMI to the PLC.
The ladder conversion is how I was able to get what I am calling real (data type?) data to convert into a time value to assign to my timer.
I hope this clears it up a little.

I also feel like a dummy for not thinking about multiplying by 60000 instead of 1000 then by 60....

janner_10 March 7th, 2018 04:12 PM

Unless I misunderstand. Convert Screen Input to mS then convert to time!

janner_10 March 8th, 2018 12:39 AM

Silly Tag names above - should of course be minutes!

Bryan_Mitchell March 8th, 2018 01:01 PM

did you need to declare "MytimeconvHours" as a tag? of so what data type should it be?

janner_10 March 8th, 2018 01:31 PM

Yes, it's a DINT.

You can scale the tag in the panelview, and just use that in the ANY_TO_TIME directly.

But IMO, it makes it more obvious what you are doing if it's right there in the code. I prefer all the maths in the PLC where it is in plain sight, but horses for courses.

Bryan_Mitchell March 8th, 2018 03:34 PM

3 Attachment(s)
Thanks so much for the help.
I have entered what I think to be the exact instruction and tried to download but got the attached error messages? please advise
I have attached screenshots of my tags for verification.

Bryan_Mitchell March 9th, 2018 09:52 AM

Can I provide more details?

janner_10 March 9th, 2018 05:09 PM

Hello Brian

Here's how I got it to work:

All times are GMT -5. The time now is 09:02 AM.