AT/PS2 Keybord - PIC Interface?


Results 1 to 40 of 74

Threaded View

  1. #23
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Pic To Ps/2 Send

    HELLO GURU'S,

    I AM TRYING TO SEND SOME FIXED CHARACTER FROM THE PIC TO THE PC VIA PS/2 WITHOUT ANY RESULT.

    CAN SOMEONE PLEASE HELP !

    BACKGROUND:
    I HAVE JUST ADAPTED A CODE I FOUND ON THE NET FOR BS2 FOR MY PURPOSE. THE FILE IS ATTACHED TO THIS MAIL. ITS GOT SOME VERY GOOD DATA FOR HOW TO........ FOR THE PURPOSE.

    THE ONLY DIFFERENCE IS THAT I HAVE DIRECTLY CONNECTED THE PORTPINS TO THE PC PS/2 CABLE SO AT A COUPLE OF PLACES I HAVE INVERTED THE SENDS.

    MY CODE:

    @ device PIC16F73 , hs_osc, wdt_off, pwrt_on, protect_oN
    Include "MODEDEFS.BAS" ' Include Shiftin/out modes
    '-----------------------------------------------------------------
    Define Osc 8 ' We're using a 8 MHz oscillator
    '-----------------------------------------------------------------
    Adcon1 = 7 ' Set PORTA DIGITAL
    OPTION_REG.7 = 1 ' DISABLE INTERNAL PULLUPS
    Trisa = %00000000 ' SETS ALL PORTA PINS TO OUTPUT
    Trisb = %00001100 ' ALL OUTPUT
    Trisc = %00001011 ' 6 Pins - LCD and 2 Pins RF Module
    '-----------------------------------------------------------------
    SCLK VAR PORTB.1
    SDATA VAR PORTB.0
    LED VAR PORTC.5 ' LED
    '-----------------------------------------------------------------
    temp var BYTE 'Temp variabel
    char var WORD 'Variabel containing the character
    breakcode var WORD 'Variabel containing "Breakcode"
    extcode var WORD 'Variabel containing "Extended charcode"
    I VAR BYTE ' TEMP VARIABLE
    ' -----[ Initialization ]---------------------------------------------
    '
    'Set datpin and clkpin default to high (1)
    HIGH SDATA ' low datpin
    HIGH SCLK ' low clkpin

    'Define breakcode
    ' s--DATA--PS (s=start, DATA=LSB First, P=parity, S=stop)
    breakcode=%00000111111 '/F0H

    'Define extcode
    ' s--DATA--PS (s=start, DATA=LSB First, P=parity, S=stop)
    extcode=%00000011101 '/E0H

    ' -----[ Main Code ]--------------------------------------------------
    '

    PAUSE 4000 : LOW LED

    start:

    temp=0 : pause 1000
    HIGH LED : GOSUB button00 : TEMP = 0 : PAUSE 500 : LOW LED : PAUSE 500
    HIGH LED : GOSUB button01 : TEMP = 0 : PAUSE 500 : LOW LED : PAUSE 500
    HIGH LED : GOSUB button02 : TEMP = 0 : PAUSE 500 : LOW LED : PAUSE 500
    HIGH LED : GOSUB button03 : TEMP = 0 : PAUSE 500 : LOW LED : PAUSE 500
    HIGH LED : GOSUB button04 : TEMP = 0 : PAUSE 500 : LOW LED : PAUSE 500
    HIGH LED : GOSUB button05 : TEMP = 0 : PAUSE 500 : LOW LED : PAUSE 500

    goto start

    ' -----[ Test Characters ]--------------------------------------------
    ' These are inverted
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%10110101110 '/SPACE
    'char=%11100011110 '/a
    'char=%11010010100 '/CR
    'char=%11011001110 '/b
    'char=%11100101110 '/t
    'char=%10100101100 '/r
    'char=%10011101110 '/d
    'char=%10101111100 '/F1
    'char=%11111000110 '/INS

    button00:
    'Assign char a character with startbit, parity and stopbit. OBS inverted !
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%11100011110 '/a
    char=%00011100001 '/a
    gosub sendchar
    RETURN

    button01:
    'Assign char a character with startbit, parity and stopbit. OBS inverted !
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%11010010100 '/CR
    char=%00101101011 '/CR
    gosub sendchar
    RETURN

    button02:
    'Assign char a character with startbit, parity and stopbit. OBS inverted !
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%11011001110 '/b
    char=%00100110001 '/b
    gosub sendchar
    RETURN

    button03:
    'Assigne char a character with startbit, parity and stopbit. OBS inverted !
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%10110101110 '/SPACE
    char=%01001010001 '/SPACE
    gosub sendchar
    goto start

    button04:
    'Assigne char a character with startbit, parity and stopbit. OBS inverted !
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%10101111100 '/F1
    char=%01010000011 '/F1
    gosub sendchar
    RETURN

    button05:
    'Assigne char a character with startbit, parity and stopbit. OBS inverted !
    ' s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%11111000110 '/INS
    char=%00000111001 '/INS
    gosub sendextchar
    RETURN

    ' -----[ Subroutines ]------------------------------------------------
    '
    sendchar
    'Send character
    shiftout SDATA,SCLK,1,[char\11] : pauseus 10
    'Send breakcode + character
    shiftout SDATA,SCLK,1,[breakcode\11] : pauseus 10
    shiftout SDATA,SCLK,1,[char\11] : pauseus 10
    return

    sendextchar
    'Send extcode + character SDATA
    shiftout SDATA,SCLK,1,[extcode\11] : pauseus 10
    shiftout SDATA,SCLK,1,[char\11] : pauseus 10
    'Send extcode + breakcode + character
    shiftout SDATA,SCLK,1,[extcode\11] : pauseus 10
    shiftout SDATA,SCLK,1,[breakcode\11] : pauseus 10
    shiftout SDATA,SCLK,1,[char\11] : pauseus 10
    return

    ' -----[ End ]--------------------------------------------------------


    ANY BETTER IDEA WOULD ALSO HELP.

    REGARDS
    Attached Files Attached Files

Similar Threads

  1. MXcom "C-BUS" interface to PIC question
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st May 2014, 03:59
  2. Interface a pic with a Iphone/Itouch
    By Luckyborg in forum General
    Replies: 1
    Last Post: - 6th May 2009, 16:02
  3. 4 pin 4 x 4 keypad interface using pic basic pro
    By dunlao_john in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th January 2009, 05:21
  4. USB Interface using PIC
    By Tissy in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 22nd May 2006, 16:04
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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