archie, i've managed to get around this problem by adding in extra code to the control which basically examines the string and converts it to binary, then it checks how long the byte is and if it comes back longer then 16 bits it trims it down. then it goes through and drills down to the bit you want and carries on as usual. this has removed the flicker problem and works with all file registers. do you have any issues reading 16-bit registers with the 16th bit set? its strange because it is only specific registers that do this…. one other thing, i can't read input or output registers only B's?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This problem is coming from the integer declaration. The conversion to string is based on a 32 bit number. If a negative number comes back from the PLC, then the conversion sets bit 31. Here is a way to prevent the problem:
dim read1 as int16 = df1comm1.readany("B3:0")
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
following on from my previous posts about flicker etc, i've found a quirk with the subscribe and readany commands.
My set up:
df1comm driver
textbox1 with width set quite wide
converting the reads to binary
If you read a 16-bit register that looks like this:
000000000010001
When the read comes back, it returns only the significant bits, ie:
10001
Which is fine,
but, if you try and read when the Most Significant Bit is set ie:
1000000000000001
The read returns this:
11111111111111111000000000000001
Could this be the reason i'm getting flicker on some of my controls?
How are you converting to binary?
pretty much like this:
dim read1 as integer = df1comm1.readany("B3:0")
dim byte1 as string
byte1 = convert.tostring(read1, 2)
archie, i've managed to get around this problem by adding in extra code to the control which basically examines the string and converts it to binary, then it checks how long the byte is and if it comes back longer then 16 bits it trims it down. then it goes through and drills down to the bit you want and carries on as usual. this has removed the flicker problem and works with all file registers. do you have any issues reading 16-bit registers with the 16th bit set? its strange because it is only specific registers that do this…. one other thing, i can't read input or output registers only B's?
This problem is coming from the integer declaration. The conversion to string is based on a 32 bit number. If a negative number comes back from the PLC, then the conversion sets bit 31. Here is a way to prevent the problem:
dim read1 as int16 = df1comm1.readany("B3:0")
i'll put that in my code to stream line it. it's strange how its just specific registers that upset it, but the problem is sorted now so im happy,