SD_Card_Control
updated on April 7th, 2018
new updated information is below.
SD Card Control (New)////////------------------- OLD INFORMATION ---------------------- ///////
Keywords: SD Card, 2GB, Micro SD, LCD, Logger, File system, G sensor, RTC
Control Program
Reference
Function
Evey one second, five analog inputs are logged in SD-Card.
If you can use RTC function, you will get folliwng functions.
1. Time stamp in the file
2. One second period with high acuuracy
3. File name creates by time stamp then you can save several files with no overwrite condition
If you can connect TEXT LCD, you can see the data on the screen.
If you set up COM line via USB, you can also see DEBUG information from PC screen.
Hardware Configlation
Please refer following links
------- Sensors ---------
G-sensor KX52-1050
Vref TL431
Temperature sensor LM60
------- Pin connection ------
Software
----- File name creation ------
seconds = time(NULL); seconds %= 100000000; // Adjust 8 charcters file name sprintf(buf,"/sd/%d.txt",seconds); // File name is defined based on time from 1970/1/1 FILE *fp = fopen(buf, "w"); // Open "out.txt" on the local file system for writing
RTC has time infromation based on Jan. 1st, 1970. "seconds" is a second data since at the time.
This time infromation is always unique number then if it uses as a file name, it doesn't need to consider conflicts.
The other hands, file name doesn't allow "Long File Name" on mbed current library.
So we need to keep 8 charcters for a file name then
seconds %= 100000000;
is very essential part to keep 8 characters.
Sample of logging data
This is a test program for logging /by JH1PJL Time:07:19:35 PM, 2010/04/03 G-Sen, 0.813187, 0.282784, 0.262271 VB, 0.310623, T, 0.350183 G-Sen, 0.814164, 0.284005, 0.264713 VB, 0.317216, T, 0.366789 G-Sen, 0.814652, 0.284005, 0.263980 VB, 0.317216, T, 0.367277 G-Sen, 0.814896, 0.282784, 0.260806 VB, 0.311844, T, 0.363126 G-Sen, 0.813919, 0.284005, 0.264957 VB, 0.317216, T, 0.367033 G-Sen, 0.812698, 0.283028, 0.261783 VB, 0.311600, T, 0.362393 G-Sen, 0.814164, 0.283028, 0.262515 VB, 0.311600, T, 0.361905 G-Sen, 0.814164, 0.284249, 0.264225 VB, 0.317460, T, 0.366545 G-Sen, 0.814408, 0.283761, 0.264713 VB, 0.313309, T, 0.364591 G-Sen, 0.812454, 0.283761, 0.264469 VB, 0.313309, T, 0.364103 Time:07:19:45 PM, 2010/04/03 G-Sen, 0.813919, 0.283761, 0.264713 VB, 0.313309, T, 0.364347 G-Sen, 0.814408, 0.282540, 0.264469 VB, 0.313553, T, 0.364835 (delted contents) G-Sen, 0.814408, 0.283028, 0.262515 VB, 0.311600, T, 0.369963 Time:07:21:05 PM, 2010/04/03 G-Sen, 0.812454, 0.283028, 0.262515 VB, 0.311355, T, 0.370208 G-Sen, 0.812698, 0.282784, 0.262515 VB, 0.311600, T, 0.370696 G-Sen, 0.812698, 0.283516, 0.264469 VB, 0.317216, T, 0.374603 G-Sen, 0.814164, 0.282784, 0.262271 VB, 0.311600, T, 0.370696 G-Sen, 0.814164, 0.284005, 0.264225 VB, 0.313553, T, 0.372405 G-Sen, 0.814164, 0.283761, 0.264469 VB, 0.317216, T, 0.376068 G-Sen, 0.814164, 0.284005, 0.264713 VB, 0.313065, T, 0.373626 G-Sen, 0.812698, 0.283761, 0.264469 VB, 0.317460, T, 0.377045 G-Sen, 0.814408, 0.283028, 0.262271 VB, 0.311844, T, 0.373138 G-Sen, 0.814164, 0.283028, 0.262271 VB, 0.311844, T, 0.372894 Time:07:21:15 PM, 2010/04/03 G-Sen, 0.814408, 0.284005, 0.263980 VB, 0.317460, T, 0.376557 Sampling numbers: 100
My Dirty Board
Picture2
Debug screen on PC com
Micro-SD card which I'm using for this project
Another solution for File sytem
If you don't want to set up SD-Card interface hardware, you can use 2MB mbed data strage which you can see from PC as USB memory.
Follwing is a sample program for this.
Other related program
If you will make above mentioned several interfaces, you can use follwing programs to check each function.
------- Text LCD ---------
I used 40 charcters x 2 line type.
Following declaration is an essential.
TextLCD lcd(p22, p28, p27, p26, p25, p24, p23, 40, 2); // rs,rw,e,d0,d1,d2,d3,40char's x 2 lines
------ RTC Adjustment -------
Connect to 3V battery separate with 3.3V regulated voltage line. You set up this battery backup circuit then you can use RTC function.
Future improvement items
- Time stamp for File itself
- File acceess from Host (using USB Interface or LAN)
Revistion
April 3rd, 2010 Create this page
April 4th, 2010 Modify explanation
0 comments
You need to log in to post a comment