Feed on
Posts
Comments

Monthly Archive for May, 2011

Today I’ll be showing how we can integrate the Standalone Temperature Logger (SATL) into the V-USB Test program we have. It’s taken me a little while to find my way around V-USB and its kinks.

Schematic

The schematic has been updated to include the USB port. Another change is that when the LED turns on it also turns on the thermistor, before we used to do this with the dataPin.

Cleaning up the V-USB code

The first thing I’ve done is copy over our setup.c file from the SATL WinAVR to our project and then move everything related to V-USB setup or procedures (except the sending of keys) to our setup.c file which now leaves us with just two functions in main.c (evaluateADC and main).

Next I would like to cut down on the main’s USB setup code, lets make a new function called startUSB() and place all the code below in it.

(more…)

Read Full Post »

In this demo we show how we can change the ATtiny85 clock speed on the fly by modifying the prescaler. We note that using _delay_ms() is subject to the F_CPU and if we double the MHz we need to double _delay_ms() in order for the timing to be correct. Changing the clock speed on the fly may be useful for power saving applications where there might be brief moments to increase the clock speed, e.g. communicating with devices like USB.

Download the code: ATtiny85_CPU_Speed_v1.0

Read Full Post »

Today we’ll be modifying the ATtiny85_Blink WinAVR example to convert the Standalone Temperature Logger from using the Arduino software to WinAVR so that we can easily integrate it in with V-USB. Download here: Standalone_Temperature_Logger_v2.0_Beta_1

Changes to setup.c

Let’s begin with the setup.c file, to make things easier we will put all of our commonly used functions in this file too.

// Used from http://www.arduino.cc/playground/ComponentLib/Thermistor2
double Thermistor(int RawADC) {
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15; // Convert Kelvin to Celcius
  return Temp;
}

First we put in the Thermistor function without any changes made.

// Used from http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/
void system_sleep(void) {
  DDRB &= ~((1<<ledPin) | (1<<dataPin)); // Set outputs to inputs to save some power
  cbi(ADCSRA,ADEN); // Switch Analog to Digital converter OFF
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Set sleep mode
  sleep_mode(); // System sleeps here
  sbi(ADCSRA,ADEN);  // Switch Analog to Digital converter ON
  DDRB |= ((1<<ledPin) | (1<<dataPin)); // Set those outputs back to outputs
}

Next we insert the system_sleep function, other than the switching between outputs and inputs which is done using DDRB. Notice that we have referenced ledPin and dataPin, we will define those ports in the main.c file.

(more…)

Read Full Post »

Playing around with V-USB for AVR

Today I’ll be showing you one of the example projects of V-USB called EasyLogger, it’s basically a project using the ATtiny45 that logs a voltage and writes the value to your computer via USB. I choose EasyLogger because it’s very similar to the sort of things I’ll be using, i.e an ATtiny85 and no external crystal.

We’ll start off by downloading the latest version of EasyLogger and then viewing the schematic for it.

It looks pretty simple but to make it even simpler we’ll actually be ignoring the LED, button and input voltage so it’s just the USB connection and nothing else.

(more…)

Read Full Post »

ISP to Breadboard Connector

So I’ve finally gotten myself a USBtinyISP Programmer to use instead of the Arduino acting as an ISP. It comes with a 10 and 6 pin cable. For my needs I’ll just be using it on a breadboard and using wires from the 6 pin cable was a little tedious.

I decided just to make a simple PCB to convert those 6 pins (2×3 pins) into a 6 pin header specifically made for the ATtiny25/45/85 as it you can just simply plug it on the right hand side of the ATtiny and then just wire up the Reset and Ground lines.

More information  and download available at the ISP to BB Connector project page.

Read Full Post »