Help - Search - Members - Calendar
Full Version: Programming Question (Help)
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
enigma
I have an application with 4 photoeyes in different locations. I would like to be able to determine which of the photoeyes was activated first, second, third and fourth. Then access subroutines that do "something" depending on the which photoeye was first, second,third or fourth. Then repeat.

I hope that is clear.

Does anyone have an idea on how to proceed.

Thanks in Advance
Ron Beaufort
Greetings enigma ...

and welcome to the forum ...

I hope that this isn’t a homework assignment ... if it is, then you really should post what you’ve already tried and let us help you LEARN your way through the assignment ... but if it’s something for work, then just keep reading ...

the program that I’ve attached below should give you all of the “big ideas” that you’ll need for the project you outlined ...

just for the record, you didn’t say what (if anything) you want to happen if ANOTHER photoeye happens to come on WHILE the task for the FIRST photoeye is still being performed ...

if you need help with details like that, please post again and be more specific ...

hope this helps ...
enigma
Thanks for the quick reply Ron.

No it's not homework. I was just wondering what other methods there were.

The idea is to service the first photoeye activated with a subroutine. If other photoeyes are activated, I'd like to know what order they were activated in. That way I can service each photoeye in the sequence that they occured. Then repeat the process. While I'm processing one , the other three will wait their turn. I was thinking of using the stack FIFO instructions but I have to figure out what to use as a trigger.

I'll take a look at what you have posted.

Thanks again
ssommers
Sounds a lot like "traffic cop" logic. I wrote a PLC program for an extremely complicated warehouse application. I had several conveyors merging to one main loop conveyor that sent the packages several ways - into the warehouse, out to a loading dock, or moving it to another storage location.

Here are a couple of things I took into account when I was writing my traffic cop...

1. Do you need any of the photoeyes to get "priority handling"? Is there a time limit on how long a package can wait at a photoeye? Would you rather release packages singly or in bunches from one photoeye?

2. What happens if the package at photoeye that you select to service has something at it that won't physically move (it's jammed, motor won't go, etc)? How do you handle removing that command from the queue (sending the fault to an operator) to allow the others to get handled? How does the faulted photoeye point get put back into service after a fault is corrected?

As for the PLC code, every intersection had it's own subroutine. This way I was able to literally cut and paste several different standard types of intersections. And that was very handy when I had over 1000 intersections!

If you need more than this, I'll see if I still have some of the pseudocode I wrote. That project was a few jobs back, but it was a piece of art work that will stick with me forever.

Susan
Ron Beaufort
QUOTE
If you need more than this, I'll see if I still have some of the pseudocode I wrote. That project was a few jobs back, but it was a piece of art work that will stick with me forever.


Greetings Susan ...

regardless of whether our new friend enigma is interested, personally I'd love to see a sample of that project ... anything that you can post along those lines would be greatly appreciated ...


enigma
Greetings Susan ...

Thanks for the offer, I would be interested if you have the spare time.

I've been playing around on a simulator using FFL and FFU instructions.

As long as the 4 eyes are blocked the stack continually cycles(Loads/Unloads)

When one eye is clear stop the unloading of the stack and examine the word in which the eye cleared.

Continue to scan the eyes in the background until the stack is full.

Do the subroutine in the mean time. (May be finished before stack is full)

Then continue to unload the stack.

As soon as the stack starts to clear, Start loading the stack again. Repeat

May be a bit complicated. A work in progress.

It would be nice if some A.I. was included in the processor blink.gif

@Ron

The code supplied looks interesting.
BobLfoot
Nothing sound simpler to write than a 2 to 1 conveyor merge until you try and write your first eh Susan?

Used to do a lot of conveyor programs myself. Had a 4 to 1 merge I was pretty proud of, but left the code when I left that company.

So yes post yours if you can.
Ron Beaufort
see if this comes closer to what you want ... basically I set up a queue with four positions N7:1 through N7:4 and cycled the flags for the photoeyes through the queue with indirect addressing ... many programmers find this home-brew approach easier to work with than the built-in FIFO instructions ...

you still haven't nailed down a few "what-if" situations - so I'll leave those issues (if any) for you ...

hope this helps ...
enigma
Looks a bit more like I was thinking. It's a shame the simulator doesn't handle the COP instruction.

Thanks for your time and effort.



This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.