Hi,
I’m working on a digital hobbs meter. The idea is to have a timestamp printed to a csv file on a SD card at startup then another on power loss. This needs to be 12v powered as it will go in an airplane to record flight time.
I’ve got a working prototype on the bench with the following code and schematic.
It’s using a teensy 3.6 since it has built in SD card and RTC. I’ve attached a coin cell battery to it to preserve the time.
A cheap ebayed 12v to 5v DC to DC converter is used to power the teensy. A resistor divider and Zener are hooked to the 12v to detect power off. A few caps are on the 5v line to provide power to the teensy while it writes out the last timestamp.
I’ve got a few questions to those in the know:
Thanks
Clayton
I’m working on a digital hobbs meter. The idea is to have a timestamp printed to a csv file on a SD card at startup then another on power loss. This needs to be 12v powered as it will go in an airplane to record flight time.
I’ve got a working prototype on the bench with the following code and schematic.
It’s using a teensy 3.6 since it has built in SD card and RTC. I’ve attached a coin cell battery to it to preserve the time.
A cheap ebayed 12v to 5v DC to DC converter is used to power the teensy. A resistor divider and Zener are hooked to the 12v to detect power off. A few caps are on the 5v line to provide power to the teensy while it writes out the last timestamp.
I’ve got a few questions to those in the know:
- Should I replace the resistor divider with a opt isolator?
- Is there a better solution to keep the teensy powered long enough, than the capacitors? The capacitors I used are just what I had on hand I plan to replace them with something closer to 5v.
- Lastly should I leave the SD card open between then first and last write?
Thanks
Clayton
Code:
#include <TimeLib.h>
#include <SD.h>
const int chipSelect = BUILTIN_SDCARD;
File dataFile;
int Sens_pin = 29;
void setup() {
pinMode(Sens_pin, INPUT);
//pinMode(Sens_pin, INPUT_PULLUP);
setSyncProvider(getTeensy3Time);
SD.begin(chipSelect);
recordTime(0);
attachInterrupt(Sens_pin, Sens, FALLING );
}
void loop() {
}
void recordTime(int last) {
dataFile = SD.open("logbook.csv", FILE_WRITE);
if(!last){
dataFile.println();
}else{
dataFile.print(",");
}
dataFile.print(year());
dataFile.print("-");
dataFile.print(month());
dataFile.print("-");
dataFile.print(day());
dataFile.print(" ");
dataFile.print(hour());
dataFile.print(":");
dataFile.print(minute());
dataFile.print(":");
dataFile.print(second());
dataFile.close();
}
time_t getTeensy3Time()
{
return Teensy3Clock.get();
}
void Sens(){
detachInterrupt(Sens_pin);
recordTime(1);
}