Help with non-blocking delay

Thanks for the confirmation Lou. I thought perhaps I could webset var1 to the ISY but it looks like the isy will only allow 10 digits in a variable so that kind of shoots that down.
 
In the 3.02.17 firmware, there is ALLOUTS, that is 8 bit number each represent an output.  That takes only one unsigned byte.
 
TJF1960 said:
Thanks for the confirmation Lou. I thought perhaps I could webset var1 to the ISY but it looks like the isy will only allow 10 digits in a variable so that kind of shoots that down.
 
You're mixing up decimal digits and binary digits again.  ISY takes a 32 bit number just like VAR1.  So you do get the full value.  ISY also has bitwise operations, so you can extract the individual values.
 
TJF1960 said:
Thanks for the confirmation Lou. I thought perhaps I could webset var1 to the ISY but it looks like the isy will only allow 10 digits in a variable so that kind of shoots that down.
 
ISY variables are 32 bit signed as well.  It is the same as CAI.  2.1 billion is a 10 digit number that is 31 bits.  You can definitely sync the two using bitwise.  ISY also has some bitwise functions built-in (and/or/xor).
 
EDIT: sorry AZ1324, didn't mean to just repeat your post, you posted while i was typing.
 
Oh, ok. Didn't realize ISY accepted 32 bit in. Am away from home now so can't try it first but if you send a 32 bit in to a ISY var. does the ISY show the decimal equiv. on the variable page?
 
TJF1960 said:
Oh, ok. Didn't realize ISY accepted 32 bit in. Am away from home now so can't try it first but if you send a 32 bit in to a ISY var. does the ISY show the decimal equiv. on the variable page?
 
You are still not thinking like a binary brain.  Decimal and binary are just 2 ways to display the same number.  It is like Spanish vs English, totally different letters, but the same word. "caliente" and "hot" are the same thing, it is just 2 ways to display it.
 
ISY will always display the numbers in decimal.  You need to type your binary representation of a number into your windows calculator with the "binary" dot checked, then check the decimal dot and it will show the decimal version.  It's like a Spanish to English translator.  
 
For example, lets say you have your 16 inputs/outputs coded in binary as follows where the first 8 are inputs and the second 8 are outputs.
 
1000110101100011
 
That is 36195 in decimal.
 
Now lets say you want to test the status of input 4
 
To do this, you "and" it with 0001000000000000 (or 4096 in decimal, or 1000000000000 if you get rid of the leading 0's which you don't need but can leave if you want)
 
If the result is 0, then the 4th bit from the left is off, if it is non-zero, then it is on.
 
In ISY, lets give a name to a variable that stores your 16 i/o states.  Let's call it $iostate
 
First, copy $iostate to a working variable, we'll call it $bitcheck
 
If
 - - - whatever you want to cause the status check to occur
 
Then
$bitcheck = $iostate
$bitcheck &= 4096
Run If program 2
 
Else
 - - 
 
Program 2
 
If $bitcheck is not 0
 
Then
- - do whatever it is you want to happen if input 4 is on.
 
Else
 - -  do whatever it is you want to happen if input 4 is off
 
Lou,
 
Thanks very much!
 
I think I get it. I coded up a test program in the ISY to see if I understood how to do it. Each input and output has its own variable slot (integer for now). I wanted to figure out how to use the binary expressions in the ISY to populate all I/O variables (with ones and zeros) once the webcontrol board webset the data. Here is what I came up with:
 
$sWC5_IO_DataInput is a State variable set by WebSet,
$iWC5_Math is a Integer variable slot for ISY computation only
$iWC5_O1, O2 etc are (for now) Integer variables and represent the current state of each output of the webcontrol board, once implemented they will get changed to State variables.
$iWC5_I1, I2 etc are (for now) Integer variables and represent the current state of each input         "    "    "
 
Of course anytime $sWC5_IO_DataInput variable changes this program retriggers and sets all the in/output variables. And once all the in/outs are changed to State variables any changes in them will trigger the other programs associated with them.
 
If
        $sWC5_IO_DataInput is not 0                                # a state variable set by webcontrol webset
 
Then
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 1                                                  # a integer variable used for computation only
        $iWC5_Math /= 1
        $iWC5_O1  = $iWC5_Math                                   # iwc5_O1 variable for output 1 of webcontrol, O2 would be output 2
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 2
        $iWC5_Math /= 2
        $iWC5_O2  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 4
        $iWC5_Math /= 4
        $iWC5_O3  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 8
        $iWC5_Math /= 8
        $iWC5_O4  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 16
        $iWC5_Math /= 16
        $iWC5_O5  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 32
        $iWC5_Math /= 32
        $iWC5_O6  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 64
        $iWC5_Math /= 64
        $iWC5_O7  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 128
        $iWC5_Math /= 128
        $iWC5_O8  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 256
        $iWC5_Math /= 256
        $iWC5_I1  = $iWC5_Math                                      # iWC5_I1 variable representing input1 of webcontrol, I2 would be input 2 etc
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 512
        $iWC5_Math /= 512
        $iWC5_I2  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 1024
        $iWC5_Math /= 1024
        $iWC5_I3  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 2048
        $iWC5_Math /= 2048
        $iWC5_I4  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 4096
        $iWC5_Math /= 4096
        $iWC5_I5  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 8192
        $iWC5_Math /= 8192
        $iWC5_I6  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 16384
        $iWC5_Math /= 16384
        $iWC5_I7  = $iWC5_Math
        $iWC5_Math  = $sWC5_IO_DataInput
        $iWC5_Math &= 32768
        $iWC5_Math /= 32768
        $iWC5_I8  = $iWC5_Math
 
Else
   - No Actions - (To add one, press 'Action')
It seems to work perfectly... so far. Do you see any possible problems or concerns?
 
At a glance it looks like this is parsing out your merged values into separate variables.
 
The only problem I see is your "if" line.  If all of your I/O values shut off, then the program won't run because the value of $sWC5_IO_DataInput will be 0.  Instead I would say "is not -1". 
 
You could also probably drop the /2, /4, /8, etc.  That extra line of code just consumes resources.  All you need is for the variable to be 0 or not 0.  Who cares if it is a 1 or 8, or 4096, or whatever, if it is not 0 then it represents "on".
 
If you are using all the bits then it could be -1 so you could do
 
If
        $sWC5_IO_DataInput is not 0     
        or
        $sWC5_IO_DataInput is 0
 
Hello az1324,
 
Thank you for the suggestion, again. Can I ask under what conditions might it be -1?
 
Lou,
 
Just saw your edit. I do like to try and keep it resource light when I can. I had thought about it and the only reason I added the /2 /4 etc was to keep all the variables uniform 0 or 1. But of course you are right, all that matters is the variable is either 0 or not 0 so I will get rid of the extra steps. Thanks.
 
CAI,
 
4 of my 5 boards are 3.02.16c so they probably do not have the ALLOUTS function, or might they possibly?
 
If not how would be the best way to code this. Say I want to store all 8 outputs on VAR1 in order. I had a couple of examples I was going to post but I realized they didn't make sense so I deleted them. If you could provide one or two examples I could probably take it from there.
 
Thank you all so much.
 
TJF1960 said:
Hello az1324,
 
Thank you for the suggestion, again. Can I ask under what conditions might it be -1?
 
Lou,
 
Just saw your edit. I do like to try and keep it resource light when I can. I had thought about it and the only reason I added the /2 /4 etc was to keep all the variables uniform 0 or 1. But of course you are right, all that matters is the variable is either 0 or not 0 so I will get rid of the extra steps. Thanks.
 
CAI,
 
4 of my 5 boards are 3.02.16c so they probably do not have the ALLOUTS function, or might they possibly?
 
If not how would be the best way to code this. Say I want to store all 8 outputs on VAR1 in order. I had a couple of examples I was going to post but I realized they didn't make sense so I deleted them. If you could provide one or two examples I could probably take it from there.
 
Thank you all so much.
 
 
I don't think it can be negative in your context.  The variable is set by CAI, and I don't believe there is anyway for bitwise logic to set the 32 bit (the sign bit) in CAI.  Of course if you use something besides bitwise logic in CAI to establish the value of the variable, then it could be negative.  You certainly can use "is 0 or is not 0", or for that matter you could say "is x or is not x" where x is any number at all.
 
Lou Apo said:
I don't think it can be negative in your context.  The variable is set by CAI, and I don't believe there is anyway for bitwise logic to set the 32 bit (the sign bit) in CAI.  Of course if you use something besides bitwise logic in CAI to establish the value of the variable, then it could be negative.  You certainly can use "is 0 or is not 0", or for that matter you could say "is x or is not x" where x is any number at all.
I don't see why that would be true.  ORB 0xFFFFFFFF 0 VAR1 should set VAR1 to -1.
 
Code:
PACKOPS:
    ANDB VAR1 0xFFFFFF00 VAR1
    ORB VAR1 OP1 VAR1
    ROTL OP2 1 RAM1
    ORB VAR1 RAM1 VAR1
    ROTL OP3 2 RAM1
    ORB VAR1 RAM1 VAR1
    ROTL OP4 3 RAM1
    ORB VAR1 RAM1 VAR1
    ROTL OP5 4 RAM1
    ORB VAR1 RAM1 VAR1
    ROTL OP6 5 RAM1
    ORB VAR1 RAM1 VAR1
    ROTL OP7 6 RAM1
    ORB VAR1 RAM1 VAR1
    ROTL OP8 7 RAM1
    ORB VAR1 RAM1 VAR1
    RET
 
 
Back
Top