Dimmer Circuit


Closed Thread
Results 1 to 10 of 10

Thread: Dimmer Circuit

Hybrid View

  1. #1

    Default Dimmer Circuit

    Hi,
    I make a Dimmer Circuit with Pic16f870,the Zero Detection work,all work fine,but I have a Problem.
    I want to Send with my VB Software Data to my Pic to Increase and Decrease my Light Bulb with a Scrollbar.
    I do this for example:
    Visual Basic Part.

    Private Sub Form_Load()
    VScroll1.Min = 85
    VScroll1.Max = 10
    VScroll1.Value = 10
    Private Sub VScroll1_Change()
    TxtRXLoops.Text = VScroll1.Value
    end sub

    Private Sub VScroll1_Change()
    MSComm1.Output = "!" & Chr(Val(CmbAdresse.Text)) & Chr(VScroll1.Value) _
    & Chr(13) & Chr(10)
    Sleep 10

    End Sub

    This is my Pic Part:

    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds
    DEFINE HSER_CLROERR 1
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''Communication Variable'''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
    RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
    TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''
    ADCON1 = 7
    TRISC=0
    TRISA.0=1
    DataIn var byte [3]
    Adresse var byte
    ZeroDetect var PortA.0

    low PortC.0
    SOUND PORTB.1,[124,100]
    low PORTB.0 '''''''''''''''''''''''''''''''''''''''''''''RS485 Input Data Enable'''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
    Delay_1 = 8500
    MainStart:
    Adresse = $1

    POS_FLNK:IF ZeroDetect = 0 Then POS_FLNK
    NEG_FLNK:IF ZeroDetect = 1 Then NEG_FLNK

    PauseUs Delay_1
    high PortC.0
    PauseUs 100
    low PortC.0
    hserin [WAIT("!"),STR Datain\5]

    goto CheckAdr
    Discard:
    Delay_1 = Datain[1] * 100
    goto MainStart

    CheckAdr:

    AdresseIn = Datain[0]
    if Adresse = AdresseIn then RcvData

    GoTo MainStart


    RcvData:


    IF Datain[2] = 13 Then CheckEnd

    Goto MainStart
    CheckEnd: ' CheckEnd Routine

    IF Datain[3] = 10 Then Discard

    Goto MainStart

    I Send from VB Values between 10 and 85,in Pic I Multiplicate this with 100 and then I have values between 1000 and 8500.
    I think but that my Hserin loop not good is,I try with
    hserin 1,mainstart,[WAIT("!"),STR Datain\5]
    but I think that 1 millisecond to much is :-(
    This dont work !
    Please I need Help,thanks.

    Regard Pesti.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    What is Delay_1 ?

    Byte or WORD?

    if Byte, then it can not have any value above 255 as you know.

    It must be a WORD to carry a value between 1000 and 8500.


    ----------------------------------

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Delay_1 is a Word,I try now something more simple:

    INCLUDE "modedefs.bas"
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds
    DEFINE HSER_CLROERR 1
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''Communication Variable'''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
    RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
    TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''
    ADCON1 = 7
    TRISC=0
    TRISA.0=1
    DataIn var byte
    ZeroDetect var PortA.0
    Delay_1 var word
    low PortC.0
    SOUND PORTB.1,[124,100]

    low PORTB.0 '''''''''''''''''''''''''''''''''''''''''''''RS485 Input Data Enable'''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
    low PortC.0
    Datain = 10
    MainStart:
    hserin [Datain]
    Delay_1 = Datain * 100
    POS_FLNK:IF ZeroDetect = 0 Then POS_FLNK
    NEG_FLNK:IF ZeroDetect = 1 Then NEG_FLNK
    PauseUs Delay_1
    high PortC.0
    PauseUs 100
    low PortC.0
    GoTo MainStart


    This work the light is now Increase and decrease,but the Bulb dont stay on.

    Regard
    Pesti

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Ok Thanks I find the Way.
    Maybe someone need this example too:

    INCLUDE "modedefs.bas"
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds
    DEFINE HSER_CLROERR 1
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''Communication Variable'''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
    RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
    TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''
    ADCON1 = 7
    TRISC=0
    TRISA.0=1
    DataIn var byte
    ZeroDetect var PortA.0
    Delay_1 var word
    low PortC.0
    SOUND PORTB.1,[124,100]

    low PORTB.0 '''''''''''''''''''''''''''''''''''''''''''''RS485 Input Data Enable'''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
    low PortC.0
    Datain = 10
    Delay_1 = 9000
    MainStart:
    'hserin [Datain]


    POS_FLNK:IF ZeroDetect = 0 Then POS_FLNK
    NEG_FLNK:IF ZeroDetect = 1 Then NEG_FLNK
    PauseUs Delay_1
    high PortC.0
    PauseUs 500
    low PortC.0
    hserin 0,MainStart,[WAIT("!"),Datain]

    Delay_1 = Datain * 100

    GoTo MainStart

    Regard
    Pesti

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi,:-)

    Another question have I,did I have a chance to dimming two or more bulb on one PIC.
    While I find that is a little problem with the Delay method.

    POS_FLNK:IF ZeroDetect = 0 Then POS_FLNK
    NEG_FLNK:IF ZeroDetect = 1 Then NEG_FLNK
    PauseUs Delay_1
    high PortC.0
    PauseUs Delay_2
    high PortC.1
    PauseUs 500
    low PortC.0
    low PortC.1
    hserin 0,MainStart,[WAIT("!"),STR Datain\3]
    goto CheckAdr
    Initialize:
    Delay_1 = Datain[1] * 100
    Delay_2 = Datain[2] * 100

    GoTo MainStart

    Can not work with two delays !?

    Regard
    Pesti

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Hello,

    Did someone had the same Problem like Me.

    I try all methods but I can not Dimm two Outputs.

    Please I need Help or just a answer if this can work with two Channels.

    Thanks.

    Regard
    Pesti

Similar Threads

  1. Circuit Design Question
    By bradb in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th August 2009, 08:18
  2. Ideas on ir-code for dimmer
    By tirithen in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th February 2009, 23:22
  3. Short circuit portection circuit ?
    By iugmoh in forum Schematics
    Replies: 1
    Last Post: - 21st December 2008, 21:33
  4. Circuit reliability issues
    By hkpatrice in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd November 2007, 14:55
  5. Replies: 3
    Last Post: - 29th October 2006, 09:16

Members who have read this thread : 0

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

Posting Permissions

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