Flashing Output On and Off

jthornton

Member
Join Date
Jul 2002
Location
Poplar Bluff, MO
Posts
295
Having to learn AB coming from Automation Direct where they have a bit that is on for 1/2 second and off for 1/2 second as well as others to use. I had to roll my own so here is what I came up with. My AB rep said I "had" to use two timers... After I thought about it I said to my self WHY??? When I sent him the following code he told me that it would only cycle the ouput one time... But it works as long as you have B:0/0 toggled on. And it used less user words...

flashout.jpg


Is there any reason why not to just let it cycle on and off all the time and instead of and output use a bit then just put that bit in the rung you want to flash the output... such as the following?

flash2.jpg


All comments welcome
John
 
It looks like it depends on the proc as far as scan and memory useage:

proc type   instr. type   false execution    true exec     mem usage  

micrologix les 6.60us 23.6us 1.5
1000 ton 30.38us 38.34us 1.0

fixed,5/01 les 12.0us 60.0 1.5
ton 12.0us 135.0us 1.0

5/02 les 38us 38us 1.5
ton 36us 83us 1.0

5/03 les w/no float point 1.25us 1.25us 3.0
les w/float point .75us 13.19us 3.0
ton 1.40us 1.40us 1.0

5/04 les w/no float point 1.25us 1.125us 3.0
les w/float point .562us 13.94us 3.0
ton 1.312us 1.312us 1.0







I've seen a lot of progs written with the dial timer written at the begining of the code once, then just address the appropriate bits through out the prog.

Drewcrew6
 
Ok, the S:4 word contains the flasher bits (SLC500 only).

S:4/0 flashes at a 20ms rate
S:4/1 flashes at a 40ms rate
S:4/2 flashes at a 80ms rate

.....etc

So S:4/4 (320ms) and S:4/5 (640ms) tend to be the ones I use most.

On another note regarding the logic posted on the first post. Change the LES to a GRT and then you can lose the XIC on the enable bit at the beginning of the rung.

for a PLC-5 you will have to build your own flasher bits. People commonly use two timers to create flashers when one will do it just fine. Plus by varying the source B in the GRT/LES instruction you can vary the on/off cycle time. I usually flash on for 70% and off for 30%, but that's just me.

OG
 
With apologies in advance for offering “more-than-you-ever-wanted-to-know-about-flashers” - I’ll stick in my opinion. (Why kill when you can overkill?) Some of this got pre-posted while I was typing – so extra apologies to Kim Gold and to Operaghost for reiterating some of their ideas.

John, May I suggest that you stick with the SECOND construction of your "flasher" - and look where it can lead you ...

Suppose that someday the boss wants to collect some data every XXX seconds. Use your first rung (second example) and all you have to do is adjust the timer's preset to set up the required period. Then use the timer's done bit on a separate rung to "trigger" the data collection. In other words, the construction you have shown for your first rung, is a text-book example of a TRIGGER for a "repetitious cycle". There are many, many, many uses for this. And if you came up with this solution on your own, congratulations are certainly in order.

The second rung is good - but would be a little better if you were to delete the enable bit contact. (As per Kim Gold). This contact is superfluous - a fancy word for "it doesn't buy you anything". But hold on, don't take my word for it - let's use it as a learning exercise. Modify the rung by adding an unconditional branch right around the enable bit contact. That's the ladder logic equivalent of an electrician's "hot wire - jumper it out" test connection. Now retry the operation of your flasher. If it works just as well (with the branch), then you'll have PROVEN that the contact is indeed superfluous (and more importantly, possibly learned a useful troubleshooting technique in the process). You can now delete the superfluous contact and the branch with confidence. Some programmers leave the "jumper branch" in their programs for days or weeks - just to make sure that something they THINK is extra - actually is. Later they come back and clean up by deleting the extra junk and their "test jumpers". On the other hand, if the test proves that they were wrong, they can easily put the questionable contacts back in service by simply deleting the "jumper" branch. This, of course, is much easier and quicker than re-entering a bunch of deleted contacts.

Next, why did you use a LESS THAN comparison rather than a GREATER THAN the way most students do? Just luck or sheer genius? Think about this: instead of entering the constant value 50 for Source B, suppose that you entered N7:0 for a VARIABLE location. Now enter 50 into N7:0 and you've got exactly the same flashing pattern as before. But watch what happens when you put 20 into N7:0. Now your flashing bit is 20% ON and 80% OFF. Try putting 80 in N7:0. Now you've got 80% ON and 20% OFF. That's why I personally like the LESS THAN approach. With the GREATER THAN I have to "invert" the value I enter - in other words, for 10% on, I have to enter 90 at N7:0. I like the straight-forward advantage of the LESS THAN for my flashers. (OG obviously has me beat in the math arena).

Next lesson: Let's suppose that you have an electric range at home - as opposed to a gas one. Let's further suppose that to increase or decrease the heat for a pot of beans, you turn a knob - as opposed to pushing a series of buttons. Most modern ranges work this way. Now set the heat to about halfway and put your ear close to the knob. That click....click....click.... that you hear is a "time proportional signal" generated by the burner switch. Set a different heat and you'll hear a different pattern - for example: ............click..click..........click..click............click..click....... The switch is just turning the heating element off and on in different PROPORTIONS of time. See where I'm going with this? Replace your flashing lamp bulb with the heating element on your range. Now the PLC can control the temperature of your pot of beans just by varying the value in N7:0. In another lesson we'll find out how to scale the output of a PID block from 0 to 100 and aim it at N7:0. Hook up a thermocouple as a temperature input to the PLC and we'll be ready to control the temperature of the pot of beans in fine style. And your excellent "flashing lamp" solution is an integral part of that.

Next lesson: suppose that we need an alarm light for a "boiler pressure too high" condition. You COULD just turn the light ON for an alarm - or even flash it when the pressure gets too high. But how about this? Mathematically scale the pressure signal and send it to N7:0. Now the operator can look at the flashing pattern of the alarm lamp (a LITTLE BIT on - or a WHOLE LOT on, etc.) - and get a fair idea of just HOW MUCH too high the pressure has become. True, the scaling part of this might be a lesson for another day - but the "flashing lamp" exercise will come in very handy down the road.

The scariest part of all this is: most people just "figure it out" on their own - usually using two timers - and go away happy with a "flashing lamp". There's a lot more educational juice hidden in most of these little "beginner" exercises. I commend you on having squeezed this one beyond what the rep told you "had" to do.

Want more flasher fun? Investigate bits S:42/0 or S:42/1, etc. How about T4:0.ACC/4, etc.? How about S:4/4, etc.? Suppose that for our "boiler pressure too high" flashing lamp exercise above, we want the lamp to stay COMPLETELY on when N7:0 reaches 100. Specifically, absolutely NO FLICKER is acceptable.

Offline until Tuesday – a safe and enjoyable Labor Day to all -
 
OG I specificly asked the rep if there was a bit like S:4 he said no! Go figure... For general flashing light with a 50% on cycle this will work great. When I test it out on my Micro 1500 I see an erratic flashing pattern. Any idea why this is?

Also, why do you flash a light 70% on 30% off?

Thanks
John
 
Ron,

Let me thank you so much for such a great reply. When you take your time up with such a long reply I will spend even more time studing it. I really thought that it was neet to use the timer ACC on the bit level to flash an output. Depending on which bit you use as to what flashing pattern you get.

On the second example the second rung the enable contact was left over from the first example. I got in too much of a hurry and forgot to delete it. It was there in the first example so the output would not be on all the time when the timer was not timing...

As for the test branch I assume you put a XIO in the branch as without it I get an error. I have seen some programs where a bit is used as a test bit and labeled so clean up is easier.

The reason I used LESS THAN is it made more sense to me and seemed to make the code more readable to me. Maybe more luck than genius, but I catch on quick... When using an interger to store the source for the LES instruction is there a slick way to prevent the value from being larger than the preset of the timer? and the light never flashes...

The "Boiler Pressure too High" looks like a fun one to do. I have done scaling for conversion of analog inputs to engineering values for load cells with AutomationDirect PLC's. So that does not scare me... Would the total length of the flashing cycle be easier to interpert for an operator. For example start with a 2 second total cycle and (thanks to OG) 70% on 30% off cycle then as the pressure goes to 50% overload have the cycle time at 1 second up to full overload when the lamp stays lit. Of course scaling the cycle time from the 2 seconds to 0 seconds or on all the time... In other words a slow flash indicates we are over pressure a bit and as the flash speed increases it indicates the increse of pressure... I'm sure there is some logical point to quit decreasing the cycle time I don't think you can see the flash much past 1/20th of a second or so...

More flasher fun... I know you put the "Specificly, absolutely NO FLICKER is acceptable" in there for a reason... but I don't know why yet... I don't know everthing I don't know about it yet, but I'm learning.

Thanks a million
John
 
John,

Take another (closer) look at this one:
As for the test branch I assume you put a XIO in the branch as without it I get an error.
I’ll bet that when you try to compile the rung with an unconditional branch, what you get is a “WARNING” for the “shorted branch leg” NOT an “ERROR”. A “warning” is the software’s user-friendly way of letting you know that what you programmed looks a little bit fishy. But it WILL go ahead and compile (and run) in an Allen-Bradley – although other brands may not accept it at all. Note that true “errors” will NOT compile.

Hint for “Specifically, absolutely NO FLICKER is acceptable":

The range of values in the timer’s accumulator will be 0 to 100. The way we originally set up the LESS THAN comparison, N7:0 would have a maximum value of 100 (representing 100% of some input signal). When the timer reaches 100 (which it WILL DO once each second) then the LESS THAN will test false – and the lamp will flicker out. Now if you’re using an incandescent lamp, the filament won’t actually cool enough for your eye to notice the flicker. But with an LED (including the built-in one on the SLC’s output) if you look closely enough, you should see a slight flicker once each cycle when the timer is done. It’s only there for ONE SCAN – but it IS there. Now suppose that the output we’re flashing is controlled by remote I/O (as opposed to local I/O) then the flicker will be much more noticeable – and it will be more erratic too. That’s because remote I/O is handled through a “buffer” and is not serviced each and every scan. Even with an incandescent lamp, you will notice an annoying flicker using remote I/O. This demonstration makes a very convincing argument as to why time-critical and fast-acting signals are better handled by local I/O rather than by remote I/O. So now the question remains – how do we cure the flicker?

You also asked:
When using an interger to store the source for the LES instruction is there a slick way to prevent the value from being larger than the preset of the timer?
The answer is “yes” – but I’m not posting it now since you might want to think about it some more on your own. Hint: If the value of N7:0 is greater than the value of the timer’s preset ... then .... what do I want the processor to do?
 
John, When you asked OG:
When I test it out on my Micro 1500 I see an erratic flashing pattern. Any idea why this is?
I hope I'm not being too presumptuous by answering for him, but were you by chance watching the flashing pattern of an "internal" bit on your computer screen? If so I may have an answer for you. The screen lies. Send the flashing action to a physical output and watch the action there. It should be 50% on and 50% off. Sad but true: the indications on your screen are NOT tied directly to the processor's scan. Plus the information that the software posts on your computer screen must be transferred from the processor to the computer through the (relatively slow) serial link. All of this amounts to a certain amount of "slack" between what is actually happening inside the processor and what you see represented by the software on the screen. This effect plays havoc with some of the best intentioned troubleshooting efforts of many beginners - so even if you're familiar with it, I thought I'd bring it up for those who are reading over our shoulders.
 
Ron just as I read the first sentence of your last reply it hit me between the eyes... I was familiar with it but forgot. Thanks for reminding me. Now back to the problem...

John
 
Ron I got one warning and one error when I did the shorted branch.

I tried to d/l to the plc but no luck. My test rig is a Micro 1500.

Warning Shorted Branch Leg
Error Compiler Error number 4098

John
 
Hi Ron,

Here is what I came up with on the flashing output that would blink one each second. First I could not see the flicker and not trusting my eyes I had to prove it true or false by inserting a counter to count the flicker.

ladder6.jpg


Next I changed the LES (Less Than Comparision for newbies) to LEQ (Less Than or Equal To). Then ran the code again to prove to myself that it was not flickering even for one scan.

ladder7.jpg



Both screen shots are while online and in run mode so you can see the values of the counter.

I love this stuff
John
 

Similar Topics

Hello everyone, I am having issues with an output module connected to my 5069-L306ER PLC. The modules I have connected are a 5069-IA16 in slot 1...
Replies
1
Views
642
When trying to troubleshoot a machine at my factory, I was checking out the PLC and on one of the output cards there were a bunch of flashing...
Replies
4
Views
2,111
Hello there, Sorry I am quite new to this... thank you for taking the time to answer my thread. I have a small problem trying to get an output...
Replies
23
Views
5,053
Hi everyone, I have an output module that is blinking outputs 6 and 7 even when I take the wires out from the terminals. I thought it was the...
Replies
6
Views
4,893
Im trying to flash an output (50/50 duty cycle, .5 sec on/off.) I thought a TON/TOFF setup, but I cant get the logic down right. Is there an...
Replies
7
Views
18,125
Back
Top Bottom