Color Sorting in Studio 5000

I'm sorry I cannot give you code in TIA as I don't have it & sometimes word shifts involve a bit more work that is why I did it with a block move, I think TIA has that. I'm sure that someone here with TIA could show you how to shift data in an array.
I have never used either these in-built functions of TIA but assume you have created a data block i.e. DB10 with say 100 words long (best make it a little larger than you need) say 110
Then on the block move it would be
source DB10.DBW0
Destination DB10.DBW1
Length 99
Someone will correct me if the block move does not work like this,
 
I guess my confusion comes in when it comes to setting up the actual instruction. Never worked with arrays in studio 5000 so trying to find the best youtube videos of actually setting up the logic.


The fastest way to learn may be to poke around for yourself; go forth and code yourself!



TL;DR


http://www.plctalk.net/qanda/showthread.php?t=18344

  1. Do you have ready access to Studio 5000, and its emulator?
  2. Can you figure out how to create an array tag in Studio 5000 (it's pretty easy, create a tag and then give it a single dimension; cf. here and other entries in that thread; poke around, be bold!)?
  3. Do you know how to make a program to count to 1000, then set a bit to 1 for one scan when the counter hits 1000 and also reset the counter to zero?
If yes to all three, then the fastest way to learn may be to poke around for yourself. Make a simple test program that uses the FFL and FFU instructions to push (FFLoad) the current seconds-of-minute value (GSV WallClockTime/LocalDateTime; cf. here) every time that counter hits 1000 (or 1500, or 2345). then watch (monitor) the values in the array (until it faults, then come back here and tell us why it faulted and what the fix is).

If you do not have access to Studio 5000, install the RSLogix Micro Starter Lite and RSEmulate freebies (see here) and poke around there; Micro Starter Lite (RSLogix 500) is data-file-based instead of tag-based, which means you create* a data file in the window on the left to create an "Array", but it still uses the FFL and FFU instructions cf. here and here, along with nearby pages.

FYI: it's all bookkeeping. An "array" is a series of INT elements in memory. the first one is "0" and the last one is "N-1" where N is the number of elements allocated to the array, which you define when you create the array tag. Then

  • FFL triggers on a rising edge of its input rung (e.g. [GEQ counter 1000]).
  • FFL keeps track of a position (.POS) and a length (.LEN) in a FIFO (the array)
    • .LEN is the maximum number of elements the FIFO can hold (it does not have to be N, but it should not be greater than N)
    • .POS should never exceed .LEN
    • .POS starts at 0, is the position of the next new element to be added to the FIFO
  • When FFL is triggered, it
    • puts the value from its [Source] into fifo_array[.POS]
    • and increments .POS by 1, in anticipation of the next FFL trigger
  • FFU is similar, and also fires on a trigger, except it
    • removes the oldest value from the FIFO i.e. fifo_array[0]
    • and shifts the rest of the array down 1
      • fifo_array[1] is moved to fifo_array[0]
      • fifo_array[2] is moved to fifo_array[1]
      • ...
      • fifo_array[.POS-1] is moved to fifo_array[.POS-2]
      • a 0 is moved to fifo_array[.POS-1]
    • and decrements .POS by 1
There is a lot of bounds- and error-checking and other folderol, but that is the gist of it.

* right-click on [Data Files] and click [New], sett [File type]=Integer and [Elements]=100 or so.


-
 
The forum starred out the name K***** Automation even in the links


If you copy the link and paste it in Firefox it will show

I came back to your suggestions while working on the project over the weekend. We were finding it difficult to do your suggestions in ladder but instead it seemed that structured text was helping. Is it possible to what your are saying in ladder?

Would it be as simple as working with 3 different arrays and doing a MOV of either a DINT of 1, 2, or 3 to that array?

I am starting to think I am way overthinking it
 
Since the 3 colors have unique values other than 0 just use one array shifted.
When the right value for that ejector is in the right place eject and 0 the value, if it's the wrong value let it pass without ejecting.
I think a simple EQU 1 Array[correct position]
 
Since the 3 colors have unique values other than 0 just use one array shifted.
When the right value for that ejector is in the right place eject and 0 the value, if it's the wrong value let it pass without ejecting.
I think a simple EQU 1 Array[correct position]

Logically, how would that look? The idea makes sense I am just having a difficult time transferring that to ladder logic.
 
Logically, how would that look? The idea makes sense I am just having a difficult time transferring that to ladder logic.


In this example the Lego at the Orange photoeye is Tan & will pass

and the Lego approaching the Black photoeye is Black and will latch

the Eject_Black tag and zero out the array entry as soon as the photoeye is made.


Then use the latched tag to run your eject cycle and unlatch it.
EDT: Make the rung comment "Black Ejector" not "detector"

Capture.JPG
 
Last edited:
OP was close in some respects, but needs to improve their understanding of the basics of Ladder Logic before continuing.

The top half of the attached image is Exhibit A, which shows a rung they supplied earlier in this thread.

The problem with the upper rung is that the Seal-in at the left is meant to hold a value of 1 in the output bit (LegoSorter.Steps[2]), even after the Start Condition [XIC LegoSorter.Inputs[12]) returns to False, and as long as the not-Stop Conditions [EQU LegoSorter.OrangeLegoMemory 1 XIO LegoSorterInputs[3]] remain True. However, the One-Shot [ONS LegoSorter.OneShot[1]] will never evaluate to True for longer than the initial scan (a few milliseconds) when Start Condition is first True.

The bottom half of the image shows how close the top half was to workable code*:

  • the Start Condition going True would extend the orange eject cylinder,
  • and the Seal-In would continue to extend the cylinder,
    • Until the cylinder advanced to the end of its travel,
      • As indicated by the Stop Condition.
    • Even after the [MOV] on the right Canceled the Start Condition,
      • Because putting 0 in LegoSorter.OrangeLogoMemory would make the [EQU] of the start condition evaluate to False on the next scan.
N.B. the blue words above are meant to highlight a basic tenet of PLC programming: programming PLCs is about time; i.e. PLC programs control when output events occur in relation to the timing of input events; it can be about a fixed time (allow ten seconds wind-down before re-starting motor), or it can be about the sequence of what happens before or after something else (after starting to extend the cylinder, continue extending it until it is fully advanced, then stop extending it).

* That second rung implements almost exactly the same functional logic as that most recently provided by @I_Automation. Adding a rung [XIO Orange Lego Cyl 1 Advanced OTU Eject_Orange] to @I_Automation's code would make them essentially identical.

Capture2.png
 
Last edited:
In this example the Lego at the Orange photoeye is Tan & will pass

and the Lego approaching the Black photoeye is Black and will latch

the Eject_Black tag and zero out the array entry as soon as the photoeye is made.


Then use the latched tag to run your eject cycle and unlatch it.
EDT: Make the rung comment "Black Ejector" not "detector"

This for sure cleared things up for me. Are Color_Seen[3] and Color_Seen[4] always assigned to Orange (1) and Black (2)? Or are the color values of 1 and 2 moving through an array similar to a BSL?
 
Color_Seen is a DINT array, that I made 12 DINT's long but can be whatever length is needed. Color_Seen[4] will change its value every shift to represent the next block that came through, or 0 if it shifted without a Lego present.



The color sensor when it detects a color puts that value in Color_Seen[0], then the array is shifted up. Thus Color_Seen[3] was the block detected 3 shifts ago, which I figure is at the orange ejector, but in actuality it might be from Color_Seen[2] to Color_Seen[6] depending on the layout of the conveyor and control of the shifting


Bonus question: How much money has the guy that invented the blocks made in all these years? HINT = $0.00 because the founder of Lego stole his idea and the inventor lost in court.
 
Color_Seen is a DINT array, that I made 12 DINT's long but can be whatever length is needed. Color_Seen[4] will change its value every shift to represent the next block that came through, or 0 if it shifted without a Lego present.



The color sensor when it detects a color puts that value in Color_Seen[0], then the array is shifted up. Thus Color_Seen[3] was the block detected 3 shifts ago, which I figure is at the orange ejector, but in actuality it might be from Color_Seen[2] to Color_Seen[6] depending on the layout of the conveyor and control of the shifting


Bonus question: How much money has the guy that invented the blocks made in all these years? HINT = $0.00 because the founder of Lego stole his idea and the inventor lost in court.

So I was able to get value into an array but shifting it is where Iā€™m having my issue now.

And I understand shifting a bit through but how does one shift a DINT through an array?
 
So I was able to get value into an array but shifting it is where Iā€™m having my issue now.

And I understand shifting a bit through but how does one shift a DINT through an array?


Actually it's done with FIFO Load and FIFO Unload

The help page for the instructions is in the installation, if installed. In Studio press F1, then search for FFL and it will come up. If it doesn't go to rockwell.com for FFL
 
Last edited:
This for sure cleared things up for me. Are Color_Seen[3] and Color_Seen[4] always assigned to Orange (1) and Black (2)? Or are the color values of 1 and 2 moving through an array similar to a BSL?

TL;DR

as @I_Automation confirmed, yes, the color values are moving through an array, similar to (bits in) a BSL.

all computer programs are models of something in the real world; PLC programs are no exception. the only real design choice is the fidelity of the model to the actual process; every other choice flows from that.

in this case, the array of integers is a model of the Legos, or absence of same, on the moving conveyor belt. that model comprises two parts of the process:

1) the sequential index of each element in the array models a sequential fixed position along the conveyor.

2) the value of each element in the array models both the presence of a Lego at the corresponding position and the color of a single Lego, if a Lego is present. Since there are only three colors, any value other than 1 or 2 or 3 will do for the no-Lego value, e.g. 0 or -99.

in this approach, the position along the conveyor of the color sensor station, and of the eject stations are modeled as particular indices of the array, so the presence and color of a Lego at the orange eject station at any instant would be indicated by the value of Color_seen[3] at that instant, in I_Automation's example.

How, when, and how often to shift the elements in the array is an implementation detail; refer to@parky's initial response on Post#2 for some ideas; PLC programming is all about timing, and getting the timing right will be crucial here. I also suggest looking at the FFL/FFU and COP instructions for ladder, and at the FOR/END_FOR statements in "structured" text.
 

Similar Topics

Hello, I have a problem... I want to make a sorting by color project for my univercity. But the problem is that I have to make a color buffer. So...
Replies
5
Views
1,995
Does anyone know how to set the background colors of instuction blocks (TON, MOV, etc)?
Replies
1
Views
135
HEllo, still satruggling with the curse WinCC Unified. See attached picture. I just want to change the fill colour from turqoise to grey and then...
Replies
5
Views
482
Hello all. It's already have been discussed here and over internet, but I'd like to have your opinion again on the topic. If you physically...
Replies
17
Views
1,610
Dumb question, Hooking up two wire reed switches out in the field. They are wired into sinking input cards. Once the wires leave the panel, do...
Replies
5
Views
1,504
Back
Top Bottom