Buffer

Consider what each conveyor should do in each mode.

I would save the mode in an integer variable like this:
  • Idle/empty = 0
  • Buffering = 1
  • Buffering Full = 2
  • Transport to sink = 3

Depending on the mode each conveyor will behave differently.

For example:
  • Conveyor 2 will only run when you are in mode 3 (transport to sink). After conveyor 2 have sent 5 packages + some extra time to clear the conveyor the mode should change to mode 0 (idle/empty).
  • Conveyor 0 will only run when you are in mode 1 (buffering).
  • Buffer conveyor will only run when you are in mode 1(buffering) or in mode 3 (transport to sink).
  • Etc.
This is the stuff you need to figure out before coding. This is the solution to the problem.
If you don't have a clear idea how it's going to work, don't write any program code. Spend time thinking about it more instead. Use paper or a whiteboard or whatever. Visual is better than text.
 
do the parcels ever slide/move relative to the conveyor, or do all parcels on the conveyor move at 700mm/s or 2000mm/s? here are 4 modes to be considered 1, buffering 2, bufferfull, 3, transport to sink 4, idle/empty. The procedure will have Conv0, buffer (seg0,seg1,seg2,seg3,seg4) and Conv2. The buffer (700mm/s) has 5 points where the parcels has to stay at the sensor of each buffer seg. Once the buffer is full it has transported to sink in 2000m/s.

That's interesting, but it does not answer the question: do the parcels ever slide/move relative to the conveyor? Because I have been thinking of this process has having only two sections of conveyor belt: Conv0, which has five sections (seg0-seg4), and Conv2. With that model, I don't understand how one parcel could stay at one segN sensor while other parcels have to keep moving toward other sensors that do not yet have a parcel at their location.

Or do those six names (Conv0, seg0, seg1, seg2, seg3, seg4, Conv2) refer to six distinct conveyor belts, which can move independently?

If yes, then as @Pete.S. suggests, write the code for one small piece at a time. For example, write only the logic to control when the seg4 section of conveyor feeding the last sensor should run.

The other piece of this is the data model. Computer programs, and PLC programs, model something in the real world. The primary consideration of the model is the level of fidelity: you care about when a parcel is in front of a sensor; you don't care about the color of the operator's socks. Some parts of that model are inputs e.g. the five sensors. Some parts of that model are the outputs e.g. whether each conveyor section is running or not. Some parts of that model will be stored in PLC internal memory e.g. you have described the four modes of the system (buffering; buffer full; transport to sink; idle/empty). All parts of that model are stored in PLC memory, whether that memory is a map of inputs or output or internal and only used by the program.

So a key task will be designing and implementing the model that represents the process in memory. In addition to the mode (integer tag with possible values of 1-4 meaning buffering, buffer full, etc.), there also needs to be a mode for each segN section.

For example, the seg4 conveyor needs to run while the overall system is in buffering mode and there is no parcel at the seg4 sensor, and it also needs to run when in transport-to-sink mode, so the existing mode tag plus the seg4 sensor input seems to be enough to model seg4. However, to choose when to end transport-to-sink mode, the model must keep track of the number of falling (parcel-trailing) edges so it is known when the five parcels blocking the five sensors in buffer full mode have been transferred to Conv2.

Also, seg0 needs to run until a fifth parcel blocks the seg0 sensor while in buffering mode, so there needs to be some memory (e.g. an integer tag) that keeps track of the number of parcels (or parcel leading edges) detected by the seg0 since the start of the current buffering mode, and outside of buffering mode that integer tag can be set to 0.
 
It is still difficult to understand what the OP is trying to do, still not direct confirmation if there are more than one conveyor the OP says is conveyor 1.
Regardless of how many conveyors why all these variables like buffers etc. it is so simple either thge parcels are already spaced & there is one conveyor (not really practical ) then at the most only need one or two sensors, if the conveyor is split into seperate drives then again just use the sensors i.e. all run until segment 5 sensor is covered, stop segment 5, when segment 4 is covered stop segment 4 & so on, when all 5 segments are occupied & conveyor is ready to accept parcels either run all conveyors until all sensors are clear or run segment 5, once clear run segment 4 & 5 & so on until all segments are clear ready for next batch of parcels.
I think the OP is over thinking this regarding code.
What I posted would be simple to convert into ST.
But as we all know, ST is better suited to maths functions & it becomes a pain to do Bool logic it actually often takes more compiled code by the use of IF statements (normally compiled into jumps rather than use actual bool logic like ladder (well that is my experience having seen some copiled ST programs to keep it compatible).
Using IF statements not really required in most Bool operations for example
1741852175584.png
Is the same as this in ST
1741852541759.png
This is the compiled code for an IF statement
1741852459114.png
As shown using IF statements (in this Platform anyway) used more code to do the same thing.
 

Attachments

  • 1741852217093.png
    1741852217093.png
    26.7 KB · Views: 0
I know it's probably too late & we still don't really know if the segments are seperate conveyors & have made dsome assumptions & probably not thought of all scenario's i.e. signal to what ever feeds the conveyor 1, assumed some signal from something that tells when conveyor 2 is able to accept parcels & not tested fully (cannot be A&**D to make a simulation but here is how I see the basic ST working.

Just to demonstrate it is better to write this sort of thing in ladder it took me about three quarters of an hour to do it in ladder, took me over 2 hours to write it in ST (getting the brackets right lol)
1741866098575.png
 
As I knew that you tried your effort in writing code, thank you so much but actually, mine is three conveyors (Conv0, Buffer1 with Seg0,seg1,seg2,seg3,seg4) and Conv2) Image is below. from conv0, I have to fill the 5 parcels as there are 5 segments with 700mm/s speed. sensors
I_Conv_0_SensStart_Occupied: BOOL;
I_Conv_0_SensEnd_Occupied: BOOL;
I_Buff_1_0_Sens_Occupied: BOOL;
I_Buff_1_1_Sens_Occupied: BOOL;
I_Buff_1_2_Sens_Occupied: BOOL;
I_Buff_1_3_Sens_Occupied: BOOL;
I_Buff_1_4_Sens_Occupied: BOOL;
I_Conv_2_SensStart_Occupied: BOOL;
I_Conv_2_SensEnd_Occupied: BOOL;


* Bufferfull - Once my buffer is filled with 5 parcels (each parcel in each segment yellow line) it is transported to sink (red box in the below image) with conv2 at 2000mm/s speed. Conv0 has to stop no parcel has to enter.
* Now the buffer region is empty, Conv0 has to start and load 5 parcels in each buffer segment. I had tried the code but nothing carrying out the process in Structured text PLC TwinCAT. I tried using Timers and triggers still nothing worked when running in the simulation. Please help me with a code



1741871608056.png1741871608056.png
 
Ah.. I think I understand now it sounds like that buffer conveyor actuall indexes i.e. When sensor 1 detects a parcel, the conveyor runs until the sensor 1 sees the trailing edge & stops when it reaches sensor 2, when another parcel is seen on sensor 1 the conveyor indexes until it sees the trailing edge (or perhaps the next sensor is seen so in effect each time a parcel enters it indexes one place until all 5 segments are occupied is that correct.
 
the conveyor doesn't just run continuously; it only moves in increments, one step for each parcel entering, until it fills up the 5 buffer slots. Once all 5 segments are filled (i.e., all 5 sensors in the buffer conveyor detect parcels), the buffer is considered "full."
 
Just to demonstrate it is better to write this sort of thing in ladder it took me about three quarters of an hour to do it in ladder, took me over 2 hours to write it in ST (getting the brackets right lol)
OP is using TC. This took less than 15min to write and test. Not how I would implement it in the real world, but it's quick and dirty.

1741875905068.png
 
Ah.. I think I understand now it sounds like that buffer conveyor actuall indexes i.e. When sensor 1 detects a parcel, the conveyor runs until the sensor 1 sees the trailing edge & stops when it reaches sensor 2, when another parcel is seen on sensor 1 the conveyor indexes until it sees the trailing edge (or perhaps the next sensor is seen so in effect each time a parcel enters it indexes one place until all 5 segments are occupied is that correct.
That would make a little more sense.

Not the easiest to follow if not an ST person, but quick and functional.

1741877721858.png
 
At last now we know if you had mentioned that in the first place that it effectively indexed until all five parcels were on the conveyor it would be easy.
In actual fact you would only need one sensor as you could use a time delay to ensure the package tas indexed to the right position beyond the sensor to allow next package.
 
. Please help me with a code
For buffering mode

Only two sensors matter:
  • the sensor at the exit of conv0/entrance of seg0
  • The sensor at the exit of seg0
Count trailing edges at conv0 exit, call that counter ctconv0

Count leading edges at seg0 exit, call that counter ctseg0

Both counters start at 0 i.e. reset those counters, and inhibit count input, whenever mode is not buffering.

Whenever the counts (accumulators) of ctconv0 and ctseg0 are equal, them run conv0.

Whenever EITHER the conv0 exit sensor input value is 1 (object present), OR the counts are not equal (ctconv0 count will be one more than ctseg0 count), then run buff1 conveyor.

When the ctseg0 count reaches 5, transition mode from buffering to transport (which will reset ctconv0 and ctseg0). Buffet-full mode may not be needed.

For transport mode

Only two sensors matter
  • the one at the exit of seg4
    • call it ctseg4, and
    • reset it, and inhibit counting, in any other modes than buffering or transport, and
    • have it count trailing edges at exit of seg4.
  • The one at the exit of conv2
    • Call it ctconv2, and
    • Reset it, and inhibit counting, in any other modes than transport, and
    • Have it count trailing edges at exit of conv2

Run buff1 conveyor in transport mode until ctseg4 count reaches 5

Run conv2 conveyor for all of transport mode,

When ctconv2 count reaches 5, transition from transport mode, possibly back to buffering mode.
 
At last now we know if you had mentioned that in the first place that it effectively indexed until all five parcels were on the conveyor it would be easy.
In actual fact you would only need one sensor as you could use a time delay to ensure the package tas indexed to the right position beyond the sensor to allow next package.
Minor detail but you could even get away without even needing a timer. You just run the buffer conveyor until the sensor clears again.
Start and stop ramps will ensure you have a small distance between all packages regardless of their size.

And you're right about the sensors. No need to have "segments" and sensor for each.
 
Note that the buff1 conveyor runs at two different times
  • When indexing, i.e. in buffering mode, the next new parcel to seg0 exit sensor,
  • OR
  • When in transport mode until buffer is empty.
The significance is that there are two logically independent, though related, types of logic in this code:
  • The sequence logic, which observes inputs (prox sensors) and process model star in internal memory (count values) in order to transition between states, and
  • The business logic, which writes ones or zeros to the output image memory map, based on the current mode and other process state information.
In order to make it easier to write, debug, and maintain, it will be best to isolate those two types of logic to separate areas in the program.
 
Yeah my way of approach and sense I said it went wrong but it's the way I have to do
At last now we know if you had mentioned that in the first place that it effectively indexed until all five parcels were on the conveyor it would be easy.
In actual fact you would only need one sensor as you could use a time delay to ensure the package tas indexed to the right position beyond the sensor to allow next package.
 

Attachments

  • IMG-20250313-WA0006.jpeg
    IMG-20250313-WA0006.jpeg
    187 KB · Views: 2
  • IMG-20250313-WA0003.jpeg
    IMG-20250313-WA0003.jpeg
    191.3 KB · Views: 2

Similar Topics

Hi everyone, Hoping to get some insight from the veterans here. I primarily work on the low-voltage/security integration side, but we've been...
12
Replies
1,408
Views
The SF LED on an S7-300 CPU is illuminated and the diagnostics buffer has several events with Event ID: 16# 3942. The following description is...
7
Replies
2,426
Views
Hi All, can anyone help me with clearing data from the input that has given by the Scanner. (Clear Buffer) I tried COP and MOV instruction to...
16
Replies
2,333
Views
Hi, is there a way to change the time and date in the plc so they appear right in the diagnostic buffer. Also am I right in thinking the error is...
1
Replies
680
Views
I've been developing a tester using a Micro850 in Connected Components Workbench and part of that tester requires me to scan a barcode every test...
17
Replies
4,921
Views
Top