You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old May 22nd, 2020, 12:07 PM   #16
neilsibub
Member
United Kingdom

neilsibub is offline
 
Join Date: Aug 2012
Location: Carlisle
Posts: 19
Quote:
Originally Posted by drbitboy View Post
I
I've got to get a life.
No, this is gold for me, I've written a couple of programmes in Crimson over the years, but have always felt the code was messy and probably incorrect, my background is PLC.

The plant only runs 5 days a week (0 ==Sunday)

So starting with seconds means it will only look at the next statement every minute instead of every tick? Aww man I've got a lot of code to correct!

Thanks for taking the time.
  Reply With Quote
Old May 22nd, 2020, 12:35 PM   #17
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 846
Quote:
Originally Posted by neilsibub View Post
So starting with seconds means it will only look at the next statement every minute instead of every tick?

Exactly.
  Reply With Quote
Old May 22nd, 2020, 12:41 PM   #18
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 846
Quote:
Originally Posted by neilsibub View Post
The plant only runs 5 days a week (0 ==Sunday)

So there are a few choices
  • if (.Day>0 && .Day <6)
  • if (!(.Day<1 || .Day>5))
  • if (.Day%6)
  • if (MOD(.Day,6)>0)
I dunno about correct syntax; I suspect the first two are faster, but as the inner tests executing only seven times a week it will not matter. That said, the last two are just cute and so should be avoided.
  Reply With Quote
Old May 22nd, 2020, 12:47 PM   #19
neilsibub
Member
United Kingdom

neilsibub is offline
 
Join Date: Aug 2012
Location: Carlisle
Posts: 19
Quote:
Originally Posted by drbitboy View Post
[*]if (.Day%6)
What is this? I thought % was modulo?
  Reply With Quote
Old May 22nd, 2020, 02:21 PM   #20
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 846
Quote:
Originally Posted by neilsibub View Post
What is this? I thought % was modulo?

yes, modulo binary operator; if .Day is not 0 (Sunday) or 6 (Saturday), it will be a weekday.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Crimson 3.1 Crashes Shell Application CesarTamayo LIVE PLC Questions And Answers 3 November 19th, 2019 12:20 PM
Array issues in Crimson 3.1 Bullzi LIVE PLC Questions And Answers 3 July 5th, 2019 03:19 AM
Red Lion Crimson 3.1 writing array position into tag ijustdunnoaname LIVE PLC Questions And Answers 5 April 26th, 2019 09:43 AM
Sorting a Crimson 3 integer array in ascending order bbaker123 LIVE PLC Questions And Answers 1 February 22nd, 2016 03:00 PM
Variable array size call to add-on instruction - A solution Mr Modbus LIVE PLC Questions And Answers 4 July 17th, 2015 08:59 AM


All times are GMT -4. The time now is 05:12 AM.


.