I managed to set up my Arduino fine as a trigger - whenever I trip the laser the camera triggers almost instantly (I think there's probably about a 1-5ms delay) and I even hooked up a mode switch (trip forever or trip once).
Here's the basic circuit (sorry for the basic schematic - just whipped up on a whiteboard):
However, when I try the code on the ATtiny, suddenly the camera no longer fires. I've tried plugging a normal LED where the IR LED is and I can see that it's firing - it's just not triggering the camera for some reason.
I've tried using 3.3V input and 5V input for the ATTiny and the IR LED but no dice.
Here's the device wired up:
My guess is the timing on the ATTiny isn't precise enough to trigger properly - but I have no way of testing this.
Does anyone have any suggestions?
I'd also appreciate any feedback - this is about the third circuit I've ever built (blink!) so any general advice would be great I'd really like to get this is a standalone item.
Your schematic shows a transistor grounding the cathode of a diode connected directly to Vcc. Is that the yellow LED? Shouldn't there be a current limiting resistor somewhere in there?
If I recall the IR protocol, it flashes the IR light for precise periods. It might be the library you are using is tuned towards 16Mhz, and perhaps you are running the ATtiny85 at a different speed like 8Mhz or 20Mhz.
MichaelMeissner:
If I recall the IR protocol, it flashes the IR light for precise periods. It might be the library you are using is tuned towards 16Mhz, and perhaps you are running the ATtiny85 at a different speed like 8Mhz or 20Mhz.
Ah yes of course, I am running the ATtiny at 8Mhz! The code for the library shows this to fire the Canon camera:
Does the delayMicroseconds() function depend on the speed that chip is running at then I assume? Would I be safe enough in just halving all the times to get the same effect without having to use a crystal do you reckon?
johnwasser:
Your schematic shows a transistor grounding the cathode of a diode connected directly to Vcc. Is that the yellow LED? Shouldn't there be a current limiting resistor somewhere in there?
It is a yellow LED that I just used to visually test if the rest of the circuit was working, but you're right I should have had a resistor in there really! My bad.
The same person goes into detail about the timing and tolerances here:
However, when I replace the PORTB = LEDON/LEDOFF; parts of the code above with standard arduino code (digitalWrite(pin,HIGH)) it ceases to work properly...
Manticorp:
However, when I replace the PORTB = LEDON/LEDOFF; parts of the code above with standard arduino code (digitalWrite(pin,HIGH)) it ceases to work properly...
I'm tearing my hair out over here!
Note that writing a value to PORTB will change ALL pins associated with PORTB. It looks like LEDON and LEDOFF are changing two different pins. One of those pins is an input so writing to it is turning the pull-up resistor ON (1) and OFF (0).
johnwasser:
Note that writing a value to PORTB will change ALL pins associated with PORTB. It looks like LEDON and LEDOFF are changing two different pins. One of those pins is an input so writing to it is turning the pull-up resistor ON (1) and OFF (0).
Ah thanks, I'm still getting the hang of all this programming microchips stuff (obviously!). I'm so used to web programming and whatnot, all this 'hardware' stuff is really confusing ('what the hell is a register!?').
I'm beginning to think that instead of relying on programming for all of this (the mode switching, LDR calibration, etc) I should be taking a more hardware approach and designing the circuit a bit better and just using the little ATtiny85 to send the pulses that trigger the camera, that way I can keep the ATtiny in sleep mode most of the time and only turn it on when I need a pulse sent. Hmm.
Manticorp:
and I just want to get a few things straight before I potentially damage a chip...
Just include 220 ? (or higher) resistors in series: Arduino ? resistor ? ATtiny85. You can never go wrong with a series resistor.
I connect PB3 (which is transmitting) to the serial receiver and PB4 (which is receiving) to the serial transmitter.
I believe that is correct.
The Receive/Transmitter presumably can just be the TX/RX pins on an Arduino Uno for example?
Yes but you will have to remove the 328 processor from the circuit. You can either force it into reset by connecting a jumper from RESET to GND or you can remove the 328 processor from the board (with the power off).
Because there are only 128 steps in the OSCCAL value 1, in the worst case, you call not be able to get better than 1/128*100 = 0.78% 2. The goal is ±1%. Anything better than that is just good luck.
1 Tiny Tuner 2 uses the full range; 256 values. 2 The actual value is a bit lower because the relationship between OSCCAL and the frequency is not linear.
BTW as an experiment I tried using 3V in room temperature - and 3V and low temperature (I put the Attiny85 in the freezer), but that didn't change much
3V ->1501
3V low temp. -> 1499
I built a three-minute timer for my wife that runs directly from two AA batteries using the internal oscillator (ATtiny13). Over the entire voltage range (3.2 V to 1.6V) there is less than a two second difference (2/(3*60)*100 = 1.1%).
This should give you a rough idea of what Atmel guarantees...