Data logging to a microSD card

Jeremy Harris

Senior Member
In another thread here I mentioned using a 14M2 to acquire data and log it to a microSD card. To keep the other thread on-topic, I've started this thread to discuss the way I went about doing this. In simple terms, I used an OpenLog (see here: https://github.com/nseidle/OpenLog/wiki ) a cheap and simple way of using a microSD card as a data storage device, with simple serial commands to create files, read files, and write data to existing files.

There is more on this project in this finished project thread: http://www.picaxeforum.co.uk/showthread.php?20551-Environmental-uSD-card-data-logger and I'd be more than happy to share some of the things I did with that project here and help others use this technique for using microSD cards with any Picaxe chip.
 

John West

Senior Member
It is indeed helpful. I seem to spend far to much time researching code and circuits that aren't well developed or don't really have much to do with what I'm interested in. This is both well done and just what I'm interested in. Thank you.

I've met Nate. Talked to him a couple of times. Pretty nice guy.
 
Hello Jeremy, did you ever go back and get the USB stick VDRIVE2 working.....
did you find a simple fix....microCards are good, and well done on your work...interesting
picaxe to USB is a pathway that interests me....not right now but later
Regards
Ray
 

Jeremy Harris

Senior Member
No, I'm afraid I haven't had time to go back to it, as I wanted to get the logger installed and working whilst the weather's still cold.

I'm planning on having another look at it, when I get some free time, as overall I'd prefer the robustness of being able to log to a USB stick. The little microSD cards are a bit too flimsy for the sort of use this will be put to, and also slightly less convenient to get at, as it's not too easy to physically mount the OpenLog in a way where the card slot can be properly accessed from outside a case (at the moment I have to take the lid off the case to get at the card).

The bottom line was really that the OpenLog was very simple to drive from two serial lines, so simple that I reckon pretty much anyone could get it up and running with a Picaxe of any flavour very quickly (for example, I'm far from being a Picaxe expert, as this was only my second project, yet I had it up and running well inside an hour). The VDrive2 seems much harder to drive, although I'm sure that once I've cracked how to read, create, and append data to files it would do as good a job as the OpenLog.
 

GreenLeader

Senior Member
I'll second that - I bought the SDLogger, which is the same thing as OpenLog but for full size SD cards (I also did not like the microSD cards - was afraid I might lose them too easily in the field - or in my case in the boot of the car). Had it running very quickly - once I put in a decent SD card!!. Wish I'd known about these earlier!
I am busy modifying my existing 40X1 car datalogger, which currently writes 7 channels at 10Hz to 8xEEPROMS, to write to the SDLogger instead. The amount of time I spent writing code to put the data into those EEPROMs and get it out again later (via serial port) is just mind boggling. And its so complex (at least for a dodgy programmer like me) that it takes me forever to figure out what its doing if I want to change anything (so I just don't!). The SDLogger has made it sooooo much better - code is 1/4 of the size and no need to download to PC by serial - just pull the card! Not to mention that I can log almost indefinitely to a big (2GB+) SD card, compared to only 1 hour on the 8x256k EEPROMs.
 

Jeremy Harris

Senior Member
The SDLogger is a good find, I wish I'd seen that before I bought the OpenLog, as full size SD cards are a lot more robust. It looks as if the SD logger could be directly substituted for the OpenLog in my project, perhaps with the PCB adapted so that the SD card slot could be accessed from outside the case. AFAICS, the commands look to be the same so no changes to the code I used would be needed.
 

Jeremy Harris

Senior Member
I've spent a few hours this morning playing around with the VDrive2 module again, to see if I can get to the bottom of the problems I'd experienced with it when I started this project. What I've found is that it appears to have some problems with the non-hardware serial ports. If hooked up to a hardware port then it seems to work OK ('ish - it's still pretty quirky) but when hooked up to a standard serial port I was having great trouble in sending commands (although could apparently receive OK, as I could grab most of the start up power on message).

I've come to the conclusion that speed, or more probably timing accuracy, is an issue when trying to send data at the default 9600 baud via a software serial port (i.e. one that uses the serout command). After a bit of digging around I discovered the utility on the Vinculum website that allows the default baud rate etc to be changed on the VDrive2. The relevant information on changing the firmware (it's easy to do) is in the manual for the driver chip in the VDrive2, here: http://www.ftdichip.com/Firmware/Precompiled/UM_VinculumFirmware_V205.pdf The little utility programme from Vinculum that allows things like default baud rate and data entry mode to be changed can be downloaded from here: http://www.ftdichip.com/Support/Utilities/VncFwMod.zip You will also need to download the latest firmware file for the VDrive2, from here: http://www.ftdichip.com/Firmware/Precompiled/ftrfb_main_03_68VDAP.ftd

The procedure is to unzip the utility programme and run it (it doesn't install, it just runs). This then allows you to select an .FTD file (the new one you've downloaded from the last link) and make a copy, then change the values to those that you would prefer (nice and easy, just simple menu selections), finally saving the copy with a new file name. You then copy the newly saved .FTD file to a USB stick and rename it FTRFB.FTD. With the VDrive2 powered off, insert the USB stick and turn the power on and the new firmware will install, as described on page 9 of the firmware manual.

So far my (very limited!) testing shows that this works fine on a software serial port at 4800 baud, using a hack 08M2 running at the basic 4MHz. There are options for selecting handshake controls on the Vinculum utility that might be worth exploring, as the timing of responses from the module seems a bit haphazard.

All told it's still far from being an easy module to drive, unless you're using an X2 part with hardware serial ports and the ability to use the scratchpad to buffer data. Getting data in and out was just the first hurdle!
 
Top