Interfacing PIC16F877A with VB to display ADC Readings

Discussion in 'Programmer's Corner' started by navidbox, Sep 2, 2011.

  1. navidbox

    Thread Starter Member

    Mar 6, 2009
    10
    0


    In fact, I am working on a project ( Data Acquisition system for Solar Panel) which collects all the data (from the sensors e.g. light, temperature, voltage, current) and after processing by Microcontroller (PIC Microcontroller) will display it on the LCD. It is also required to show/display these Four (4) parameters in the computer screen.
    Therefore, as per need of the project, I selected Visual Basic to do it for me.
    I have already completed the interfacing part (All the necessary codes-C Language for transmitting data from PIC to the UART-USB), and it is successfully transmitting data to the computer.

    What I need is to configure my VB file to receive the data from USB and show it on the specified textbox( which is designed by VB).

    Since I have not done the VB design and my friend helped me to do it, I am having some difficulties by working with it. I am getting errors and the measured values which supposed to be displayed in the defined text box can not be showed.

    Please help me to eliminate the errors and give me your advice on how I can establish the communication between the VB and Microcontroller.

    Here are the errors I am getting.
    --------------------------------------------------------------------
    I get this error “Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: startIndex”
    ' Text display routine, which appends the received string to any text in the Received TextBox.
    Private Sub Display()
    Temperature.Text = New String(stringtoparse, 1, 5)
    Light.Text = New String(stringtoparse, 6, 5)
    Volt.Text = New String(stringtoparse, 11, 5)
    Current.Text = New String(stringtoparse, 16, 5)
    ------------------------------------------------------------------------







     
    • VB.zip
      File size:
      375.8 KB
      Views:
      53
  2. upand_at_them

    Active Member

    May 15, 2010
    246
    29
    I think what you want is the SubString method:

    Temperature.Text = stringtoparse.SubString(1,5)
    ...
     
Loading...