I am working on a project in which I have to collect voltages from a teensy 2.0(which I am programming with arduino) and send those voltages to Python. I also have to send the microsecond the data was taken on. I am using PySerial to communicate with the teensy. I first read in all my data to an array of length 3998. I have two other arrays, a "timeData" array, which keeps track of the microseconds, and a "radarData" array, which keeps track of the voltages. Each array carries half the data, or 1999 points.
A sample output of the teensy is:
b'1468095384rn'
b'0.01rn'
This will get repeated 1999 times. The Python code takes these inputs and writes them into and array "SerialData". After it is done reading all the data it separates all the points into the two arrays like so:
for i in range (0,3998):
if(i % 2 == 0):
radarData[samples] = float(str(SerialData[i], 'utf-8'))
samples = samples + 1
else:
timeData[samples1] = float(str(SerialData[i], 'utf-8'))
samples1 = samples1 + 1
Sample and Sample1 are counter variables.
From printing out float(str(SerialData[i], 'utf-8'))
, I know that parsing the string as a float works, but whenever I print out radarData[samples] or timeData[samples], I just see 0. What am I doing wrong? Any help is appreciated.
Thanks!
Aucun commentaire:
Enregistrer un commentaire