Wednesday, December 9, 2015

Fixing Pin P5 or 6 on Digispark Clones

The digispark ATTINY85 is a handy microcontroller for simple projects. The genuine version, available here: http://digistump.com/products/1 comes with the micronucleus bootloader installed and 6 GPIO pins enabled.

There are Chinese clones available on ebay for about $1.50 that are pin for pin compatible and come with the micronucleus bootloader installed. The catch is that pin P5 (the last one, physically counted as number 6, ADC0) may be configured as a reset pin. If you only need 5 pins, or want a reset pin that's great, you can stop reading. If you need 6 pins, read on.

The ATTINY85 comes from the factory set up for ISP (in system programming), for this to work it needs a reset pin. The micronucleus bootloader allows the user to program the ATTINY85 with a USB connection. This is well documented on the digistump site.

After the bootloader is added, we no longer need that reset pin, and on the genuine boards they go ahead for us and set the "fuse" on the ATTINY85 to disable the reset pin, allowing it to be used as a GPIO pin. On the clones they may not.

To test if your clone can use pin 5, there are some simple methods. One would be to upload a sketch that blinks an led on pin 5, if it works that's great! You don't need to change anything. If it doesn't work pin 5 will not work for GPIO.

Another simple test would be to pull pin 5 to ground through a small resistor (~220 ohms) while a program is running. If the program resets (the micronucleus bootloader waits 5 seconds and then the program runs) you cannot use pin 5 for GPIO.

(If pin 5 is working for GPIO and you want change it to a reset pin, it is possible. You need a high voltage programmer, which is fairly simple to build and use, but it beyond the scope of this post. Look here to get started: http://www.rickety.us/2010/03/arduino-avr-high-voltage-serial-programmer/)

Ok, so now you know that your pin 5 is configured as a reset pin and you want it for GPIO.

First and foremost be sure the micronucleus bootloader is installed on your ATTINY85 and working properly.

After we change the configuration fuse, you will not be able to load micronucleus without a high voltage programmer! Be sure the bootloader is present and working first. If you can upload programs to your ATTINY85USB via the USB connection from the Arduino IDE the bootloader is present and working.

You will still be able to upload programs via the USB connection as you normally do after changing the configuration fuse.


The next thing you will need is another Arduino, I used a Duemilanove, but you can also use an Uno. Using the Arduino IDE (I used v1.6.6), go to file > examples > ArduinoISP and upload this sketch to your Duemilanove (or Uno). If you have been playing around with your digispark, be sure the bootloader and board in the Arduino IDE are set correctly to the board you are now programming.

After uploading, go to tools > port and note the port where your Arduino is connected. For me it was  '/dev/ttyUSB0'. We will need this later.

If you are using a Duemilanove, add a 120 ohm resistor from RESET to 5v on the Duemilanove board. Do not use a resistor smaller than 110 ohms or larger than 124 ohms. Please do not skip this step. Read the comments for more information.

On an Uno, do not add the resistor but instead add a 10uF capacitor from RESET to GROUND on the Uno board. Please do not skip this step. Read the comments for more information.

Connect as shown:

Duemilanove -- > Digispark ATTINY85USB Clone

GND --> GND
5v --> 5v
10 --> P5
11 --> P0
12 --> P1
13 --> P2

These are the connections for Duemilanove and ATTINY85, for other boards be sure to determine the proper pins, you want SS, MOSI, MISO, and SCK on the other Arduino connecting to RESET (P5), MOSI (P0), MISO (P1), and SCK (P2) on the digispark ATTINY85USB clone. Note these are not the pins on the ATTINY chip itself, but the IO pins on the digispark clone.

It should look something like this...




Next go to a terminal and enter (replace '/dev/ttyUSB0' with the port your Arduino connects to that you noted earlier): 

avrdude -P /dev/ttyUSB0 -b 19200 -c avrisp -p attiny85 -n


It should output something like this...

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e930b

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


I am using linux, if you use windows I would assume this works the same in command prompt, if you enter (replace '/dev/ttyUSB0' with the port your Arduino connects to that you noted earlier):

avrdude.exe -P /dev/ttyUSB0 -b 19200 -c avrisp -p attiny85 -n


If all goes well, the next command to enter is (replace '/dev/ttyUSB0' with the port your Arduino connects to that you noted earlier):

avrdude -P /dev/ttyUSB0 -b 19200 -p attiny85 -c avrisp  -U hfuse:w:0x5F:m 


The response should be:

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e930b
avrdude: reading input file "0x5F"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x5F:
avrdude: load data hfuse data from input file 0x5F:
avrdude: input file 0x5F contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.



That's all, your digispark clone should now allow you to use P5 as a GPIO pin, and be programmable via the USB connection. If you want to go back to having a reset pin, or program with ICSP, you need a high voltage programmer. See the link above.

Wednesday, December 2, 2015

New Mexico Balloon Festival

A neat event with hot air balloons from around the world. The black and white pictures were taken with the infrared camera I modified in an earlier post.












Thursday, July 23, 2015

Pike's Peak International Hillclimb 2015

Sunrise at ~14,000'

914-8

Glacier

918

911 GT3? Yep, that's snow on the hood. In late June.

Saturday, July 11, 2015

Lightning

We had this neat storm come through with a lot of lightning and only a light rain.
 

Wednesday, March 4, 2015

Seeing Through Things


One of the most interesting things about infrared photography is that some things that appear opaque in visible light are transparent to infrared. Perhaps the most obvious example would be the classic R72 filter used for IR photography. This filter blocks all visible light while allowing infrared to pass.

R72 Filter with Visible Light Only

R72 Filter with Full Spectrum Camera

Neat, but predictable. Here is a pair of matte black sunglasses.

Visible Light

Full Spectrum Camera, R72 Filter
 
Notice how you can see the "O" shaped logo through the right temple in the infrared photo?

Here is another example. These appear even more transparent than the example above. The image was desaturated to remove the bluish cast seen in the above example.

Visible Light

Full Spectrum Camera, R72 Filter, Desaturated in Post


These are neat, but the most dramatic example I have found is sunglasses made from Acetate. These appear completely transparent when photographed with infrared light.

Visible Light

Full Spectrum Camera, R72 Filter, Shot in B/W

Notice how clearly you can see the metal frame? That is pretty well known way to verify that your Wayfarers are authentic, but if you have black frames it is normally difficult to see for obvious reasons. Not the case here.



Full Spectrum Camera, R72 Filter, Shot in B/W


What else?

The camera window on a WiiMote is a predictable one.

Visible Light

Full Spectrum Camera, R72 Filter, Shot in B/W

The camera can clearly be seen through the window, which is probably just a filter similar to the R72 filter I am using. This would also suggest that the "sensor bar" that the Wii uses is improperly named. Most likely it consists of a couple infrared LEDs that the camera in the WiiMote uses to sense movement. Unfortunately I don't have the rest of my Wii anymore to test that theory. Not that it really matters...


Here is an obvious example of the opposite situation. The hot mirror we removed from the camera during conversion to full spectrum is transparent to visible light and appears opaque when only infrared light is used.



Visible Light

Full Spectrum Camera, R72 Filter, Shot in B/W

A couple bonus pictures:

Light painting with a TV remote. More it faster to space the dots out, or slower to space the closer. Notice all the reflections caused by the filter?




Light painting with sparklers on an RC airplane, not at all IR related, but still neat.



A flame provides a strong IR source.

Visible Light, Dark Room. 1/10s, f/5.0, ISO 400 (EV100 = 6)

Full Spectrum Camera, R72 Filter, Dark Room. 1/30s, f/2.8, ISO 400 (EV100 = 6)
Although the photos were taken at the same EV, the infrared image is clearly brighter, evidence as to just how much infrared light is produced by the flame. The other photo looks a lot better though.