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.
Bookmarks