Red Lion - for an old dog learning new tricks ...

Ron Beaufort

Lifetime Supporting Member
Join Date
Jul 2002
Location
Charleston, SC
Posts
5,701
it's a long story – but suddenly I'm being forced to "dabble" with a Red Lion G306 – and I've hit a snag where the subject of "Programs" is concerned ... I'd appreciate some help – please ...

I've got the G306 talking back and forth with my ControlLogix over Ethernet ... actually that part wasn't too hard to figure out ... I now have a DINT tag (MUTT) updating reliably between the CLX and the HMI ... I can push a button – and the magic happens ...

but ...

how do you get a "Program" to execute? ... I'm guessing that I'm not properly "calling it" into action – but (so far) nothing in my customary "trial-and-error" approach has worked ...

I'm particularly perplexed with the "Prototype" setting – since (so far) I haven't been able to find that term defined anywhere in the documentation that I have on hand ...

void Program1(void)

what the heck is THAT all about? ... probably nothing to do with my immediate problem - but frankly I'm puzzled ...

anyway – "success" (at least for right now) would be the ability to reliably execute a "Program" (???) "Continuously" (???) in the "Background" (???) – and have said program update a ControlLogix tag with a value developed by the Red Lion ...

all help is appreciated ...

.

PROGRAM_CODE.jpg
 
From the compute programming compiler legacy - a function prototype allows you to declare the return value of a function and the parameters that you'll be passing to it:
void function(void);
return_value functionname(passed_parameters);
like:
int myFunction(int somevariable);

in your case 'void' says nothing is declared for the return value and nothing is passed to the function.
 
You've cleared the first hurdle, to get that icon to go green.

When you are editing a Red Lion "Program", the diamond icon is yellow until the program is "Translated".

Why Red Lion used that word instead of "Compiled" or "Validated", I'll never know. This is especially confusing because Crimson 3 also provides a feature that is properly called "translation", for switching between human languages in text strings.

There is a white-sheet-with-green-checkmark icon that appears 4th-from-right in the toolbar for "Translate" when you are editing Programs, or you can press Control-T.

The Crimson 3 "C-Like" programming language can be found in places like the Action definition for a button, or in the Triggers definition for a Tag, or in these larger Programs. There are frequently multiple ways to skin a given squirrel.

Let's say you wanted to execute that Program on a button press.

Create a button, then add an Action to the button.

Make the Action Mode "User Defined".

In the Action Details, leave the type of action as "General" and call the Program with the empty parentheses syntax, like "Program1()".

That's it. No "Call" or "Gosub" command needed.

I am not a C programmer, so to make the most use of Red Lion's programming language I picked up a vintage copy of Kernighan and Ritchie's classic "The C Programming Language, 2nd Edition".
 
Ken,
Is it possible to have a program run all the time in the background? Or do you have to call the program using a "situation" like a button press or ???
 
thank you, danatomega ... that helps point out that the "Prototype" setting (probably) is not causing my "update" problem ... so far I'm not interested in passing parameters to or from the program – so I should be able to strike that off of my "maybe-it's-this" list ...

thank you Ken ... I attached the action to a button as you suggested – and it worked perfectly ... each time that I press the button the value of GetSec gets instantly written into TOAD – and the CLX tag reflects that value ... so at least now I know that the syntax of my code is correct ...

my issue is that I don't want to have to press a button to have the code executed ... specifically, I'd like the value from GetSec to be written into TOAD continuously (about every 500 ms would be fine) without my having to take any action at all ...

maybe that can't be done – and if not, I'll move on to something else ... but I'm just thinking that there SHOULD be a way to have the Program code (or something else like it) be executed on some type of specified "schedule" – or "update" – or something along those lines ... if the Red Lion can do that, I haven't been able to figure out HOW just yet ...

EDIT: Bullzi just summed it all up for me while I was typing ...
 
From the navigation pane, go to Display Pages, and then click on the word "Pages" itself. There you'll see an option to run an action "On Tick". If you put Program1() into that box, the program will be executed once per second.
 
BINGO! ... we have automatic updating! ... now THAT'S what I'm talking about ...

mts5096, I sincerely thank you, sir ...
 
Last edited:
Ron, just to elaborate a little about the function prototype - it merely tells the compiler that 'there will be a function that is something like this' - the parameter name(s) aren't required typically.

This allow the compiler preprocessor to resolve the functions when they are actually referenced in the actual function definitions.

Since all the functions are declared with the prototypes, when the function definitions are encountered by the compiler, it will be able to recognize the functions and accept or reject (with a compiler error or warning) based on proper calling and parameter passing and return value.
 

Similar Topics

We have an older Red Lion HMI that the backlight on the screen went out. We found another, but the software to work it (EDICT-97) doesn't seem to...
Replies
1
Views
3,387
While they came up quickly with a fix for the alarm date issue quickly I will have to drive around for a week or so, burning up a lot of fuel...
Replies
4
Views
261
From the Red Lion website, after some customer enquiries in the last week or so... Rev. March 25, 2024 [18:30] Just thought it might help a...
Replies
9
Views
278
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
107
Hello All, I need the ability to remotely reboot a Red Lion CR3000 HMI. Due to some graphics issues when the database is updated the HMI must be...
Replies
4
Views
218
Back
Top Bottom