Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi function LED control

Status
Not open for further replies.

trellend

Industrial
Aug 4, 2015
18
0
0
US
I'm trying to drive an LED so that it shows 3 different states.

This thing goes in a circle, and there is a limit switch at the bottom. (Hydraulic motor spins a gear) When you press Start (X1), the motor runs (Y1) until the limit switch (X2) is hit again. (Can't use rising because of bouncy switches, timing is such that a 50 ms debounce makes stopping at the right spot impossible (Sensor location)). But when you press start, the sensor is active for a while, so I set a timer for 1.5secs (T1) to set a bit (C1) so that it only Stops again when both the Timer expired and it hits the limit switch. I didn't design the mechanics of this.

The LED (Y2) is labeled "Home"

1. When nothing is happening, and it's at HOME position, I want the LED On
2. When you press the button, I want the LED flashing while it's still Home, but moving away.
3. After it clears HOME, I want the LED off.
4. When it hits HOME again, it stops, repeat to step one.

I can write this, but I get warnings "multiple rungs are setting the same output". I prefer to have no warnings.

Can that be done in one rung with multiple rows, or must I use control bits and only have one set command?

Pseudo code:

if (IGNORESENSOR) {
LED = (HOME AND FLASHERBIT);
} else {
LED = HOME;
}

The problem for me is that IF, not used to ladder logic.

--[/IGNORE]--------------------------(LED)
-[HOME]--|
--[IGNORE]------------[FLASHERBIT]---(LED)

I'm not on site to test that. I'm looking for opinions...

And I can't press the button to test unless it's in operation, press it twice without a full cycle, 30 minutes downtime for repairs.












States:

1. Motor/Drive (Y1) is off, Sensor is at HOME (X2), LED status: ON
2. Motor/Drive (Y1) is ON, Sensor is at HOME (X2), IgnoreHomeSensor (C1) ON LED status: Flashing
3. Motor/Drive
 
Replies continue below

Recommended for you

You normally have your "logic" code at the top of the program and the "outputs" all occurring at the bottom of the program JUST ONCE. The way the PLC runs, this also makes physical sense because the outputs are only checked and physically set at the end of a scan.

So, you want a single LED output at the bottom of your program and all the various other cases you had for LED converted into virtual contacts that activate the single LED output at the bottom of the code. This should be the same for all your program's OUTPUTS.

Keith Cress
kcress -
 
This is what I wanted:

LED = Home AND NOT (Ignore AND (NOT Flash))

No parenthesis in PLC, so I did

[Ignore]--[/FlashBit]--->(OUT C5)
[Home]--[/C5]---------->(OUT LED)

It's different going form C/C#/Delphi to this...






 
um... Not sure you have it 'proper' yet.

More like:

Code:
[Ignore]--[/FlashBit]--->(OUT C5)
[Home]]--[/C5]---------->(OUT C6)

======= BEGIN System OUTPUT statements =============
[C6]-------------------->(OUT LED)

======== END System OUTPUT statements =============

Yes, going to ladder logic or actually going to PLC ladder logic from C is a complete mind-screw I agree.

Keith Cress
kcress -
 
What's kinda cool is once you go back to those coding languages from ladder logic, is you have a new found grasp on latching, since that is most of what you have been doing.
 
Status
Not open for further replies.
Back
Top