mark_harrington

Mark Harrington

Engineer Audio, PC embedded technology

A brief overview of my experience to date Born In Saudi Arabia 1964 Spent 13 years in South Africa then emigrated to Britain Interests began in electronics from age of six Crystal radio’s etc matriculated at the age of 17 years with the equivalent of 6 O levels I spent my early days working for companies such as GEC South Africa and Aiwa SA where my interests began in electronics I’ve had many varied jobs ranging from working on the Gold mines to motorcycles to ordinary run of the mill work including working in pub’s , clubs , MacDonald’s, Food chains and so forth So experience wide and varied in many different aspects of the world industries On emigrating back to England my career started with companies such as Rediffusion Electronics in background Industrial music systems, moved onto Comet radio vision services, Telefunken Uk in the TV Video , Audio Industry in its hay day That was when electronics was an awful lot of fun , still is only far more advanced and products defiantly more serviceable than they are these days I also spent considerable time in the Mobile Phone Industry during the early days of the launch of this technology and undertook courses’ with Motorola , Panasonic , Nec working with all the latest Hi Tec equipment to component level on all surface mount devices , multilayer boards with some of the most advanced test equipment available at that time I continued and tried many variants of jobs so I’m fully skilled on washing machines Microwave ovens and now PC’s Ive spent time at universities and colleagues and have taken many specialized courses to undertake service both at customer level , field level and bench level Now I write software for embedded devices make My own pcb’s I experiment at home now learn as much as I can and continue to strive to achieve far more results leading to linking embedded devices with RF and the much use internet both using hardware and software I trust you find at least some of the interesting my website The address of which is address is http://www.harrington.force9.co.uk Lots and lots of articles there on the site also all code PCB layouts and some of the –projects that I still work on to this day Even valve radio and amplifiers

Interests

Quotes

verni verdi victi "I did I saw I overcame "

Latin

EEWeb Stats

Mark's Projects :

Return to Projects

CITROEN Saxo Vehicle Touch Sensitive switches

Project Summary

The CITROEN Saxo Vehicle Touch Sensitive switches For operating Hazards and two peripheral devices If you want to change the look of your dash board inside a vehicle, maybe just fancy some of modern electronics This could be the design for you

Project Description

Figure:1 Touch Switch Design

Figure 1  Touch Switch Design

Faced with a challenge last year a young lad came and spoke to me re his vehicle

Of course the challenge was obviously to fit a car stereo and car amplifier but also to illuminate the rear shelf which held his speakers create some under car vehicle lighting , different colors of course and do away with the Hazard light switch such that he had touch sensitive switches to operate Relays

The task had to achieve the following
A: Switch the hazards lights on
B: use switches to ether switch under car lighting on in the form of LED’s and operate the rear Led’s independently
C: If the hazards were on they would flash at regular intervals keeping the front led’s on or the rear led’s on or both
D: Single touch to turn on visa versa to turn off

Nice easy Microchip to develop small applications for anybody that might be interested a good start to Micro Processors, wanting to learn how to handle interrupts and deal with sensing switches as well as Timer interrupts

The circuits comprises A power supply derived from the 13.8 volt Battery of the vehicle A cpu which uses port A as inputs which rely purely on the fact that our body potential is higher thanthat of ground potential i.e Zero volts combined with fet characteristics of PORTA

An output side comprising PORTB which is connected to relay’s 1 to 4 via npn transistors , pulling the relay’s in

Protection to the input i.e PORT A is set to 5V6 this ensures that any static voltages are suppressed and protects PORT A from spikes D1 to D4, D11

Ignition sense is sensed on Porta RA4.

This ensures that we cant turn on the relays except the hazard lights which must be operable even when the car ignition is off

The relay’s simply short out the links on the back of the hazard switch which has been removed
See Diagram in PDF File for explanation

D9 to D13 provide back EMF protection for the transistors Q1 to Q 4 of the relay drive circuitry
R1 to R4 , R17 ensure that PORTA is held at Zero potential when switches are not being touched
D20 ensures reverse polarity protection as does D23 on the 5volt regulator for the cpu which comprises Q5 , R13, D18

D14 to D17 provide luminous indication that a switch has been activated, current limited through the led’s via R9,R10,R11,R12

D5 to D8 ensure that should the transistors break down that we don’t end up destroying PORTB in the case of Collector, Base short circuit fault symptoms

R5 to R8 ensure that we limit the base current to Q1 to Q4

D21 and R15 ensure only 5 volts to PORTA, RA4, which forms the ignition sense line

Finally D24 flashes in accordance with the normal hazard light indicator

Explanation of interrupts and code

An interrupt is an unscheduled input, which interrupts the normal flow of a program, causing it to temporarily suspend what it is doing and perform a specified sequence of instructions required by the interrupting agent before returning to its original point in the program

An interrupt is a signal originating in peripherals

In PIC microcontrollers, these peripherals need not necessarily be external devices, although they usually are,

In the PIC16F84A these interrupts are as follows

A rising or falling voltage pulse on pin RB0 / INT41

2. A change in one or more of the voltage levels on the group of pins RB4 to RB7
3. An overflow of the timer registers TMR0 from 0xFF to 0×0 Decimal 255
4. A ‘write complete’ signal generated when writing to the EEPROM is complete

There are four interrupt flags, namely TOIF, INTF, RBIF and EEIF which are bits in the INTCON register and are set whenever that particular interrupt triggers, irrespective of whether it has been enabled by setting its corresponding enable flag.

The interrupt enable flags are TOIE,INTE, RBIE and EEIE

When an interrupt occurs, the processor immediately pushes the return address onto the stack, branches to the interrupt vector at address 0×4 in program memory and starts executing the code at that address. The sequence of instructions executed is called the interrupt service routine.

When the system is switched on, the program begins at the reset vector address hex 0×00

We enable the interrupts through the intcon register. This is one many of what we call special function registers inside the CPU

The SFR or Special function registers are responsible for setting the ports direction
In other words whether its input or output
Other SFR’s deal with the timer register which overflows every 256 clock count inside the CPU

Looking at the code we can now see what “ON_INTERRUPT GoTo INTPROC” does

This should now begin to make the subject a little clearer

When the timer overflows execution of code at the interrupt vector begins i.e hex 0×04

‘ *********** Interrupt Procedure starts here ******************

INTPROC: ‘ Handles the interrupt procedure routine
GIE = 0 ‘ disable the interrupt until interrupt complete
T0IE = 0 ‘ disable Timer interrupt reason we dont want the interrupt service routine to interrupt again whilst executing this code

‘ * method for TMR0 starts here ‘

T0IF = 0 ‘ Clear the TMR0 overflow flag we clear the falgs so as to reset
TMR0 = 0 ‘ Clear TMR0 initially

If CLOCKTICKS = 15 Then
Toggle HZLED
CLOCKTICKS = 0
End If

If CLOCKTICKS < 20 Then
CLOCKTICKS = CLOCKTICKS + 1
End If

GIE = 1 ‘ re enable the interrupt flag
T0IE = 1 ‘ enable Timer interrupt
TMR0 = 62 ‘ reload the timer to interrupt 20 times per second

Context Restore

The above will restore the address where the code last executed before the interrupt occurred in our case for the hazard lights timing to turn the hazard indicator on and off.

This is the interrupt service routine

Initially we don’t deal with any interrupts occurring, So at hex 0X00 we start the program by calling procedure which is defined by a line label

This is equivalent to a jump to address instruction Line labeled OVERINT:

Code execution start here and we set up ports timers different types of input and we ensure that we don’t have any interrupts enable until a particular switch on the micro is activated requesting Hazard Lights on

After Jumping to Address OVERINT: we call another sub procedure with a JUMP too Instruction labeled INITCPU:

Here is the INIT CPU Code

INITCPU:
ALL_DIGITAL = True
Clear

Clear INTCON
Clear PORTB ‘ make sure no output on port b
Clear PORTA ‘ make sure no output on port a

TRISA = $1F ‘ make all port a input
TRISB = $81 ‘ make portb output except bits 0 and 7
T0IF = 0 ‘ clear the timer interrupt flag

‘ 15 times per second pre-scaler setting
PS0 = 1
PS1 = 1
PS2 = 1
PSA = 0

T0CS = 0 ‘set the clock source for internal oscillator

GIE = 0 ‘ disable interrupts
T0IE = 0 ‘ clear Timer interrupt
Return

In this procedure we set up the ports direction The Pre-scaler and then finally we clear all the ports down so that we don’t land up with false values and clear all the Interrupt Flags which let us know that an Interrupt has occurred

Analogy

Imagine your self in a lecture hall with the CPU being the lecturer , the pupils being the interrupt flags as a student raises his / her hand The lecturer being the CPU stops execution of what he is saying and deals with the students question after answer in the student, “The interrupt service routine “ The student clears the Flag “Lowering of hand “ and a returns control back to the Main Class i.e. the lecturer recommences from where he left off “

We could call this the Main method

The Main Method we could analogise as the lecturer asking the Class to work in groups and discuss the topic further, each student being a button press

This would equate to one of his colleagues answering the concern or interaction equivalent to Hardware interaction within his / her group

If the question needs to go back to the lecturer a interrupt flag is enabled in our case a timer interrupt enablement and the lecturer re iterates his/ her service routine with the last event having occurred , stores that address and then returns to that address for the class to continue from where they left off

This should make this a lot easier for you to understand as to what’s happening in the code

The rest of the code should be self explanatory I have commented the code in full for you and also included the Drill Plots , Code in Hex and of course the code / circuits pcb layout , Gerber plots etc for you to download plus of course the Proteus design files in pdf as well as the circuit

I hope you will find this a very interesting project not only for your car but also from a standpoint of what I hope will help you further to understand Pic Micro devices and interrupts

Have fun I hope you’ve enjoyed reading about this and maybe even making this yourselves

The projects has been fully tested All the printed circuit bourds are made and assembled by hand

Mark

http:// http://www.harrington.force9.co.uk

Project Files

File NameFile Size
PCB Layout540.56 KB
Circuit design in PDF Format75.6 KB
Proteus design files PCB58.29 KB
Proteus design files Circuit113.56 KB
Bill Of matarials29.08 KB
PIC Basic code6.76 KB
Hex File for the 16F84A1.46 KB
ASM File for Code9.61 KB
Cadcam , gerber plot files43.99 KB
Tags: PCB_ design, PIC Microcontrollers, relay, automotive,

Comments on this Project:

There are currently no comments.

Login or Register to post comments.
 
Click Here