Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Project idea for Attiny13

Status
Not open for further replies.

HarveyH42

Banned
Yesterday, I flashed some LEDs for the first time with a microcontroller. Now, I want to do something a little more useful, hopefully completed and in a case with in a week.

The idea is for an IR detector (proximity), flash a red and blue LED like police strobe for 10-15 seconds, and reset. Wanted to add a siren, but think that might be a little much for me to program at this time, and an external unit would kill a 9v battery quick.

I've got everything I need for parts and materials, just need a little help putting all together.

For the power, it'll be a 9v battery. I've got the Tiny13v, which can go as low as 1.8 volts, but slower clock. Thought about using 3 AAs, but figured it would take more space, wanted to keep this small. So, I'll be using a 7805 regulator for the Tiny13 and the IR reciever module. I've got 2 choices in regulators the large 1 amp to-220(?), and a 100 mA little transitor looking thing, to-92. Would like to try the smaller ones (got a bunch, shouldn't need 100mA), but there is no heatsink.

Th IR reciever is 5v and 38khz. Digital out, so shouldn't be a problem to program. The IR emitter might be the biggest problem of this whole project. I have several choices, but have no experience yet. The tiny13 can directly drive 20 mA LEDs, but how do I get it to flash close to 38Khz. I have 2 PWM channels, one Timer/Counter with pre-scaler, and of course software to choose from. Hoping to use the internal clock, not real sure how this all relates or works just yet. From what I understand about the reciever, the 38khz is a center frequency, but the unit will function correctly if the emitter is close or varies slightly, so it's perfect for me (not the precision king). Close enough, is good enough...

The blue and red LEDS are the easiest part, could do that in a couple of minutes. Kind of what inspired this whole project. I was re-programming the Tiny13 for a different sequencing pattern, and there was a cop doing a traffic stop outside my house. Thought about how our maintence guy at work had his toolbox broken into... Anyway, haven't decided if I will go with single 5mms directly off the Tiny13, or go with a transistor switch and drive some 70mA Pirahnas off the battery (better if I use the 100 mA regulator).

From what I did yesterday, don't think I'll have any programming problems, other than getting the IR emitter to flash close to 38khz. Will hit the datasheet after posting this. Not sure what kind of range to expect, hoping for about 6 inches (15 cm in british?), of course if its a foot or so, that's even better, but beyond that it might get some false triggers.

Plan on attaching this to a rare earth magnet from an old hardrive, so it should stick solid to the toolbox. Wonder if the magnet will mess up the microcontroller... Anybody have any such experience? Pretty sure its not covered in the datasheet.
 
Can't help you on AVR's, but my PIC tutorials cover IR reception and transmission, transmission is EXTREMELY easy, it's so simple to generate 38KHz in software, no need for timers or anything like that.

You might check the hardware that my tutorials use?.

You might also check one of my other websites which has a PIC based IR proximity detector
 
Last edited:
Did some reading, the Tiny13 datasheet was rough going, didn't get the Timer/Counter/PWM all related no useful code examples, and not familiar enough with the conventions to use this stuff yet. So, went to those tutorials and took a quick read (scanned for related stuff). The software solution for driving the emitter seems pretty dependent on clock speed and how long each instruction takes, delay loops and NOP instructions. Guess its more trial and adjustment, then actually calculating values. Figured I could use an interupt for the reciever module, so I wouldn't need to keep checking it in the program. I'd still like to figure out how to use the Timer/counter/PWM for the frequency generator, it's there for this purpose, seems like a waste. Got the impression that once its started, it runs independent of the program, just a matter of setting the proper flags. Seems like the program space will only need to be used to wait for the interupt, and flash some colored LEDS.

Did some hardware stuff. The 100 mA regulators work fine on the LED sequencer, no heat detected. Pretty cool, because I must have a hundred or so of them. Hadn't realized it until digging them out, never used them before.
Hooked up the receiver module and tested it with a VCR remote, works fine. Couldn't tell how much range I was going to get, so built a 555 astable, turned out slightly over 40 khz (bad math or component tolerence...). Not too good, maybe an inch or two at best. Hoping its the frequency, but have 4 other types of modules, maybe a couple more I never got around to pulling, just no datsheets on hand. I know a couple of thos modules have no numbers.
 
Alright, got a 40 kHz signal from Timer0, so hardware will be taking care of the emitter part.

Next thing will be the reciever. The module I've been testing with is unmarked (first one I found laying out), the output is always on, until a signal is recieved. It works good though, getting 5-6 inches, which is good enough. Anyway, not sure if its the way I got it hooked up, or if that's the way it works. Hooked the output pin to an LED->220 ohm resistor->ground. Didn't think about going to the +5v side until now. Anyway, shouldn't really matter, if I'm understanding the external interupts on the Tiny13. Haven't worked out the particulars, but there are pin-change-interupts, which I take to mean that if the pin changes state, the interupt is generated, and the CPU switches to the address in the interupt vector. Seems simple and sweet, but haven't figured out how to confine this to just one pin, since the pin used for the IR LED will be changing state at 40 kHz. Anyway, think its just a matter of setting a few bits in a couple of registers.

Should have some cable making stuff friday, so I'll be able to program in system. This will make work much quicker and easier.
 
Assuming it's an IR receiver IC?, then the output is normally HIGH, and goes LOW when it receives suitable 38KHz (or so) modulated IR. The 38KHz doesn't appear at the output of the receiver.

Again, my IR PIC tutorial esplains it and shows how to connect it.
 
Nigel Goodwin said:
Assuming it's an IR receiver IC?, then the output is normally HIGH, and goes LOW when it receives suitable 38KHz (or so) modulated IR. The 38KHz doesn't appear at the output of the receiver.

Again, my IR PIC tutorial esplains it and shows how to connect it.

Think that was what I used to hook it up in the first place...
I'm about to try the interupts shortly, pretty sure I got it figured out. Was kind of playing with an idea for using the timer for a siren, but should have stayed on track with getting the interupt working.
 
Having trouble getting the interupt routine working stable. Spent most of the day on it, but still not right. The first thing I learned was that 10 MHz is very fast, wonder why my first 286 computer was so slow (Windows 3.11...). Slowed the internal clock down to 128 kHz, and I could atleast see what was going on. This was after rewritting the progam a few times with little improvement. I used the flashing LED routine to let me know when the progam is waiting for an interupt on pin 2 (PB3). Shorting pin 2 to +5v generates the interupt, which turns the LED full on for a while. The problem comes after it returns to the idle flashing, it does see any new interupts for a while. Also, if I just leave it alone after the first interupt, it returns to flashing, but after a while (few seconds), something triggers the interupt. After it returns from handling this interupt, it sits ready and waiting for an interupt. It goes on like this, so it the program or the setup. Give it another try tomorrow. Think it best to start from scratch at this point, the program is kind of a patch-job mess.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top