Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

one switch three relays....help ??

Status
Not open for further replies.
Mike said:
I would skip the 8-pin 12F675 and recommend an 18-pin 16F628A and the 8-pin 12F683, the latter with 2-kwords program memory, an 8-MHz INTOSC, and a Timer2 peripheral...

Kind regards, Mike

The 12F683 is 30% more expensive than the 16F628A to buy in the UK. :(
 
eblc1388 said:
The 12F683 is 30% more expensive than the 16F628A to buy in the UK. :(

I was offering what I think is a much better alternative to the 8-pin 12F675...

Granted, the 18-pin 16F628A is "a bargain"...

Regards, Mike
 
Ok guys, in the hope that this might help push you newcomers in the right direction, here's a quick-n-dirty 8-pin 12F683 solution/concept... Note: code is "untested", simply thrown together while waking up with my java this morning...

A switch press provides a 40-msec 500-Hz beep for audible feedback and cycles through relay 1, relay 2, relay 3, and relays off...

The code is much more elaborate than need be, using 1.0-msec interrupts and switch code from a recent project that was really designed to process up to 8 switches in parallel in the ISR (interrupt service routine) including the use of a 5-bit vertical counter to debounce switches independantly... Once you look past the ISR code you'll find simple initialization code and the main program switch/relay logic code...

Have fun... Regards, Mike

Code:
;
;  sequence relay outputs through the following values after
;  a switch press
;
;  00000000 relays off
;  00000001 relay 1 on (GP0)
;  00000010 relay 2 on (GP1)
;  00000100 relay 3 on (GP2)
;
LOOP    btfss   SWITCH,0        ; switch operated?                |B0
        goto    LOOP            ; no, branch, else                |B0
        bcf     SWITCH,0        ; clear switch latch bit          |B0
        clrc                    ; clear Carry                     |B0
        movf    OUTPUT,W        ; relays off (00000000)?          |B0
        skpnz                   ; no, skip, else                  |B0
        setc                    ; set Carry                       |B0
        rlf     OUTPUT,W        ; rotate left                     |B0
        andlw   b'00000111'     ; 000, 001, 010, or 100           |B0
        movwf   OUTPUT          ; update relay output variable    |B0
        movf    GPIO,W          ; get GPIO port data              |B0
        andlw   b'11111000'     ; mask off relay output bits      |B0
        iorwf   OUTPUT,W        ; pick up new relay output bits   |B0
        movwf   GPIO            ; update relay outputs            |B0
        goto    LOOP            ; loop forever                    |B0

;******************************************************************
 

Attachments

  • 12F683 Relay Controller.JPG
    12F683 Relay Controller.JPG
    53.1 KB · Views: 460
  • 12F683 Relay Controller v1.txt
    12.1 KB · Views: 233
Last edited:
eblc1388 said:
Your objective is to learn PIC programming and build the device to control the relays. Don't expect this to happen within short period of time as there will be a steep learning curve, weeks perhaps. There are more informations in the sticky of this forum and please go and have a look.

Actually, based on the OP, I believe his objective is to control the relays. the PIC is simply one means to an end. I think it is hard to justify all that goes into learning PICs for a single project (especially this one). However, if other projects are envisioned, then all that trouble to learn will pay off.

to those who suggest bigger PICs, lets keep in mind that this project needs 1 input pin, 3 output pins and all of a couple hundred instructions. I'd buy (or sample from microchip) the cheapest one I could find. Basically, I don't think there is a PIC that won't satisfy the requirements.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top