The number is just the same either hex, binary or decimal. 128 is the same as %10000000 or $80. You show it in different way.
The trackbar object, what exactly is?
Ioannis
The number is just the same either hex, binary or decimal. 128 is the same as %10000000 or $80. You show it in different way.
The trackbar object, what exactly is?
Ioannis
Trackbar is only an object ID in VISI GENIE OS for the Display like the following.
in our case we do use the LEDDIGITS which the OBJECT ID is $0F
![]()
OK, I see.
So, if you want to move the trackbar to position $28 you will use
and the slider will goto position $28.Code:HserOut [$01,$05,$00,$00,$28,$2C]
But I guess you have to set beforehand the two ends of the trackbar? I mean the zero can be 100 and the maximum position 200, or whatever.
Can you try and see if you can move the trackbar just by sending straight in values? and the CRC computed by hand.
Then you may do more complicated things.
Ioannis
in my case i do not use the trackbar, but the LED digits as shown below.
In the software 4D SYstems they have, you can set manually a number for example 167, and will show you the command as shown in the SET DIGIT VALUE:
I have tried to give manually a constant number and it worked!
what i did is:
i set a new var mTEMP ' for manually hex number and
a new var mTEMPIR ' for manually hex number as well.
In our case the number 167 for:
then i did the CS calculation and return to the HSEROUT command.Code:mTEMP = $00 mTEMPIR = $a7
I placed it with:Code:IRCS=0 IRCS= $01^$0F^$00^mTEMP IRCS = IRCS ^ mTEMPIR
then i got the right result on the display.Code:HSEROUT [$01,$0F,$00,mTEMP,mTEMPIR,IRCS)
The problem is that when i use the variables i cannot get the right values.
Last edited by astanapane; - 18th December 2021 at 23:14.
i assume the real question in this jumble is how do i sent a word var as a binary number msb first using hserout
Temp var word
Temp=167
HSEROUT [$01,$0F,$00,Temp.highbyte,Temp.lowbyte,IRCS)
Warning I'm not a teacher
Richard!!!!
it really worked!!!
Now i'm trying to figure out how to add the remainder in the command.Code:'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' VAR for IR to LCD ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' IRCS var byte ' this is the checksum for the IR required in external display command TEMP var word ' this is the word variable for TEMP temperature var word ' for result and output to lcd TEMPIR var word ' set a variable tempir Remainder var word ' Get the remainder = tempir//50 '------------------------------------------------------------------------------* ' Measure IR object temp sent to uLCD * '------------------------------------------------------------------------------* object: reg = $07 ' based on the datasheet $07 is the object's temp addr = %10110100 ' $B4 binary value: %10110100 i2cwrite SDA, scl, addr ' send write command, shift the address B4, 8 bits where LSB is W = 0 i2cwrite sda, scl, reg ' register is $07 addr = %10110101 ' $B5 Binary value: %10110101 i2cwrite sda, scl, addr ' sends read command, shift the address B5, 8 bits where LSB is R = 1, clock idles low i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07 tempir = (temp.highbyte << 8) + temp.lowbyte temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02 temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15 remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100 pause 100 gosub display return '------------------------------------------------------------------------------* ' IR Display 1 the parameters * '------------------------------------------------------------------------------* display: ' IR TEMP hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00] Hserin2 timeout,error,[wait(6)] hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature,".",dec2 remainder,"*C",00] 'this one works on display 1 which doesnt require CS Hserin2 timeout,error,[wait(6)] gosub checksum2 HSEROUT [$01,$0F,$00,temperature.highbyte,temperature.lowbyte,IRCS) ' this one works. Hserin timeout,error,[wait(6)] return '------------------------------------------------------------------------------| ' CHECKSUM IR | '------------------------------------------------------------------------------| checksum2: IRCS = 0 IRCS = $01 ^ $0F ^ $00 ^ temperature 'IRCS = IRCS ^ remainder ' commended this as i need to figure out how to import it in the HSEROUT command. return
i hope this is not a medical diagnostic deviceNow i'm trying to figure out how to add the remainder in the command.
your temperature calculation is not accurate and the remainder calculation is mathematically incorrect
yields the temp in deg C to about 1 deg of resolution with an error of +- 1 degreeCode:temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02 temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
calculated the 100 modulus of the temp in deg kelvinCode:remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100
adding them together is nonsense , trying to display a two decimal point result is from any of these results is just not right
display like thisCode:wtf tempir = (temp.highbyte << 8) + temp.lowbyte ;just Nooooo! its the hardest most convoluted way i have ever encountered to go tempir = temp which serves no purpose anyway don't like this either, it pisses away too much resolution hence its not particularly accurate temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02 temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15 remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100 ;this is good although it could be even more accurate [temperature = temp*2 - 27315 ; temp x 2 - 273.15*100 ] >==>temperature*100] if the raw value won't exceed 32768 temperature = (temp - 13657)<<1 ; (temp-[273.15*50]) x 2 <==> temperature*100; is good i make the assumption temperature * 100 is the value required by the slider display tempir and remainder are not needed
Code:'------------------------------------------------------------------------------*' IR Display 1 the parameters * '------------------------------------------------------------------------------* display: ' IR TEMP hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00] Hserin2 timeout,error,[wait(6)] hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature/100,".",dec2 temperature//100,"*C",00] Hserin2 timeout,error,[wait(6)] gosub checksum2 hserout [$01,$0F,$00,temperature.highbyte,temperature.lowbyte,IRCS] Hserin timeout,error,[wait(6)] return '------------------------------------------------------------------------------| ' CHECKSUM IR | '------------------------------------------------------------------------------| checksum2: IRCS = 0 IRCS = $01 ^ $0F ^ $00 ^ temperature.highbyte ^ temperature.lowbyte return
then lets have a look at the i2c stuff , its not right either really
ps if negative temps are possible then additional code req
Last edited by richard; - 19th December 2021 at 10:07.
Warning I'm not a teacher
Bookmarks