Setting OPx other than 1

TJF1960

Active Member
I have read a few posts in the past about the ability to set OPx to a value other than 1, but haven't located them since.
I am running some boards which are v03.02.16c and higher. I played around a little with this function and have found:
 
  1. setting OP1 to 0 = 0 output
  2. setting OP1 to 1 = 1 output
  3. setting OP1 to 2-9 = 0 output, but can still test against the value.
  4. Once OP1 is set to 2 or higher it cannot be set to 0 directly, it has to be set to 1 then 0.
 
Having OP1 output equal zero when it is any number other than 1 works perfect for an application I am considering.
 
Questions I have are:
  1. Is this function by design or a bug?
  2. Are there any other limitations i haven't discovered yet?
  3. Will this function still be available in future revs or should I not program using this function?
Thanks,
Tim
 
I have never tried this and always assumed that outputs were stored as a single bit in memory meaning that they could never be anything but 0 and 1.  I would expect setting it to anything except 0 would be translated to 1.  
 
But, it appears you have done experiments that show this to be otherwise.
 
In point 3, you state that "can still test against the value"  Do you mean that something like
 
SET OP1 3
TSTEQ OP1 3 => gives a true result
TSTEQ OP1 1 => gives a false result
TSTEQ OP1 0 => gives ? what result, but the output is physically off
 
OPx should only be set to 0 or 1.  Although supposedly setting bigger than 1 should be treated like 1, the compiler somehow did not work that way.  az1324 had pointed that out to us.  That is fixed in a beta release of next update.
 
If you do not set OPx to anything other than 1 and 0, you will not have any problem.  However, if you PLC logic set it to above 1, like Tom did, then it will have issue.  You can either fix that in the PLC code to make sure only set OPx to 0 or 1, or get our new beta firmware.  With bootloader, this can be done easily over the network.
 
Lou Apo said:
In point 3, you state that "can still test against the value"  Do you mean that something like

 
SET OP1 3
TSTEQ OP1 3 => gives a true result
TSTEQ OP1 1 => gives a false result
TSTEQ OP1 0 => gives ? what result, but the output is physically off
In testing on a .16c board
 
Set OP1 3
TSTEQ OP1 3 = true but actual output is off.
TSTEQ OP1 1 = false and output is off.
TSTEQ OP3 0 = false and output is off.
 
So the two odd things I noticed were when output set to 2-9 the output is off and if it is set to 2-9 you have to set it to 1 before you can set it to 0 otherwise if set with 2-9 and trying to set it to 0 will not happen.
 
CAI, just so I am clear, you are saying that OPx should never be set to anything but 0 or 1, period, even with the new firmware?
 
Thanks,
Tim
 
Tim,
 
Sorry for I did not say clearly, OPx only has two states, 0 or 1. for off and on.
When we tested in the past, we only tested SET OPx 1 or 0, not any other number. 
 
In the beta version firmware, we changed to make sure anything above 1 will be treat like 1. But that is not in the current shipping firmware.  Customer with bootloader firmware can easily get beta firmware loaded to their boards, if they contact us by email. But that is not  a released version yet.
 
For firmware without bootloader, you could work around by only set OPX to 0 or 1, or you can send the board in for update to beta firmware.  The beta firmware is with bootloader allowing easy update in the future.
 
Ok, Thank you for the clarification, just wanted to make sure before spending too much time writing code using this method.
 
Thanks,
Tim
 
Yes, Lou.  If setting OPx to anything above 1, currently it is not work.  Its internal storage is Boolean, a bit position to indicate either true or false.  Somehow the compiler did not cast value larger than 1 to true. 
 
It is not considered as a bug, since it is match exactly as documented in user guide page 26.  However, there is a fix for this in the beta firmware, that treats anything above 1 as 1.
 
Back
Top