Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Ascii Help

Options
  • 20-03-2006 11:51am
    #1
    Closed Accounts Posts: 65 ✭✭


    :confused: Hi guys

    i am having quite a problem here, i have spent some time on this and was wandering it anyone can help me?

    i have my mikroelectronika PICeasy3 board connected to my pc via rs-232, on my pc i have a visual basic interface.

    when i test the communication i send down say chr(65) on the vb side and hence i want to display the charachter A on my LCD.

    my c program goes like:

    char txt

    LCD_init(2400)
    .
    .
    .
    .
    LCD_config (1,1,text)

    ALL i get on my LCD is strange letters, does anybody know what i should do so that my board recognises exactly what i am sending down??


Comments

  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    char txt
    
    LCD_init(2400)
    .
    .
    .
    .
    LCD_config (1,1,[B]text[/B]) 
    
    Shouldn't you have written "txt" instead of "text"?


  • Closed Accounts Posts: 65 ✭✭katiepwr


    thank you mutant fruit

    text is just a variable, in my vb program i have:

    'Event for sending data to the serial port
    Private Sub cmdSend_Click()

    MSComm1.Settings = "2400,n,8,1" 'Making an assumption here
    MSComm1.CommPort = 1 'Another assumption
    MSComm1.PortOpen = True
    MSComm1.Output = Text1.Text
    MSComm1.PortOpen = False

    End Sub

    so what ever i type into my textbox i want to display this onto the LCD, i have c code to take in the contents of the serial port but when i send for example A in vb the LCD doesnt display A it displays an unknown character sort of like chinese

    thanx again


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    but havn't you declared it as "char txt" as opposed to "char text", so shouldn't you have written "txt" as opposed to "text"?


  • Closed Accounts Posts: 65 ✭✭katiepwr


    hi mutant fruit

    sorry that was just a typing error. i have it the code working as far as i know its just that it doesnt seem to recognise what i am inputting form vb??


  • Registered Users Posts: 1,996 ✭✭✭lynchie


    I guess the lcd display you have takes ascii character sequences? I think VB will return a unicode string from the .Text property. You may need to convert this to ascii before sending it to the com port. I guess you can test this quickly by counting the number of bytes in the .text property if thats possible. Haven't touched vb in ages so am not sure how thats done.


  • Advertisement
  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    try sending just the integer 65 (as opposed to chr(65)). Your C code should cast that to a char without a problem and display it correctly as a letter. If that displays, it means there is something dodgy with your VB code.


  • Closed Accounts Posts: 65 ✭✭katiepwr


    yea i was thinking it could be the vb side of things but was worried that i would have to set up the LCD manually.

    Do you think that the LCD only accepts ascii charachters, i am new to vb, does anyone have a small example that i can test out please?

    would i use something like atoi

    thanks lads


  • Closed Accounts Posts: 54 ✭✭charlo_b


    maybe try :
    mscomm1.portopen = true
    
    'this loop will send the ascii value for each character in the textbox
    for i = 1 to len(text1.text)    
         mscomm1.output = asc(mid(text1.text,i,1))        
    next
    
    mscomm1.portopen = false
    

    Do you not have a programmers manual for this LCD Display it should tell you what it expects to receive!


Advertisement