View WyoLum Emergents in a larger map
Category Archives: Development
I2SD library
This library has a single class call I2SD with simple interface (see below). A call to Wire.begin() must be made before any of these calls. See Hello World to see a simple example of the library in use.
/* Transmit n_byte bytes of data to I2SD card. * return true if identical bytes are returned from I2SD card */ boolean ping(uint8_t* ping_data, uint8_t n_byte); /* Move file cursor to addr bytes from the beginning of the file */ void seek(unsigned long addr); /* Open a file with the specified name and mode * May induce I2SD_OPEN_ERROR on I2SD card */ void open(char* filename, uint8_t mode); /* Read n_byte bytes of the current file. * File must be open for reading */ uint8_t read(uint8_t *data, uint8_t n_byte); /* Write n_byte bytes of data to current file * File must be open for writing * May induce I2SD_MODE_ERROR on I2SD card */ void write(uint8_t *data, uint8_t n_byte); /* Clear any error on I2SD card. * May induce I2SD_MODE_ERROR on I2SD card */ void clear_error();
**************************************************************************************************************
Oops: ATTN Vic and Florin!
While writing this I realized I left a bug in the inital version of the code. The I2SD will show an error if the file “DEFAULT.TXT” is not present on the SD card. So add that file to the root. It does not have to have any bytes. It just provides a default file pointer. This will be taken care of in the next version, or you can delete the offending lines and re-load the script.
**************************************************************************************************************
I2SD Hello World!
So WyoLum is working on the I2SD. This is a SD card interface that sits on the I2C bus, also known as the Two Wire Interface or TWI. We created the board so that we could add an SD card to ClockTHREE and ClockTHREEjr . But while we were at it, we made this board as useful as we could so that it can be used in several applications.
Features:
- Can be used as a stand alone data logger.
- Arduino Shield adding real time clock and SD to any Arduino. This saves 8KB of program memory over just using the SD library.
- Chronodot compatible! This means you can add an SD card to any project that already has a ChronoDot slot.
- Integrated Real time clock.
- Two LEDs, no WyoLum project is complete without LEDs.
Hello World
Required Parts
- Arduino
- I2SD
Steps
- Write a long file to the SD card called “TEST.TXT” For example this one.
- Connect I2SD to the Arduino.
- Upload code below to the Arduino.
- Monitor the serial port on the Arduino.
If everything goes right, the file on the SD card should stream through the serial port on the Arduino. If an error occurs, an “error code” will flash on the I2SD. This is all pretty new, so you may encounter unforeseen situations. If so, just let me know and I will address them as soon as I can.
The Code
/* Read and write some data to the I2SD */ #include "C3SB.h" #include "I2SD.h" #include "SD.h" #include "Wire.h" const boolean WRITE_TEST = true; const int DBG = 13; I2SD i2sd; void setup(){ uint8_t msg_back[100]; unsigned long n_byte; Serial.begin(57600); Wire.begin(); // DON'T FORGET THIS!!!! // wait for I2SD hardware to start up Serial.println("PING..."); while(!i2sd.ping((uint8_t*)"PING", 4)){ delay(100); } Serial.println("PONG received"); i2sd.open("TEST.TXT", FILE_READ); } void loop(){ const int n_byte = 32 * 7; char big_data[n_byte]; i2sd.read((uint8_t*)big_data, n_byte); Serial.print(big_data); }
German Jr — ClockTHREEJr in German!
Announcement: I2SD, A disk drive for Arduino
WyoLum is proud to announce I2SD which provides disk drive storage to your Arduino based project.
I2SD is an I2C interface for an SD card compatible with ClockTHREE and ClockTHREEjr. The idea behind I2SD is to allow easy read/write access to files stored on an SD card. If the I2C bus is already part of a circuit, I2SD does not require any extra pins, therefore optimizing pin usage on the micro.
Thanks to AdaFruit and SparkFun for sharing there SD designs!
Why I2SD? Good question! After all there are a few boards that allow you to connect an SD card to your project: AdaFruit’s data logging shield, and SparkFun’s MicroSD shield are two stand outs in this category.
There are three reasons you should consider I2SD:
- ATMEGA328 memory limitations.
- ATMEGA328 pin count.
- You want a small form factor stand alone data logger.
On ClockTHREE we are both pin count and memory limited and we wanted to be able to store lots of cool animations. We designed for the stand alone data logger as a target of opportunity.
The next rev will sport optional locations for an RTC chip and battery back up.
Details
Components:
- ATMEGA328
- SD card
- 2 LEDs
- ChronoDot or DS3231 (optional)
Interfaces:
- 6-pin ISP
- FTDI
- 2x C3SB (see below)
- Buckler (see below)
Using I2SD from an Arduino Master (Buckler interface see below)
Currently there are five methods implemented for simple file reading and writing.
ping(uint8_t* ping_data, uint8_t n_byte); seek(unsigned long addr); open(char* filename, uint8_t mode); read(uint8_t *data, uint8_t n_byte); write(uint8_t *data, uint8_t n_byte);
Which can be used to read and write a small file: //Write a file i2sd.open("NEW_FILE.TXT", FILE_WRITE); char* msg="Hello from I2SD_Client.pde. " "Please note this is longer than 32 chararters."; i2sd.write((uint8_t*)msg, strlen(msg) + 1); //Read it back i2sd.open("NEW_FILE.TXT", FILE_READ); uint8_t msg_back[100]; unsigned long n_byte = i2sd.read(msg_back, 100); msg_back[n_byte] = NULL; Serial.println((char*)msg_back); write(uint8_t *data, uint8_t n_byte);
C3SB (preview)
This is the first peripheral to implement the ClockTHREE Serial Bus interface which deserves a post of its own (coming). Its like USB for Arduino which allows the connection of many peripherals without increasing pin usage. C3SB is build on I2C
C3SB physical interface, 4 pins with 0.1″ spacing:
- VCC — 5V min 100mA
- SCL — I2C Clock pin
- SDA — I2C Data pin
- GND — +0V
C3SB software Master interface:
I2C transfers are limited to 32 bytes. The C3SB allows up to 255 bytes by breaking them up to 32-byte I2C packets for you. Two read/write functions.
uint8_t read_from(uint8_t device_id, uint8_t* dest, uint8_t n_byte); boolean write_to(uint8_t device_id, uint8_t *payload, uint8_t n_byte);
Buckler form factor (preview)
A “buckler” is a small shield, 15 to 45 cm (6 in to 18 in) in diameter , gripped in the fist (From Wikipedia). I2SD is a small shield so we thought this was a clever name for this form factor.