Click here to Skip to main content
15,886,753 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to read data from pic using vb. For example, I want to read voltage from pic and display it on textbox.

here my pic code:

C++
unsigned long value;
float volt, voltscale;

char txt[13];
char txt2[4];
// LCD module connections
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;

sbit LCD_D7 at RB7_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D4 at RC4_bit;
// End LCD module connections

// LCD Pin direction
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;

sbit LCD_D7_Direction at TRISB7_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC4_bit;
// End of LCD Pin direction

void main()

{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Volt=");
Lcd_Out(1,15,"V");

 while(1){


    value=adc_read(0);
     volt=value*5.0/1024;

     voltscale=volt*100.0;
     floattostr(voltscale, txt);
     strncpy(txt2, txt, 4);
     txt2[4]='\0';
     Lcd_Out(1,4, txt2);

     delay_ms(200);
     if ( voltscale >= 275){
        UART1_Write('overvoltage');}

      if ( voltscale <= 215){
        UART1_Write('undervoltage');}


     }
}


vb code:
VB
Label9.Text = SerialPort1.ReadExisting()
Posted
Updated 26-Apr-14 5:13am
v2
Comments
pdoxtader 26-Apr-14 10:06am    
Yeah... We'll need a lot more information then that.
Member 10567184 26-Apr-14 11:18am    
i have included my code in the question
[no name] 26-Apr-14 12:06pm    
Well since you have not told us what the problem is, my guess would be that you need to send a linefeed from your PIC.
Member 10567184 26-Apr-14 13:49pm    
Actually i'm new to vb, the problem is i want to take the adc output of the pic and display it on vb (like a digital voltmeter) but i don't know how to do it.
[no name] 26-Apr-14 14:11pm    
Okay and so what exactly is the problem? You must have some sort of a problem otherwise you would not be posting this. I still think that you need to be sending a CRLF from the PIC though. And single quote characters usually enclose single characters not strings. And you might get more help from someplace like http://www.mikroe.com/forum

1 solution

We can't answer that.
There are way, way too many variables, starting with what connection you are using, and continuing to what kind of output you programmed into the PIC.

Start by looking at the SerialPort class[^] and work your way from there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900