The VDrive2 datalogger is a self-contained unit that allows a PICAXE to read and write data placed on USB memory sticks.
More details...
VDrive2 USB Stick Datalogger
Schematic
![](_/thumbnailcb0a.jpg)
PCB
![](_/thumbnail08c9.jpg)
Write to the datalogger
This program will add an incrementing data value to a log file on an USB memory stick attached to the VDrive2 datalogger.
- Code Example:
-
symbol loopcounter = b1 symbol point = b2 symbol first_byte = b3 symbol temp = b4 init: pause 500 ; allow 500ms to wake-up main: ; create a log file called 'log' (for some reason 'log.txt' didn't work) sertxd ("<Sent> Open file",CR,LF) hserout 0,("opw log",CR) gosub get_response sertxd ("<Sent> write to file",CR,LF) bintoascii loopcounter,b5,b6,b7 ; convert loopcounter byte to 3 ascii digits ; and write 8 bytes loop_xyz hserout 0,("wrf ",$00,$00,$00,$08,CR,"loop_",b5,b6,b7,CR) gosub get_response sertxd ("<Sent> Close file",CR,LF) hserout 0,("clf log",CR) gosub get_response inc loopcounter ; increment counter goto main ; repeat ; Sub procedure to receive background bytes get_response: pause 1000 ; wait a while sertxd ("<Response> ") point = 0 ; reset local pointer get point,first_byte ; Save the first reply byte do get point,temp ; get returned byte sertxd (temp) ; transmit it inc point ; increment pointer loop while temp <> CR ; if not CR loop sertxd (LF) ; Add a LF to the received CR sertxd (CR,LF) ; Do another blank line hserptr = 0 ; reset the background receive pointer return
Copy Code Submit an Example
VDrive2 Commands
The following is a list of all commands which can be used with the VDrive2
- Code Example:
-
Device Information Commands ; Firmware version serout pin, t9600, ( "FWV", CR ) ; Display information about the disk if disk is less than 4GB serout pin, t9600, ( "IDD", CR ) ; Display information about the disk serout pin, t9600, ( "IDDE", CR ) ; Display information about the disk serout pin, t9600, ( "IDD", CR ) ; Display disk serial number serout pin, t9600, ( "DSN", CR ) ; Display disk volume label serout pin, t9600, ( "DVL", CR ) ; Returns the free space available on disk if less than 4GB is free serout pin, t9600, ( "FS", CR ) ; Returns the free space available on disk serout pin, t9600, ( "FSE", CR ) Directory Control Commands ; List directory serout pin, t9600, ( "DIR" , CR ) ; List specified file and size serout pin, t9600, ( "DIR", " ", "filename.ext", CR ) ; List specified file and date and time of create, modify and file access serout pin, t9600, ( "DIRT", " ", "filename.ext", CR ) ; Change current directory serout pin, t9600, ( "CD", " ", "filename.ext", CR ) ; Move up one directory level serout pin, t9600, ( "CD", " ", " ..", CR ) ; Make a new subdirectory in the current directory serout pin, t9600, ( "MKD", " ", "filename.ext", CR ) ; Delete subdirectory from current directory serout pin, t9600, ( "DLD", " ", "filename.ext", CR ) ; Delete a file serout pin, t9600, ( "DLF", " ", "filename.ext", CR ) ; Rename a file or directory serout pin, t9600, ( "REN", " ", "filename.ext", " ", "filename.ext", CR ) File Handling ; Reads a whole file serout pin, t9600, ( "RD", " ", "filename.ext", CR ) ; Open a file for writing or create a new file serout pin, t9600, ( "OPW", " ", "filename.ext", CR ) ; Open a file for reading serout pin, t9600, ( "OPR", " ", "filename.ext", CR ) ; Write the number of bytes specified to the currently open file serout pin, t9600, ( "WRF", " ", msb, lsb, CR, "data" ) ; Read the number of bytes specified from the currently open file serout pin, t9600, ( "RDF", " ", msb, lsb, CR ) ; Close the currently open file serout pin, t9600, ( "CLF", " ", "filename.ext", CR ) ; Seek to the byte position in the currently open file serout pin, t9600, ( "SEK", " ", msb, lsb, CR )
Copy Code Submit an Example
Create Module
![](../../../thumbnail48bc.jpg)
A VDrive2 module may be connected to the generic terminal block create module.
Bill of Materials
Description | Code | Qty | |
---|---|---|---|
VDrive2 USB module | USB031 | 1 | Buy Now |
4-way 0.1" header | CON036 | 2 | Buy Now |
Simulation
Submit Your Own Code!
You must be logged in to submit code examples. Login now.
Share