small help please

John Grizia

Member
Join Date
Jun 2002
Location
leeming Western australia
Posts
4
I need to write a small rutine to energize 6 outputs on and off with
one single imput push button.
for example one push will operate output 1 on next push will deenergize output 1 next push will energize output 2 and next will
deenergize output 2 and so on in a continuos loop always starting with
output one .
thanks

John
 
This is the effect you are looking for...??




STEP Y1 Y2 Y3 Y4 Y5 Y6 C1

1 1 0 0 0 0 0 0

2 0 1 0 0 0 0 0

3 0 0 1 0 0 0 0

4 0 0 0 1 0 0 0

5 0 0 0 0 1 0 0

6 0 0 0 0 0 1 0

7 0 0 0 0 0 0 1


.

The Y#'s represent your outputs.

Notice how, from Step to Step, the "1" proceeds across to the right.

Does this look familiar at all? Have you seen anything in your book that looks like this? Have you read your book? The "C1" might give you a clue.

You should also think VERY carefully about "CAUSE & EFFECT".

What is your "CAUSE" and what "EFFECT" should it produce?
 
Small help

Terry, I may be wrong, but to me it looks like John describes something like this:

Code:
Push  Y6 Y5 Y4 Y3 Y2 Y1
   0   0  0  0  0  0  0
   1   0  0  0  0  0  1
   2   0  0  0  0  0  0
   3   0  0  0  0  1  0
   4   0  0  0  0  0  0
   5   0  0  0  1  0  0
   6   0  0  0  0  0  0
   7   0  0  1  0  0  0
   8   0  0  0  0  0  0
   9   0  1  0  0  0  0
  10   0  0  0  0  0  0
  11   1  0  0  0  0  0
  12   0  0  0  0  0  0
  13   0  0  0  0  0  1

So maybe the INCREMENT (or MULTIPLY with 2) should depend of a TOGGLE bit...
 
For the specific sequence, you are mo' righter than I am.

There's only about a half-dozen (or more) ways to do this.

I simply displayed a very generic idea of a similar effect.
 
I got a private message and since I am agree upon that all correspondence should be on this board, giving others the possibility to learn and give assistance, I will put my answer here.


Hi John

I'm not a Mitsubishi-man, so here is a general answer.

Personally I would use an INTEGER (a WORD) to solve this task.

The pushbotton toggles an internal bit. If the bit goes high (egde detect), an integer is incremented. (When it reaching max limit, it must be reset to zero again)
If the toggle bit is low, all outputs (or Output{INDEX}) are reset.
If the toggle bit i high, only the output{INDEX} is ON.
That is, if you can use INDEX or INDIRECT adressing with your PLC.

Of course you can also write a rung for each output with:
COMPARE INTEGER with OUTPUTnumber + AND togglebit

Another tips is MULTIPLY with 2. If you multiply 1 with 2 with 2 with 2 etc you get: 1, 2, 4, 8, 16, 32.
Binary it looks like this:
000001 = 1
000010 = 2
000100 = 4
001000 = 8
010000 = 16

Does the pattern looks familiar?

This is only a few suggestion's. There are others, like Graftech etc.

I'm also sure that someone soon would show you a K-map solution on the situation......


Regards
Karl Egil
 
Last edited:
You could use a shift register

The insruction looks like this

--{m0}-------{SFTL M1 Y0 K1}

m0 needs to be pulsed by the push button and M1 needs to be on to operate the shift.

On each pulse, this will move the Y outputs one to the left.
To cycle, y5 will have to break the supply to M1 to reset the shift pattern.
 
TANGENT ALERT

Earlier this year there was many threads (also tangents) with PLC versus PC, Ladder vs Instruction list and related topics.

Poster's feelings was involved and there was many comments, like :
- "dumbing down the code for the sake of maintenance"
- "programming versus maintenance"
- "that ladder is overall just as effective "
- "engineers that want it to be so high level that the working man can not deal with it, which in turn puts more money in their pocket"
The debate ended quickly.

As I guess the oldtimers here know, I am a listprogrammer. And I also consider Index/Indirect adressing as standard tools. (Hey, this sounds like a AA meeting : My name is XXX and I am a listprogrammer)

To the end (or until some money) I will be convinced that Instruction List is:
- Faster to write
- More compact
- have more opportunities
- less "copy-errors"
etc
(There can be PLC brand exception's)

Mr John Grizia's "problem" can be used as an example:

--------------
Example of STRUCTURED TEXT:
(This code can be used by a Telemecanique Micro or Premium PLC. STRUCTURED TEXT conforming to standard IEC 1131-3)

Code:
IF RE PushBotton       (* RE = RaisingEgde  *)
THEN
   ToggleBit := NOT ToggleBit;  (* Invert internal bit *)
END_IF

IF RE ToggleBit        (* RE = Raising Egde *)
THEN
   OutPutNumber := OutPutNumber + 1;  (* Increment OutPutNumber *)
   IF OutPutNumber > 5        (* 6 outputs: OutPutNumber = 0-5 *)
   THEN
       OutPutNumber:=0;       (* Reset index  *) 
   END_IF;
END_IF;

Output[OutPutNumber] := ToggleBit; (* Output(Adress+OutPutNumber) gets status of Togglebit *)
Where:
Pushbotton = input of type %Ix.i
Togglebit = internal bit of type %Mi
OutPutNumber = internal word of type %MWi
Output= output(s) of type %Qx.i

The initial status of OutPutNumber and the outputs are zero. All outputs must be in a sequence and on the same module.

--------------------------------
INSTRUCTION LIST example from another PLC:

The initial status of OutPutNo and the outputs are zero. All outputs must be in a sequence and on the same module OR useing 16 output modules in following slots.

Code:
PushBotton	EQU	I 0		;Input: PushBotton
OutPutBase	EQU	O 16		;Output: 1. in sequence
DynBit1 	EQU	F 600		;Internal bit
DynBit2 	EQU	F 601		;Internal bit
ToggleBit	EQU	F 500		;Internal bit: Toggle
OutPutNo	EQU	R 500		;Int DoubleWord: OutputNumber

;- "RUNG1": IF RaisingEgde Pushbotton THEN invert (COMplement) Togglebit ELSE jump to PASS
	STH	PushBotton
	DYN	DynBit1
	JR	L PASS

	COM	ToggleBit

;- "RUNG2": IF RaisingEgde ToggleBit THEN INCrement OutPutNo ELSE jump to PASS2
PASS:	STH	ToggleBit
	DYN	DynBit2
	JR	L PASS2

	INC	OutPutNo

;- "RUNG3": IF (CoMPare) OutPutNo < 6 THEN jump to OK ELSE LoaD OutPutNo to 0
PASS2:	CMP	OutPutNo
		K 6
	JR	N OK

	LD	OutPutNo
		0

;- "RUNG4": SEt Index to OutPutNo
OK:	SEI	OutPutNo

;  Status of ToggleBit goes to output (OutPutBase + indeX)
	STH	ToggleBit
	OUTX	OutPutBase

Especially the first example should be readable for everybody. As it has been said here in the forum: It is almost in plain english!

May be "C" is not comming as a PLC programming language, but structured text is part of IEC and I am looking forward to the time when all PLCs can be programmed with it.

my 2 cents


Regards
Karl Egil Liaset
(a engineer that want it to be so high level that the working man can not deal with it, which in turn puts more money in my pocket) ;)



BTW: OK, this can be solved with ladder. Also without use of index.

If it hasn't been for the off state for each second push, I guess a shiftreg could be used "as is".

2 suggestions from the top of my head (remember I am not a Ladder-man... )


Increment a word (OutPutNumber) each time ToggleBit goes high (egde), and then make a rung for each output:
Code:
                                        ToggleBit  Output1
--(Compare OutPutNumber with 1, Equal?)---| |--------( )-

                                       ToggleBit   Output2
--(Compare OutPutNumber with 2, Equal?)---| |--------( )-

etc

Or use a shiftreg with internal bits ("MirrorBits") that shiftes each time ToggleBit goes high (egde) and then make a rung for each output:

Code:
"MirrorBit1"  ToggleBit  Output1
--| |-----------| |--------( )


"MirrorBit2"  ToggleBit  Output2
--| |-----------| |--------( )

etc

I'm shure (wellcome back Pierre..) others can put in some more examples. (a half-dozen or more.....)
 
Pushbutton project

Like all the other posts, there are many way to do this. That is what PLCs are all about, FLEXIBLE

A very simple method would be have the pushbutton enable a (CTU) counter, on one rung. Then have [EQU] equal to instructions energize the (OTE) output. Reset the CTU with the last rung.

PB
---------] [----------------------------------------(CTU)-----------

EQU
-------[CTU.ACC]------------------------------------(OTE)-----------

EQU
-------[CTU.ACC]------------------------------------(OTE)-----------

EQU RES
-------[CTU.ACC]------------------------------------(CTU)-----------

Good Luck
 

Similar Topics

Hi all, I’m new to programming and want to write a simple routine. Push start button, turns on sensor. 2 second delay before anymore logic read...
Replies
1
Views
325
Good Afternoon , This may be a different subject on this forum . I have been brainstorming a project with my hometown. Like many small and...
Replies
3
Views
1,818
Hello all, I need help in a small plc program in Allen Bradley plc. Need to generate a 1 second pulse on every ON and OFF of a bit. Suppose for...
Replies
4
Views
2,108
Hi everyone. I'm new to PLC's and STL and i have a uni project i could use some help with. Here it goes: There is a sensor where every time it...
Replies
1
Views
1,492
Dear sir. i have one Automation Direct hmi, if you have the CMORE Programming software,i will send you .eap file in email, can you please...
Replies
3
Views
2,437
Back
Top Bottom