Michael started looking at the MsTimer2 library to easily hook into the Timer2 so we can get a reliable interrupt for reading the pressure transducers. I put that into the app and did some testing with delays and Serial printing to verify that Timer2 really would interrupt loop, delays, and Serial. It looks good so far.
Here's a clip of code that sets up Timer2 to just print 'Reading Transducer.' and then a Serial call that should happen about the same time as the interrupt. I got lucky in the timing and feel like it proved itself.
void setup() {
Serial.begin(BAUD_RATE);
Serial.println("FTH-Arduino Booting...");
...
// Read the transducers @ 1kHz
MsTimer2::set(1000, readTransducer);
MsTimer2::start();
}
void loop() {
delay(4000);
Serial.println("Boo");
...
void readTransducer() {
Serial.println("Reading Transducer.");
}
Here's the serial output.
FTH-Arduino Booting...
Reading Transducer.
Reading Transducer.
Reading Transducer.
BoReading Transducer.
o
Reading Transducer.
I've still got the PIC code in Bit Bucket and may build something with the PIC in the future but for now I'm loving the Arduino. Here's the current breadboard.
No comments:
Post a Comment