Build Your Own Clone Message Board

It is currently Thu Aug 11, 2022 8:17 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: relay bypass switch
PostPosted: Thu Aug 07, 2014 2:11 pm 
Offline
Site Admin
User avatar

Joined: Sun Jan 22, 2006 1:39 pm
Posts: 5639
Location: Moses Lake, WA
This is code for use with a BASIC based compiler. It's intended for use with PIC12C508/509/608/609 or 12F508/509/608/609 microcontrollers, but could be modified to work with other mcu's. GPIO.0 = pin 7 of the PIC on around to GPIO.4 which would be pin 3. GPIO.5 would be pin2, but we aren't using it. You could swap the variables around if you need to.

This is for use with either a single latching or double latching relay such as the TQ2-L-5V or TQ2-2L-5V. If you find that the relay is in bypass with the LED is on, just switch the LATCH0 and LATCH1 variables.

Code:
LATCH0 var GPIO.1
LATCH1 var GPIO.2
LED var GPIO.4
MUTE var GPIO.0
PB Var GPIO.3      ' Alias GPIO.3 to push button
LEDon var bit
LEDoff var bit

    LEDoff = 0         
    LEDon = 1

   
    ANSEL = 0 ' Set all digital
    CMCON0 = 0 ' Analog comparators off
    TRISIO = %11001000
    LED = 0
    LATCH0 = 0
    MUTE = 0
    LATCH1 = 1              'initiate program in bypass with LED off
   
    pause 10                'pulse to initiate latch1 on
    LATCH1 = 0              'bypass then turn off to save power
   
   

main:
    if PB = 0 then
        MUTE = 1                    'mute while switching occurs
        pause 40                    'mute & debounce
            gosub LEDstatus
   
    pause 10                        'allow 10ms pulse to actuate relay
    LATCH1 = 0                      'end pulse to relay to save power
    LATCH0 = 0
    pause 40                        'allow another 40ms to mute
    MUTE = 0
    gosub switchrelease
    pause 30                        'debounce
    endif
   
goto main
End

LEDstatus:                          'toggle LED status &  bypass
    if LED = 1 then
       
        LED = LEDoff
        LATCH0 = LEDoff
        LATCH1 = LEDon
    elseif LED = 0 then
        LATCH1 = LEDoff
        LED = LEDon
        LATCH0 = LEDon
       
    endif
return


switchrelease:                  'wait for footswitch to be released
    do until PB = 1
        pause 5
    loop
return

_________________
*patience is a virtue*

Please do not PM me. email is prefered. keith@buildyourownclone.com


Top
 Profile  
 
 Post subject: Re: relay bypass switch
PostPosted: Thu Aug 07, 2014 2:18 pm 
Offline
Site Admin
User avatar

Joined: Sun Jan 22, 2006 1:39 pm
Posts: 5639
Location: Moses Lake, WA
Here's the HEX code for the program. If you use this, you must use a PIC12F609 and you must use my pinout.

Code:
:020000040000FA
:100000002828C301C200FF30C207031CC307031C1A
:1000100023280330C100DF300F200328C101E83E50
:10002000C000C109FC30031C1828C007031815289C
:10003000C0076400C10F152840181E28C01C2228C4
:1000400000002228080083130313831264000800B1
:100050005810D81483169F0183129A018316C83052
:100060008500831205128510051005150A30012040
:100070000511640085194A280514283001204D20F7
:100080000A300120051185102830012005106D204F
:100090001E300120392863004B286400051E5D28AE
:1000A00058180516581C051258188514581C851028
:1000B000D8180515D81C05116C286400051A6C2881
:1000C00058180515581C0511D8180516D81C051206
:1000D000D8188514D81C8510080064008519732869
:0800E000053001206D28080025
:02400E00CC3FA5
:00000001FF

_________________
*patience is a virtue*

Please do not PM me. email is prefered. keith@buildyourownclone.com


Top
 Profile  
 
 Post subject: Re: relay bypass switch
PostPosted: Thu Aug 07, 2014 2:27 pm 
Offline
User avatar

Joined: Tue Jul 31, 2012 11:33 pm
Posts: 159
Wow, it even has a switching mute. Thanks!
I'mm going to have to dig up my PicKit2...


Top
 Profile  
 
 Post subject: Re: relay bypass switch
PostPosted: Thu Aug 07, 2014 4:26 pm 
Offline
Site Admin
User avatar

Joined: Sun Jan 22, 2006 1:39 pm
Posts: 5639
Location: Moses Lake, WA
I'll get a schematic up for this asap.

_________________
*patience is a virtue*

Please do not PM me. email is prefered. keith@buildyourownclone.com


Top
 Profile  
 
 Post subject: Re: relay bypass switch
PostPosted: Fri Aug 15, 2014 7:22 am 
Offline
User avatar

Joined: Thu Mar 15, 2012 9:20 pm
Posts: 1707
Sounds like fun. I really know nothing about this stuff but I do have the ability to flash/program (whatever you call it) PIC's at work. Maybe I'm about to learn something.

_________________
MIL-TDD-41


Top
 Profile  
 
 Post subject: Re: relay bypass switch
PostPosted: Tue Apr 14, 2015 3:43 am 
Offline

Joined: Tue Apr 14, 2015 3:35 am
Posts: 1
there are interrupt programs for making the mcu recognize a button, and perform Pulse Width Modulation, which is exactly what you seem to want to do. There is probably something very similar to this for Arduino. ???

_________________
leather jacket


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group