Arduino Forum

Topics => Device Hacking => Topic started by: MarlonVets on Apr 26, 2014, 01:34 am

Title: PS/2 BARCODE SCANNER INTERFACING
Post by: MarlonVets on Apr 26, 2014, 01:34 am
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?
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: jremington on Apr 26, 2014, 06:40 am
Quote
When i use it on the arduino
What is this phrase supposed to mean?
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: robtillaart on Apr 26, 2014, 03:17 pm
can you post the code used?
how did you connect the scanner?
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: MarlonVets on Apr 26, 2014, 10:22 pm
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 (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);
   }
 }
}


Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: MarlonVets on Apr 27, 2014, 12:26 am
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.
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: dlloyd on Apr 27, 2014, 12:35 am
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.
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: MarlonVets on Apr 27, 2014, 12:39 am
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
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: MarlonVets on Apr 27, 2014, 09:07 am
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.
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: MarlonVets on Apr 27, 2014, 11:08 am
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.
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: jesusverastegui on May 06, 2014, 05:24 pm
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 (https://www.facebook.com/photo.php?v=10152437371009122&l=5259942383660458734)
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: tburrellsaward on Jul 25, 2014, 03:36 pm
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:

(http://xfer.timc3.com/uploads/photo_1.JPG)

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:

(http://xfer.timc3.com/uploads/S.png)

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?
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: srizzi72 on Aug 25, 2014, 10:14 am
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 (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);
    }

  }
}

Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: schmurgon on Aug 15, 2015, 08:55 am
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)

(http://forum.arduino.cc/index.php?action=dlattach;topic=235894.0;attach=136326)

[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?
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: restart on Aug 25, 2015, 11:41 pm
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 ?
Title: Re: PS/2 BARCODE SCANNER INTERFACING
Post by: petrosanteneh2007 on Oct 20, 2016, 10:22 am


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.