QR Barcode Scanner TTL

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

QR Barcode Scanner TTL

Postby nothinrandom » Tue Jun 28, 2011 2:54 pm

Hi All,

I've search this forum and google for a few days already and was able to get a small start on this project. I originally wanted to use a linear barcode, but I realized that QR is super popular and so 2D is the way to go. So I got one of these uber scanners online: http://www.barcodesinc.com/code/cr8000.htm. I'm using this scanner because it outputs RS232 TTL (5V) and not RS232 (12V), and this is perfect for the uart on the arduino. Also, it can scan both linear and 2D and has a dedicated decoder (less work for me). I got the darn thing to scan some information. However the output is gibberish, but consistent gibberish (good). By consistent, I mean to say that when I scan 123456 from either a linear barcode or a 2D barcode, the output is the same. The scanner is currently configured to use 8 Data Bits, no parity, 1 stop bit.

So far:
I have Clear To Send (CTS) pulled to high all the time on the scanner. When Request To Send (RTS) is sent from scanner, arduino would send out a flag (digitalWrite(x, HIGH)) to tell the scanner to go ahead a send the package.

If someone could help me get the true output, that would be great.

#define CTS 9
#define RTS 8
#define PUSH 10

boolean REQUEST, BUTTON;
int barcode;
void setup()
{
Serial.begin(115200);
Serial.flush();
pinMode(CTS, OUTPUT);
pinMode(RTS, INPUT);
pinMode(PUSH, INPUT);
pinMode(11, OUTPUT);
digitalWrite(11, HIGH);
Serial.println("TEST");
}

void loop()
{
REQUEST = digitalRead(RTS);
BUTTON = digitalRead(PUSH);
if(BUTTON == HIGH)
{
delay(250);
Serial.println("BUTTON IS PRESSED"); //make sure something still works
}
if(REQUEST == HIGH)
digitalWrite(CTS, HIGH);
if(Serial.available() > 0)
{
barcode = Serial.read();
Serial.println(barcode, DEC);
}
}

Example. When I scan 123456, the serial monitor outputs:
g (should be 1)
3
æ
™
¹
r (should be 6)


I hope others can help me on it. Once finished, I'll post all hardware/software regarding this small project (similar to the 2.8" TFT Touchscreen).
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby adafruit » Tue Jun 28, 2011 6:03 pm

do you have a logicn analyzer or scope? that would -really- help
User avatar
adafruit
 
Posts: 10491
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: QR Barcode Scanner TTL

Postby nothinrandom » Tue Jun 28, 2011 6:46 pm

I do have a scope, but I know the scanner works perfectly fine. How do I know? I took the rs232 TTL output and hooked it into a serial to usb adapter and plugged it into my computer. Then I opened up HyperTerminal. I started scanning random barcodes, and voila...everything shows up perfectly fine. However, when I do this on the arduino, I get the gibberish. I think it has to do something with the RS232 being the inverted signal when compared to UART. I'm going to get an inverter chip and see if this solves the problem. Another weird thing that I've realized is that the arduino only outputs something when I have RxD (scanner) hooked to RxD(arduino), and TxD(scanner) to TxD(arduino). If I hook it up the other way, then it doesn't work at all. Doesn't output anything to the screen.
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby mtbf0 » Tue Jun 28, 2011 7:33 pm

so you've got uart on the arduino connected to your computer and to the scanner?

is your computer seeing the transmissions from both the scanner and the arduino? that would tend to garble things.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1642
Joined: Fri Nov 09, 2007 11:59 pm
Location: oakland ca

Re: QR Barcode Scanner TTL

Postby nothinrandom » Tue Jun 28, 2011 7:51 pm

mtbf0 wrote:so you've got uart on the arduino connected to your computer and to the scanner?

is your computer seeing the transmissions from both the scanner and the arduino? that would tend to garble things.


LOL. Excellent point! I totally forgot about that. Well, when I scoped the output, the output of the scanner is at -5V when compared to gnd. But still I think you're right. I guess I can print to an LCD to see what the output is.
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby richms » Wed Jun 29, 2011 3:37 am

If its at -5v then it might be trying to do RS232 instead of TTL levels, so needing invertion before going into the usart on the avr.
richms
 
Posts: 556
Joined: Tue Jan 20, 2009 2:05 am
Location: New Zealand

Re: QR Barcode Scanner TTL

Postby nothinrandom » Wed Jul 06, 2011 1:58 pm

So I bought a normal RS232 to TTL converter from this site (http://alldav.com/index.php?main_page=p ... ucts_id=11) that uses the MAX232 chip, hooked up the arduino to a parallel 20x4 LCD, and connected Rx(converter) to Rx(arduino), then tried Tx(converter) to Rx(arduino)...and it still doesn't work. Just a simple lcd.print(value);. I scoped the converter output, and it's constantly 5V on Rx and 0V on Tx.

Do you know what's wrong richms, or anyone?
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby yvest » Wed Jul 06, 2011 8:18 pm

That's a cool piece of hardware you got! Unfortunately, It's expansive!

Here's another tip that might help you.

If the characters show up properly in hyperterm, it means that the scanner is sending you ascii values, not strait decimal value.

For example if you are scanning the digit '1' the scanner will send Decimal value 49 or 0x31. Therefore when you print the output, you can send it directly to the display, there is no need to reconvert it.

I'm referring to your "Serial.println(barcode, DEC);" This expect a real value in barcode, not an ascii representation of it. Ex. if barcode = 0x01, it would print '1'; In your case, your scanner would send you 0x31 and your print would output "31" when you expect to see '1';

To get Serial.print to output your ascii caracter as is, you would need to write something like: "Serial.print(barcode, BYTE)"

You can try with your serial to usb adapter and use CoolTerm instead of hyperterm. Coolterm has a hex display mode that show both HEX value and ascii value at the same time.

Hope that helps!

-yvest
yvest
 
Posts: 18
Joined: Wed Jun 01, 2011 10:23 am

Re: QR Barcode Scanner TTL

Postby nothinrandom » Wed Jul 06, 2011 8:36 pm

Thanks for the info yvest. In my previous post, I stated that I printed the output directly onto the LCD screen using lcd.print(value). There's absolutely no conversion whatsoever, but it still doesn't work. So weird.
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby ElectricMonk » Thu Jul 14, 2011 10:21 pm

Have you had any luck finishing this? Did you get the cheapest kit, without the USB & Focus and whatnot? I'm looking to pick one up myself for a prototype, but I'm having a hard time finding additional photos and info as to which of the kits/bundles I need to grab.
ElectricMonk
 
Posts: 2
Joined: Wed Feb 02, 2011 12:33 pm

Re: QR Barcode Scanner TTL

Postby nothinrandom » Sat Jul 16, 2011 10:10 pm

I decided to do something else instead. I realized that Arduinos have a tough time trying to read in RS232; even when it's at TTL level. My way of around this for now is to read in information using Processing (running on a computer) or through an application using C# or the company's provided javascript dev. kit, and then send information to the arduino via usb. I think eventually, I'll figure out how to read directly from barcode into arduino, and then output to a LCD display.

I just got the scan head itself. It can output both RS232 or USB. What you need to do is to get this scanner and the ribbon cable. It's a 12 pin PFC connector that's 0.05" pitch. Make a custom board (with pfc connector) with some pull-up and pull-down resistors (depends on which port), and you're good to go. I'll upload the manual soon.

It's a crazy barcode scanner! I can scan barcodes sideways at 20 degrees parallel, and it still works on first click.
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby pstemari » Mon Jul 18, 2011 1:47 am

One common problem is that the Arduino's baud rate's are slightly off. The baud rate is determined by dividing down the 16 MHz clock to (IIRC) 8x the baud rate, and since 16,000,000 isn't a multiple of 115,200, the result is somewhat off. The hardware serial, software serial, and new software serial all handle this a bit differently.

First thing to try if you're having problems is lowering the baud rate to 57,600 or less. The lower the baud rate, the less error in the divisor.

Second thing is to double check the bar code scanner's output frequency. Something I found out with XBee's is that they have the same problem, and fixing the baud rate on the Arduino side causes XBee communications to fail.

There's some software hacks you can use use to get around the issue, but it takes some diving into the details of the bit timers.
--Paul

A wholly owned subsidiary of:
Persephone: DL R+W+B C 7 X L W C++ I++ T+ A E H++ S+ V-- F+ Q P B PA+ PL
Aldebaran: DM Rt H 5 Y L- W+ C+ I++ T++ A+++ E H++ S+ V+ F++ Q+ P B++ PA- PL--
User avatar
pstemari
 
Posts: 309
Joined: Sun Mar 21, 2010 5:10 pm
Location: Seattle, WA

Re: QR Barcode Scanner TTL

Postby nothinrandom » Mon Jul 18, 2011 11:00 pm

The first thing I tried was running the barcode and arduino at 9600 and below, and arduino was still not reading correctly. Then I tried the other ones above 9600 and it was still not working. Then, I tried a whole bunch of things before moving on. Thanks for your input though, pstemari!

I also have the manual if anyone is interested. I can't attach because "The extension pdf is not allowed."
nothinrandom
 
Posts: 31
Joined: Fri May 27, 2011 5:18 pm

Re: QR Barcode Scanner TTL

Postby sec33567 » Sun Aug 28, 2011 5:19 am

Hi, I am starting a similar project, could you please forward me a copy of the manual?

thanks.

nothinrandom wrote:I decided to do something else instead. I realized that Arduinos have a tough time trying to read in RS232; even when it's at TTL level. My way of around this for now is to read in information using Processing (running on a computer) or through an application using C# or the company's provided javascript dev. kit, and then send information to the arduino via usb. I think eventually, I'll figure out how to read directly from barcode into arduino, and then output to a LCD display.

I just got the scan head itself. It can output both RS232 or USB. What you need to do is to get this scanner and the ribbon cable. It's a 12 pin PFC connector that's 0.05" pitch. Make a custom board (with pfc connector) with some pull-up and pull-down resistors (depends on which port), and you're good to go. I'll upload the manual soon.

It's a crazy barcode scanner! I can scan barcodes sideways at 20 degrees parallel, and it still works on first click.
sec33567
 
Posts: 1
Joined: Sun Aug 28, 2011 4:41 am

Re: QR Barcode Scanner TTL

Postby thommo » Thu Oct 06, 2011 12:48 pm

I'm new arduino but want to develop an entry system using 39 code barcodes that I print using VB6. I'm using handheld reader at the moment using the arduino code that is on that site but it wont recognise the output from the reader. I have ried changing the start byte and the end byte to * for this is what is read. Any help please
thommo
 
Posts: 2
Joined: Sun Oct 02, 2011 11:29 am

Next

Return to Arduino

Who is online

Users browsing this forum: No registered users and 7 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [108]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[31]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[34]
LCDs & Displays[48]
Components & Parts[70]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[111]
 
Wireless[14]
Cables[62]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]