Conveyor Control

Robocoaster

Member
Join Date
May 2022
Location
istanbul
Posts
3
Hi everyone, I'm newbie at here.I need to help.Can you share your experience to me?
The scheme is as at picture.
R4JDWM.png


The robot is palletizing at conveyor 1 and then send to me palletcompletedbit. After, ı must move this pallet to conveyor 2 with plc code. Also my customer want to run conveyors manually via buttons.

My code is :

[/ladder][/code]
timer_conv2empty(in:=,pt:=t#20s);

CASE MachineMode OF
Man:
StateAuto:=0;
StateConv1:=0;
StateConv2:=0;

IF AlarmStatus THEN
StateMan:=99;
END_IF
IF StateMan=0 AND bttnMode_RTRIG.Q THEN
MachineMode:=Auto;
END_IF

CASE StateMan OF
0: (*Manual control*)
IF bttnConveyor1 THEN
IF NOT in_Sensor1 THEN
out_Conveyor1:=TRUE;
ELSE
out_Conveyor1:=FALSE;
END_IF
END_IF

IF bttnConveyor2 THEN
IF NOT in_Sensor2 THEN
out_Conveyor2:=TRUE;
ELSE
out_Conveyor2:=FALSE;
END_IF
END_IF

IF bttnConveyorTransfer THEN
IF NOT in_Sensor2 THEN
out_Conveyor1:=TRUE;
out_Conveyor2:=TRUE;
ELSE
out_Conveyor1:=FALSE;
out_Conveyor2:=FALSE;
END_IF
END_IF

IF NOT bttnConveyor1 AND NOT bttnConveyorTransfer THEN
out_Conveyor1:=FALSE;
END_IF

IF NOT bttnConveyor2 AND NOT bttnConveyorTransfer THEN
out_Conveyor2:=FALSE;
END_IF
99: (*Alarm*)
out_Conveyor1:=FALSE;
out_Conveyor2:=FALSE;
IF NOT AlarmStatus THEN
StateMan:=0;
END_IF
END_IF
END_CASE;
Auto:
StateMan:=0;

IF AlarmStatus THEN
StateMan:=99;
END_IF
IF (StateAuto=0 OR StateAuto=99) AND bttnMode_RTRIG.Q THEN
MachineMode:=Man;
END_IF

CASE StateAuto OF
0: (*Stop*)
out_Conveyor1:=FALSE;
out_Conveyor2:=FALSE;
IF in_StartButton_RTRIG.Q THEN
StateAuto:=1;
END_IF
1: (*Running*)
IF in_StopButton_RTRIG.Q THEN
StateAuto:=0;
END_IF

CASE StateConv1 OF
0: (*initial*)
out_Conveyor1:=FALSE;
IF NOT in_Sensor1 THEN
StateConv1:=1;
ELSE
StateConv1:=2;
END_IF
1: (*conveyor empty*)
IF palletcompletedbit THEN
out_Conveyor1:=TRUE;
ELSE
out_Conveyor1:=FALSE;
END_IF

IF out_Conveyor1 AND in_Sensor1 THEN
StateConv1:=2;
END_IF
2: (*conveyor loaded*)
IF StateConv2=1 THEN
out_Conveyor1:=TRUE;
ELSE
out_Conveyor1:=FALSE;
END_IF

IF NOT in_Sensor1 AND in_Sensor2 THEN
StateConv1:=1;
END_IF
END_CASE;

CASE StateConv2 OF
0: (*initial*)
out_Conveyor2:=FALSE;
IF NOT in_Sensor2 THEN
StateConv2:=1;
ELSE
StateConv2:=2;
END_IF
1: (*conveyor empty*)
IF StateConv2=2 THEN
out_Conveyor2:=TRUE;
ELSE
out_Conveyor2:=FALSE;
END_IF

IF out_Conveyor2 AND in_Sensor2 THEN
StateConv2:=2;
END_IF
2: (*conveyor loaded*)
timer_conv2empty.IN:=NOT in_Sensor2 ;
IF timer_conv2empty.Q THEN
StateConv2:=1;
END_IF
END_CASE;
99: (*Alarm*)
out_Conveyor1:=FALSE;
out_Conveyor2:=FALSE;
IF NOT AlarmStatus THEN
StateAuto:=0;
END_IF
END_CASE;
END_CASE;
Code:
[ladder]
What should I do if the pallet stays between the sensors?
What should I do if the sensors are triggered incorrectly?

thank you for reply
 
Last edited:
Welcome to the forum!

If you put [/ladder] after the code and
 before the code, you can keep the indentation ([/code] and 
	
	


Code:
 also works but it more limited by width):

[ladder]
 [SIZE=1]timer_conv2empty(in:=,pt:=t#20s);

    CASE MachineMode OF
    Man:
    StateAuto:=0;
    StateConv1:=0;
    StateConv2:=0;

        IF AlarmStatus THEN
        StateMan:=99;
        END_IF
        IF StateMan=0 AND bttnMode_RTRIG.Q THEN
        MachineMode:=Auto;
        END_IF

        CASE StateMan OF
        0: (*Manual control*)
            IF bttnConveyor1 THEN
                IF NOT in_Sensor1 THEN
                out_Conveyor1:=TRUE;
                ELSE
                out_Conveyor1:=FALSE;
                END_IF
            END_IF

            IF bttnConveyor2 THEN
                IF NOT in_Sensor2 THEN
                out_Conveyor2:=TRUE;
                ELSE
                out_Conveyor2:=FALSE;
                END_IF
            END_IF
            
            IF bttnConveyorTransfer THEN
                IF NOT in_Sensor2 THEN
                out_Conveyor1:=TRUE;
                out_Conveyor2:=TRUE;
                ELSE
                out_Conveyor1:=FALSE;
                out_Conveyor2:=FALSE;
                END_IF
            END_IF
            
            IF NOT bttnConveyor1 AND NOT bttnConveyorTransfer THEN
            out_Conveyor1:=FALSE;
            END_IF

            IF NOT bttnConveyor2 AND NOT bttnConveyorTransfer THEN
            out_Conveyor2:=FALSE;
            END_IF
        99: (*Alarm*)
        out_Conveyor1:=FALSE;
        out_Conveyor2:=FALSE;
            IF NOT AlarmStatus THEN
            StateMan:=0;
            END_IF
        END_IF    
        END_CASE;
    Auto:
    StateMan:=0;

        IF AlarmStatus THEN
        StateMan:=99;
        END_IF
        IF (StateAuto=0 OR StateAuto=99) AND bttnMode_RTRIG.Q THEN
        MachineMode:=Man;
        END_IF

        CASE StateAuto OF
        0: (*Stop*)
        out_Conveyor1:=FALSE;
        out_Conveyor2:=FALSE;
            IF in_StartButton_RTRIG.Q THEN
            StateAuto:=1;
            END_IF
        1: (*Running*)
            IF in_StopButton_RTRIG.Q THEN
            StateAuto:=0;
            END_IF
            
                CASE StateConv1 OF 
                0: (*initial*)
                out_Conveyor1:=FALSE;
                    IF NOT in_Sensor1 THEN
                    StateConv1:=1;
                    ELSE
                    StateConv1:=2;
                    END_IF
                1: (*conveyor empty*)
                  IF palletcompletedbit THEN
                  out_Conveyor1:=TRUE;
                  ELSE
                  out_Conveyor1:=FALSE;
                      END_IF
                
                  IF out_Conveyor1 AND in_Sensor1 THEN
                  StateConv1:=2;
                  END_IF
                2: (*conveyor loaded*)
                  IF StateConv2=1 THEN
                  out_Conveyor1:=TRUE;
                  ELSE
                  out_Conveyor1:=FALSE;
                      END_IF
            
                   IF NOT in_Sensor1 AND in_Sensor2 THEN
                   StateConv1:=1;
                   END_IF
                END_CASE;

                CASE StateConv2 OF 
                0: (*initial*)
                out_Conveyor2:=FALSE;
                    IF NOT in_Sensor2 THEN
                    StateConv2:=1;
                    ELSE
                    StateConv2:=2;
                    END_IF
                1: (*conveyor empty*)
                  IF StateConv2=2 THEN
                  out_Conveyor2:=TRUE;
                  ELSE
                  out_Conveyor2:=FALSE;
                      END_IF
                
                  IF out_Conveyor2 AND in_Sensor2 THEN
                  StateConv2:=2;
                  END_IF
                2: (*conveyor loaded*)
                  timer_conv2empty.IN:=NOT in_Sensor2 ;
                  IF timer_conv2empty.Q THEN
                  StateConv2:=1;
                  END_IF
                END_CASE;
        99: (*Alarm*)
        out_Conveyor1:=FALSE;
        out_Conveyor2:=FALSE;
            IF NOT AlarmStatus THEN
            StateAuto:=0;
            END_IF
        END_CASE;
    END_CASE;[/SIZE]
[/ladder]

 
CASE StateConv1 OF 
0: (*initial*)
out_Conveyor1:=FALSE;
IF NOT in_Sensor1 THEN
StateConv1:=1;
ELSE
StateConv1:=2;
END_IF
1: (*conveyor empty*)
IF palletcompletedbit THEN
out_Conveyor1:=TRUE;
ELSE
out_Conveyor1:=FALSE;
END_IF

IF out_Conveyor1 AND in_Sensor1 THEN
StateConv1:=2;
END_IF
2: (*conveyor loaded*)
IF StateConv2=1 THEN
out_Conveyor1:=TRUE;
ELSE
out_Conveyor1:=FALSE;
END_IF

IF NOT in_Sensor1 AND in_Sensor2 THEN
StateConv1:=1;
END_IF
END_CASE;

CASE StateConv2 OF
0: (*initial*)
out_Conveyor2:=FALSE;
IF NOT in_Sensor2 THEN
StateConv2:=1;
ELSE
StateConv2:=2;
END_IF
1: (*conveyor empty*)
IF StateConv2=2 THEN
out_Conveyor2:=TRUE;
ELSE
out_Conveyor2:=FALSE;
END_IF

IF out_Conveyor2 AND in_Sensor2 THEN
StateConv2:=2;
END_IF
2: (*conveyor loaded*)
timer_conv2empty.IN:=NOT in_Sensor2 ;
IF timer_conv2empty.Q THEN
StateConv2:=1;
END_IF
END_CASE;


*Disclaimer* I did not proof read the code. Quick skim.

Buffer the sensor inputs with Rising and Falling edge triggers. You can use these edges for tracking purposes and proper sequence. Conveyor is loaded on the rising edge of sensor 1. The falling edge would set a "transitioning" state. You can add a timer to this bit to alarm that sensor 2 never saw a transition. If sensor 2 shows a rising edge without a transitioning flag then you have an improper sequence. Assuming I understand your layout correctly.
 
In my industry, these are commonly called zone conveyors but we try to use (2) sensors per zone, pallet_entering (which you have) and pallet_present. Makes the logic easier for Sparky.
 
Personally, I would do this in ladder, it's easier the OP did not state what PLC & it seems a little complicated & messy.
Here is one that works (well as I assume what is required), the OP did not state if in manual the operator controls the conveyors ignoring certain things like the sensors or signal from palletiser etc. so assume not, have not included all things like that.
A simple alarm if for example the conveyors run for more time than expected to move pallet from conveyor 1 to conveyor 2 sensor then it assumes stuck pallet regardless of if moved off sensor 1.


PLS(Auto_Man,Auto_Sw_Rising_Pulse); (* Create a rising pulse on switching to auto *)
PLF(Auto_Man,AUto_Sw_Falling_Pulse); (* Create a falling pulse when switching to Manual*)

IF Auto_Sw_Rising_Pulse OR AUto_Sw_Falling_Pulse THEN (*Onswitching from Auto to Man or man to Auto stop the conveyors *)
SEQ:= 0;
END_IF;
IF SEQ = 0 AND Pallet_Comp_Bit AND PE01 AND NOT PE02 AND Auto_Man THEN
SEQ:= 1; (* Run Conveyor 1 to Conv 2 iin Auto*)
END_IF;

IF SEQ = 1 AND PE02 THEN (* When in Auto & pallet reaches PE02 then set SEQ back to 0 *)
SEQ:= 0;
END_IF;

IF SEQ = 0 AND PE01 AND Start_Button AND NOT PE02 AND NOT Auto_Man THEN
SEQ:= 11; (* Run conveyors in man*)
END_IF;

IF PE02 OR Stop_Button AND SEQ = 11 THEN (* Stop in Manual if reaches PE02 or Stop pressed *)
SEQ:=0;
END_IF;

CASE SEQ OF (* Run the conveyors*)
0: Conv_1_Out:= FALSE;
Conv_2_Out:= FALSE;
1: Conv_1_Out:= TRUE;
Conv_2_Out:= TRUE;
10: Conv_1_Out:= FALSE;
Conv_2_Out:= FALSE;
11: Conv_1_Out:= TRUE;
Conv_2_Out:= TRUE;
END_CASE;

(* Alarm handling*)
Alarm_Timer(IN:= (Conv_1_Out OR Conv_2_Out),PT:=T#10s); (* If conveyors run for more time than expected then set alarm*)
IF Alarm_Timer.Q THEN
SEQ:= 99;
Conv_1_Out:=FALSE;
Conv_2_Out:=FALSE;
END_IF;

IF SEQ = 99 AND Alarm_Reset THEN (*Alram reset *)
SEQ:= 0;
END_IF;



Did not add any on/off delay on the photocells, this would depend on if the natural stop of the conveyors ensured the photocells were fully covered or if the pallets would have gaps that the photocells could see.
 
Last edited:
Yes, the 'real' ladder logic will be shine in this case. I am guessing his homework requirement to be ST.
your logic is a better than the two previous two.
but it wont work because of PE01 need to be broken "IF SEQ = 0 AND Pallet_Comp_Bit AND PE01 AND NOT PE02 AND Auto_Man THEN".

I'd start the seq when receiving the complete bit. run it to PE01, then start Conv2 at that point.
 
Last edited:
It is assumed that PE01 is made when the pallet is placed on the conveyor this works I have simulated it. It assumes that the pallet is put on the conveyor, the PE is made which tells the palletizer to do what ever it needs to do then the palletizer gives the signal to transfer it. But yes if the PE is not made & only rely on the palletizer to initiate it then it would need to be modified, I realise now that the picture of the two conveyors shows the pallets not on the PE's however, this is wrong as the conveyor 2 PE is not covered which it would have to be to stop the sequence (or rely on timers to assume pallet in middle of conveyor (very poor design if so ).when passed from conveyor 1 to 2, the OP's description is poor in regarding exactly how it should work.
 
Last edited:
So only one pallet to be present on each conveyor ever ?
Or can one pallet start leaving conveyor 2 when the pallet on conveyor 1 has begun to leave ?
Shall the sensor at the entry of conveyor 2 also function as the exit sensor for conveyor 1 ?
Can the pallet extend from conveyor 2 onto conveyor 1 without conveyour 1 running until the sensor 1 is activated ?
Also, consider error scenarios, such as there is a pallet on conveyor 2, and when it starts to move but no signal from sensor 1 is received, there is possibly a blockage.
Similar, the signal(s) on sensor 1 or sensor 2 stays on and does not go off.
etc..
What shall be the functionality of the buttons ?

Write a detailed spec of the programs functionality, and the actual code almost writes itself.
 
Actually, every conveyor have a sensor. I dont want to lose pallet at conveyor. So, ı set persistent that conveyors state. Also, these buttons at HMI.So, I didn't use rising or falling edge.
Is this true ?
 
@Jesper: My thoughts exactly, I have done many of these & in all cases the sensor is covered when pallet in place, did many systems where the pallets came in different sizes i.e. half euro, full Euro, 1.5 Euro, 2 Euro & if I remember correctly 2.5 Euro sizes, so the last two would straddle 2 of the conveyors. These were feed conveyors to a Strapper a total of 14 & two on the outlet. The pallets were measured in a number of different configurations just before the Strapper, by length, width, if pallet had bottom runners or not (if runners then swords were used to feed the straps or straps were sent between the conveyor rollers) the strapping patterns were determined by the above i.e. could be 3 or 4 straps across, if half Euro then one strap each way, full Euro 2 straps each way so about 30 strap patterns in total.
 
Based on what I did last time here is a more concise bit of code that does the same job


PLS(Auto_Man,Auto_Sw_Rising_Pulse); (* Create a rising pulse on switching to auto *)
PLF(Auto_Man,AUto_Sw_Falling_Pulse); (* Create a falling pulse when switching to Manual*)

IF Pallet_Comp_Bit AND PE01 AND NOT PE02 AND Auto_Man THEN
Conv_1_Out:= TRUE; (* Run Conveyor 1 to Conv 2 iin Auto*)
Conv_2_Out:= TRUE;
END_IF;

IF PE01 AND Start_Button AND NOT PE02 AND NOT Auto_Man THEN
Conv_1_Out:= TRUE; (* Run Conveyor 1 to Conv 2 iin Man*)
Conv_2_Out:= TRUE;
END_IF;

IF Stop_Button AND NOT Auto_Man OR PE02 THEN (* Stop in Manual if reaches PE02 or Stop pressed *)
Conv_1_Out:= FALSE; (* Stop Conveyor 1 to Conv 2 iin Auto*)
Conv_2_Out:= FALSE;
END_IF;

(* Alarm handling*)
Alarm_Timer(IN:= (Conv_1_Out OR Conv_2_Out),PT:=T#10s); (* If conveyors run for more time than expected then set alarm*)
IF Alarm_Timer.Q THEN
Alarm_Bit:= TRUE;
Conv_1_Out:=FALSE;
Conv_2_Out:=FALSE;
END_IF;

IF Alarm_Reset THEN (*Alram reset *)
Alarm_Bit:= FALSE;
END_IF;

 
Could have done it in less lines but at my age all those brackets make my brain hurt so here is a ladder one rung, missing are the alarm for jammed pallet & the stop if switched from auto to man or back.
Just goes to show that ST is fine for calcs but for Boolean Lad is faster to code (well in my old brain) & easier to understand.

Conv Lad.png
 

Similar Topics

"Hello, I am a beginner learning about PLC. Could you please give me some advice? I want to write PLC instructions as follows: When the sensor...
Replies
18
Views
3,233
Hi Guys! Please, I'd like to know how Motor speed Control in Conveyor/Sortation Systems are Programmed/achieved for Factory and Warehouse...
Replies
10
Views
2,039
Hi,all: we have over head chain conveyor drove by PF525,the total conveyor length is about 1350 foot, its speed jumping too much (not stable)...
Replies
30
Views
6,108
Hello Everyone, I am working on a project to control the conveyor at my work. This is my first hands-on experience on PLC project. Please look...
Replies
2
Views
3,466
Hello Everyone, I am very new to PLC programming and trying to learn PLC by myself. I found this awesome forum and would like to get some advice...
Replies
34
Views
8,245
Back
Top Bottom