Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions accel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,47 @@

# Make sure the out file is opened properly
while 1:
try:
f1 = open('acceleration.csv','a')
# raise IOError
print "Successfully opened", f1.name
f1.write("Month,Day,Hour,Minute,Second,Xraw,Yraw,Zraw,X,Y,Z,Norm\n")
break
except Exception as err:
print 'Error:', err
time.sleep(1)
try:
f1 = open('acceleration.csv','a')
f2 = open('acceleration_errors.csv','a')
print "Successfully opened", f1.name
print "Successfully opened", f2.name
f1.write("Month,Day,Hour,Minute,Second,Xraw,Yraw,Zraw,X,Y,Z,Norm\n")
f2.write("Month,Day,Hour,Minute,Second,Error\n")
break
except Exception as error1:
print 'Error ' + str(error1)
time.sleep(1)

# Get accelerometer values and write them to file
while 1 :
try:
now = datetime.datetime.now()
rawX = ADC.read("P9_36")
rawY = ADC.read("P9_38")
rawZ = ADC.read("P9_40")

# Convert raw values to g values
# Reference: http://beagleboard.org/support/BoneScript/accelerometer/
Xvalue = ((rawX * 3.6) - zeroOffsetX)/conversionFactorX
Yvalue = ((rawY * 3.6) - zeroOffsetY)/conversionFactorY
Zvalue = ((rawZ * 3.6) - zeroOffsetZ)/conversionFactorZ

# raw input is multiplied by 3.6 because it has to be multiplied by 1.8 to get voltage and since it is hooked up to a voltage
# divider it also needs to be multiplied by 2 to get the original voltage
#print 'X =', str(Xvalue), 'Y =', str(Yvalue), 'Z =', str(Zvalue)
a = np.array([Xvalue, Yvalue, Zvalue])
#print 'Norm =', str(np.linalg.norm(a))
#print 'Xraw =', str(rawX * 3.6), 'Yraw =', str(rawY * 3.6), 'Zraw =', str(rawZ * 3.6)
f1.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(rawX)+','+str(rawY)+','+str(rawZ)+','+str(Xvalue)+','+str(Yvalue)+','+str(Zvalue)+','+str(np.linalg.norm(a))+'\n')
except Exception as err:
print 'Error:', err
time.sleep(1)
while 1:
try:
now = datetime.datetime.now()
rawX = ADC.read("P9_36")
rawY = ADC.read("P9_38")
rawZ = ADC.read("P9_40")

# Convert raw values to g values
# Reference: http://beagleboard.org/support/BoneScript/accelerometer/
Xvalue = ((rawX * 3.6) - zeroOffsetX)/conversionFactorX
Yvalue = ((rawY * 3.6) - zeroOffsetY)/conversionFactorY
Zvalue = ((rawZ * 3.6) - zeroOffsetZ)/conversionFactorZ

# raw input is multiplied by 3.6 because it has to be multiplied by 1.8 to get voltage and since it is hooked up to a voltage
# divider it also needs to be multiplied by 2 to get the original voltage
print 'X: ' + str(Xvalue)
print 'Y: ' + str(Yvalue)
print 'Z: ' + str(Zvalue)
a = np.array([Xvalue, Yvalue, Zvalue])
print 'Norm: ' + str(np.linalg.norm(a))
print 'Xraw: ' + str(rawX * 3.6)
print 'Yraw: ' + str(rawY * 3.6)
print 'Zraw: ' + str(rawZ * 3.6)
f1.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(rawX)+','+str(rawY)+','+str(rawZ)+','+str(Xvalue)+','+str(Yvalue)+','+str(Zvalue)+','+str(np.linalg.norm(a))+'\n')
except Exception as error2:
print 'Error ' + str(error2)
f2.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(error2)+'\n');
time.sleep(1)

f1.close()
f1.close()
f2.close()
74 changes: 40 additions & 34 deletions accel_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,47 @@

# Make sure the out file is opened properly
while 1:
try:
f1 = open('/media/CARD/acceleration2.csv','a')
# raise IOError
print "Successfully opened", f1.name
f1.write("Month,Day,Hour,Minute,Second,Xraw,Yraw,Zraw,X,Y,Z,Norm\n")
break

except Exception as err:
print 'Error:', err
time.sleep(1)
try:
f1 = open('/media/CARD/acceleration2.csv','a')
f2 = open('/media/CARD/acceleration_errors2.csv','a')
print "Successfully opened", f1.name
print "Successfully opened", f2.name
f1.write("Month,Day,Hour,Minute,Second,Xraw,Yraw,Zraw,X,Y,Z,Norm\n")
f2.write("Month,Day,Hour,Minute,Second,Error\n")
break
except Exception as error1:
print 'Error ' + str(error1)
time.sleep(1)

# Get accelerometer values and write them to file
while 1 :
try:
now = datetime.datetime.now()
rawX = ADC.read("P9_36")
rawY = ADC.read("P9_38")
rawZ = ADC.read("P9_40")

# Convert raw values to g values
# Reference: http://beagleboard.org/support/BoneScript/accelerometer/
Xvalue = ((rawX * 3.6) - zeroOffsetX)/conversionFactorX
Yvalue = ((rawY * 3.6) - zeroOffsetY)/conversionFactorY
Zvalue = ((rawZ * 3.6) - zeroOffsetZ)/conversionFactorZ

# raw input is multiplied by 3.6 because it has to be multiplied by 1.8 to get voltage and since it is hooked up to a voltage
# divider it also needs to be multiplied by 2 to get the original voltage
#print 'X =', str(Xvalue), 'Y =', str(Yvalue), 'Z =', str(Zvalue)
a = np.array([Xvalue, Yvalue, Zvalue])
#print 'Norm =', str(np.linalg.norm(a))
#print 'Xraw =', str(rawX * 3.6), 'Yraw =', str(rawY * 3.6), 'Zraw =', str(rawZ * 3.6)
f1.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(rawX)+','+str(rawY)+','+str(rawZ)+','+str(Xvalue)+','+str(Yvalue)+','+str(Zvalue)+','+str(np.linalg.norm(a))+'\n')
except Exception as err:
print 'Error:', err
while 1:
try:
now = datetime.datetime.now()
rawX = ADC.read("P9_36")
rawY = ADC.read("P9_38")
rawZ = ADC.read("P9_40")

# Convert raw values to g values
# Reference: http://beagleboard.org/support/BoneScript/accelerometer/
Xvalue = ((rawX * 3.6) - zeroOffsetX)/conversionFactorX
Yvalue = ((rawY * 3.6) - zeroOffsetY)/conversionFactorY
Zvalue = ((rawZ * 3.6) - zeroOffsetZ)/conversionFactorZ

time.sleep(1)
# raw input is multiplied by 3.6 because it has to be multiplied by 1.8 to get voltage and since it is hooked up to a voltage
# divider it also needs to be multiplied by 2 to get the original voltage
print 'X: ' + str(Xvalue)
print 'Y: ' + str(Yvalue)
print 'Z: ' + str(Zvalue)
a = np.array([Xvalue, Yvalue, Zvalue])
print 'Norm: ' + str(np.linalg.norm(a))
print 'Xraw: ' + str(rawX * 3.6)
print 'Yraw: ' + str(rawY * 3.6)
print 'Zraw: ' + str(rawZ * 3.6)
f1.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(rawX)+','+str(rawY)+','+str(rawZ)+','+str(Xvalue)+','+str(Yvalue)+','+str(Zvalue)+','+str(np.linalg.norm(a))+'\n')
except Exception as error2:
print 'Error ' + str(error2)
f2.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(error2)+'\n');
time.sleep(1)

f1.close()
f1.close()
f2.close()
13 changes: 13 additions & 0 deletions check_experiments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash


ps aux | grep gps_raw
ps aux | grep pressure_kPa
ps aux | grep pressure_kPa_card
ps aux | grep temp
ps aux | grep temp_card
ps aux | grep extTemp
ps aux | grep extTemp_card
ps aux | grep accel
ps aux | grep accel_card

66 changes: 36 additions & 30 deletions extTemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,45 @@

#See June 4 comment on http://ealmberg.blogspot.com/2015/06/4-june-15.html

Bvalue = 3348 #Beta
Ro = 1000 #Resistance at 25 C
To = 298.15 #Room temperature in Kelvin
Bvalue = 3348 #Beta
Ro = 1000 #Resistance at 25 C
To = 298.15 #Room temperature in Kelvin

# Make sure the out file is opened properly
while 1:
try:
outfile = open('externalTemp.csv','a')
#raise IOError
print "Successfully opened", outfile.name
outfile.write("Month,Day,Hour,Minute,Second,ADC,Resistance,Kelvin,Celsius,Fahrenheit\n")
break
except Exception as err:
print 'Error:', err
time.sleep(1)
try:
f1 = open('externalTemp.csv','a')
f2 = open('externalTemp_errors.csv', 'a')
print "Successfully opened", f1.name
print "Successfully opened", f2.name
f1.write("Month,Day,Hour,Minute,Second,ADC,Resistance,Kelvin,Celsius,Fahrenheit\n")
f2.write("Month,Day,Hour,Minute,Second,Error\n")
break
except Exception as error1:
print 'Error ' + str(error1)
time.sleep(1)

# Get thermistor values and write them to file
while 1:
try:
now = datetime.datetime.now()

adcValue = ADC.read("P9_35")
R = Ro/((1/adcValue) - 1) #Get measured resistance
kelvin = 1.0/To + (1.0/Bvalue)*mt.log(R/Ro) #Formula from above blogspot address
kelvin = 1.0/kelvin
celsius = kelvin - 273.15
fahrenheit = celsius*(9/5.0) + 32.0

outfile.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(adcValue)+','+str(R)+','+str(kelvin)+','+str(celsius)+','+str(fahrenheit)+'\n')
print str(kelvin) + 'K', str(celsius) + ' C', str(fahrenheit) + ' F'
except Exception as err:
print 'Error:', err

time.sleep(1)

outfile.close()
try:
now = datetime.datetime.now()

adcValue = ADC.read("P9_35")
R = Ro/((1/adcValue) - 1) #Get measured resistance
T = 1.0/To + (1.0/Bvalue)*mt.log(R/Ro) #Formula from above blogspot address

t_k = 1.0/T #Temperature in Kelvin
print str(t_k) + 'K'
t_c = 1.0/T - 273.15 #Convert to celsius
print str(t_c) + 'C'
t_f = t_c*(9/5.0) + 32.0 #Convert to Fahrenheit
print str(t_f) + 'F'

f1.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(adcValue)+','+str(R)+','+str(t_k)+','+str(t_c)+','+str(t_f)+'\n');
except Exception as error2:
print 'Error ' + str(error2)
f2.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(error2)+'\n');
time.sleep(1)

f1.close()
f2.close()
70 changes: 38 additions & 32 deletions extTemp_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,45 @@

#See June 4 comment on http://ealmberg.blogspot.com/2015/06/4-june-15.html

Bvalue = 3348 #Beta
Ro = 1000 #Resistance at 25 C
To = 298.15 #Room temperature in Kelvin
Bvalue = 3348 #Beta
Ro = 1000 #Resistance at 25 C
To = 298.15 #Room temperature in Kelvin

# Make sure the out file is opened properly
while 1:
try:
outfile = open('/media/CARD/externalTemp2.csv','a')
#raise IOError
print "Successfully opened", outfile.name
outfile.write("Month,Day,Hour,Minute,Second,ADC,Resistance,Kelvin,Celsius,Fahrenheit\n")
break
except Exception as err:
print 'Error:', err
time.sleep(1)

# Get thermisotr values and write them to file
try:
f1 = open('/media/CARD/externalTemp2.csv','a')
f2 = open('/media/CARD/externalTemp_errors2.csv', 'a')
print "Successfully opened", f1.name
print "Successfully opened", f2.name
f1.write("Month,Day,Hour,Minute,Second,ADC,Resistance,Kelvin,Celsius,Fahrenheit\n")
f2.write("Month,Day,Hour,Minute,Second,Error\n")
break
except Exception as error1:
print 'Error ' + str(error1)
time.sleep(1)

# Get thermistor values and write them to file
while 1:
try:
now = datetime.datetime.now()

adcValue = ADC.read("P9_35")
R = Ro/((1/adcValue) - 1) #Get measured resistance
kelvin = 1.0/To + (1.0/Bvalue)*mt.log(R/Ro) #Formula from above blogspot address
kelvin = 1.0/kelvin
celsius = kelvin - 273.15
fahrenheit = celsius*(9/5.0) + 32.0

outfile.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(adcValue)+','+str(R)+','+str(kelvin)+','+str(celsius)+','+str(fahrenheit)+'\n')
print str(kelvin) + 'K', str(celsius) + ' C', str(fahrenheit) + ' F'
except Exception as err:
print 'Error:', err

time.sleep(1)

outfile.close()
try:
now = datetime.datetime.now()

adcValue = ADC.read("P9_35")
R = Ro/((1/adcValue) - 1) #Get measured resistance
T = 1.0/To + (1.0/Bvalue)*mt.log(R/Ro) #Formula from above blogspot address

t_k = 1.0/T #Temperature in Kelvin
print str(t_k) + 'K'
t_c = 1.0/T - 273.15 #Convert to celsius
print str(t_c) + 'C'
t_f = t_c*(9/5.0) + 32.0 #Convert to Fahrenheit
print str(t_f) + 'F'

f1.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(adcValue)+','+str(R)+','+str(t_k)+','+str(t_c)+','+str(t_f)+'\n');
except Exception as error2:
print 'Error ' + str(error2)
f2.write(str(now.month)+','+str(now.day)+','+str(now.hour)+','+str(now.minute)+','+str(now.second)+','+str(error2)+'\n');
time.sleep(1)

f1.close()
f2.close()
Loading