Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Multi function LED control

Multi function LED control

Multi function LED control

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:

} else {

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


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.


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

RE: Multi function LED control

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 - http://www.flaminsystems.com

RE: Multi function LED control

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...

RE: Multi function LED control

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 - http://www.flaminsystems.com

RE: Multi function LED control

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.

RE: Multi function LED control

int main() {int c; cout << ++c; return c;}

Then stuff like that pops out.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close