Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Tiny project using Attiny13

Status
Not open for further replies.

HarveyH43

Newbie level 3
Joined
Apr 8, 2006
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,340
attiny13 projects

I'm working in Assembler, and just started with microcontrollers (about a week), so still getting familiar with it all. My previous assembly experience was with th 6502 in a Commodore 64 (yeah, been a few years...)

Anyway, the first thing I did, was flash some LEDs, of course... And thought to expand on that with a project using a few Tiny13 features. Something useful, and learn at the same time.

The project: IR proximity detector, flashing red/blue LEDs (police style strobe), and a siren.

Flashing the LEDS was simple.

Setting up Timer0 to drive the IR emitter took a couple days, but got it going. The reciever module detects at about 5-6 inches, good enough, but was hoping for a foot or so.

Setting up a pin-change-interupt to handle the reciever module has been a royal pain. Does some weird stuff. Trying to use PCINT3 (pin 2). If anybody has an example, willing to throw something together, it would really help.

The siren: Figure I could use Timer1, and just change the frequency, when change colors when flashing the LEDs. If somebody has more of a police sounding siren code, would appreciate a look, but this should be good enough, and pretty sure Timer1 will work same as Timer0.

Think this is pretty good for a beginner, got the hardware features doing most of the work once configured.

Thanks for reading through this, and appreciate an help or pointers. I still have a lot of stuff to learn, but it's going pretty well. Haven't started putting it all together yet, just seperate test programs. Figure best to wait, then figure out my pin options. Don't think I can move the Timer outputs, and using 5 out of 6 I/O pins.
 

ad IR - check if IR your carrier frequency ist the same as receiver. the distance must be few meters nowadays. what king of proximity detector do you use? if Sharp, the distance few inches is ok if I remember corretly the datasheet.
ad siren - use PWM and audio amplifier. The police siren is just your programming art.
 

Here's an example for you to work with, for the PCINT3:
Code:
program PCINT13

sub procedure PCINT3_ISR() org IVT_ADDR_PCINT0 'PCINT0..3 ISR
'Complement bit to show interrupt occured
    PORTB.B0 = 0
end sub

main:
     DDRB = $17 'PCINT3 input, ADC0/Reset input
     '$17 = 0x17, ie it's in hex
     PORTB.B3 = 1 'Enable pull-up on PB3

     PCMSK.PCINT3 = 1 'Enable pinchange function on PCINT3
     SREG.SREG_I = 1 'Enable global interrupt
     GIMSK.PCIE = 1 'Enable pinchange interrupt
     
     PORTB.B0 = 1 'Show that waiting for interrupt
     
     while true 'Wait for interrupt while working
     
     wend
     
end.

I've just coded this and tested, it's fine.

Hope this helps.
Tahmid.

---------- Post added at 05:52 ---------- Previous post was at 05:38 ----------

Alternately, instead of interrupt, you could use polling method:
Code:
program PCINT13_poll

main:
     DDRB = $17 'PCINT3 input, ADC0/Reset input
     '$17 = 0x17, ie it's in hex
     PORTB.B3 = 1 'Enable pull-up on PB3

     PCMSK.PCINT3 = 1 'Enable pinchange function on PCINT3
     GIMSK.PCIE = 1 'Enable pinchange interrupt
     'This allows the flag to be raised, but since SREG_I_bit is not set,
           'Interrupt will not occur
     
     PORTB.B0 = 1 'Show that waiting for change

     while GIFR.PCIF = 0 'Wait for flag to be raised
     wend
     
     if GIFR.PCIF then 'If flag raised, ie, status of PCINT3 changed
        PORTB.B0 = 0 'Clear LED to show action happened
        GIFR.PCIF = 1 'Clear flag by writing 1 to it
     end if
     
     while true
     wend

end.

These should help you set it up nicely.

Use interrupt or polling as required in your code.

Hope this helps.
Tahmid.

---------- Post added at 06:32 ---------- Previous post was at 05:52 ----------

Hi,
I'm not good with assembler and use mikroBASIC (the codes above are in mikroBASIC). But they should be pretty clear.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top