Feed on
Posts
Comments

I received a comment by Steve asking if I was going to combine the SATL and SAVL together. It sounded like a good idea to me so I’ve gone ahead and done just that.

The schematic was updated with the voltage sensing circuit,  I added in a Mosfet so that we only draw power from the voltage source when needed and you’ll notice there are 2 jumpers – Temp and Volt. You can switch between logging temperature and voltage by completing the connection of the jumper and modifying a variable with button presses.

// Write to EEPROM
if (functionInuse == functionTemperature) {
  if (dataCount <= eepromMap[eepromMemsize]) {
    ...
  }
}
else {
  if (dataCount <= eepromMap[eepromMemsize] - 1) {
    ...
  }
}

I’ll spare you most of the modified code as it just has some if statements as above. There is a new variable called functionInuse which lets us choose between temperature or voltage logging.

// Button held down
if (buttonPressed == 1) {
  setup_watchdog(T2S);
  system_sleep();
  if (buttonPressed != 1) { // If button is released after 3 seconds, change delay time
    ...
  }
  else { // Change between temperature or voltage logging
    cbi(GIMSK,PCIE);
    functionSelect = CONFIGFUNCTION;
    functionInuse = -1;
    blinkLed(1, T4S, SKIPLEDOFFDELAY);
    sbi(GIMSK,PCIE);
  }
}

We modify functionInuse by holding down the button for 5 seconds.

Allow 1 or 2 bytes logging

Since we’re already doing 1 byte temperature logging and 2 bytes voltage logging, why not allow both options for temperature and voltage?

#define functionTemperature 0
#define function2Bytetemperature 1
#define functionVoltage 2
#define function2Bytevoltage 3
int functionInuse = -1;

Our functionInuse variable has now been updated to handle 1/2 bytes temperature or voltage logging.

2 byte temperature logging

As we did last week, we can calculate the formula which we need to use, 1024 bit / 165 temperature range gives us 6.206 then we do -40C x 6.206 gives us our value to minus as 248. The formula is temperature = (value – 249) / 6.206.

1 byte voltage logging

With voltage logging our maximum voltage is 15V which is a value of 517. All we need to do is divide 517 by 254 for a 1 byte value which gives 2.035. The formula is voltage = (((value – 1) * 2.035) * 0.001074) * 27.

Download

You can download the SATVL_v1.0_Source which should be used once the v1.0 PCB is released. At the moment the program size is up to 8028 bytes which is very close to the ATtiny85 program size limit!

Leave a Reply