Go Down

Topic: PS/2 BARCODE SCANNER INTERFACING (Read 17592 times) previous topic - next topic

MarlonVets

Im trying to use the library with a PS/2 barcode scanner that gives its output just like a keyboard would.(http://www.karlssonrobotics.com/cart/Barcode-Reader-Scanner-Module-CCD-Camera-PS-2-Interface/) link to it. I tested the scanner on a pc and it works perfectly. When i use it on the arduino it seems to work but the arduino is either not getting an output or is not processing it properly. Any Ideas?

jremington

Quote
When i use it on the arduino
What is this phrase supposed to mean?

robtillaart

can you post the code used?
how did you connect the scanner?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

MarlonVets

#3
Apr 26, 2014, 10:22 pm Last Edit: Apr 27, 2014, 09:05 am by MarlonVets Reason: 1
I connected it to the arduino Uno using the guidelines that come with the PS/2 KEYBOARD LIBRARY, i also used the attached picture as a guide and added pullup resistors I also tried the code that came with it http://playground.arduino.cc/ComponentLib/BarcodeScanner. The code is from the "simple test" example that comes with the library i only changed the data and clock pins.
Code: [Select]


/*  PS2Keyboard library example
 
 PS2Keyboard now requries both pins specified for begin()

 keyboard.begin(data_pin, irq_pin);
 
 Valid irq pins:
    Arduino Uno:  2, 3
    Arduino Due:  All pins, except 13 (LED)
    Arduino Mega: 2, 3, 18, 19, 20, 21
    Teensy 2.0:   All pins, except 13 (LED)
    Teensy 2.0:   5, 6, 7, 8
    Teensy 1.0:   0, 1, 2, 3, 4, 6, 7, 16
    Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
    Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
    Sanguino:     2, 10, 11
 
 for more information you can read the original wiki in arduino.cc
 at http://www.arduino.cc/playground/Main/PS2Keyboard
 or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
 
 Like the Original library and example this is under LGPL license.
 
 Modified by Cuninganreset@gmail.com on 2010-03-22
 Modified by Paul Stoffregen <paul@pjrc.com> June 2010
*/
 
#include <PS2Keyboard.h>
#include <interrupts.h>


const int DataPin = 5;
const int IRQpin =  2;

PS2Keyboard keyboard;

void setup() {
 delay(1000);
 keyboard.begin(DataPin, IRQpin);
 Serial.begin(9600);
 Serial.println("Keyboard Test:");
}

void loop() {
 if (keyboard.available()) {
   
   // read the next key
   char c = keyboard.read();
   
   // check for some of the special keys
   if (c == PS2_ENTER) {
     Serial.println();
   } else if (c == PS2_TAB) {
     Serial.print("[Tab]");
   } else if (c == PS2_ESC) {
     Serial.print("[ESC]");
   } else if (c == PS2_PAGEDOWN) {
     Serial.print("[PgDn]");
   } else if (c == PS2_PAGEUP) {
     Serial.print("[PgUp]");
   } else if (c == PS2_LEFTARROW) {
     Serial.print("[Left]");
   } else if (c == PS2_RIGHTARROW) {
     Serial.print("[Right]");
   } else if (c == PS2_UPARROW) {
     Serial.print("[Up]");
   } else if (c == PS2_DOWNARROW) {
     Serial.print("[Down]");
   } else if (c == PS2_DELETE) {
     Serial.print("[Del]");
   } else {
     
     // otherwise, just print all normal characters
     Serial.print(c);
   }
 }
}



MarlonVets

#4
Apr 27, 2014, 12:26 am Last Edit: Apr 27, 2014, 12:36 am by MarlonVets Reason: 1
The scanner also has a RS232 mode, i set it to that and tried it with the serial event example for arduino. I connected the data pin to the arduino Rx pin.

dlloyd

Could be large voltage swings on RS232 (even negative voltage).  I think you would need an RS-232 to TTL232 converter so all signals are at 0-5V.

MarlonVets

sorry meant to say rs232 mode, the device is a 5v device so didn't think of that thanks.
Just trying to get the data from it by any means

MarlonVets

Still not solved, tried with another code and still nothing. It seems to work for others so if anyone knows anything not explained in the library i need to do please help me.

MarlonVets

Solved it! works perfectly now.  The scanner has two connectors but only the VCC and GND are connected in both. The scanner has to be connected through the male connector else no data will be transmitted. The power can go through either end.

jesusverastegui

Hi

I'm trying to do the same but in my case is a keyboard, i don't know what's happening in a moment the keyboard works fine then not.

https://www.facebook.com/photo.php?v=10152437371009122&l=5259942383660458734

tburrellsaward

I too am having trouble getting a reader (MCR12) to talk to an Arduino Uno. I've made my own four wire cable and have wired it up like this:



Scanner pin 1 to AX Gnd
Scanner pin 2 to AX +5V
Scanner pin 7 to AX Data pin
Scanner pin 8 to AX Clock pin

Here's the scanner pin chart from the manual:



I've tried multiple different variations of the PS2Keyboard sketch and don't get any data from the scanner when I open serial monitor. All I see are "keyboard test" or similar. The scanner has power and scans fine, but nothing is being received by the AX.

I've also tried swapping  round the data and clock wires going into the AX, as well as inserting pull up resistors. I've also tried different pins depending on the sketch (usually 5 & 8 or 2 & 3).

Does anyone have any idea why this isn't working?

srizzi72

Hi.
For the MCR12 Clock pin you must use Arduino Uno R3 pins 2 or 3 (that are INT0 and INT1 pins), no others.
Use the PS2Keyboard library 2.4 https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Try this sketch:


#include <PS2Keyboard.h>

const int DataPin = 3;
const int IRQpin =  2;

PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DataPin, IRQpin);

  delay(1000);
  Serial.begin(9600);
  Serial.println("Keyboard Test:"); 
}

void loop() {
  if (keyboard.available()) {

    char c = keyboard.read();
   
    if (c == PS2_ENTER) {
      Serial.println();
    } else {
      Serial.print(c);
    }

  }
}


schmurgon

#12
Aug 15, 2015, 08:55 am Last Edit: Aug 28, 2015, 09:54 am by schmurgon
I'm having the same problem with an MCR12 PS/2 version talking to an Arduino Uno.  My cabling is as suggested above.

Scanner pin 1 (brown) to Uno Gnd (black)
Scanner pin 2 (red) to Uno +5V (red)
Scanner pin 7 (yellow) to Uno Data (pin 4) (yellow)
Scanner pin 8 (white) to Uno Clock (pin 3) (white)

I'm using version 2.4 of the PS/2 keyboard library, with the sample sketch modified with IRQpin 3 and the DataPin from 4.

Apart from the IRQ pin placement, my setup is identical to the photo above. 

I'm only getting "Keyboard Test:" as output, and keyboard.available() never returns true.

I've tried the scanner defaults, and other 9600/Keyboard/all codes combos.

(EDIT: Updated wiring and attached photo)



[EDIT] I just read at http://www.jkmicro.com/ps2keyboard_en.pdf which suggests CLK and DATA need pull up resistors? 

"DATA and CLOCK signals are "open
collector" type: they need to be "pulled-up" to
5VDC via 10kOhm resistors. Remember that
a logical "0" generates a 5V signal, while a
logical "1" is observed as 0V !"

It seemed like people had this working without them from the posts above?

restart

Is it working now?

Im having the same problem now, but I had connected it to the 5,6 on the module. I watched the adafruit video of the module and thought that i saw it connected to 5 and 6.

Changed to 7,8 now, but its still not working.


http://www.adafruit.com/datasheets/MCR12_configuration.pdf

Have you tried to set it up for PS/2 ?

petrosanteneh2007



Hello everyone, i want to ask something about a barcode.
I am working my final year project on a library management system which need to include a barcode reader design, now what i want to ask is, i really want to find a barcode reader/scanner module which has a ttl output (binary output) then i will get the ASCII using  using arduino then send to my C# code on my Pc (it isn't a problem i will do it easly). 
(i.e i don't need a barcode reader with final output!!!)

I have arduino uno and mega micro controller.
 
Anyone who have an idea let me know where or how i can get such kind of module please.
10x in advance and thank you for your time.

Go Up