Sie sind auf Seite 1von 5

Circuit Cellar AVR 2004 Contest Entry # A3784

Abstract

CAR GEAR INDICATOR

This project is an indicator for the selected gear of 5-speed manual gearboxes. It can be used in cars,
with the classical x-y movement of the gearstick. It can also be installed in bikes, where the gearbox
lever has a linear movement. In this case only one potentiometer is required.
The circuit is based on a ATtiny26 microcontroller. The ATtiny26 is without doubt very well suited
to this application. It has everything on chip that we need to detect the current gear selection. And
also it is very cheap.
The software (written in assembler language) continuously sample the potentiometers position and
consequently drives the seven leds. There is one led indicating Null selection (yellow), five leds,
one for every speed (red) and one for Reverse speed (green).
In addition, there is a microcontroller pin outputs a software serial transmission indicating the
current speed selection. This make possible interfacing our indicator with a PC-based telemetry
system.
The circuit can be adapted to various models of cars and bikes: you should only mount the two
potentiometers in orthogonal position and only proceed to the software calibration.
The power supply can be derived from the 12 V car (or bike) electric system. Since one led is lit at a
time the current draft is only 30 mA.
Figure 1: the block diagram

Figure 2: the Car Gear Indicator Schematic


Figure 3: an example of installation on 5-speed + reverse gearstick

Selected speed Transmitted char LED


Null N Yellow
1 1 Red
2 2 Red
3 3 Red
4 4 Red
5 5 Red
Reverse R Green
Listing 1: some assembler source code

;************************************************************
; RS 232 TX routine
;
; Settings: 19200,n,8,1
;
; Baud rate = 19200 >> 52uSec
;
; r18= data to send
;************************************************************
TX19200:
;send start bit
cbi PORTB,TX232
rcall DEL52US
;send 8 data bits
ldi R19, 8 ;this is a counter
TX232_L:
sbrc R18,0 ;skip if r18,0 = 0
rjmp SETBIT
CLEARBIT:
cbi PORTB,TX232
rjmp XMIT ;goto transmission
SETBIT:
sbi PORTB,TX232
XMIT:
rcall DEL52US
ror R18
dec R19
brne TX232_L ;if not 0 branch

;send stop bit


sbi PORTB,TX232
rcall DEL52US
ret

;************************************************************
; Calibration Routine
;
;************************************************************
CALIB:
rcall delay
CAL_N_l:
;wait for S2 pressed
rcall LEDNon
sbic PINB,PUSHBUTTON2
rjmp CAL_N_l ;loop
;read and store POT1 and POT2
rcall ADCPOT1
ldi EEaddress, EEadrN_P1
mov EEdata, POT1value
rcall EEWRITE
rcall ADCPOT2
ldi EEaddress, EEadrN_P2
mov EEdata, POT2value
rcall EEWRITE
rcall delay
CAL_1_l:
;wait for S2 pressed
rcall LED1on
sbic PINB,PUSHBUTTON2
rjmp CAL_1_l ;loop
;read and store POT1 and POT2
rcall ADCPOT1
ldi EEaddress, EEadr1_P1
mov EEdata, POT1value
rcall EEWRITE
rcall ADCPOT2
ldi EEaddress, EEadr1_P2
mov EEdata, POT2value
rcall EEWRITE
rcall delay

Das könnte Ihnen auch gefallen