Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - Run timer for hours

(you are viewing a thread; or go back to list of threads)

Run timer for hours (by Victor)
Hello!
I would like to run a timer for 6 hours then turn off.
Is this possible?

Thanks in advance!
Mon Oct 22 2018, 11:37:06
(no subject) (by Tom J.)
I imagine there's at least a dozen ways, I'm relatively new so this method is undoubtedly not the most efficient but here's one example using ADD statements.

If the timing is critical you'll need to run external oscillator to be accurate due to slight inaccuracies with internal RC clocks.

Changing the two "compare for =" values can accomplish many overall durations.
Mon Oct 22 2018, 19:29:57, download attachment 6HrTimer.ld
Run timer for hours (more simple) (by DanielH)
Hello Victor!

Attached 6HrTimer_simple.ld example on how to program an one shot timer up to 546 hours (32767 minutes, max. positive value of a 16 bit signed variable) including 0.01 second resolution.

This program use COMPARE, ADD and MOVE instructions and only TWO variables (thus, saving RAM usage).
Also, its implement PLC Cycle Time setting = 10.000 ms as timer base; of course, you must change the tic compare operation value at Rung 2 (6000 in this example) according to your cycle time parameter.

You must set the minute and tic (0.01 seconds) values in COMPARE >= operations at Rung 3, according to your needs.

In this example, timer parameter is 6 hours, 4 minutes and 3.5 seconds (of course, if you don't need such resolution, you can set the tic parameter to 0, or delete the tic COMPARE operation in this rung if you want use only minute resolution).

Also, if you wish you can use other variables from math operations, analog reads, etc. (not fixed values) as parameters for minute and tic comparations.

As TomJ. says, is better to use external oscilator (crystal) to increase timing accuracy

Best regards,
DanielH
Tue Oct 30 2018, 15:43:29, download attachment 6HrTimer_simple.ld
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):