Time Pulse with Random Generated Time values.

duckie112

Member
Join Date
Mar 2012
Location
In a cardboard box
Posts
46
Hi, I have a problem with my Pulse Timer that need to work with pseudo-random generated time values.
Code:
      A(    
      L     MW    30
      L     MW   200
      ==I   
      )     
      L     MW   150
      SP    T     20
      A     I      4.7
      R     T     20
      NOP   0
      NOP   0
      A     T     20
      =     Q      0.7
This is my pulse timer code. The mw200 and mw150 are psuedo-random values. The part with the mw200 is working but when the timer got his enable signal the timer wont pick up the mw150 value. I want the random time value be working 100% instead making it a standard value. It is a simple program to simulate downtime at a random number of products and with a random downtime to max 15mins. The values both change every 15 minutes.
 
Last edited:
Code:
...
L MW   150
ITB
SP T     20
...


Timers use binary coded decimal.
Which is not the same as a normal integer.
 
To restart a timer, the RLO at SP T 20 needs to go from 1 to 0 and then back to 1 again.
this means that if MW30 and MW200 remain identical, you CANNOT use I 4.7 to reset the timer. As it is written now.

Change it to:
Code:
      A(    
      L     MW    30
      L     MW   200
      ==I   
      )     
      AN    I      4.7
      L     MW   150
      ITB
      SP    T     20
      NOP   0
      NOP   0
      A     T     20
      =     Q      0.7
That's the only reason I see why it won't work.
As you can see in my screenshot, it works.

Timer.jpg
 
To restart a timer, the RLO at SP T 20 needs to go from 1 to 0 and then back to 1 again.
this means that if MW30 and MW200 remain identical, you CANNOT use I 4.7 to reset the timer. As it is written now.

Change it to:
Code:
      A(    
      L     MW    30
      L     MW   200
      ==I   
      )     
      AN    I      4.7
      L     MW   150
      ITB
      SP    T     20
      NOP   0
      NOP   0
      A     T     20
      =     Q      0.7
That's the only reason I see why it won't work.
As you can see in my screenshot, it works.
The 2 values are changing at a set interval time. MW30 is counting 1 up every 14 seconds and MW200 is randomly generating a number between 0-999 every 15 minutes. When the time comes above 10mins in the MW150 it refuses to pick up that value for some reason. And when the timer is started MW30 stops counting until the timer is done.
EDIT: After a bit of testing it seems it doesn't work with 99% of the time values.
 
Last edited:
Have you accounted for the format of the S5#Time use with the Timers ?

The time format is a word. This word can be represented as:
bvvv

Where b = time base (0-3)
Where v = BCD value (0-999)

The time base is the resolution at which the BCD value should be interpretted.
0 = 10 msec (10 msec to 9.99 sec)
1 = 100 msec (100 msec to 99.9 sec)
2 = 1 sec (1sec to 16min 39sec)
3 = 10 sec (10sec to 2h 49min 30sec)

Examples:

W#16#0124 = 1240 msec
W#16#1475 = 47.5 sec
W#16#2048 = 48 sec
 
Have you accounted for the format of the S5#Time use with the Timers ?

The time format is a word. This word can be represented as:
bvvv

Where b = time base (0-3)
Where v = BCD value (0-999)

The time base is the resolution at which the BCD value should be interpretted.
0 = 10 msec (10 msec to 9.99 sec)
1 = 100 msec (100 msec to 99.9 sec)
2 = 1 sec (1sec to 16min 39sec)
3 = 10 sec (10sec to 2h 49min 30sec)

Examples:

W#16#0124 = 1240 msec
W#16#1475 = 47.5 sec
W#16#2048 = 48 sec

I think the values will go out of range most of the times.
Code:
      L     MW     150
      L     W#16#2000
      OW    
      T     MW     160
I think I'm going to try this with it. Didn't use this part alot so don't know if it works.
EDIT: So far this method with yours works but it still needs more testing. Thanks for the help. I keep learning more and more from this forum about SCL/STL :D
Edit2: Seems the values are going from 0vvv-Fvvv. Also I need to cap this to maximum 15 minutes.
 
Last edited:
I got it working by dividing the output of the number generating with 1000 and import that value to BCD and using the
W#16#2000
OW
Sometimes it still goes out of the S5T value but now it will run good for 99% of the time so thats fine with me.
Thank you for your help. I understand the problem much better now :D
 

Similar Topics

Hi All, I'd like to know can we use DTR instruction to get a week pulse ? Could anyone please help me to understand that one ? I've managed to...
Replies
4
Views
163
Hello, I am struggling to figure out some logic. I have an analog pressure sensor coming into the PLC and would like to have multiple timing...
Replies
4
Views
129
I have PLC Omron CJ2M with OD211 module. I want to use the pulse output and PWM output and this module. But i confuse how to activated this, i...
Replies
0
Views
75
I am monitoring two BMXDDO3202K digital outputs for their behaviour, they are each for opening and closing, and so the on time affects how far the...
Replies
1
Views
270
Hi, So we have a flowmeter installed but doesnt have a feature to send a pulse to plc for it to compute the total volume. I want to somehow...
Replies
3
Views
556
Back
Top Bottom