Forums.MrPLC.com: Math with data type TIME? - Forums.MrPLC.com

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Math with data type TIME? Rate Topic: -----

#1
User is offline   IamJon 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 199
  • Joined: 15-May 06
  • Gender:Male
  • Location:USA
  • Country:United States
    United States
I have a block that mimics the AB TON functionality. The ACCUM and Setpoint are both TIME data types.

I need to turn on a warning light when I have a time difference of 10s between ACCUM and Setpoint. Can I convert the TIME data to an Int? Or is there any way to do this?


It almost seems like I will need to change all my TON data types to a standard S_ODT timer. It already has the remaining time etc, I would just need to convert it from BCD to Int.
0

#2
User is offline   IamJon 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 199
  • Joined: 15-May 06
  • Gender:Male
  • Location:USA
  • Country:United States
    United States
So I'm trying to use the S_ODT timer now. I can choose the BI time left address, which is a WORD, or the BCD. Siemens has no WORD to INT converter, and BCD is not an optional data type when I create a tag.

I need to compare either the BI or BCD to 10 in order to start flashing my light. How can I do this?


ETA: Nevermind, I was only looking in the LAD help. I can do it in STL.

This post has been edited by IamJon: 08 August 2012 - 10:52 AM

0

#3
User is offline   Groo 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 241
  • Joined: 07-February 06
  • Country:Wales
    Wales
when you say you have a block, are you using the Siemens IEC Timer SFB4 "TON"?
0

#4
User is offline   IamJon 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 199
  • Joined: 15-May 06
  • Gender:Male
  • Location:USA
  • Country:United States
    United States

View PostGroo, on 08 August 2012 - 02:17 PM, said:

when you say you have a block, are you using the Siemens IEC Timer SFB4 "TON"?

I WAS going to use that, but I can't do anything with the TIME data type that uses. I'm switching to the S_ODT timer. Even though the BI is a WORD data type, it seems if I do a <I in STL, it lets me compare a WORD with an integer value of 10. Sound correct?


ETA: It saved and compiled, so I think I got it.

And yes, it was SFB4.

This post has been edited by IamJon: 08 August 2012 - 03:15 PM

0

#5
User is offline   Groo 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 241
  • Joined: 07-February 06
  • Country:Wales
    Wales

View PostIamJon, on 08 August 2012 - 02:45 PM, said:

View PostGroo, on 08 August 2012 - 02:17 PM, said:

when you say you have a block, are you using the Siemens IEC Timer SFB4 "TON"?

I WAS going to use that, but I can't do anything with the TIME data type that uses. I'm switching to the S_ODT timer. Even though the BI is a WORD data type, it seems if I do a <I in STL, it lets me compare a WORD with an integer value of 10. Sound correct?


ETA: It saved and compiled, so I think I got it.

And yes, it was SFB4.



The TIME format is mS, as Siemens describe "The data type TIME is stored with milliseconds prefix as two's complement INTEGER" a value of 1000 = 1 second.
0

#6
User is offline   IamJon 

  • Sparky
  • PipPipPip
  • Group: MrPLC Member
  • Posts: 199
  • Joined: 15-May 06
  • Gender:Male
  • Location:USA
  • Country:United States
    United States
Just talked to Siemens. Apparently I can simply do a MOV function to move the WORD data type to INT, then do an integer compare with 10.

And just to clarify, I ended up using the S_ODT timer.

This post has been edited by IamJon: 08 August 2012 - 03:38 PM

0

#7
User is offline   JesperMP 

  • Guru
  • PipPipPipPipPip
  • Group: MrPLC Member
  • Posts: 784
  • Joined: 03-May 05
  • Location:Copenhagen
  • Country:Denmark
    Denmark
IamJon, I suggest you use the IEC timer TON, as the S5Timers are really an arcaic leftover from S5.

To do math with a TIME variable, switch to STL mode, since there is no typechecking in STL.

You can switch back to LAD or FBD, only the rungs that no longer can be represented as LAD or FBD will display as STL.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users