Saturday, 7 July 2012

The SD Card


The next task is to interface a microSD with Arduino and play music files. The first thing to know about SD card is its pinout. 

SD CARD PINOUT
Te various pins are:
CS:         Chip Select
MOSI:   Master Out Slave In
GND:     Ground
VDD:      Supply pins
SCK:       Serial Clock
MISO:    Master In Slave Out
NC:          No Connect
IRQ:        Reserved

The SD card communicates using SPI mode of communication. Beginners dont have to worry about it much as the Arduino IDE provides a header file<SD.h> for the communication. All you need to know is the basic commands and the rest is IDE's job.

HARDWARE
For basic purposes , i don't think there is much of hardware required. All you need to do is connect MISO, MOSI, SCK and CS pins of SD to the respective pins of arduino. On arduino UNO we have: 
SCK:        pin 13
MISO:     pin 12
MOSI:     pin 11
CS:            pin 10
Also note that SD card works on 3.3V and Arduino on 5V, So we need to use an appropriate voltage divider circuit.The connection diagram is :


I had my own arduino shield with connections already made.
For playing music, we will need other cicuitary about which we'll discuss later.

SOFTWARE
I started with making .txt files and reading the ones already on it. I think <SD.h> is a very a nice library to help beginners read and write data to SD card. The SD library , by default creates an object called "SD". The various functions for this object are:
  1. begin()
  2. exists()
  3. mkdir()
  4. open()
  5. rmdir()
  6. remove()
These are a set of basic operations on SD card.
The various file operations are...
  1. available()
  2. flush()
  3. close()
  4. peek()
  5. print()
  6. pritln()
  7. seek()
  8. size()
  9. read()
  10. write()
  11. isDirectory()
  12. rewindDirectory()
The exact syntax of these functions is available on arduino playground
There are many test functions which give clear insight of how to play with SD Card.....

Saturday, 9 June 2012

Analog Clock and Thermometer on an Oscilloscope

This was our first major project at CEDT, NSIT. Using Arduino and two DACs, we had to generate an analog clock and thermometer on an oscilloscope in x-y mode. We started on 31st may, the day our 4th sem exams finished. Though Initially, it seemed quite tough. But it isn't that tough.



First of all our aim was to develop a shield with two DAC and a thermistor. We made it on 1st june. Then we started developing code for the project. We ,at first, tested the working of the DAC. It was working perfectly fine except the one or two minor flaws in it. Then made a sine and a cos wave. It was good but not fantastic. In xy mode, it presented a circle.


They weren't that bad. Because we were first to make it. The feeling was awesome. We have made something useful. The error was due to frequency considerations. The program was quite slow. It required further optimization. The solution was to write the code in AVR . The frequency of operation improved.  Next we moved on to drawing lines, we made a function which takes the angle in degrees and draws a line.
It was successfully implemented. We could now make most of the shapes on the Oscilloscope.

The next major thing was to implement the RTC. We couldn't use the delay function of the program as this would stop the rest of the program too. We didn't want that. So ,we had to use AVR timer interrupts. Luckily we got much of the help needed from the internet and were able to use the Timer of ATMega 168.

Now,we are almost done with our project. The video of our project is on youtube: http://goo.gl/HglPx