Crimson 3.0 - Issue Writing Program

jrsnydley

Member
Join Date
Dec 2014
Location
Minnesota
Posts
155
Hello everyone!

I am trying to write a program in Crimson 3.0 that will turn on an output if a number of tags are not equal to zero. When I hit the translate button a message box pops up and says "The left-handed side of operator '=' must be writable.

Here is my code:

// If any alarms are present on any of the controllers, sound the audible alarm via Output 1

if ( PLC1.Alarms != 0 ) {
[Module1.Variables.OutputCoil1] = 1;
}
else if ( PLC2.Alarms != 0 ) {
[Module1.Variables.OutputCoil1] = 1;
}
else if ( PLC3.Alarms !=0 ) {
[Module1.Variables.OutputCoil1] = 1;
}
else {
[Module1.Variables.OutputCoil1] = 0;
}

end

Is it possible to turn on an output with a program or not?
 
Is "Module1.Variables.OutputCoil1" a tag? If so it must be set up as writable in the tag properties, and you shouldn't have square brackets around it. (Square brackets are used when directly addressing a register in an external device without a tag.)

Here's a shorter way to accomplish the same thing:
Module1.Variables.OutputCoil1 := (PLC1.Alarms!=0 || PLC2.Alarms!=0 || PLC3.Alarms!=0)

Your program will also have to run repeatedly to work correctly, like in the On Tick action.
 
I have gotten into the habit of always using two characters when performing any operation involving the equals sign

"==" test for equality
":=" assignment, which is how an equal sign all by itself gets translated.

With that said, John is right, your tags need to be set as read/write on their properties. You can fix one of them, and then copy and paste that property by selecting all the others and then pasting special > selective > pick the property you want to paste from the list.
 
You can also simplify things a lot:

[Module1.Variables.Output1] = (PLC1.Alarms || PLC2.Alarms || PLC3.Alarms);

The || operators treats each of arguments as a logical value, which for a numeric means whether it's equal to zero. It returns true (or 1) if either argument is true. So the code above will set the output to on if any of those values is not equal to zero, and to zero otherwise.
 

Similar Topics

We updated from Crimson 3.2.0067.0 to Crimson 3.2.0071.0 and now there is no comms between the 12" Graphite HMI and the AB Compact Logix PLC...
Replies
2
Views
509
Well, I have yet another question for the great minds on this forum! We have a red lion HMI for one of our machines and every time I hook my...
Replies
11
Views
1,660
Hello Kind Folks, On my Red Lion Crimson, the "Send to Emulator" box is greyed out, and thus I'm unable to run the emulator. Has anyone run...
Replies
12
Views
3,441
Hi everyone, I honestly think this is a stupid question and I am completely missing something simple here, but I am having difficulties trying to...
Replies
3
Views
5,649
Hi everyone.. This is my first attempt trying to connect a QLogix PLC to the Crimson 3.0 software. I am using the G310 emulator to view the...
Replies
4
Views
2,938
Back
Top Bottom