Hserin/out BYVAC serial LCD


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default Hserin/out BYVAC serial LCD

    Hi all

    I'm trying to interface a serial LCD by byvac with keypad via HSERIN/OUT
    http://www.byvac.com/index.php/BV4619
    but have the following problem

    If I want to read a "keypress" ,following the datasheet i need to send:

    rg(carriage return)
    if no key is pressed i get the following back from the LCD module 0ack in hex (30 06)
    if a key is pressed it returns 4 bytes example key 1 pressed it returns 238ack (hex 32 33 38 06)

    how can i handle for eaxmple the STR hserin function to check if a key is pressed = 4 bytes returned or unpressed 2 bytes returned

    Thanks

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Hserin/out BYVAC serial LCD

    From the looks of it you have a terminator character 06, so use the STR see manual

    "STR followed by a byte array variable, count and optional ending character will receive a string of characters. The string length is determined by the count or when the optional character is encountered in the input."

    So regardless of how many characters you are expecting put into the command the MAX COUNT characters it will return and then the optional ending character.

    Then all you need to do is look down the array and pick out the value you need - the 06 is the terminator.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Hserin/out BYVAC serial LCD

    Quote Originally Posted by aerostar View Post
    From the looks of it you have a terminator character 06, so use the STR see manual

    "STR followed by a byte array variable, count and optional ending character will receive a string of characters. The string length is determined by the count or when the optional character is encountered in the input."

    So regardless of how many characters you are expecting put into the command the MAX COUNT characters it will return and then the optional ending character.

    Then all you need to do is look down the array and pick out the value you need - the 06 is the terminator.

    Thanks aerostar

    something like this:

    get_key:

    hserout ["rg", 13]
    Hserin 1000, start, [STR char\4\$06] '
    pause 10

    if char[0] = $30 then
    goto get_key
    endif
    char[0] = char[0] - %110000
    char[0] = char[0] << 6
    char[1] = char[1] - %110000
    char[1] = char[1] << 4
    char[2] = char[2] - %110000
    b0 = char[0]+char[1]+char[2]
    lookdown b0, [101,184,183,181,162,161,153,208,201,199,177,149,19 5,89,102,99],keypressed
    hserout ["rdkey= "dec keypressed,13,10]
    pause 10
    return

    is it possible to simplify the pressed key number ?

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Hserin/out BYVAC serial LCD

    Thing to do is try it and see if it works ! I do not see 238 in your lookdown table, you said key 1 returns 238

    converting your bytes so

    char(0)=$32
    char(1)=$33
    char(2)=$38

    char(0) = (char(0)-$30) * 100 'answer 200
    char(1) = (char(1)-$30) * 10 'answer 30
    char(2) = char(2)-$30 'answer 8

    b0 = char(0)+char(1)+char(2) 'answer 238

    compiles but not tested !

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Hserin/out BYVAC serial LCD

    Hi

    Thanks for the char handling

    thisone is working perfectly

    hserout ["rg", 13]
    Hserin 1000, start, [STR char\4\$06] ' Get a char from serial port
    pause 10
    if char[0] = $30 then
    goto get_key
    endif

    char(0) = (char(0)-$30) * 100 'answer 200
    char(1) = (char(1)-$30) * 10 'answer 30
    char(2) = char(2)-$30 'answer 8
    serout2 tx,84,[dec char[0]," ",dec char[1]," ",dec char[2],13,10]
    b0 = char[0]+char[1]+char[2]
    serout2 tx,84,[dec b0,13,10]
    lookdown b0, [125,238,237,235,222,221,219,190,189,187,231,215,18 3,119,126,123],keypressed
    serout2 tx,84,[dec keypressed,13,10]
    pause 10
    Hserout ["rc1", 13] ' Send text followed by carriage return and linefeed
    pause 10
    Hserout ["rd","key= ",dec keypressed,13]
    'keypressed = 0
    pause 10

    return

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Hserin/out BYVAC serial LCD

    If this is in a subroutine and get_key is not in the subroutine then you will get problems by not using RETURN, do not jump out of a subroutine.

    if char[0] = $30 then
    goto get_key
    endif

Similar Threads

  1. pic16f88 Serial questions (hserin/hserout, etc.)
    By harralk in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th October 2012, 00:29
  2. serial port interrupt without using hserin
    By cluster in forum Serial
    Replies: 3
    Last Post: - 27th September 2011, 14:56
  3. PIC16F88 HSERIN to LCD Problem
    By robbrownuk in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 6th June 2009, 22:32
  4. parallel LCD to serial LCD
    By maxbao in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th October 2006, 11:44
  5. to convert LCD // hd 44780 --> serial LCD
    By in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th March 2003, 12:37

Members who have read this thread : 1

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