related with logic

What about this??

This works... Tell the pros and cons...
FlipFlop.JPG


r_champion.gif
 
I've always been a proponent of making code as complicated as it needs to be to provide the best resuls for the user... however...

Daniel, your code requires data logging (mental or otherwise, for trouble-shooting purposes) whereas my code, in the thread you pointed to, does not... the ultimate status is always known, all the time, without counters and compares.

Counters certainly work... but... if you pursue this line of thought... yer gonna pi$$ Ron off!

Randy posted, in another thread, that programmers tend to think that their particular code is creative... he is right. However, that does not mean that the particular programmer is right... but, then again... like I said in my post, in that thread, that depends on the experience of the programmer. A lack of experience will cause a novice to go in all kinds of "new directions"...

Most programmers MUST go through RGSP (the Rube Goldberg School of Programming) before they realize the folly of their ways.

"CUTE" code is not "ELEGANT" code.

Scientifically speaking, an "Elegant Solution" is that solution which provides the expected result in the simplest manner. An "Elegant" solution must be only as complicated as necessary to handle all possible cases.
 
Darn it

Counters certainly work... but... if you pursue this line of thought... yer gonna pi$$ Ron off!

Dont reckon I should mention my flasher ckts using compare instructions or the LIM instructions with an AB?
http://www.patchn.com/ab_plc_flasher.htm
I do have it with 2 timers though.

Tell the truth I am not sure whether counters should be that complicated for someone that is expected to connect to a plc and troubleshoot.

I reckon its not always knowing what IS but also what WAS.
OR
I am being converted to Engineering thinking...eeeewwwww.
 
Not sure what the heck you said... but...

Terry Woods said:
Daniel, your code requires data logging (mental or otherwise, for trouble-shooting purposes) whereas my code, in the thread you pointed to, does not... the ultimate status is always known, all the time, without counters and compares.

Data Logging? Mental? OMG... Why do we have counter and compares in programming if they are not stable or reliable... As far as "the ultimate status" if you want to know, just look at the LIGHT.

Terry Woods said:
A lack of experience will cause a novice to go in all kinds of "new directions"...

I just wanted to give another viewpoint of how this could be done...
Now, don't tell me it's:
Terry Woods said:
"CUTE" code is not "ELEGANT" code.
Tell me why, in your opinon it would not be suitable for use?
Furthermore, who in there right mind would use one fricking input to turn something on or off?

Ron said:
Tell the truth I am not sure whether counters should be that complicated for someone that is expected to connect to a plc and troubleshoot.
It works, its not complicated and it consise...
 
Terry Woods said:
Daniel, your code requires data logging (mental or otherwise, for trouble-shooting purposes) whereas my code, in the thread you pointed to, does not... the ultimate status is always known, all the time, without counters and compares.

honestly, i think daniel's code is pretty easy to follow... just because it uses something other than XIC/XIO and TON instructions it's suddenly horribly complicated? :confused:

and being a maintenance guy who stumbled into PLC's I know i would have rather tried to decipher his rung rather than try to figure out the examples that require a good knowledge of how the ladders are scanned.
 
I gave a little but dont mean I ever think something as simple as a flip flop should ever ever use anything but bit instructions.

Ever seen a counter used to create this in relay logic?

Whats so neat about a plc is that you can create something like this that resembles relay logic and is easy, for an ordinary maintenance/electrician to understand.

As was stated...ITS CUTE. Now to disassemble your code, if 0 (zero) sets the lamp (ouptut)ON and the rung in front of it is FALSE then at startup it will be OFF. When you push the PB it then counts to 1 which will UNLATCH a non latched bit. Push the PB again then it resets the counter to zero.

I would have to test this but one of 2 things will happen. Either it will take pushing the button twice to turn on the output OR the OSR will just reset the counter and never set the OTL.

Did I see this wrong?
 
Last edited:
ron... i'm obviously pretty new to this, but i thought counters were memory locations that were immediately changed unlike inputs and outputs that are only updated between scans.

i figured that's why he didn't use XIC C5:0/DN on the second branch and the GEQ instruction instead.
 
ron... i'm obviously pretty new to this, but i thought counters were memory locations that were immediately changed unlike inputs and outputs that are only updated between scans.

I aint new, just not a programmer. I forget how some updates work from brand to brand for different functions, thats why I said I would have to test it.

The way I see this code on startup (if OTL is FALSE) you would have to have the input true twice to make the OTL true. Let me see if I can explain what I see

PLC is powered
OTL is False when powered. (OTL is retentive)
Count is zero
Rung is false so OTL stays false.
Input goes true, OSR goes true, count goes to 1
Equal 1 OTU true (OTU is retentive)
Input goes true, counts goes to 2, count is reset to zero
Equal to zero then OTL is true.

This assumes that a counter is immediately updated in one scan, I havent checked that yet. I believe that is how AB works but havent tested it yet.

If it does NOT immediately update then its worthless, zero count will never set the OTL.

I may be looking at this wrong but I have a SLC fixed I/O that I can test it on tomorrow.

The S bits are kind of standard if the timing sequence fits your application. I have 2 reasons I dont use them, one is they rarely ever fit my timing needs, the other is I deal with many brands that do not have the equivalent.
 
If you want to use a counter to create a flip flop this is the simplest way to do it. No need to reset, no need to worry about the DN bit, no need to worry about roll over, no need to give a rip about what the actual ACC value is.
untitled.GIF


If you want it to set to off on the first scan, just do this.
untitled1.GIF


This code is predictable and it will behave as expected every time, even when roll over from 32767 to -32768 occurs because of the two's compliment binary format
 
Last edited:
rsdoran said:
If it does NOT immediately update then its worthless, zero count will never set the OTL.

I may be looking at this wrong but I have a SLC fixed I/O that I can test it on tomorrow.
Not to worry it has been tested and works fine... Why is it so dificult to accept another way of doing something? I was Project Engineer for 20 programmers, and if I gave the same program to 20 people to do, I would end up with 20 different programs all that do the job. However, I look for, ease of understanding, scan time, memory usage and of course that it is stable... I am not so arogant to think my ideas are the best and I will always accept any valid criticism...
 
Daniel,


I have used something similar.

We used it toggle an HMI Graphic with the Integer State, and used the bits of the integer to control manual and auto functions. Quite nice actually. It served a dual purpose. ANd I did not find any maintenance guy not able to understand it with a brief explanation.

David
 
Alaric said:
If you want to use a counter to create a flip flop this is the simplest way to do it. No need to reset, no need to worry about the DN bit, no need to worry about roll over, no need to give a rip about what the actual ACC value is.
untitled.GIF

Damn... that's slick. It never dawned on me that you could treat the ACC at the bit level.
 
rsdoran said:
I aint new, just not a programmer. I forget how some updates work from brand to brand for different functions, thats why I said I would have to test it.

Sorry, I wasn't implying 'greeness' on anyone's part other than my own.

I coincidentaly was taking a microprocessor/microcontroller class at the same time that I was teaching myself the the SLC's instruction set, so it always made a lot of sense to me that memory locations are updated immediately in AB.
 

Similar Topics

I need to know how to take a schematic like this and solve it for let’s say a run time of 5 seconds By solve I mean determine which rungs are...
Replies
33
Views
9,132
We got one installation that have most of the Win10 PC in a rack above the control room. In the past they always used various flavor of KVM...
Replies
7
Views
2,969
What's your favourite source of PLC/SCADA-related news? Maybe some of you still read printed magazines?
Replies
4
Views
2,082
... yesterday I removed the plastic liner on the tail-gate of my Kia Soul to get at the broken reversing camera... It has 12 of those plastic...
Replies
17
Views
7,256
Good morning all, this is not PLC related so if not allowed just delete. But i have a problem with my RV that has got me stumped big time. I have...
Replies
12
Views
3,709
Back
Top Bottom