Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Cybro-2 PLC if clause problem

Status
Not open for further replies.

MarkoSiroki

Member level 2
Joined
Feb 17, 2013
Messages
46
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Location
Ljubljana
Activity points
1,558
Hi to all!

I ma working on PLC program (using CyPro's Structure Text Language) that will drive light on/off via DALI protocol compatible wall switch. Now, I have a chunk of code:
Code:
// *****************************************
// * Light operation according to statuses *
// *****************************************
if state_light_on[COMP_RED] then
    turn_light_on(COMP_RED);
else
    turn_light_off(COMP_RED);
end_if;

if state_light_on[COMP_GREEN] then
   turn_light_on(COMP_GREEN);
else
   turn_light_off(COMP_GREEN);
end_if;

if state_light_on[COMP_BLUE] then
   turn_light_on(COMP_BLUE);
else
   turn_light_off(COMP_BLUE);
end_if;

if state_light_on[COMP_ALL] then
   turn_light_on(COMP_ALL);
else
   turn_light_off(COMP_ALL);
end_if;
The problem is, regardless of number of this if checks, only the last one is taken into account, i.e. executed, so only the one (last) of four switches is "alive". Why are other if clauses ignored?

Sincerely,
Marko
 

You mean this:
**broken link removed**
?
some help:
**broken link removed**

p.s.
you wrote only small amount of code...how can we help you?
 

I have this documents, and I have already described a problem. Why only last if is executed, i.e. I can turn on/off light only on 4th wall switch?!
 

Isn't COMP_ALL for all lights?
remove last IF and then test!
 

Yes, but you did not understand me, let me explain the background:I have a single light, composed of 3 bars of LED diodes. The wall adapter contains 4 buttons, which is connected to DALI controller. If I press the first button, I want to turn on RED bar, if I press second button, I want to turn on GREEN bar, if I press third button, I want to turn on BLUE bar and if I press 4th button, I want to turn all bars, according to my task I have 4 if clauses, but instead all are working, only the last one is working. Why?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top