how get the value in uV...

Hi everybody, i'm having some problems to undestand the value that the board send to pc, i explain.
I'm working in python, and i wrote this while loop statement, to read what the board serd:
while True:
pacchetto = []  #this is an array of integer that rapresent a packet
canale_1 = [] #another array where i put the conversion byte in integer that rapresent the channel 1
fine = scheda.read() # in this the line of code i manage the sincronism between the board an the pc
inizio = scheda.read()# in this the line of code i manage the sincronism between the board an the pc
if ord(fine) == 192 and ord(inizio) == 160: # start byte and closer byte of the packet
for c in range(0,31): # read all the byte that compose a packet
valore = scheda.read()
pacchetto.append(ord(valore)) # in pacchetto[] i put integer

canale_1 = [pacchetto[1], pacchetto[2], pacchetto[3]] # as sad in the guide the byte 3 4 and 5 is refered to channel 1
print canale_1 
valore = conversione(pacchetto[1], pacchetto[2], pacchetto[3]) #simple function that convert an array of integer in one value 
print valore

def conversione (primo, secondo, terzo):
intero_senza_segno = (primo*pow(2,16)) + (secondo*pow(2,8)) + terzo
if primo >= 127: #in this if - else statement i manage the sign of the value 
intero_con_segno = intero_senza_segno - pow(2,24)
return intero_con_segno*fattore_di_scala  # fattore di scala = 0.02235
else:
return intero_senza_segno*fattore_di_scala # fattore di scala = 0.02235

my output is this:

[152, 198, 207]
-453618.52838
[233, 72, 30]
-99836.2570806
[152, 199, 14]
-453614.303901
[231, 255, 216]
-105471.444782
[152, 198, 44]
-453629.458383
[233, 145, 128]
-98576.5574666
[152, 199, 200]
-453601.831627
[232, 70, 109]
-104259.823771
[152, 199, 99]
-453608.604206
[232, 216, 79]
-101755.579025
the array is the byte of channel and the float is the value in uV... in theory... 
The question... what i'm doing wrong... i try the famous user.py, but this code give me an error infact the code can't decode the start byte or the ending byte... so i decide to write my self the code... 

thx for your time to read this, and thx for the replies

Comments

Sign In or Register to comment.