Not meaning to flood this thread, but just spotted something else:
"call sendchar" should be "gosub sendchar" as call is only for routines written in assembly.
Not meaning to flood this thread, but just spotted something else:
"call sendchar" should be "gosub sendchar" as call is only for routines written in assembly.
Hi,
You can use a built-in feature of Windows if the PC has an unused serial port.
This feature lets you send any kind of keystroke to the PC via serial port.
* * *
Use an Alternative Input Device Instead of a Keyboard or Mouse
SerialKeys is accessibility feature designed for people who have difficulty
using the computer's standard keyboard or mouse. SerialKeys provides support
so that alternative input devices, such as single switch or puff and sip
devices can be plugged into the computer's serial port.
https://www.microsoft.com/windowsxp/...erialkeys.mspx
How to Set Up and Use SerialKeys in Windows:
http://support.microsoft.com/?kbid=260517
Best regards,
Luciano
Sorry for the delay, I have been working on trying different things. I am starting the PC with a regular keyboard and then swaping it with the PIC replacement.
I have tried a 16F627A and I have moved back to the 16F688
Below is the code I am testing, I am sending the data twice trying to send it both LSB and MSB first. Sometimes I get a beep from the PC when I change the PauseUS delay and other times I do not.
' PIC 16F688
' PortC.5 - Data
' PortC.4 - Clk
' PortA.2 - Switch in, normal low, active high
' PortA.4 - LED Out, high if switch pressed
' Circuit description
' 10K pull up on PortC.5 - Data
' 10K pull up on PortC.4 - Clk
' 10K pull up on /MCLR
' 10K pulling down on switch input, PortA.2
'Goal of program, to send a chracter to the PC keyboard port when switch is pressed
@ device INTRC_OSC_NOCLKOUT
INCLUDE "modedefs.bas"
DEFINE SHIFT_PAUSEUS 25
DEFINE OSC 8 ' 8 Mhz
TRISA = %00000100 ' Set PORTA.2 to input, all others are output
TRISC = %00000000 ' set PORTC to outputs
CMCON0 = 7 ' turn off comparitors
ANSEL = %00000000 ' set all as digital ports, analog off
WPUA = %00000000
char var word
breakcode var word
clkout var portc.4
switch1 var portA.2
ledout1 var portA.4
dataout var portc.5
'char = %10101101010 ' 'CR' mode 0
'breakcode = %11000011110 '/F0H mode 0
char = %01010110101
breakcode = %01111000011
'----- Main Loop --------------------------------
Start: ' loop start
low ledout1 ' turn off LED
if switch1 = 1 then ' check switch, if pushed then LED on and Char our
pause 50
if switch1 =1 then
high ledout1 ' LED on
shiftout dataout,clkout,4,[char\11]
shiftout dataout,clkout,4,[breakcode\11]
shiftout dataout,clkout,4,[char\11]
PAUSE 1
shiftout dataout,clkout,5,[char\11]
shiftout dataout,clkout,5,[breakcode\11]
shiftout dataout,clkout,5,[char\11]
endif
endif
goto start ' restart loop
'----- Main Loop --------------------------------
I have tried the character to send and the breakcode both ways, but they respond the same.
I see the characters and clock on the scope, all six characters come across but nothing on the PC.
I am driving the keyboard direct from the chip, no transistors. Do you think the open-collector could be an issue with the driving? Could the Clock and the timing be an issue?
I would think that something would appear with both combinations of send's but i seem to be going in circles.
USB would be great but it's not an option, I am not talking to a Windows OS. I have to use the PS/2 port to send data to the terminal.
Any thoughts would be great, my goal is to send about 24 pre-defined single characters on switches to the port. I have been
Thanks,
HH
2 problems that i can see:
First, looks like ur clock is too fast. PS2 keyboards generate a clock between 10khz-16khz. I'd be changing the shift pause to:
DEFINE SHIFT_PAUSEUS 40
Second, The "mode 0" as you call it is the only one with any chance of working, but "%10101101010" corresponds to a scancode of $AD which as far as i can tell is not a valid scancode.
Try using these:
char = %10001110000 '$1C = 'a'
breakcode = %11000011110 '$F0
shiftout dataout,clkout,4,[char\11]
shiftout dataout,clkout,4,[breakcode\11]
shiftout dataout,clkout,4,[char\11]
Something else you may want to try is this:
shiftout dataout,clkout,4,[char\11]
pauseus 100
shiftout dataout,clkout,4,[breakcode\11]
pauseus 100
shiftout dataout,clkout,4,[char\11]
pauseus 100
*edit* Check out this page for all the scancodes: http://www.computer-engineering.org/...cancodes2.html
Bookmarks