12F683 Light Dimmer Problem (SOLVED)


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem

    Sorry this took longer than expected. Hopefully I did not make any mistakes creating the schematic after the fact but I am pretty sure I did not. I'm using diptrace to produce the schematic and I've only used it a few times. Here is the picture of my schematic and code. This is working really good I've had it on for several days and have not seen anything going wrong however I am open to suggestions/criticism if anyone spots anything and wants to comment please feel free.
    Regards
    David

    Code:
        ' LightHouse Lamp dimmer
        ' ======================
        '
        ' File name : Lighthousemorse.pbp
        ' Programmer : David C. Bittner
        ' Date : 2020-07-02
        ' Device : PIC12F683
        '
        ' This program is use to dim intensity of an AC line load
        ' like lamp, motor and other.  Developped for 60 Hz line.
             '
        ' The software need :
        '     1. A full wave signal from the AC line on GP2/INT
        '
    TRISIO = %00101101        ' All input except GP1 GP4  GP1 out to TRIAC
    OPTION_REG.7=0            ' Enable pull-ups
    OPTION_REG.6=1            ' Interupt on rise
    CMCON0 = 7                ' Disable analog comparator
    ANSEL=0                   ' Disable analog converter
    Triac  var GPIO.1 ' Output to TRIAC gate
    ACLine var GPIO.2 ' Input for the FullWave rectify AC line
    morse  var GPIO.5 ' used to check switch if 1 operate as dimmer, 0=morse out
    outp   var GPIO.4
        '
        '        Variable definitions
        '        ===================+    
        '
    TriacDelay var Word
    counter var word
    timercount var word
    updown var bit
    unit var word
    counter=0
    unit = 500
    
    TRIAC=1  'TEST TO MAKE SURE LIGHT COMES ON
    PAUSE 1000  'LEAVE IT ON FOR 1 SECONDS
    triac=0
    pause 5000   ' wait 5 seconds before starting
    triacdelay=8000
    ON INTERRUPT GOTO ACDetect
    INTCON=%10010000 ' Enable interrupt on GP2/INT change
    
    updown=1       '1=dim to bright, 0=bright to dim
    start: 
       '
       ' do what we need to in this routine if more
       '
       if morse=1 then
          triac=1
          outp=1
       else
          outp=0
          triac=0
          gosub morsecode
       endif
    goto start
    morsecode:
         pause 2000
         triac=1     ' W
         pause 400   'dot 
         triac=0
         
         pause 400
         triac=1
         pause 850   'dash
         triac=0
         
         pause 400
         triac=1
         pause 850   'dash
         triac=0
         
         pause 800
         triac=1     'E
         pause 400   'dot
         triac=0
         
    return    '
        '       ACDetect
        '       --------
        '
        ' Interrupt routine called by ACLine (GP2/INT) pin state change
        '
    disable
    ACDetect:
        'pauseus 240
        counter=counter+1
        if counter==5 then
            counter=0
            if updown==1 then
                triacdelay=triacdelay-100
                if triacdelay==-100 then
                    'triacdelay=8000
                    updown=0
                endif
            endif 
            if updown==0 then
                triacdelay=triacdelay+100
                if triacdelay==8100 then
                    updown=1
                endif
            endif 
        endif
        triac=0    
        pauseus triacdelay
    INTCON.1=0
    resume
    enable
    Attachment 8898
    Name:  Lighthouse.jpg
Views: 2997
Size:  128.6 KB
    Last edited by DavyJones; - 7th July 2020 at 13:41. Reason: wrong picture

  2. #2
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem

    Can one of the mods change the title thread from "12F683 Light Dimmer Problem" to "12F683 Light Dimmer Problem (Solved)" I think that would be appropriate. Not sure if you can or not.
    Regards
    David

  3. #3
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem (SOLVED)

    thank you
    David

  4. #4
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem (SOLVED)

    So sorry on the original schematic I had the gate on the triac on the wrong pin. The gate is on pin 3 not pin 2
    Name:  Lighthouse.jpg
Views: 2983
Size:  128.5 KB

    David
    Attached Images Attached Images  
    Last edited by Ioannis; - 7th July 2020 at 22:23.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem (SOLVED)

    I see you have corrected the image, right?

    Ioannis

  6. #6
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem (SOLVED)

    yes I corrected it and had to upload it again.

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Light Dimmer Problem (SOLVED)

    CAP100 is showing the wrong polarity.

Similar Threads

  1. Light dimmer not working
    By Normnet in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 13th January 2013, 17:26
  2. Light dimmer problem
    By FromTheCockpit in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 9th July 2012, 12:36
  3. Replies: 12
    Last Post: - 15th May 2011, 23:06
  4. 12F683 GPIO.3 problem
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 30th October 2009, 08:43
  5. 50hz sync for light dimmer
    By tirithen in forum General
    Replies: 2
    Last Post: - 6th September 2008, 19:29

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts