flashing a lamp and buzzer

bgtorque

Member
Join Date
Oct 2013
Location
Northampton
Posts
127
Hi All
There have been a few questions looking through at code for flashing a lamp/buzzer/output at a given frequency. I want to create an ouput that will vary depending on whether in Alarm or in Trip, so basically I have looked at a 4-timer solution to give me an On/Off/On/Off that I can vary the urgency basically. I'm sure that I had this running but have made a mod somewhere along the way and cannot get back to a working condition.

Essentially Timer1On and Timer2On are the times the alarm is ON, Timer1Off and Timer2Off the alarm is off. Here is my Logix code:


TON(Timer1On,150,0);
XIC(Timer1On.DN)TON(Timer1Off,300,0);
XIC(Timer1Off.DN)TON(Timer2On,150,0);
XIC(Timer2On.DN)TON(Timer2Off,1500,0);
[XIC(Timer1On.TT),XIC(Timer2On.TT)]OTE(Output);
XIC(Timer2Off.DN)RES(Timer1On);



My issue seems to be that Timer2Off never completes and even though Timer2Off doesnt complete and so Timer1On RES is never triggered, Timer1On.TT still resumes.

I have tried to to put XIO(Timer2Off.DN) on the first line ahead of Timer1On, but obviously the whole thing never kicks off. Any help on where i'm being thick would be appreciated.

many thanks.
 
Last edited:
Hi, there are 4 timers in there, I incorrectly referenced them as Timer1, Timer2, Timer3 and Timer4 wheras you'll see in the code they are Timer1On, Timer2On, Timer1Off and Timer2Off. I have amended the explaination now to the original post to correct this.

Apologies for the confusion, asking for some help and not explaining things correctly and clearly is not a good start. Thank you for looking and commenting.
 
Hi Steve.

Thanks,the 4th timer starts but never reaches completion. If say the preset is 1500ms then it might reach say 1300 ms. Let me run and trend it and see if I can get an image to post.
 
If say the preset is 1500ms then it might reach say 1300 ms.
When you are monitoring the operation what values do you see for the fourth timer's .ACC tag? Could it be you aren't getting fast enough updates from the PLC to your computer running RSLogix? You'll never see the fourth timer's .ACC value actually get to 1500 because at that point everything resets.
As a sanity check, increase or reduce the fourth timer's .PRE value and monitor to see how close the .ACC value gets to the .PRE
 
I would do all of this with one timer, manipulating the preset, and the comparison instructions "Source B" elements depending on the severity of the alarm conditions ....
 
not sure how you would independantly control the time it is on and the time it is off with a single timer. I want the ability to have two seperate On lenghts and two seperate off lengths essentially. So a quick beep, beep and a long-ish period before it restarts the sequence again. This would be the Alarm state. the beep, beep would be longer beeps and a shorter period before restarts the sequence again.
 
not sure how you would independantly control the time it is on and the time it is off with a single timer. I want the ability to have two seperate On lenghts and two seperate off lengths essentially. So a quick beep, beep and a long-ish period before it restarts the sequence again. This would be the Alarm state. the beep, beep would be longer beeps and a shorter period before restarts the sequence again.

OK, I came up with a beep beep at a slow and fast rate depending on which condition .... perhaps it could be modified to suit your requirements ....

2020-12-13_003940.jpg
 
OK, I came up with a beep beep at a slow and fast rate depending on which condition .... perhaps it could be modified to suit your requirements ....

many thanks for this, just to be clear I am trying to create something akin to this crude representation:

.....| |....| |............| |....| |............| |....| |............


not akin to this:

....| |....| |....| |....| |....| |....| |....| |....| |....| |....| |

If that makes any sense at all. The two on periods could also be different preset values, as coudl the tow off periods (well the two off periods are different presets in the first example.
 
Ok, I was being an absolute dipstick, apologies all. My code was working but i had two issues.

I was testing in a seperate routine and already had the output being triggered by a second version of the code, so these were conflicting.

in the one that I was trying to troubleshoot I had simply not taken enough care and had entered my preset values the wrong way round (so put longer timing in the on's and shorter timing in the off's).

So part of what Steve was suggesting was correct in that I just was not seeing the completion due to the timing. All is good an my original code as in the original post is solid. Thanks for the help and sorry for being a bit of a numpty.
 
not sure how you would independantly control the time it is on and the time it is off with a single timer.


Seems you're on Logix... you can achieve different frequencies pulsing without even using a single timer as long as the frequencies are multiple of each other-ish.

Imagine 1 Hertz rate is the highest frequency you'll need.

Create a timed program/task that runs every 500ms. Create a global tag of type DINT. inside this program increment the tag by 1.

In your logic, use bit 0 of the tag you created and it will be a 1Hz wave. Bit 1 will have half of the frequency and so on...
 
Another country (Codegolfistan ;)) heard from.


yyy.png


TL;DR


Assumes RSLogix 500/Micro/MicroLogix-ish, with 10kHz Free-Running Clock (FRC); could be adapted to Logix using GSV and wallclocktime thingy.

Sequence periods are 102ms on, 307ms off, 102ms on, 1229ms off (ratios of 1+2+1+12=16); can be doubled by doubling N7:1 and N7:2 to 30720 and 6144, respectively. Cannot get 150ms base period or OP ratios of 1+2+1+10=14 with this approach, but it might be close enough. Logix/wallclocktime would make ~134ms base period available (bit 27 in 1MHz, 64-bit clock).




Also, same idea using a single timer, that achieves the 150ms, 1+2+1+10=14 spec:


xxx.png
 
Last edited:

Similar Topics

Hey, New to the forum so apologise if I break any rules. I am trying to write a program insturctured text that will allow me to flash a warning...
Replies
8
Views
16,705
Hi all plz I need ur help, I have a modicon micro plc and the error lamp is flashing (red colour), this happened before from 2year I just changed...
Replies
5
Views
10,855
I have a 1769-L24ER-BB1B and I am trying to flash it to 34xx, its flashing red and faulted, when I try to flash it I get a popup stating it needs...
Replies
14
Views
257
Hi Guys, I have a 1769-L24-QBFCB1 that has the OK light flashing on the embedded counter module. The manual states it is a resettable fault, but...
Replies
0
Views
112
Hello all. I have a remote that uses a 1734-AENTR series C. We had to change it to a new one and, after adjusting the IP and number of slots...
Replies
16
Views
540
Back
Top Bottom