PDA

View Full Version : Help Quick Need to make code smaller



Programmednew
- 16th January 2005, 17:56
I need to srink this code from 1688 to 1024 or less for a 16F84.
This to make a car horn honk when the circuit gets power. It's adjustable from one to ten honks. This is the first code I have ever written so if you find any thing else wrong please tell me.


DEFINE OSC 4
TRISA.2 = 0
High PORTA.2
Pause 50
TRISB = %11111111
TRISA.0 = 1
TRISA.1 = 1
TRISA.3 = 1
TRISA.4 = 1
SWITCH:
Pause 250
IF PORTA.4 = 1 Then End
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then GoTo SW10
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then GoTo SW1
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then GoTo SW2
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then GoTo SW3
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then GoTo SW4
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then GoTo SW5
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then GoTo SW6
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then GoTo SW7
IF (PORTA.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then GoTo SW8
IF (PORTA.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then GoTo SW9
GoTo SWITCH
SW1:
PulsOut PORTA.2, 50000
End
SW2:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW3:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW4:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW5:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW6:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW7:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW8:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW9:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End
SW10:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
End

Any help is appreciated.
Thanks

Archilochus
- 16th January 2005, 19:08
Hi Programmednew,
Well, just at a glance you might try nested IF...THEN's instead of using the "AND"s (try to get rid of all of the AND's if you can).

The "PULSEOUT"s can be replaced with something like:

PortB.0 = 1 ; Make PortB.0 'high'
pause 1000 ; or whatever pause you need
PortB.0 = 0 ; Make portb.0 'low'

Try to get rid of all the PULSEOUT's too.

Using the "HIGH" command automatically makes the pin an output, so these two commands could be changed:

TRISA.2 = 0
High PORTA.2

To just this:
HIGH PORTA.2

Better yet, can all the "HIGHs and "LOW"s and just set your TRIS registers as needed then use:

PortA.2 = 1

Arch

Archilochus
- 16th January 2005, 19:13
Couldn't edit my last post for some reason - so here's another idea to try:

Where you have some code like this:

SW10:
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000
Pause 500
PulsOut PORTA.2, 50000

You could try this:

CounterA VAR BYTE

FOR CounterA = 0 TO 9
PulsOut PORTA.2, 50000
Pause 500
NEXT CounterA

Or get rid of the PULSEOUT as mentioned above.
Starting the FOR...NEXT loop at 0 instead of 1 saves a bit of space too.

>>>>
Also, you could set up the loop in a sub-routine, then just load a CounterStop value:

CounterStop VAR BYTE

; Your code sets a loop amount here.
CounterStop = 5 ; Or whatever amount of loops you want

GoSUB HornLoops

Horn_Loops:
FOR CounterA = 1 TO CounterStop
PulsOut PORTA.2, 50000
Pause 500
NEXT CounterA
RETURN


Arch

mister_e
- 16th January 2005, 20:38
I don't think i can do better than the following... 197 words now !!



DEFINE OSC 4

TRISB = %11111111
TRISA=%11111011

MaskFromPORTB var byte
AmountOfPulsout var byte
LoopVar var byte
PORTA.2=1
Pause 50

SWITCH:
Pause 250
IF PORTA.4 = 1 Then End
MaskFromPORTB=PORTB & %01111100 ' Get only PORTB<6:2> bits
SELECT CASE MaskFromPORTB
CASE %00100000
amountofpulsout=10

case %00110000
amountofpulsout=1

case %00100100
amountofpulsout=2

case %00110100
amountofpulsout=3

case %01100000
amountofpulsout=4

case %01110000
amountofpulsout=5

case %01100100
amountofpulsout=6

case %01110100
amountofpulsout=7

case %00101000
amountofpulsout=8

case %00111000
amountofpulsout=9

case else
amountofpulsout=0
end select

if amountofpulsout>0 then
for loopvar=0 to amountofpulsout
PulsOut PORTA.2, 50000
Pause 500
next
end
endif
GoTo SWITCH



the only thing i'm not sure of was on your following lines
IF (PORTA.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then GoTo SW8
IF (PORTA.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then GoTo SW9

Since PORTA.2 is the output for your pulsout... i'd assume you was meaning PORTB.2

let us know what happen on this.

mister_e
- 16th January 2005, 20:53
you can still save codespace using the following... but this imply to modify your circuit too. It will gives you pulses from 0-15 depending on the PORTB<3:0> binary representation



DEFINE OSC 4

TRISB = %11111111
TRISA=%11111011

MaskFromPORTB var byte
AmountOfPulsout var byte
LoopVar var byte
PORTA.2=1
Pause 50

SWITCH:
Pause 250
IF PORTA.4 = 1 Then End
MaskFromPORTB=PORTB & %00001111 ' Get only PORTB<3:0> bits
amountofpulsout = maskfromPORTB
if amountofpulsout>0 then
for loopvar=0 to amountofpulsout
PulsOut PORTA.2, 50000
Pause 500
next
end
endif
GoTo SWITCH
about 118 words nows... can use PIC12c508 or else 12c or 12F for that. without any need of external crystal or oscillator.

if you remove PULSOUT statement and you use those line


PORTA.2=0
PAUSE 500
PORTA.2=1

the whole code will take about 87 words...

Archilochus
- 16th January 2005, 21:38
Nice example code Steve!

You can shave off a tiny bit more by changing:

IF amountofpulsout > 0 THEN


To:

IF amountofpulsout THEN

Since when you're just checking if the variable is any value more than 0, if it is more than 0, the IF...THEN will return true.

Arch

mister_e
- 16th January 2005, 21:59
yeah for sure, we can also remove the FOR TO NEXT loop and place a simple IF THEN at the end or do few assembly language lines too to save few more words. There's so many way to save codespace.

Programmednew
- 17th January 2005, 00:16
I changed the code to

DEFINE OSC 4
Input PORTA.2
High PORTA.2
Pause 50
Input PORTB.2
Input PORTB.3
Input PORTB.4
Input PORTB.5
Input PORTB.6
Input PORTA.4
Horncount VAR BYTE
CounterStop VAR BYTE
SWITCH:
Pause 250
IF PORTA.4 = 1 Then End
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 9: GoTo Horn_Loops
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 0: GoTo Horn_Loops
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 1: GoTo Horn_Loops
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 2: GoTo Horn_Loops
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 3: GoTo Horn_Loops
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 4: GoTo Horn_Loops
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 5: GoTo Horn_Loops
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 6: GoTo Horn_Loops
IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 7: GoTo Horn_Loops
IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 8: GoTo Horn_Loops
GoTo SWITCH
Horn_Loops:
For Horncount = 0 TO CounterStop
PulsOut PORTA.2, 50000
Pause 500
Next Horncount
End

It did compile but I have another problem now. Its is with the circuit. I have attached a picture of the schematic. In it with with everything hooked up U2 overheats. Without the PIC in it it has a five volt output.

mister_e
- 17th January 2005, 00:27
You revert PIC voltage PIN... VSS= Ground VDD=5Volt And now your PIC is probably burn!!!!

+ you can't connect two 7805 output together...

1000uF at the output of the regulator is unusefull. Can be good to place them at the input (ignition switch). at the output i suggest 10uF(tantalum or 47uF electrolitic) + 0.1uF ceramic.

I'll also suggest to tie to ground unused input to avoid electric interference from any external car noise(common CMOS handling... also avoid to burn PIC). Be sure of your TRIS define for the unused pins... must be set as input.

mister_e
- 17th January 2005, 00:36
and the IF THEN statement will have to be modify.


IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 9: GoTo Horn_Loops

to something like that

IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then
CounterStop = 9
GoTo Horn_Loops
endif


in case you don't modify, PBP will not execute the GOTO Horn_Loops statement.

Input/output statements are great, but i'll prefer to use only TRIS and comment it on the right like



TRISA=%10101010 'PORTA definition
'Input on bits : 1,3,5,7
'output on bits : 0,2,4,6


it's my own opinion. I can agree it can be a bit more readable when using Input/Output statement.

NavMicroSystems
- 17th January 2005, 02:52
Originally posted by mister_e
You revert PIC voltage PIN... VSS= Ground VDD=5Volt And now your PIC is probably burn!!!!

+ you can't connect two 7805 output together...

1000uF at the output of the regulator is unusefull. Can be good to place them at the input (ignition switch). at the output i suggest 10uF(tantalum or 47uF electrolitic) + 0.1uF ceramic.

I'll also suggest to tie to ground unused input to avoid electric interference from any external car noise(common CMOS handling... also avoid to burn PIC). Be sure of your TRIS define for the unused pins... must be set as input.

Programmednew

please forgive me

Steve is absolutely right, your PIC is most likely dead
and this is good for a 16F84.
There are far better chips at much lower prices available.

As you now have got to get a new one anyway this is
a perfect moment to think about a re-design of your hardware.
(This will reduce the total cost of the circuit dramatically!)

Sorry again, but your initial design wouldn't have worked anyway.
In addition to what Steve already has mentioned,
there should be Pull Down Resistors on RB2,3,4,5,6 and RA4

If you need help with the re-design let us know.

Steve

Yet another case where someone started with 16F84 where life could have been so easy.

Programmednew
- 17th January 2005, 02:53
The chip did burn and the reason why is that I have a cousin that knows a lot about electronics and me not knowing a lot I sent the circuit off to him. He sent it back and said it's fixed. So I wired it up. I think he just wasn't thinking but anyways thank you for all the help and I mean that, I am really thankfull. I have the hex file thanks to y'all and will be getting another PIC. If I have anyother problems I will come back to this thread.

mister_e
- 17th January 2005, 04:54
I agree with Ralph on that issue... Let us know what's happen, if we can help you on anything else. Let us suggest you PIC16F627 or PIC16f628. If you still want to do your project, PIC12F508 can be the cheapest FLASH PIC you can use for your need, and you'll not need any external crystal.

Give some *words* to your cousin...

Ralph


Steve is absolutely right, your PIC is most likely dead
and this is good for a 16F84.
There are far better chips at much lower prices available.

Hehe... seems you really don't like those F84. I have to agree to the better chips at much lower price. Maybe one day Microchip will stop the production... they're still bringing$$$


In addition to what Steve already has mentioned,
there should be Pull Down Resistors on RB2,3,4,5,6 and RA4


Indeed, just forget/skip when i saw *virtually blown* PIC with VSS VDD inverted. Next design could be also made with internal pull up.

BTW Programmednew welcome to the forum and in the PIC world!!!

Warrier
- 17th January 2005, 19:49
Hi Programmednew:

Besides all that Steve and Ralph suggested don't forget that the PIC chips don't put out lot of current to drive a relay directly. Absolute rating is only 25mA so unless you are using a hi sensitivity type you're going to kill the output of the PIC pretty fast! Talk to your cousin about this also.


STEVE:

It looks like he needs more I/O than the F508 can get him even if he uses IntRC clock!

Using F628 or F630 would be cheaper for him but then he shouldn't forget the CMCON settings! F630 has 4 lesser pins to boot.

He can replace the 7805 coming out of his ignition switch with a series resistor and a 5Vzener, I would assume....or use two 1N4148 diodes to configure an OR gate.

__warrier

NavMicroSystems
- 17th January 2005, 20:13
Just to summarize:

An 8pin pic running on INTRC OSC would perfectly fit with it's 6 I/O-pins.

1 pin for external switch / ignition detection
1 pin to drive the relay

leaves 4pins for "Config options"
that gives 16 different possibilities !

>>He can replace the 7805 coming out of his ignition switch
>>with a series resistor and a 5V zener.
this is absolutely correct, but
a simple voltage divider consisting of two resistors would do the job as well

Let Programmednew come back with his requirements and we will draw a working schematic for him.

The final board (including the relay) will fit in a matchbox.

mister_e
- 17th January 2005, 20:25
Programmednew, can you access to the horn wire directly to the stearing collumn instead, most of them are negative. In this case most car alarm/remote starter use a simple transistor npn TO92 package to drive it directly.


this is absolutely correct, but
a simple voltage divider consisting of two resistors would do the job as well


Can also be a simple resistor (let's say 1k-10K) in serie with the ignition wire(thanks to the internal diode of PIC). When you turn off the key, this wire will give enough *low level signal impedance* to avoid PIC read a floating signal.

Warrier
- 17th January 2005, 20:31
Ralph:

So long as our friend knows that in an 8pin device, he is forced to use the MCLR pin as the input and ports are GPIOs rather than PORT x etc.

__warrier

mister_e
- 17th January 2005, 20:36
well this is why we offer our service to plan his next code/schematics.

NavMicroSystems
- 17th January 2005, 20:36
OK, Guys,

let's stop here and wait for Programmednew to come back with his requirements.

Programmednew
- 21st January 2005, 01:48
I'm back. My current circuit didn't work and was to big. I need your help on designing a whole new circuit. What I need it to do is when 12VDC is put in to the circuit it needs to work a relay that uses the same 12VDC out of its point to produce pulses to honk the horn relay. I need the beeps to be adjustable from 1 to 8-10 beeps. Then I need a external switch that if it is on then the circuit won't put anything out. Then I need to monitor the ignition switch. If it is on then the circuit should not put anything out. That is it for the requirements. I am sooooo thankful that I found this forum and that ya'll are on it. I thankyou for your help soooo much.

NavMicroSystems
- 21st January 2005, 13:19
Programmednew

attached is a qiuck draft of a schematic and Board Layout.
(It will fit in a Matchbox)


regards

Ralph

NavMicroSystems
- 21st January 2005, 13:26
Attached is a Board Layout

regards

Ralph

mister_e
- 21st January 2005, 14:53
Programmednew

Ralph idea is quite good. But car horn need more than 300mA. So be carefull on your relay choice. Most car horn will need up to 5-7 amps. In thise case, most relay, that i know, will need more than 25mA to drive them. Be carefull on that to avoid blow your PIC output.

BTW i attach my own version.

Ralph
i don't want to start any kind of controversy here. Agree my apologies on that issue.

NavMicroSystems
- 21st January 2005, 15:14
Steve,

I agree there are "many" possible ways.

I was assuming (and according to the "original" schematic) there is another relay that drives the horn.
(I just wanted to make it as small as possible as I had promised it would fit in a matchbox)

I had the "IGNITION Bypass" Diode in mind to free up another Port to double the options.

regards

Ralph

mister_e
- 21st January 2005, 15:21
Ralph,

If Programmednew can access the horn wire directly under the dash at the column stearing it will be easier. Most of them are negative and they drive an external relay to drive the horn. In this case, he will be able to remove the relay and keep only the transistor + diode.

OR skip the relay idea and use a MOSFET to drive in positive the horn is a common use in some car stuff.

Programmednew

If you can provide your car model and year, i can provide you the color of the horn wire at the stearing... if i know you car model.

mister_e
- 21st January 2005, 21:05
Here's a code for you to start.

Programmednew
- 22nd January 2005, 00:16
The model is a ford 350 and year 2000. I like mister_e's idea. I also need to know whether or not the horn wire is positive. I also need help in the code you sent me.

AmountOfPulses = GPIO & $0F ' Get only value of GP<3:0>

I assume that it reads those pins and stores the value in the variable. I need to know how it does that and how does it adjust from 0 to 16 pulses with only three switches. I can access the wire from under the dash.

P.S. My Name is Albert

mister_e
- 22nd January 2005, 00:31
Ford F-350 must be BLUE (around 20 AWG) right to the stearing column... as i remind in a black 5-8 pin connector, the last one right to the stearing column. Just remove the panel under the stearing and look at this. As i remind it's in the same connector as the cruise control too (if you have)

Under the dash you can acces also
1. 12V = Yellow or Green (sometimes green/black) (14-16 AWG)
2. Ignition = RED with GREEN tracer, (sometimes green/something)

Be careful when testing the horn wire, use multimeter or logic probe. AND it's a negative signal to activate the horn.



AmountOfPulses = GPIO & $0F ' Get only value of GP<3:0>

I assume that it reads those pins and stores the value in the variable. I need to know how it does that and how does it adjust from 0 to 16 pulses with only three switches.

with my circuit, you're using 4 switches. In binary, it gives you 16 possibility

DIP PULSES
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15

NavMicroSystems
- 22nd January 2005, 00:46
Originally posted by mister_e

0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15

There are only 10 types of people:
Those who understand binary, and those who don't ...

;-)

mister_e
- 22nd January 2005, 00:49
LOL !

That's why i really love your signature ! ;-)

NavMicroSystems
- 22nd January 2005, 00:58
Steve,

you have "won" the price.

As your design is preferred I'll leave the further support with you.

;-)

Programmednew
- 22nd January 2005, 01:20
I got Ralph's signature but clearly I am not a binary thinking guy. Great Idea for the binary switch but how is the new circuit hookup ( I just don't want to get this wrong) and instead of the relay I would like to just use the transistor and diode and only if you think it will handle it.

P.S What kind of schematic drawing software are you using.

NavMicroSystems
- 22nd January 2005, 01:26
I'm using EAGLE

you can download a free version at

http://www.cadsoftusa.com/

mister_e
- 22nd January 2005, 01:30
The circuit i provide you will handle it. As i said, the stearing column activate an external relay wich is need less than 60mA

I use P-CAD.

Programmednew
- 22nd January 2005, 02:23
Ok Thankyou. I will just use the transistor. Will let you know

NavMicroSystems
- 23rd January 2005, 15:21
Originally posted by mister_e


Ralph idea is quite good. But car horn need more than 300mA. . .



Steve

B.T.W.

The OMRON Relais are good for 3 Amps

I used this one with "my design" because I have about 60pcs. in stock.

See: Relais Specs (http://www.mouser.com/catalog/620/1067.pdf)

mister_e
- 24th January 2005, 01:27
Ralph

I've to do some apologies for that... sorry Ralph. I was refering to the Digikey website, in the contact rating column they said 300ma. Forgeting the voltage rating and read the whole datasheet.

BUT, maybe i'm blind on this G6K-2P-DC5

http://rocky.digikey.com/WebLib/Omron%20Web%20Data/G6K.pdf

contact rating 1 amp @ 30VDC. let's say 2.5 amp @ 12Volts.

DPDT with contact in parrallel... can be good up to 5 amps

It was my 2 cents ;)

Programmednew
- 25th January 2005, 03:18
I like using your circuit but there is one problem. The programmer I use is the one attached in the picture, it hooks to a serial port (I didn't want to spend a lot after buying PIC Basic Pro). The hex burner I use is ICProg and it doesn't handle that chip. Any suggestions. I haven't ordered the parts yet so if you need to change the circuit then it's ok.

mister_e
- 25th January 2005, 03:39
Is your device support one of the following?

PIC12F629
PIC12F675
PIC12F683

But i think, not tested yet, you can program 12F508 with the PIC12C508 protocol.

Programmednew
- 25th January 2005, 03:43
Yes the PIC12F629 and the PIC12F675. Which one do I use and is there anything else before I order the parts.

mister_e
- 25th January 2005, 03:45
You can use one or another. As you wish. There's nothing else to add. The only thing we will have to do is to modify the code, schematic will be the same.

Programmednew
- 25th January 2005, 03:46
Ok, great I will send off for the parts tomorrow.