Example of reading data from a microSD with FSRW 2.6 PLEASE
Hello,
I've been searching for documentation over the internet, but I found nothing on "how to read data from a microSD with the propeller". I know how to write data with the FSRW object, but I can only read one character at a time.
Is there anyone who can enlight me on how to read entire strings of numbers (separated by space)?
Thanks in advance!
I've been searching for documentation over the internet, but I found nothing on "how to read data from a microSD with the propeller". I know how to write data with the FSRW object, but I can only read one character at a time.
Is there anyone who can enlight me on how to read entire strings of numbers (separated by space)?
Thanks in advance!
Comments
I would like to actually see an example (like a couple lines of code) on how this is done with the FSRW 2.6
I know that the following code would get you a character, but how can you extract strings of that?
There is enough to read files, but if you need to do more, eg string manipulaton, then Kye's code also has this as well, in a separate string object.
For reading strings of numbers with a space, it will help to know the data format. What does your data stream look like (including spaces, CR, LF etc)?
If spaces only are between the characters, we can use some extra string functions I added to Kye's code, eg "instr" to find the next space.
Thanks
I wrote the attached program to get a little experience reading lines of text from a file on the SD card (using FSRW). Note that I created a custom method called readln() as this is not part of the FSRW object.
I ran your MCP 3202 program and it works great! I was wondering if you have ever wrote anything that will take those values and write them to an SD card like the one that is used in the code above. All of the objects in the exchange use the PST as an output for either the SD card system or for the ADC, but none of them have any different programs for sending files to other slaves.
Once they are on the card it doesnt seem to be a problem dumping them.
Thanks,
Kyle
Kye, you are almost too good to be true!
Always so willing to help someone out.
And your coding skills are first class. :-)
No... but that doesn't stop me from putting on a pot of coffee and giving it a try. It turns out to be pretty easy: I simply copied the .dec() method from FDS and modified it to "print" to a string (passed by pointer) instead of to a serial stream.
I didn't want to be bothered connecting an MCP3202 so I wrote a method that provides two, randomized 12-bit values -- replace this with calls to the MCP3202. The output is to a CSV file and as you can see I was able to open it as desired in my spreadsheet, including text headers for each column.
This looks fantastic! I was thinking that using some king of shiftout or printout function was what I needed to do, but I just was not sure how to do it. I really appreciate the help, it is working great!
Cheers,
Kyle
I have connected everything and and I still seem to be having trouble. The PUB that I am calling in place of the lottery variable is read from your jm_MCP3202_ez program. In the beginning of the program I am also calling the jm_MCP3202_ez.init PUB block as is done your demo. The problem seems to be that the first value out is a good 12 bit number but the following values are much smaller. I am not sure if I am loosing bits during the transfer or what is happening. I am now wondering if I need to have a "0" terminator in this call for the pputs function or dec2str call to know where to terminate the number.
here is what I have so far:
PUB read_adc (pntr0) | ch0
'long [pntr0] := ?lottery & $FFF
long [pntr0] := ADC.read (ch0, ADC#SE)
My MCP320x code: http://obex.parallax.com/objects/625/
On another note, I've been using that readln() method in other programs and have modified it based on C source I found for a generic SD card driver. This is the new version (which terminates on LF instead of CR):
The issue was with the mux bit configuration as I am only using channel 0 on the ADC. I have looked at this readln method a bit and I think it could be useful for retrieving data from the SD card without having to remove it. As always, I appreciate the help!