In my previous post [real_time_monitor] Real Time Player Monitoring System Post#2 : Playing with CC3200 for UDP communication ,I have discussed UDP communication between CC3200 and PC/Android Cell Phone..
As all real time data of accelerometer and other sensor will be stored in SD card for future analysis purpose.. This week I have completed some test on interfacing SD card with CC3200 Launch pad to write real time data...
Energia sketch for cc3200 used in this test is below...
/* copy the two files t_read.txt and t_write.txt from the example folder in the root of the sd card*/ /* Attribute : http://elm-chan.org for providing Petit FatFS library /* Modified By Ravi Butani to write accelerometer data on SD Card... As A part of Sudden Impact Design Challenge*/ /* Released Under CC-SA 2014 */ #include "SPI.h" #include "pfatfs.h" #include <Wire.h> #include <BMA222.h> #define cs_pin 18 // chip select pin #define read_buffer 128 // size (in bytes) of read buffer unsigned short int bw, br;//, i; char buffer[read_buffer]; char tosd_buf[15]; int rc; DIR dir; /* Directory object */ FILINFO fno; /* File information object */ BMA222 mySensor; void setup() { Serial.begin(9600); pinMode(PUSH2, INPUT_PULLUP); mySensor.begin(); uint8_t chipID = mySensor.chipID(); Serial.print("chipID: "); Serial.println(chipID); // initialize the serial terminal FatFs.begin(cs_pin); // initialize FatFS library calls } void die ( /* Stop with dying message */ int pff_err /* FatFs return value */ ) { Serial.println();Serial.print("Failed with rc=");Serial.print(pff_err,DEC); for (;;) ; } /*-----------------------------------------------------------------------*/ /* Program Main */ /*-----------------------------------------------------------------------*/ void loop() { Serial.println(); Serial.println("Press button to start..."); while(digitalRead(PUSH2)==1){} delay(100); while(digitalRead(PUSH2)==0){} Serial.println(); Serial.println("Open a file to write (t_write.txt)."); delay(100); rc = FatFs.open("T_WRITE.TXT"); if (rc) die(rc); Serial.println(); Serial.println("Write a text data. (10 x Hello world!)"); delay(100); bw=0; for (uint16_t i=0;i<1000;i++) { String tosd = String(mySensor.readXData())+","+ String(mySensor.readYData()) + ","+String(mySensor.readZData())+"\r\n"; tosd.toCharArray(tosd_buf, 15); rc = FatFs.write(tosd_buf, 15, &bw); if (rc || !bw) break; } if (rc) die(rc); rc = FatFs.write(0, 0, &bw); //Finalize write if (rc) die(rc); }
I have used Petit FatFs port for Stellaris which works just great with cc3200...
link of thread from which I have downloaded this library is http://forum.43oh.com/topic/3209-energia-library-petit-fatfs-sd-card-library/
Some limitation of this port is it cant create file on SD card... File needs to be initially created with required size using following command on cmd.exe run under admin privileges
fsutil file createnew t_write 1500
Pin mapping with with standard SD card and CC3200 is as below..
SD(SPI) CC3200
VSS1 GND
VSS2 GND
VDD VCC
DO MISO
DI MOSI
CLK SCLK
CS CS(18)
Here is Pin out os SD and microSD Card for quick reference...
(image : Reading an SD card with an ATMEGA168)
CC3200 LaunchPad Pin out for energia is below..
(image:http://energia.nu/wordpress/wp-content/uploads/2014/09/cc3200lppinmap.jpg)
chipchap connection between cc3200 and SDcard is as below..
After all this test, I have converted *.txt file, written by cc3200 Launchpad on SDCard to *.csv file and here is screen shot of the results.. As now all data in *.csv, format it can be used for create informative graphs...
This all about this week ... I have found this ADXL377 and ADXL345 free samples (By ADI) from my work place...
Mean while I receive parts as part of this challenge I am planning to interface this Accelerometers with CC3200 in next days..
Happy Holidays..
Ravi
Top Comments