Problem in sending command from VB6 to PIC18F458


Closed Thread
Results 1 to 9 of 9

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Problem in sending command from VB6 to PIC18F458

    Steve

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

  2. #2
    Join Date
    Jun 2011
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Problem in sending command from VB6 to PIC18F458

    Thank you mister_e..
    I've set both baud rate=9600.

    This is my PIC coding:
    unsigned long temp_res;
    unsigned long h;
    void NumtoChar(char a)
    {
    unsigned char digit[3];
    digit[0]=a/100;
    digit[0]+=0x30;
    a=a%100 ;
    digit[1]=a/10;
    digit[1]+=0x30;
    digit[2]=a%10;
    digit[2]+=0x30;
    Soft_UART_Write(digit[0]);
    Soft_UART_Write(digit[1]);
    soft_UART_Write('.');
    Soft_UART_Write(digit[2]);
    }
    void main()
    {
    Soft_UART_Init(PORTC, 7, 6, 9600, 0);
    ADCON1 = 0x81;
    TRISA = 0xFF;
    TRISB = 0X00;
    TRISC = 0X00;
    TRISD = 0X00;
    while(1)
    {
    temp_res = ADC_Read(0) >> 2 ;
    delay_ms(300);
    PORTB = temp_res ;
    h = temp_res*1.3;
    NumtoChar(h);
    ADRESH = 0;
    ADRESL = 0;
    }
    }

    This is my VB coding:
    Option Explicit
    Dim ipt As String

    Private Sub Command1_Click()
    MSComm1.Output = "M"
    End Sub

    Private Sub Form_Unload(cancel As Integer)
    If MsgBox("Are you sure you want to quit?", _
    vbYesNo + vbQuestion, _
    "Exit") = vbNo Then
    cancel = 1
    Else
    End If
    End Sub

    Private Sub Form_Load()
    MSComm1.CommPort = 3
    MSComm1.PortOpen = True
    End Sub

    Private Sub Timer1_Timer()
    ipt = MSComm1.Input
    ipt = Right(ipt, 4)
    Text1.Text = ipt
    End Sub


    The pic coding works and the temperature measured can be displayed on VB. But the VB coding above i add command button to send a character. I should add in the pic coding too right? I'm not good at coding. When i add receive coding in pic it doesn't works. The vb can receive temperature from pic, meaning they can communicate. Just the problem is the pic can't receive from vb. how to send the command from vb to pic?

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


    Did you find this post helpful? Yes | No

    Default Re: Problem in sending command from VB6 to PIC18F458

    Did you tried the last code example over there?
    http://www.mikroe.com/esupport/index...soft_uart_read

    However I would suggest
    http://www.mikroe.com/esupport/index...barticleid=157

    I would also suggest you to post on MikroElektronika forum, here it's for Melabs PicBasic Pro Compiler

    The VB side should work.
    Last edited by mister_e; - 13th June 2011 at 02:28.
    Steve

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

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