VDrive

centrex

Senior Member
I am using a VDrive to log temperature data to a usb stick, no problems.
But, I want to be able to change the text file that is written to the VDrive to show the day that the data is written.
This the code that writes the file at the moment--
openfile1:
hserout 0,("opw Log.txt",CR)
pause 1000
gosub get_response
return

I want to be able to use a variable in place of the "log.txt" in the above, so that each day a new file is written with the day number as the text file name.
The device has a real time clock on board to get time and date.

Any thoughts would be welcome.
Regards
 

inglewoodpete

Senior Member
While I have never used the real time clock with a PICAXE, I imaging you would fetch the current date and/or day into byte registers (variables). That part has been discussed many times before on the foruum. The RTC uses BCD to encode numbers into 4-bit nibbles.

Having got the date into a number of byte variables, convert each 4-bit number to ASCII 0 to 9 by adding the nibble to "0" (zero), giving ascii "0" to "9".

Send the appropriate variables as part of the filename.

Eg. hserout 0,("opw ", b1, b5, "-", b6, b7, " Log.txt" ,CR)
 

centrex

Senior Member
Thanks for that.
Only one way to find out give it a try.
No problems reading the clock and storing the info to the usb stick, I just want to automatically change the file name.
So as I said I will give it a try.
 
Top