Search This Blog

Tuesday, October 21, 2014

Mechatronics Project 3

Project 3 was about making a datalogger and voltmeter using the arduino pro-mini. In mode-1, the arduino had to log to an SD card a sampled sine wave from a signal generator and samples from a three-axis compass. A program also had to be written to read the SD card file and plot the data. In mode 2, an analog voltage had to be sampled and displayed on the serial terminal. We got to use arduiono IDE for this one because of the lack of a good SD card library for atmel studio.

Here are pics of my setup:

Compass is lower left. It needed a 3.3V power supply, which is the voltage regulator on the lower breadboard.


The compass was from jaycon and is based on the HMC5883L chip. It communicated over I2C. There's an arduino library for it, but it's buggy. No attempt was made to calibrate or scale it correctly. The SD card board is a basic one from sparkfun that has on-board regulators so you can give it 5V (SD cards need 3.3V). The arduino 10bit ADC was used for both the signal reading and the voltmeter. Data loging timing was done with the arduino's timer 1 operating in CTC interrupt mode. The interrupt would trigger an interrupt service routine that would trigger a flag that would run the data reading and writing loop. Doing any kind of serial communication (writing to terminal, reading I2C compass, writing to SD card over SPI, etc.) inside the ISR would crash the program because serial communication is interrupt driven. It worked because we weren't sampling very fast (40Hz). High sample rates probably would have required some other way of doing it. I wrote a simple MATLAB script for plotting the data from the SD card. I had to add an outlier removal scheme because the compass would randomly have huge outliers.

Again, like with all of these projects, I can't post the code until the professor changes the projects.

Helpful resources:
http://www.instructables.com/id/Arduino-Timer-Interrupts/step2/Structuring-Timer-Interrupts/
http://letsmakerobots.com/content/arduino-101-timers-and-interrupts
http://www.gammon.com.au/forum/?id=11488
http://forum.arduino.cc/index.php/topic,115338.0.html
compass, arduino datasheets
arduino SD card library documentation

No comments:

Post a Comment