I need help writing a program.

K

Thread Starter

kc2300

when button is pushed once light1 will turn on. when it is pushed a second time light1 will turn off and light2 will turn on. when the button is pressed a third time light2 will turn off and light3 will turn on. when the button is pushed a fourth time light3 will turn off and light4 will turn on. then when the push button is pressed agian light4 will turn off and light1 will turn back on. Any input on this would be very helpful. addresses are not needed and this is for an allen bradley program. Thanks
 
A

Armando Abraham - INGDESI

<P>Hi,</P>

<P>I was thinking about that and I could do this programs,</P>
<PRE>
* *
* -(first scan bit)---------------------(C := 0)*
* *
* Pushbotton *
* ---( P )-----------------------------(C :=C+1)*
* *
* *
*---(If C=1)-------------------------("light 1")*
* *
* *
* ---(If C=2)------------------------("light 2")*
* *
* *
* ---(If C=3)------------------------("light 3")*
* *
* *
* ---(If C=4)------------------------("light 4")*
* *
* *
*---(If C=5)----------------------------(C := 1)*
*

"C" is an 16bits register.
</PRE>

<P>I hope that you can understand that, but if is not true, please send me a mail and tomorrow I can send to you a PLC program made with RsLogix5 or RsLogix500.</P>

<P>Armando ABRAHAM<BR>
INGDESI<BR>
Buenos Aires, Argentina</P>
 
B

Blunier, Mark

<PRE>
PB Y X
--| |----|/|----()

PB Y
--| |-----------()


A B C D NONE
--|/|----|/|----|/|----|/|----( )

NONE
--| |--
|
D | X A
--| |----| |----( )
|
|
A X |
--| |----|/|---

A X B
--| |----| |----( )
|
|
B X |
--| |----|/|---

B X C
--| |----| |----( )
|
|
C X |
--| |----|/|---

C X D
--| |----| |----( )
|
|
D X |
--| |----|/|---
</PRE>
<P>Mark Blunier</P>
<P>Any opinions expressed in this message are not necessarily those of the company.</P>
 
B

Bruce Axtell

<P>There are several ways to approach this. I'll give you a couple ideas, and there are variations on each.</P>

<P>Method 1: Use a counter.</P>
<PRE>
pb
|------| |------------(ctu) Preset = 3

|-----[ctu.acc = 0]-------------(ote)light 1

|-----[ctu.acc = 1]-------------(ote) light 2

|-----[ctu.acc = 2]-------------(ote) light 3

|-----[ctu.acc = 3]-------------(ote) light 4

|-----[ctu.acc = 4]--------[mov 0 to ctu.acc]

Method 2: Add 1 and place the sum back into the same address.

pb
|------| |------------------[ add: Register 1 + 1 = Register 1]

|-----[register 1 = 0]------(ote) light 1

|-----[register 1 = 1]------(ote) light 2

|-----[register 1 = 2]------(ote) light 3

|-----[register 1 = 3]------(ote) light 4

[-----[register 1 = 4]------[mov 0 to register 1]
</PRE>
<P>Depending on what you are using for a PB, you may need to debounce and/or one-shot.</P>

<P>Bruce Axtell<BR>
Engineered Control Systems<BR>
763-421-8787<BR>
763-712-5477 fax<BR>
[email protected]</P>
 
S
If you have control over the physical I/O addresses, you can initialize an integer to one (2^^0), and multiply by two on each button press, until the value is 8 (2^^3). Then reset to 1. Then you can simply MVM (move with mask) to the I/O module word. If the lamp outputs do not start at bit 0 of the module word, you would ahve to adjust the intial and final register values.
 
Boy oh boy, this looks like a shift register. There should be an example in your AB documentation.

Good luck.

John Ross
 
E

Eduardo Manuel C. Cipriano

Hello there try this program,<br>
<br>
It's a single rung program that works fine you dont have to use or waste too much rung and instructions for that..........<br>
<pre>

! I:1 !--SQO--------------------!
!---(OSR)--------------! Sequencer Output !
! ! File #N7:0 !
! ! Mask 001Fh !
! ! Dest O:3.0 !
! ! Control R6:0 !
! ! Length 5< !
! ! Position 0< !
! !-------------------------!


N7 file Setting

offset 0 1 2 3 4 5
N7:0 1 2 4 8 16 0

</pre>
Try not to use too much rung when programming
this is an actual program that i have done on RsLogix500, simple doesnt it?<br>
<br>
[email protected]<br>
Eduardo Manuel C. Cipriano<br>
Sr. Systems Engr.<br>
Systems Engineering Department<br>
Yokogawa Philippines Inc.<br>
 
D
I see that several people have the solution but I am including the actual allen bradley logic to implement one simple method:<br>
<pre>
____________
|CTU |
--|PB1|---|OSR|------------------|COUNT UP |--
I:0/0 B3/0 |COUNTER C5:0|
|PRESET 5|
|ACCUM 0|
--------------
_________________
|EQU |
--|EQUAL |-----------------(LIGHT 1)-- |SOURCE A C5:0.ACC| O:0/0
| 0|
|SOURCE B 1|
-----------------

_________________
|EQU |
--|EQUAL |-----------------(LIGHT 2)-- |SOURCE A C5:0.ACC| O:0/1
| 0|
|SOURCE B 2|
-----------------

_________________
|EQU |
--|EQUAL |-----------------(LIGHT 3)-- |SOURCE A C5:0.ACC| O:0/2
| 0|
|SOURCE B 3|
-----------------

_________________
|EQU |
--|EQUAL |-----------------(LIGHT 4)-- |SOURCE A C5:0.ACC| O:0/3
| 0|
|SOURCE B 4|
-----------------

_________________ ______________
|EQU | |MOV |
--|EQUAL |--------- |MOVE |--
|SOURCE A C5:0.ACC| |SOURCE 1|
| 0| | |
|SOURCE B 5| |DEST C5:0.ACC|
----------------- | 0|
|______________|
</pre>
 
Top