
Visit our shop for nerds in control lifestyle products.
- PC reliability?
- Windows, real time
- PID loops
- PCs vs. PLCs
- Replacing people
- MS 'monopoly'?
- Software quality
- Where do we go from here?
- Why pay?
www.control.com/rss/
To get a personalized feed, become a member at no cost.
Any suggestions are welcome.
--
Tomek
PROGRAM PLC_PRG
VAR
FirstCycle : BOOL := TRUE;
Timer : TP;
ErrorCode : BYTE := 1;
Version : WORD;
Param : ARRAY [0..3] OF FLASHING_SEQUENCE; (* Array, that the flashing sequences describes *)
PointerToFS : POINTER TO FLASHING_SEQUENCE;
END_VAR
------------------------------------- -------------
(* Example how to display an error code over the USR-LED with the Visual.lib *)
(* Initialization of the flashing sequences in the first cycle.
The entries can be modified at run-time. *)
IF FirstCycle = TRUE THEN
Version := VISUAL_VERSION(1);
(* fast flashing sequence to initiate an error code *)
Param[0].Colour := RED;
Param[0].Frequency := 10;
Param[0].Relation := 50;
Param[0].Duration := t#1s;
Param[0].NextIndex := 1;
(* display the error code *)
Param[1].Colour := ORANGE;
Param[1].Frequency := 1;
Param[1].Relation := 128;
Param[1].Duration := t#0s;
Param[1].NextIndex := 3;
(* Turn off LED if PLC is stopped *)
Param[2].Frequency := 0;
Param[2].Relation := 0;
Param[2].Duration := t#0s;
(* Turn on LED if PLC is started *)
Param[3].Colour := GREEN;
Param[3].Frequency := 0;
Param[3].Relation := 128;
Param[3].Duration := t#0s;
PointerToFS := ADR(Param); (* Get pointer to structure *)
SET_FLASHING_SEQUENCE(1, ADR(PointerToFS)); (* Give address of pointer to structure to Firmware *)
FirstCycle := FALSE;
END_IF
(* Turn on USR-LED if PLC is started *)
IF GET_RUN_VALUE(1) THEN
SET_FLASHING_SEQUENCE_INDEX(1, 1, 3);
START_FLASHING_SEQUENCE(1);
END_IF
(* Turn off USR-LED if PLC is stopped *)
IF GET_STOP_VALUE(1) THEN
SET_FLASHING_SEQUENCE_INDEX(1, 1, 2);
END_IF
(* Show an error code every 10 seconds *)
IF Timer.Q = 0 THEN
Param[1].Duration := WORD_TO_TIME(ErrorCode * 1000(*ms*) ); (* NULL => infinite flashing *)
SET_FLASHING_SEQUENCE_INDEX(1, 1, 0); (* Show the error code immediately *)
ErrorCode := ErrorCode + 1;
IF ErrorCode > 6 THEN
ErrorCode := 1;
END_IF
END_IF
Timer(IN := Timer.Q = 0, PT := T#10s);
I've had problems using the GET_RUN_VALUE and GET_STOP_VALUE functions. They never seem to work right and consequently don't turn the LED on/off to display run mode.
If you're just looking to turn the LED ON/OFF to indicate run mode then you can create two POUs as PROGRAMS in ST and call them usrLED_On and usrLED_Off.
(* Variable Declaration Section *)
PROGRAM usrLED_On
VAR
Sequence : ARRAY [0..1] OF FLASHING_SEQUENCE;
ptrFS : POINTER TO FLASHING_SEQUENCE;
END_VAR
(* Program Section *)
sequence[0].Colour := ORANGE;
sequence[0].Frequency := 0; (* Hertz*)
sequence[0].Relation := 128;
sequence[0].Duration := t#0ms;
sequence[0].NextIndex := 0;
ptrFS := ADR(Sequence);
SET_FLASHING_SEQUENCE(1, ADR(ptrFS));
START_FLASHING_SEQUENCE(1);
(* Variable Declaration Section *)
PROGRAM usrLED_Off
VAR
END_VAR
(* Program Section *)
STOP_FLASHING_SEQUENCE(1);
Then you can go to the RESOURCES Tab, Double-Click on "Task Configuration" in the left-hand pane. Select "System Events" in the Middle pane. Check "Start" and "Stop" in the "System Events" window. And enter usrLED_On in the "called POU" for "Start" and usrLED_Off in the "called POU" for "Stop".
This will create a valid Run Mode light. It works even if someone switches the internal slider to the off position - the light will change from on to off.
You can also use the usrLED_On program to setup multiple flashing sequences and then use an "Error" program to change which sequence index is running in order to display errors.
Just some thoughts, I know it's been 6 months since the question was asked, but I just found this forum. :O)
Also, I'm using Firmware Version: 01.11.01 (09) on my 750-841 Ethernet PFCs.
Take Care,<br>
Larry
Pierre
- Liquid level sensor: Non-mechanical optical technology extends application possibilities
- Wireless manager for instrumentation and control devices
- Level sensor: Magnetostrictive device extends mounting options
- New podcast: One road to wireless instrumentation
- Tutorial: Instrumentation / DCS integration languages, part 1, EDDL
- FactoryTalk industry-specific applications launched
- Torque: Hall-effect sensor, reaction torque sensor, torque data acquisition
- Transient blocking circuit protection via acquisition
- Automation Fair event focuses on convergence, sustainability, and technical talent
- Rockwell Automation releases VantagePoint for plant data visualization
Patronize our advertisers!




