Updated: The '462 Image is a 328 Flattened running at 8MHz @5V. The decoupling cap is soldered to the bottom and the chip is driving a 2x16 parallel LCD... only the pot for the contrast and the reset button are required additions! I've done the same with the Nokia display which does not use the potentiometer and the reset is kinda optional... So just the 328P-PU and the bypass cap... I think I have hit rock-bottom in minimalist part usage. The software running is Magic Morse and the circuit works flawlessly from 5WPM to 40WPM.
Any chance you could post larger copies of those 2nd and 3rd images?
Certainly!
OP's system is not exactly twiddling its thumbs, by the sounds of things.
I personally would have wrote interrupt-driven UART logger what you can do is in your main loop check if a buffer reaches a certain threshold and if so
Ray says,
"It's Open Source..." It's a dedicated $2 chip... Interrupts (in user code) are really not needed to service the serial stream (at least not in my testing at 9600 BAUD.) I did not measure uC processor bandwidth, but I did throw my 9600 BAUD 'Quick Brown Fox' generator at it and did not lose any characters in the incoming stream. I built this as part of an experimental plane (Europa) engine monitoring system... the pictures are of the prototype. My friend and plane owner builds his own circuit boards so I don't waste my time anymore, but I did start using stripboard because my friend always keep my solderless breadboards (someday, they will return...)
The code may make more sense if you realize that the Mega2560 main Arduino logs output to this logger every 10 seconds (OLEDs refresh rate). The messages are diagnostic in nature but also have all of the OLED values from the engine sensors. Therefore, it was desired to always update physically to the SD with each message. Hence the reason that the buffer is checked for being full or CR:
if (c == '\r' || (bufferidx >= BUFFSIZE-1)) {
The bulk of the setup ugliness is due to managing the insertion state of the SD card and using the colored LEDs to make some sense of the states. If you do not like blinky lights, perform surgery. XD
Ray
/*
Datalogger by M. Ray Burnette
Designed for use in Europa Mega2560 airplane engine monitor system
Target Atmel328P-PU @16MHz (3.3V so slightly out of spec.)
Binary sketch size: 13,838 bytes (of a 30,720 byte maximum)
Tested with Arduino 1.0.1
*/
#include <SD.h>
#define Red 6
#define Blue 8
#define Green 7
#define BUFFSIZE 512
#define chipSelect 10
char buffer[BUFFSIZE];
char c;
File logfile;
int bufferidx;
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void setup() {
// setup-ports for LEDS and each for 1/2 second and sync to all OFF
pinMode( Green, OUTPUT); digitalWrite(Green, LOW); delay(500); digitalWrite(Green, HIGH);
pinMode( Blue, OUTPUT); digitalWrite(Blue, LOW); delay(500); digitalWrite(Blue, HIGH);
pinMode( Red, OUTPUT); digitalWrite(Red, LOW); delay(500); digitalWrite(Red, HIGH);
pinMode(10, OUTPUT); // standard convention required for SD library
Serial.begin(9600); // Use pins 3 Tx and 2 Rx
delay(100);
Serial.print(F("Serial init at 9600 BAUD\r\n"));
Serial.print(F("(c) 2013 SofKinetics: Serial Data Logger\n\r"));
if (!SD.begin(chipSelect)) {
Serial.println(F("Card initialization failed!"));
int i = millis() + 5000; // 5 seconds
Serial.println(F("Insert card or reseat card now. Reset pending..."));
do {
digitalWrite(Red, LOW); delay(250); digitalWrite(Red, HIGH); delay(250);
} while( i > millis() );
Serial.println("Reset!");
delay(250);
resetFunc();
}
logfile = SD.open("europa.txt", O_CREAT | O_WRITE | O_APPEND);
if( ! logfile ) {
int i = millis() + 5000; // 5 seconds
Serial.print(F("Could not open logfile \n\r"));
do {
digitalWrite(Red, LOW);
delay(250);
digitalWrite(Red, HIGH);
delay(250);
} while( i > millis() );
Serial.println(F("Card write failed! Halted..."));
do; while(true); // halt
}
else {
Serial.println(F("Writing to: europa.txt"));
Serial.println(F("Ready to accept serial data..."));
}
while (Serial.read() >= 0) {}
}
void loop() {
digitalWrite(Blue, HIGH);
digitalWrite(Green, HIGH);
// read into program buffer, increment index
if (Serial.available()) {
digitalWrite(Green, LOW);
c = Serial.read();
buffer[bufferidx++] = c; // Store character in array and increment index
// CR record termination or buffer full? (CR+LF is common, so don't check both)
if (c == '\r' || (bufferidx >= BUFFSIZE-1))
{
buffer[bufferidx] = 0; // NULL
digitalWrite(Green, HIGH);
digitalWrite(Blue, LOW);
//write the program buffer to SD lib backend buffer
logfile.write((uint8_t *) buffer, (bufferidx + 1));
logfile.flush();
bufferidx = 0; // reset buffer pointer
}
}
}