Serial VB 2005 pic 16f877a problems


Closed Thread
Results 1 to 29 of 29
  1. #1
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default Serial VB 2005 pic 16f877a problems

    Hi I m back with a new project. Thank you for all you help and support on the slot car timmer. I am working on a simple thermostat withthe 1620 chip and it works great with the lcd out. I wanted to get it to the pc so I wrote a small program in VB2005 and it took hours just to get them talking but I did it... except the pic is not listening. I can send to vb fine and read it but when I try and send back to the pic it does not get it. I can see the PC trying to send out on the scope but it does not get stored in my pic variable. I even ran a wire from the tx side of the pic to the rx and still nothing. The pic is sending but not recieving.
    here is some of my code
    I decalred the variable as a word and later as byte
    I am using a max 232 converted and like I said I can see both signals on the scope
    I am sure the pc it sending the code i think
    I am just trying to get the pc to tell the pic to turn on a fan when it gets too hot.
    YES I know there are many simpler ways to do this directly threw the pic but I want to use the PC.

    serout portd.3,t2400,[#temp]
    serin porta.0, t2400,pcsig ' my data in variable
    if pcsig > 1 then high porta.1 ' pc writes 100 so even if the pic gets anything it should fire


    thanks again
    Snap
    Beer is proof that God loves us and wants us to be happy.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's quite a few culprit in VBExpress, that would be really nice if you could post your VB and the whole PIC code here.

    As you're using PORTA... make sure you have disabled the ADCs

    PortA Doesn't Work & Common 8-Bit PIC® Microcontroller I/O Pin Issues (TB3009)
    http://www.picbasic.co.uk/forum/showthread.php?t=561

    Any specific reason why you don't use the built-in PIC USART?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Snap View Post
    I can see the PC trying to send out on the scope but it does not get stored in my pic variable. I even ran a wire from the tx side of the pic to the rx and still nothing. The pic is sending but not recieving.
    Snap
    I have found this http://www.serial-port-monitor.com/index.html utility extremely useful while doing anything with VB and the serial port.

    Also, if you have another serial port, try and read what your VB code is in fact sending although serial port monitor would do the same anyway.

    Regards,

    Anand

  4. #4
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Don't ever leave this forum mister_e, my life depends on you being here sharing your knowledge. I think I speak for everyone.

  5. #5
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Smile

    Hello again, Ok I switched off the adc'd with adcon1 statement.
    And that must have done something because now everytime I start the program it locks up at the display temp part.
    If I remove the serin code it works (just the program not the recieve signal from the PC)
    If I remove the wire from the serin port to the rx on the max 232 adapter it works
    This is all when the PC is not even plugged in the the max 232
    the wire seems to be shorting out the program or the signal is screwing it up
    To me the USART seems to be more work then a simple serin command why would I use it?
    here is the pic code

    Code:
    Include "MODEDEFS.BAS"
    DEFINE LCD_DREG  PORTB
    DEFINE LCD_DBIT   0
    DEFINE LCD_RSREG  PORTB
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG  PORTD
    DEFINE LCD_EBIT 7
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATUS 50
    ADCON1=%00000111
    
    '
    RST var portd.2
    DQ var portd.0
    CLK var portd.1
    temp var word 'storage for temperature
    pcsig var word
    
    
    '
    low rst 'reset 1620
    '
    lcdout $fe,1,"Temp in Degrees C"
    
    ' Main loop
    mainloop:
    RST = 1'enable device might be high
    Shiftout DQ,CLK,LSBFIRST,[$ee] 'send read command
    RST = 0 ' reset device
    Pause 1000 ' wait for conversion to compleate
    '
    RST = 1 ' SAA
    Shiftout DQ,CLK,LSBFIRST, [$aa] ' send read command
    Shiftin DQ,CLK,LSBPRE, [temp\9]'read 9 bits temp
    RST = 0
    '
    lcdout $fe,1,dec(temp>>1), ".", dec(temp.0*5), " Degrees C"
    pause 1000
    serout portd.3,t2400,[#temp]
    pause 1000
    serin porta.1,t2400,pcsig
    if pcsig > 1 then high porta.1
    
    lcdout $fe,1,pcsig,"pcsig"
    pause 1000
    
    goto mainloop
    
    END

    Here is the VB code
    I ommitted a class
    Code:
      Public Class Form1
        Dim WithEvents serialport As New IO.Ports.SerialPort
        Dim temperature As Integer
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If serialport.IsOpen Then
                serialport.Close()
    
            End If
            With serialport
                .PortName = "com1"
                .BaudRate = 2400
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                '.DtrEnable = True
                '.ReadBufferSize = 40
                .ReceivedBytesThreshold = 2
            End With
            serialport.Open()
    
        End Sub
        Private Sub Datarecieved(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialport.DataReceived
            TextBox1.Invoke(New mydelegate(AddressOf updatetextbox), New Object() {})
    
        End Sub
        Public Delegate Sub mydelegate()
        Public Sub updatetextbox()
    
    
            Dim mytemp As New temp
            mytemp.binary = serialport.ReadExisting
            Dim resultc As Decimal = celciusconversion(mytemp.binary)
            Dim resultf As Decimal = farconversion(resultc)
            TextBox1.Text = resultc
            TextBox2.Text = resultf
            If resultc >= 24 Then
                'serialport.Write("a")
                serialport.Write(100)
                TextBox3.BackColor = Color.Green
                TextBox3.Text = "fan on"
            Else
                TextBox3.BackColor = Color.Red
                TextBox3.Text = "fan off"
            End If
    
    
    
    
        End Sub
        Public Function celciusconversion(ByVal datarecieved As String) As Decimal
            Return datarecieved * 0.5
        End Function
    
        Public Function farconversion(ByVal datarecieved As String) As Decimal
            Return (datarecieved * 1.8) + 32
        End Function
    Thank you for your time.
    I am trying to help out on this forum as much as I can, I have been sending copies of my slot car timer to users who ask for it.
    Beer is proof that God loves us and wants us to be happy.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Code:
    serialport.Write(100)
    this should send string, so i guess you'll need to change the SERIN to
    Code:
    serin porta.1,t2400,#pcsig
    I'll second Ardhuru's advice. A serial COMport sniffer is always handy to have on hand. I use HHDSoft's one
    http://www.hhdsoftware.com

    There's a load of those here and there, some are 100% free.

    Having one on hand... priceless!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply but the problem is that the program is now (after fixing port a) locking up as soon as I connect the rx pin on the 232 adapter, the serial cable is not even connected and it locks up.
    if i comment out the serin code with the 232 connected it works (without serin)
    I think the serin command is locking up the program but I don't know why.
    The voltage is always 5 volts untill a code comes threw would a constant 5 volts mess up the serin pin? this is a falling trigger do i need to tell the pic what type to look for?
    t2400 ? n2400?
    I hope I have given enough information, I have been.
    what would cause the program to lock up as soon as i connect the serin pin?

    thanks again
    Beer is proof that God loves us and wants us to be happy.

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Well that's strange indeed, why it locks... well it will lock anyways until you have some valid data.

    You said you're using a MAX232 and you're capable of sending data to your PC... T2400 is the setting. Weird enough.. my computer don't work with such low baudrates...

    Code:
    serout portd.3,t2400,[#temp]
    pause 1000
    serin porta.1,t2400,pcsig
    i would suggest to remove the pause 1000, and change your SERIN line


    Code:
    serout portd.3,t2400,[#temp]
    serin porta.1,t2400,#pcsig
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Snap View Post
    what would cause the program to lock up as soon as i connect the serin pin?
    Post #20 here...http://www.picbasic.co.uk/forum/show...ght=serin+idle
    might help you out a bit...

    Or this might:
    http://www.picbasic.co.uk/forum/show...highlight=idle

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Valid for Timeout use...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Valid for Timeout use...
    Ayy......good point...
    But what if the serial cable is 'amplifying' the unloaded pin, as in a floating input, and it ends up causing garbage to try to get into the SERIN statement.

    How about adding a pullup or pulldown as appropriate?

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    He said he use MAX232

    But yes i see what you mean.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    ok, I took out the pause, added the #, so the serin now looks like this...
    serin portc.3,t2400,10,mainloop,[#pcsig]
    it still locks up,
    i added a 4.7 pull down to rx, no luck
    pull up no luck
    serial cable still not even connected (just trying to get it to run first with serin command intact)
    will keep trying
    thanks
    Beer is proof that God loves us and wants us to be happy.

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    nope... no square brackets in that.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    how is this.........still does not work.
    serin portc.3,t2400, 10,mainloop,#pcsig
    Beer is proof that God loves us and wants us to be happy.

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    seems i'll need to try it here

    can you post your missing class or your whole VB code please?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  17. #17
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    and woops i just saw that...
    Code:
    serin porta.1,t2400,pcsig
    if pcsig > 1 then high porta.1
    you should use another pin...

    and then
    Code:
    lcdout $fe,1,pcsig,"pcsig"
    Should have another #
    Code:
    lcdout $fe,1,#pcsig,"pcsig"
    Last edited by mister_e; - 6th May 2008 at 07:06.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  18. #18
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    First of all I would like to thank you again for all of your wonderful help. It is nice to know there are people like yourself and the other members of this forum in this world who devote so much time and energy to helping newbee's like myself.

    I don't wan't you to go through all the trouble of re-createing my project unless of course, you want the code (it is a pritty nifty way of showing the temp in windows).

    Besides all that is it possible that it is the VB code that is locking up the pic when it isent even connected when the pic program hangs up?

    my next thing will be testing out the vb program on a basic stamp I have, if that works at least I know the vb part works, the next will be trying it out on a 16f84 and then if that works I will buy another 16f877 and see if it's the ic.

    If anyone has any other sugestions or you still want the code let me know
    Thank You
    Snap
    Beer is proof that God loves us and wants us to be happy.

  19. #19
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If POST #17 don't highlight anything... I still want it

    Those three textbox and this single button are already on the form!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  20. #20
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    i changed the serin pin after i sent the program, it now is portc.3
    sorry i forgot to mention it
    Beer is proof that God loves us and wants us to be happy.

  21. #21
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    i changed the serin pin after i sent the program, it now is portc.3
    sorry i forgot to mention it
    Beer is proof that God loves us and wants us to be happy.

  22. #22
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    here is the missing class
    Code:
    Public Class temp
    
        Private m_binary As String
        Private m_celsius As String
        Private m_farenheight As String
    
        Public Property binary()
            Get
                Return m_binary
            End Get
            Set(ByVal value)
                m_binary = value
            End Set
        End Property
    
        Public Property celsius()
            Get
                Return m_celsius
            End Get
            Set(ByVal value)
                m_celsius = value
            End Set
    
    
        End Property
        Public Property farenheight()
            Get
                Return m_farenheight
            End Get
            Set(ByVal value)
                m_farenheight = value
    
            End Set
        End Property
    
    
    End Class
    I added the extra methods for future things
    create a main form with a cercius and farenheit text box and a button to get it started
    good luck
    Beer is proof that God loves us and wants us to be happy.

  23. #23
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    I tried to zip my vb project but it is not working, I will try again in the morning ,
    sorry by the way it is 23.5 c in here
    Beer is proof that God loves us and wants us to be happy.

  24. #24
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I see what's happening here... as the pic is waiting for DECIMAL number, it will stuck untill there's a none-numeric ASCII value... damn... so just send something else after you send your data and you should be in business.

    try this...
    vb code
    Code:
        Public Sub updatetextbox()
            TextBox1.Text = serialport.ReadLine
            serialport.Write("aaaaOK" & TextBox1.Text & "z")
        End Sub
    The PIC side..
    Code:
    @       __CONFIG _XT_OSC & _LVP_OFF
            DEFINE LCD_DREG  PORTB
            DEFINE LCD_DBIT   0
            DEFINE LCD_RSREG  PORTB
            DEFINE LCD_RSBIT 5
            DEFINE LCD_EREG  PORTD
            DEFINE LCD_EBIT 7
            DEFINE LCD_BITS 4
            DEFINE LCD_LINES 2
            DEFINE LCD_COMMANDUS 2000
            DEFINE LCD_DATAUS 50
            ADCON1=%00000111
            
            
            DEFINE DEBUG_REG PORTD      ' Set Debug pin port
            DEFINE DEBUG_BIT 3          ' Set Debug pin bit
            DEFINE DEBUG_BAUD 2400      ' Set Debug baud rate
            DEFINE DEBUG_MODE 0         ' Set Debug mode: 0 = true, 1 = inverted
    
            DEFINE DEBUGIN_REG PORTA    ' Set Debugin pin port
            DEFINE DEBUGIN_BIT 1        ' Set Debugin pin bit
            DEFINE DEBUGIN_MODE 0       ' Set Debugin mode: 0 = true, 1 = inverted
                
    
            temp var word 'storage for temperature
            pcsig var word
            
            ' Main loop
            portc=0
            trisc=0
            HIGH PORTD.3    ' Serial OUT idle state
            pause 500
    
    mainloop:
            for temp = 0 to 1000 step 100
                lcdout $fe,1,"Temp=", dec temp
                debug DEC temp,10
                DEBUGIN [WAIT ("OK"), DEC pcsig]
                lcdout $fe,$c0,"pcsig=", dec pcsig
                PAUSE 1000
                next  
                      
            goto mainloop
            
            END
    This echo back the data, not much.
    Last edited by mister_e; - 6th May 2008 at 09:12.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  25. #25
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Unhappy

    first I tried substatuting some of yor lines of code into my program for mine like...
    serIN [WAIT ("OK"), DEC pcsig] insted of
    DEBUGIN [WAIT ("OK"), DEC pcsig]
    and i added the
    portc=0
    trisc=0
    HIGH PORTD.3 ' Serial OUT idle state
    pause 500
    at the beginning
    but it stilll locked up at the exact same spot.
    So I started a new project and used your code exactly
    I recieved the
    Error[118] C:\PBP\SAMPLES\BLINK.ASM 122 : Overwriting previous address contents (2007)
    Error[118] C:\PBP\SAMPLES\BLINK.ASM 122 : Overwriting previous address contents (2007)
    when i compiled but programmed it anyway
    it now locks up at
    Temp=0
    and will not move at all
    and the vb still cant open the port because it is locked (just like always)
    Sorry i can't get it to work, i am at a total brick wall on this one.
    Beer is proof that God loves us and wants us to be happy.

  26. #26
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    use it as is, paste my own first.. even better, try at 9600 bauds.. that's what i've used yesterday.

    For the error message refer to post #5 at the following...

    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  27. #27
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Red face

    fixed the error messages but it still locks up after the temp= 0 lcdout
    and the vb program still can't open the port because of it
    sorry again i think it's time to give up for a while, i don't want to take up any more of your time. I will add to the post if I get it going.
    Thanks again to everybody.
    I can't believe such a simple thing as a serinn(now a debug) is causing such a problem.
    Snap
    Beer is proof that God loves us and wants us to be happy.

  28. #28
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Smile Sweet Sweet Successsss

    I finaly did it (or should I say We....Mr e).The program works fine.
    The key hang ups were add in a "z" in the VB write code and sending code all the time to the pic. Im sure there are way better ways of doing this but this works.
    You need a pic and a 1620 temp ic and a serial converter and a pc.
    here is the code and thank you everyone who helped especially the big E.
    Snap
    VB2005 code
    Code:
     Public Class Form1
        Dim WithEvents serialport As New IO.Ports.SerialPort
        Dim temperature As Integer
    
        Dim setting As Decimal
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If serialport.IsOpen Then
                serialport.Close()
    
            End If
            With serialport
                .PortName = "com1"
                .BaudRate = 9600
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                '.DtrEnable = True
                '.ReadBufferSize = 40
                .ReceivedBytesThreshold = 2
            End With
            TextBox4.Text = 23
            serialport.Open()
            serialport.Write(200 & "z")
    
    
        End Sub
        Private Sub Datarecieved(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialport.DataReceived
            TextBox1.Invoke(New mydelegate(AddressOf updatetextbox), New Object() {})
    
        End Sub
        Public Delegate Sub mydelegate()
        Public Sub updatetextbox()
    
    
            Dim mytemp As New temp
            mytemp.binary = serialport.ReadExisting
            Dim resultc As Decimal = celciusconversion(mytemp.binary)
            Dim resultf As Decimal = farconversion(resultc)
            TextBox1.Text = resultc
            TextBox2.Text = resultf
            If TextBox1.Text >= setting Then
                TextBox3.BackColor = Color.Green
                TextBox3.Text = "fan on"
                serialport.Write(100 & "z")
    
            ElseIf TextBox1.Text < setting Then
                TextBox3.BackColor = Color.Red
                TextBox3.Text = "fan off"
                serialport.Write(200 & "z")
    
            End If
    
    
    
    
    
        End Sub
        Public Function celciusconversion(ByVal datarecieved As String) As Decimal
            Return datarecieved * 0.5
        End Function
    
        Public Function farconversion(ByVal datarecieved As String) As Decimal
            Return (datarecieved * 1.8) + 32
        End Function
        
        Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    
        End Sub
    
        Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
    
        End Sub
    
        Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
    
        End Sub
    
        Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
            setting = TextBox4.Text
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    End Class

    Temp Class
    Code:
    Public Class temp
    
        Private m_binary As String
        Private m_celsius As String
        Private m_farenheight As String
    
        Public Property binary()
            Get
                Return m_binary
            End Get
            Set(ByVal value)
                m_binary = value
            End Set
        End Property
    
        Public Property celsius()
            Get
                Return m_celsius
            End Get
            Set(ByVal value)
                m_celsius = value
            End Set
    
    
        End Property
        Public Property farenheight()
            Get
                Return m_farenheight
            End Get
            Set(ByVal value)
                m_farenheight = value
    
            End Set
        End Property
    pic code

    Code:
    ' Pic16f877a
    ' LCD should be connected as follows:
    '       LCD     PIC
    '       DB4     PortB.0
    '       DB5     PortB.1
    '       DB6     PortB.2
    '       DB7     PortB.3
    '       RS      PortB.5 (add 4.7K pullup resistor to 5 volts)
    '       E       PortD.7
    '       RW      Ground
    '       Vdd     5 volts
    '       Vss     Ground
    '       Vo      20K potentiometer (or ground)
    '       DB0-3   No connect
    Include "MODEDEFS.BAS"
    DEFINE LCD_DREG  PORTB
    DEFINE LCD_DBIT   0
    DEFINE LCD_RSREG  PORTB
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG  PORTD
    DEFINE LCD_EBIT 7
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATUS 50
    ADCON1=%00000111
    
    '
    RST var portd.2
    DQ var portd.0
    CLK var portd.1
    temp var word 'storage for temperature
    pcsig var word
    'portc=0
    'trisc=0
    HIGH PORTD.3    ' Serial OUT idle state
    pause 500
    
    
    '
    low rst 'reset 1620
    '
    lcdout $fe,1,"Temp in Degrees C"
    
    ' Main loop
    mainloop:
    RST = 1'enable device might be high
    Shiftout DQ,CLK,LSBFIRST,[$ee] 'send read command
    RST = 0 ' reset device
    Pause 1000 ' wait for conversion to compleate
    '
    RST = 1 ' SAA
    Shiftout DQ,CLK,LSBFIRST, [$aa] ' send read command
    Shiftin DQ,CLK,LSBPRE, [temp\9]'read 9 bits temp
    RST = 0
    lcdout $fe,1,dec(temp>>1), ".", dec(temp.0*5), " Degrees C"
    serout portd.3,t9600,[#temp]
    
    serin portc.4,t9600,#pcsig
    if pcsig = 100 then high portc.5
    if pcsig = 300 then goto mainloop
    
    if pcsig = 200 then low portc.5
    
    goto mainloop
    
    END
    Last edited by Snap; - 15th May 2008 at 22:40. Reason: wrong code line
    Beer is proof that God loves us and wants us to be happy.

  29. #29
    Join Date
    Jul 2013
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: Sweet Sweet Successsss

    Sorry Mr. Snap...

    Can you tell me about meaning of code visual basic there line by line...
    I wanna to learn visual basic, but I'm a Beginner !!

    Please help me Mr.

Similar Threads

  1. Midi, Interrupts and Pic better than SX28?
    By Lajko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2008, 01:26
  2. Automatic VB6 to pic serial connection
    By arniepj in forum Code Examples
    Replies: 13
    Last Post: - 10th January 2008, 08:57
  3. PIC serial going to sleep!
    By stma in forum Off Topic
    Replies: 0
    Last Post: - 31st October 2007, 09:17
  4. PIC to serial with visual basic
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 31st March 2007, 17:06
  5. serial comm from Pic to STAMP
    By d1camero in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th April 2004, 00:58

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