Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation Direct DL05 - random time routine needed

Status
Not open for further replies.

hrc

Electrical
Nov 8, 2001
104
I have a Koyo DL05 PLC. I have the code written (is that really a good term for developing ladder logic?) to generate a 1 min timer to increment a counter, so I can program a delay of 45 minutes. Now, what I need to do is have a random amount of time from 1 minute up to 15 minutes added to this intial 45 minutes. Using a microcontroller its easy, but how do you generate a seed for a random number generator? I played with barrel counters and IF I could have it so it could "pick" a contact when the intial counter reached 45 minutes, that might work. After the 45 min + random time, a second fixed time sequence occurs. So far, everything works except for the random time adder. Any ideas?
 
Replies continue below

Recommended for you

If I understand your problem correct then you need some sort of random number generator (1 to 15).
You can make a timer (anther timer say T2 with 17 as preset value) the timer is self reset timer when reach value of 17. when you reach your 45 minutes read the timer value and use it as your random number (if timer =0 or >15 then you can assign numbers or add/deduct 2 from timer value).
The number 17 will give you 1020 before same pattern will be repeated.
Alternative to timer you can do it with counter.

Your program may looks like this
(T0/)---------------------TMR T0 K60
{ timer T0 will generate pulse each one minute}

(TO)---------------------CNT 1 K45
(CT1/)
{Counter 1 will advance one per minute then reset it self when =45}

CT1 ----------------------> your equired actions here

Add these rungs

(T2/)------------------ TMR T2 K17
CT1-------------------- LD TA2
OUT V2000
CT1------(TA2=0)------- LD K1
OUT V2000
CT1-------(TA2>=16)---- LD TA2
SUBB k2
OUT V2000

Now in V2000 you will have your random number.
Also you can use fast timer instead of normal timer this will give you much better results
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor