Shop OBEX P1 Docs P2 Docs Learn Events
Keyboard to serial ASCII converter — Parallax Forums

Keyboard to serial ASCII converter

ChetChet Posts: 150
edited 2008-08-16 02:46 in General Discussion
To avoid re-inventing the wheel, I thought I would ask:

Has anyone written code to translate a PC keyboard data stream to ascii?·(KB -> serail ASCII)·I would like to have that option available instead of doing via my computer.

I have done searches without success.

Thanks

Chet

Comments

  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2008-08-06 16:20
    Take a look at these 2 posts:

    Micro Datapad entry: http://forums.parallax.com/showthread.php?p=736766

    PS/2 Keyboard entry: http://forums.parallax.com/showthread.php?p=737546


    I have also used the PC with Hyperterminal and the SX chips.
  • ChetChet Posts: 150
    edited 2008-08-06 17:14
    Thanks a lot. I did not get any of these references on the search. I just wanted to get away from using hyper terminal and a level shifter for symple stuff. This should take care of it.

    Thanks again

    Chet
  • ChetChet Posts: 150
    edited 2008-08-10 01:10
    Forgive me for what I am about to ask....

    I tried using the "keyboartest_with _ascii_output.src but could not figure out how to bypass writing to the LCD in parallel mode.· What change in the code is required to get the ascii output to go to a serial output so I can send it straight to the 4x20 parallax LCD?· I cannot figure out how to get the ascii code and use it in sxbasic to do a serial send to the LCD.



    I have uploaded the file in question for reference.

    Any help is highly appreciated

    Chet· blush.gif
  • PJMontyPJMonty Posts: 983
    edited 2008-08-12 21:28
    Chet,

    Is the problem that you can't figure out how to bypass writing to the LCD, or is the problem that you want to make the changes to an assembly language program using SX/B?

    Thanks,
    PeterM
  • ChetChet Posts: 150
    edited 2008-08-12 22:09
    I am trying to split out the key board routines and then hand over the ascii caracter to a SX/B program, such as serieal out "ascii caracter. Ultimately if I can get an SX28 to convert the keyboard scan results to ascii and send serial ascii out to an external device. Even if the code is such that the SX initializes the key board, gets key pressed, convert it to ascii and then sends the ascii in serial format via one of the SX28 pins. It can be a dedicated SX. Part of the objective is to have an economical serial ascii keyboard. I am working on some mobile projects and using the laptop each time for input is a pain.

    Thanks for your time.


    Regards


    Chet
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-12 22:35
    I wrote a P2/2 keyboard reader in SX/B (okay, there's some assembly mixed in, but the core program is SX/B) that should be much easier to adapt for your use. The file is posted in this thread:

    http://forums.parallax.com/showthread.php?p=737546
  • ChetChet Posts: 150
    edited 2008-08-12 23:43
    JonnyMac, I posterd my reply on the orriginal post (not paying attention...) Thanks for your help

    Regards

    Chet
  • ChetChet Posts: 150
    edited 2008-08-13 23:56
    JonnyMac said...
    I wrote a P2/2 keyboard reader in SX/B (okay, there's some assembly mixed in, but the core program is SX/B) that should be much easier to adapt for your use. The file is posted in this thread:

    http://forums.parallax.com/showthread.php?p=737546
    I tried taking out the LCD related code, but do not know how to "handoff" the key code to SX/B.· With the "watch", I can see that the scan is working as advertised, but the handoff is not.

    Modified keyboardtest_with_ascii_output as follows:



    device sx28,osc4mhz,turbo,stackx,optionx
    freq·4_000_000
    irc_cal·irc_slow
    LCD_PIN··PIN· ·RA.2 output
    KEY_ASC··VAR·BYTE
    LCD_OUT··SUB·1
    program start
    start:
    goto jump_in
    SUB LCD_OUT
    key_asc = __param1
    watch __param1, 8, uhex
    watch key_asc, 8, uhex
    break
    serout LCD_PIN, n19200, key_asc
    return
    JUMP_IN:
    ASM
    key equ $0C
    temp equ $0D
    temp2 equ $0E
    stat equ $0F

    main2
    mode $0f
    mov stat,#0
    call keyreset··'reset the keyboard
    main
    call scankey··'Gets one key
    call NCS··'Sets Num, Caps, or Scroll lock in var stat
    cja key,#$90,main
    mov w,key
    jmp @go2it
    back2it
    mov key,w
    cje key,#0,main··'jump to main if key is 0
    watch key, 8, uhex
    call LCD_OUT··'Prints to LCD
    jmp main

    Remaining code for non-lcd remains the same.

    Can I impose one more time...?

    Thanks

    Chet
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-14 04:38
    I don't get it: you've got a working routine that's already to hand-off the byte to SX/B (I'm referring to my keyboard program that encapsulates the asm code in an SX/B function_). Are you wanting someone to write the whole program for you? That would be easy enough if you'd just define to end goal.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2008-08-14 08:09
    Why did you modify the code·Peter posted, if you didn't need the lcd?
  • ChetChet Posts: 150
    edited 2008-08-16 02:46
    I got it to work. Too many late nights contributed to many mess-ups. I am going through the different versions trying to understand the asm code a bit.

    Thanks for you patience

    Chet
Sign In or Register to comment.