Author Topic: Problem reading Ps2 keyboard arduino  (Read 432 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.takniki

  • Frequent Contributor
  • **
  • Posts: 360
Problem reading Ps2 keyboard arduino
« on: March 06, 2019, 04:24:04 am »
1. I am using arduino mega, and arduino 1.8.8. Code is compied using O3 optimization. I have changes Os to O3 in platform.txt at 3 places for fast code.

2. I have foloowing features enabled in arduino:
a) code send data serial through usb port available on mega  i.e. Serial0  at 9600 baud rate and also used to burn code via arduino software
b) code reads data serially through a device, only rx pin is used, tx not connected. Serial2 at 2400 baud rate
c) Lcd 20x4. : standard arduino library
d) I2C based rtc ds1307 : https://github.com/PaulStoffregen/DS1307RTC
e) Internal eeprom to read & store data
f) serial port used to trasmit data , only tx is used, rx unconnected. Serial3 at 9600 baud.
g) Timer 3 at period interrupt of 20ms to scan 4 keys connected at pins.
h) A ps2 keyboard : https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html


3. Problem is when i start the code, i read nothing from PS2 keyboard even if I press the keys on ps2 keyboard. If I keep on pressing some ps2 keyboard for around 10sec, then keyboard start working fine.

4. If i disable everything in code except ps2 library, then code works fine.

5. in complete code, i dont see anywhere i disable keyboard lib.

6. what i suspect, is that i have too many serial interrupt on rx pin, that may be causing issue, as it may interrupt the ps2 code. I dont read serial interrupt actually, as I read on sequentially in mainloop code. where to disable serial interrupt?

7. if not, what else could be issue
 

Offline JustMeHere

  • Regular Contributor
  • *
  • Posts: 147
  • Country: us
  • Country: us
Re: Problem reading Ps2 keyboard arduino
« Reply #1 on: March 06, 2019, 04:39:38 am »
Not sure how to help, but I'm fairly each key press produces two events.  A key down and a key up.  You might be seeing something related to that.
 

Offline Vindhyachal.takniki

  • Frequent Contributor
  • **
  • Posts: 360
Re: Problem reading Ps2 keyboard arduino
« Reply #2 on: March 07, 2019, 04:49:54 am »
I realised, it works fine in below case:
1. When i power up system, without connecting PS2 keyboard, and then connect PS2 keyboard i,e after power up, then it works, all three led on keyboard blinks and it works fine.

2. Whereas when i power up the system with ps2 keyboard connceted, then keyboard dont work. If then i keep pressing some key, after sometime all three led blink & then keyboard works. But i have to press key for more than 15-20sec
 

Offline GromBeestje

  • Contributor
  • Posts: 42
  • Country: nl
  • Country: nl
Re: Problem reading Ps2 keyboard arduino
« Reply #3 on: June 14, 2019, 09:29:46 am »
When do you initialise the PS/2 interface? Are there pull-up resistors on the PS/2 lines? Is there a chance the microcontroller pulls the clock line low? (Putting the keyboard into "communication inhibited" mode)

Also, on what voltage are you running? Be aware the PS/2 interface is a 5 Volt interface. Running it 3v3 might cause an issue that a "high" is misinterpreted as a "low". Furthermore, saying it starts working after 20 sec, might there be a large capacitor charging up on the supply for the keyboard or its pull up resistors?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf