Mutiple sensor Logger to sd card HELPPPPPPPPPPPPPPP
Igor_Rast
Posts: 357
hi there , I am a fairly new to the propeller , got some electronic experiences but that aged away a little
Im working on a project to get multiple sensors logged to a excel format , so I can make a nice graph of it
now i have a problem
when I run the code like the one below :
PUB main |mount
cognew(getgeto,@stack)
mount := \sdfat.mount_explicit(DO, CLK, DI, CS)
if mount < 0
abort
sdfat.popen(string("test.csv"),"w")
repeat aa from 0 to 25
waarde1:=fp.floattostring(f.fmul(f.ffloat(waarde),co))
sdfat.pputs(waarde1)
sdfat.pputs(string(" ",13,10))
PUB getgeto
adc.start(24, 20, 21, 22, 23)
repeat
waarde :=adc.getdata(6)
I get a nice collum in ecxel , with 26 values of waarde1
this part is good
But i want to log multiple sensors, so
I wanna have something like
sdfat.pputs(waarde1,waarde2 ,waade 3 etc)
sdfat.pputs(string(" ",13,10))
but this does not work .
if I do sdfat.pputs(string("waarde1,waarde2",13,10))
than i wil make 2 collums like I want in the excel file , but than it would ste waarde1 in the collum not the valvue of waarde 1
the object i use for the sd card is :
fsrw 2.6 Copyright 2009 Tomas Rokicki and Jonathan Dummer
and I use a gangster gadget propeller usb platform
hope anyone can help me to get the multiple data logged into one excel file
Im working on a project to get multiple sensors logged to a excel format , so I can make a nice graph of it
now i have a problem
when I run the code like the one below :
PUB main |mount
cognew(getgeto,@stack)
mount := \sdfat.mount_explicit(DO, CLK, DI, CS)
if mount < 0
abort
sdfat.popen(string("test.csv"),"w")
repeat aa from 0 to 25
waarde1:=fp.floattostring(f.fmul(f.ffloat(waarde),co))
sdfat.pputs(waarde1)
sdfat.pputs(string(" ",13,10))
PUB getgeto
adc.start(24, 20, 21, 22, 23)
repeat
waarde :=adc.getdata(6)
I get a nice collum in ecxel , with 26 values of waarde1
this part is good
But i want to log multiple sensors, so
I wanna have something like
sdfat.pputs(waarde1,waarde2 ,waade 3 etc)
sdfat.pputs(string(" ",13,10))
but this does not work .
if I do sdfat.pputs(string("waarde1,waarde2",13,10))
than i wil make 2 collums like I want in the excel file , but than it would ste waarde1 in the collum not the valvue of waarde 1
the object i use for the sd card is :
fsrw 2.6 Copyright 2009 Tomas Rokicki and Jonathan Dummer
and I use a gangster gadget propeller usb platform
hope anyone can help me to get the multiple data logged into one excel file
Comments
In opposite convert value1, convert value2 ... convert last value and the write all won't work.
The fp.floattostring is using one buffer for it's conversion and returns the address of this buffer. If you call it twice, the first conversion result will be overwritten.
So, what you have to do:
waarde1 := fp.floattostring( .. value 1 .. )
sdfat.pputs( waarde1 )
sdfat.pputs( string( "," ) )
waarde1 := fp.floattostring( ... value 2 .. )
sdfat.pputs( waarde1 )
sdfat.pputs( string(",") )
just to give you the first quick and easy programming for better understanding.
Next step is use functions as described by Mike G:
WriteColumn( fp.floattostring( ... value1 ... ) )
WriteColumn( fp.floattostring( ... value2 ... ) )
...
WriteEndOfRecord( fp.floattostring( ... value last ... ) )
Ive just gave it a tweak and it works , makes my day
Need some more experience to see those thing
finally I can log the temp
Thankss
please help me to get it right
}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
MAX_DEVICES = 5
Do = 0
CLK = 1
DI = 2
CS = 3
OBJ
debug : "tv_text"
ow : "SpinOneWire"
f : "FloatMath"
fp : "FloatString"
sdfat :"fsrw"
VAR
long addrs[2 * MAX_DEVICES]
word waarde1
PUB start | i, numDevices, addr,mount
debug.start(12)
ow.start(10)
mount := \sdfat.mount_explicit(DO, CLK, DI, CS)
if mount < 0
abort
sdfat.popen(string("444444.csv"),"w")
repeat 10
numDevices := ow.search(ow#REQUIRE_CRC, MAX_DEVICES, @addrs)
debug.str(string($01, "-- Gringo's Datalogger --", 13, 13, "Devices:"))
repeat i from 0 to MAX_DEVICES-1
debug.out(13)
addr := @addrs + (i << 3)
readTemperature(addr)
sdfat.pputs(waarde1)
waitcnt(clkfreq +cnt )
sdfat.pputs(string(" "))
sdfat.pputs(string(" , "))
sdfat.pputs(string(" "))
sdfat.pputs(string(" ",13,10))
sdfat.pclose
sdfat.unmount
pub readTemperature(addr) | temp, degC, degF
'' Read the temperature from a DS18B20 sensor, and display it.
'' Blocks while the conversion is taking place.
ow.reset
ow.writeByte(ow#MATCH_ROM)
ow.writeAddress(addr)
ow.writeByte(ow#CONVERT_T)
' Wait for the conversion
repeat
waitcnt(clkfreq/100 + cnt)
if ow.readBits(1)
' Have a reading! Read it from the scratchpad.
ow.reset
ow.writeByte(ow#MATCH_ROM)
ow.writeAddress(addr)
ow.writeByte(ow#READ_SCRATCHPAD)
temp := ow.readBits(16)
' Convert from fixed point to floating point
degC := f.FDiv(f.FFloat(temp), 16.0)
' Convert celsius to fahrenheit
degF := f.FAdd(f.FMul(degC, 1.8), 32.0)
fp.SetPrecision(4)
debug.str(fp.FloatToString(degC))
debug.str(string("°C "))
waarde1:=fp.floattostring(degC)
return
hope someone can help
that's the main problem
In Excel create an example of what you expect. Then export to CSV. Open the exported file in a text editor and compare the export with the file created by the Prop. Update your code logic to match the file format.
Can you help me with the code so it get in 5 diferent collums,
probably the comma needs to be somewhere else, but I tryed everything, getting crazy abou it ;
Excel uses tabs as deliminators by default.
I usually use the .txt ending with my files that way Excel "imports" the file. You just need to make sure the check box next to "comma" is checked when in import it.
If you use open office, you can right click the file, select "open with" choose "OpenOffice.org Calc". OpenOffice uses commas by default.
You could also try using tab as your deliminator instead of a comma.
Change
sdfat.pputs(string(" , "))
to
sdfat.pputs(string(" ", 9," "))
Duane
im verry gratefull spend 3 nigts placing the comma everywhere without chekking the excel
thanks.