DonNH

Trigger action at specific time each day

7 posts in this topic

I want to start an action (send a mobile robot to its charger base) at 9pm each evening.

This logic works in simulation, but for some reason seems a bit awkward to me.

I assume this is a fairly common thing to do, so is there a better way?

Basically I check the time every 4s, convert to seconds so I can check to see if it's between 9:00 and 9:00:20 (should probably cut down the interval and time gap).

Any thoughts?

Also - any idea why the Simulator doesn't pull the correct clock time from my PC?  Earlier today it was about 15 minutes behind actual - just ran this again and it was about 5 minutes behind.

 

time check ladder snip.png

Edited by DonNH
added question regarding incorrect clock time

Share this post


Link to post
Share on other sites

I haven't done exactly what you are trying to do, but is there any reason that you are checking every 4 seconds? Can you just delete the first line, and the NO contact on the second line, and just have it run every cycle of the PLC? It just makes the code simpler. You could reduce your 'window' then also (instead of it being 20 seconds).

As for the computer vs simulator time, I have always found that the simulator and PLC time are the same the moment I start the simulator. But then the simulator time runs about 1/3 of the speed of the computer time. Not entirely sure why (I calibrated my PC when I was trying to make them the same), but for most stuff I do it doesn't bother me that much. The calibration option is under the Simulation menu in Sysmac Studio, if you haven't done that yet give it a try. I might help a bit.

Share this post


Link to post
Share on other sites

I picked the 4 second cycle and 20 second window mostly to be able to watch the values and see what's happening when I'm in simulation - actually used a much longer window.

If I remove the first  rung I can actually fit the entire process into a single rung.

Not sure whether there are any downsides to checking every cycle - any appreciable effect on bandwidth?

Currently have a 2ms primary task and 10ms secondary, neither of which is tight for headroom.  Guess if it were an issue I could put it in its own task with a longer cycle time.

Still trying to figure out where it makes sense to have separate tasks/cycle times.

Just fired up the simulator and, as you noted, the times are currently the same.

Edited by DonNH

Share this post


Link to post
Share on other sites

Cannot comment on your particular Omron, but in the Rockwell world the system call {GSV} to read the Clock takes multiple scans to execute and too many of them can affect performance.  I would check yout instruction help and manuals to see how much overhead the GetTime instruciton loads the system.  Having just one I would wager won't kill anything, but do this for a dozen or more times in a scan as I've seen some "green" programmers do and all bets would be off.

Share this post


Link to post
Share on other sites
48 minutes ago, BobLfoot said:

Cannot comment on your particular Omron, but in the Rockwell world the system call {GSV} to read the Clock takes multiple scans to execute and too many of them can affect performance.  I would check yout instruction help and manuals to see how much overhead the GetTime instruciton loads the system.  Having just one I would wager won't kill anything, but do this for a dozen or more times in a scan as I've seen some "green" programmers do and all bets would be off.

The instruction "GetTime" shouldn't exist really. The system variable "_CurrentTime" gives you the exact same thing and is updated automatically.

1 person likes this

Share this post


Link to post
Share on other sites

@DonNH

Threw something on one of my current PLCs real quick that might work for you.

I made them all internal variables, but you could make your upper and lower limits global and editable from a Maintenace menu or something.

65aa2d59d2692_CheckTimeRange.thumb.png.b

 

 

Sadly, Omron does not have very good general "In Range' functions so i usually write some of my own with this exact logic.

For your case, would need to use TIME_OF_DAY variable but to make other range check functions just change the variable types as needed and create any InRange function to suit your need.

 

65aa27f852adf_TimeRangeFunction.png.55c7

 

 

Edited by Str8jCkt

Share this post


Link to post
Share on other sites

The _CurrentTime function looks very useful.

Tried creating and using the RangeChk function - didn't seem to do anything on first try - guess I need to read up on the process of creating and using functions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now