Propeller Chip and DataloggerSPI
-GRIMM-
Posts: 56
For a quick background, I know my way around with the BS2, but needed something with more speed for this current projects, so I decided to go with the Propeller chip. The spin language is new to me, so this might be easy for you guys.
I am using the propeller chip to read a value from a few sensors (already got that part working).
The problem arises when I try to use dataloggerSPI with the parallax memory stick datalogger. I have no problem writing a string to the USB drive, but the value I need to write is a number (a byte).
The program I have checks for the directory, deletes it if present and recreates it (from the test code), opens it, writes a file header to it, then goes in to the data loop.
The data loop reads the sensor (coming from an ADC0831 so I believe it may be binary in form), opens the file, writes the value, closes the file.
When i open the file all I see is a bunch of random characters.
Can anyone show me how to write a byte value using dataloggerSPI, or possibly convert it to numerical and save it with CR's between each value?
The code i am using right now is:
logger.openFileForWrite(string("Data.txt"),0)
logger.writeToFile(byte[lm34temp], 8 ,0)
logger.closeFile(string("Data.txt"))
i've tried writeToFile(@lm34temp, 4,0), as well as a few others.
Thanks
-Steven
I am using the propeller chip to read a value from a few sensors (already got that part working).
The problem arises when I try to use dataloggerSPI with the parallax memory stick datalogger. I have no problem writing a string to the USB drive, but the value I need to write is a number (a byte).
The program I have checks for the directory, deletes it if present and recreates it (from the test code), opens it, writes a file header to it, then goes in to the data loop.
The data loop reads the sensor (coming from an ADC0831 so I believe it may be binary in form), opens the file, writes the value, closes the file.
When i open the file all I see is a bunch of random characters.
Can anyone show me how to write a byte value using dataloggerSPI, or possibly convert it to numerical and save it with CR's between each value?
The code i am using right now is:
logger.openFileForWrite(string("Data.txt"),0)
logger.writeToFile(byte[lm34temp], 8 ,0)
logger.closeFile(string("Data.txt"))
i've tried writeToFile(@lm34temp, 4,0), as well as a few others.
Thanks
-Steven
Comments
To use this, you'd do:
Finally recording correct, legible data!
What a relief. Any insight on writing a carriage return after each value? right now they are all in a line.
I have tried multiple things, none of these worked;
VAR
· word CRLF
CRLF = $0A0D
logger.writeToFile(@CRLF,2,0)
logger.writeToFile(10,1,0)
logger.writeToFile(13,1,0)
logger.writeToFile(string(" \r\n").....)
etc.
thanks!
I have a program to test the output, and am getting '21' as my value.
When i save this to the USB drive it saved all the numbers as '8'
Any idea why it might do this?
Thanks
This is the code im using right now, after creating the folder and file...
I have the
PUB dec(value, address) | i
routine at the bottom of the program
To write a carriage return / line feed (needed for Windows), do: logger.writeToFile(string(13,10), 2, 0)
If you want just a carriage return (like for MacOS), leave out the ", 10" and change the ", 2" to ", 1"
Thank you! finally have a carriage return.
I tested the sensor, current output is 65.
I run the program and this is what is saved to the flash drive.
Datalog Test
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
... etc
any ideas?
thanks
-Steven
Took out the byte[] and now it saves the temperature value the test program is outputting.
Thank you!
Just to verify, the dec() can record any number of digits?
Now all i have to do is find a way to record the time value. Can anyone point me in the right direction?
Thank you all
You can obviously append to the buffer provided you make it bigger and pass the correct address to subsequent conversion calls.
Any hints on outputting time steps?
Thank you!
-Steven
and since _xinfreq = 6_250_000 i an just taking the change between current and last and dividing by 6,250,000
dec(cnt,@buffer3)
the cnt im getting back is about 8,500,000 (coordinating to about 1.3 seconds) different than the one before it. But i can see the LED blinking about 10 times per second.
I have it change the state of a pin connected to the LED every time it finishes the loop.
on/off = 2 data points.
What frequency does cnt operate at?
thanks
_clkmode = xtal1 + pll16x
is that still 100MHz?
Thanks, everything is coming together!
Where can I read up on the PCB care?
Thanks
-Steven
I have yet another question though:
With your help, I got the previous code working for an ADC0831 and LM34 temp sensor.
But when i take the code from the LISY300 gyro test program (used it to make sure the circuit is working, checks out) the values from the gyroscope all save as a 0 or 8191.
Everything up to this point in the code works:
But this is where it goes bad.
Data saved looks like this:
0, -876833898
0, -862191530
0, -847551098
8191, -832909450
8191, -817573610
0, -802933178
0, -788292554
0, -773128138
Thanks again!
-Steven
There is the problem. Forgot to add:
dira[SCLK..nCS]~~
to the code!
thank you again! Looks like everything is in business now. Time for field testing!
Thanks
-Steven