Pages: [1]   Go Down
Author Topic: PS/2 BARCODE SCANNER INTERFACING  (Read 1563 times)
0 Members and 3 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Oregon, USA
Offline Offline
Edison Member
*
Karma: 65
Posts: 2125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"It seems to run on some form of electricity"

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13479
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can you post the code used?
how did you connect the scanner?
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

/*  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);
    }
  }
}



* arduino-barcode-schema.jpg (28.17 KB, 300x444 - viewed 51 times.)
« Last Edit: April 27, 2014, 02:05:06 am by MarlonVets » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 26, 2014, 05:36:52 pm by MarlonVets » Logged

Canada
Offline Offline
Sr. Member
****
Karma: 13
Posts: 401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Electricity is really just organized lightning - George Carlin

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Mexico
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1]   Go Up
Jump to: