temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Thu May 03, 2012 6:24 pm |
|
|
code snippets..
variables used..
Code: |
//flash drive data bytes
char zro=00; //#of bytes to store(long 00 00 00 nn)
char alf=0x0a; //a line feed
char acr=0x0d; //a carriage return
//default date,date,temp
char str_yer[3]="12";
char str_mth[3]="34";
char str_day[3]="56";
char str_hrs[3]="12";
char str_min[3]="34";
char str_sec[3]="56";
char str_t1[6]="-999";
char str_t2[6]="+999";
char str_s1[3]="JM";
|
function to save data to file already opened on flashdrive
Code: |
void usbfd_save_data(){
fprintf(usbfd,"WRF %C%C%C%C\r%C%C,%C%C,%C%C,%C%C,%C%C,%C%C,%C%C%C%C,%C%C%C%C,%C,%C%C%C\r",zro,zro,zro,0x21
,str_yer[0],str_yer[1]
,str_mth[0],str_mth[1]
,str_day[0],str_day[1]
,str_hrs[0],str_hrs[1]
,str_min[0],str_min[1]
,str_sec[0],str_sec[1]
,str_t1[0],str_t1[1],str_t1[2],str_t1[3]
,str_t2[0],str_t2[1],str_t2[2],str_t2[3]
,str_s1[0],str_s1[1]
,acr,alf
);
}
|
This function dumps data as a 'CSV' format allowing easy importing on a PC into say Excel or other program.
usbfd refers to the serial port connected to the flashdrive,all data are strings.The time info comes from a DS1307.str_t1[] and str_t2[] are the data from 2 I2C temp sensors,s1[] is data from 16 binary sensors.
The 'trick' is to code your data for CSV format.Yes it takes some thought, but once configured it's easy to add/delete data to the records stored onto the drive.
I currently run the V2DIP2 at 115K200 without handshaking and haven't had any bad data in almost a year of collecting remote temperatures from a solar collector system. |
|