Hi there
Yes 12V to relay and 5V to pic
flyback diode
If I change the code I can get the relay to go on and off
I have used the 16f876's never had a problem like this
am i not doing something wrong with the configuration in MP Lab
I am using microcode studio with PBP
Many thanks it works..
It is sensing now..
the relay chatters when I get it on
Is it to do with the external MCLR
There is an error message that comes on it says that ICD can not program internal clock and internal MCLR at same time any way to sort it out I have to use the on board clock
I'm a sucker for simplicity.
Try this;
When you press the switch it grounds GPIO.0.Code:GPIO.4 ----/\/\/\---|<|----+5V. LED 10K GPIO.0 --|--/\/\/\---+5V |--switch---GND.
Does this work?Code:@ device pic12F629, intrc_osc_noclkout, wdt_on, mclr_off, protect_off DEFINE OSCCAL_1K 1 DEFINE OSC 4 RELAY VAR GPIO.4 ' relay output Pswitch VAR GPIO.0 ' switch input TRISIO = %00000001 ' GPIO.0 input, rest outputs WPU = 0 ' input pull-ups disabled CMCON = 7 ' disable comparators PAUSE 10 ' POR delay MAIN: RELAY = ! Pswitch ' Relay pin = the opposite of Psiwtch pin GOTO MAIN END
Switch to ground. Definately the better way to go.
I might suggest a different Main loop though.Those pesky R-M-W'sCode:MAIN: IF RELAY = Pswitch THEN RELAY = ! Pswitch ' Relay pin = the opposite of Pswitch pin ENDIF PAUSE 20 GOTO MAIN END
<br>
DT
Hi all out there
The last time I did a 8 pin pic was 10 years ago
The problem was to do with the weak pull up
I really want to thank all out there
Bye for now
Yes, in fact, from my understanding, it reads the content of the output-latch.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Is it safe?
Well, as far as doing damage, it's perfectly "Safe".
In fact the chip "reads" the state of the OUTPUT pin, everytime you you change the state of any pin on the same port.
The only un-safe part, is if you don't take the R-M-W problems into account.
Can really mess with the program.
<br>
DT
Bookmarks