Random sequence of images

Ask me anything   Images and artworks, found and enjoyed.

Typical contents: illustrations, artworks, interesting and beautiful photos, anything ghibli, and wildlife.

(NB The female form is especially beautiful to me and I'll reblog something quite NSFW on occasion.)

IR Control for a Nikon D60 - [Updated]

Quick weekend project (would’ve likely hacked on this at Fizzpop Howduino… if I could’ve got there!)

Scenario:

You like photography and DIY electronics but you begrudge paying £15+ for a remote control for your camera. Or you are just curious as to how to hack one together.

Step 1 - Operation Hunt and Destroy

Due to the law of Conservation of Remote Controls, you can never truly lose a remote control. It may disappear down a sofa, but a new remote control will appear - hidden in a drawer - and won’t seem to work with anything you own. (Don’t ignore Sod’s law too, as a purposefully lost remote control will appear in someone else’s house: “Nature hates a clever sod”)

So, find an unused remote control and tear it apart. Get the IR LED (should be at the pointy end of the box) and desolder it from the board.

Or you can pop out and buy one but who does that, right?

Step 2 - A microcontroller

You could use an Arduino to send the right pulses from the LED and I used one to test out the timing - I found this site: http://www.bigmike.it/ircontrol/index.html in which the timings was nicely laid out for me :)

Once I had done the PoC with the arduino, I looked for a way to a) not use an expensive, shiny arduino and b) get it small enough to fit into an altoids tin.

So, I dug through my other chips and found a couple of Microchip PICs. After installing the HI-TECH PICC lite compiler and the Piklab IDE for linux (and after having found out that the chip I initially chose was screwed) I got things ported across:

#include <pic.h>



__CONFIG(WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BORDIS);



#define _XTAL_FREQ 4000000



int state = 0;



void takephoto(void)

{

// Due to using an inbuilt HI-TECH PICC Lite macro for timing

// I found that using slightly lower delays worked more reliably

// Using an actual oscillator might even have made it accurate ;)

RA0 = 1;

__delay_us(1980); // starter pulse

RA0 = 0;

__delay_us(27800);

RA0 = 1;

__delay_us(380); // 1st pulse

RA0 = 0;

__delay_us(1570);

RA0 = 1;

__delay_us(400); // 2nd pulse

RA0 = 0;

__delay_us(3570);

RA0 = 1;

__delay_us(390); // 3rd pulse

RA0 = 0;

}



main()

{

PORTA = 0b111110; // Set up all A pins but RA0 to be high

 TRISA = 0b111110; // Set up RA0 to be output

OPTION = 0b00000111;



while (1){

// If the button is pressed and the state is 0

if (0 == RA3 && 0 == state) {

takephoto();

__delay_us(100000);

state = 1;

} else if (1 == RA3) {

state = 0;

}

}

}


Once burned onto the PIC16F684A, this seemed to work reasonably well. The current circuit physically looks like this:

And the current circuit diagram - note that it’ll likely need a transistor to make the LED pulse with the full 5v, and an oscillator for accuracy.

UPDATE!

Whoops… forgot to port over the modulation part of the code. The following C code for the PIC16F684A works, but is probably very heath robinson/hacky - not really precisely timed.

#include <pic.h>

__CONFIG(WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BORDIS);

#define _XTAL_FREQ 4000000

int state = 0;
int i = 0;

void takephoto(void)
{
	// start pulse - pulsing as fast as the little chip can
	for (i=0; i != 76; ++i) {  // 26 ~= 2000 / 26us
		RA0 = 1;
		RA0 = 0;
	}
	__delay_us(27830);
	for (i=0; i != 15; ++i) {  // 15 ~= (390-410) / 26us
		RA0 = 1;
		RA0 = 0;
	}
	__delay_us(1580);
	for (i=0; i != 15; ++i) {  // 15 ~= (390-410) / 26us
		RA0 = 1;
		RA0 = 0;
	}
	__delay_us(3580);
	for (i=0; i != 15; ++i) {  // 15 ~= (390-410) / 26us
		RA0 = 1;
		RA0 = 0;
	}
}

main()
{
	PORTA = 0b111110;
	TRISA = 0b111110;
	OPTION = 0b00000111;
	
	while (1){
	    if (0 == RA3 && 0 == state) {
		takephoto();
		__delay_us(1000);
		state = 1;
            } else if (1 == RA3) {
		state = 0;
	    }
	}
}
— 4 years ago with 5 notes
  1. benosteen posted this