Hi i am a student and for my end work I need to make a machine that scans a barcode en places it to the right place.
I have a barcode scanner (LSIS 122 open end) and I need to get a respons on my serial moniter but I can't seem to read anything.
I am very new to Arduino and I used an optocoupler to convert the 12V TX signal to a 5 V signal from the Arduino wich I use to connect to the rx pin on the Arduino.
Does somebody know how to connect to the Arduino Uno properly with the TX cable and what program to write to test it out.
The baudrate needs to match the baudrate of the scanner and the serial monitor must be set to match that baudrate as well.
Note that anything that you send to the PC also goes to the scanner; this might ormight not be an issue.
A quick look at the datasheet for your scanner suggests that the open end variant (i.e. the one with no connector on the end) is the same as the one with the 9-pin D-Connector on it. I suspect that the signal levels are plain old RS-232 levels. If that's the case, then a simple RS-232 module should convert the received data back into voltage levels suitable for an Arduino UNO.
The Pi HUT sells an Arduino RS-232 shield for 9 GBP. Ebay also has some that are much smaller for around 4GBP.
You should look into using a software serial port implementation to receive the barcode values as @sterretje has said, RX & TX are used to communicate via USB to your IDE. However, software serial port baud rates on an Arduino UNO are limited to 19,200 or less, so set your barcode scanner baud rate accordingly.
It is not just the voltage levels that need converting, the signals need to be inverted. That is swap a high for a low. This will be done if you uses an RS232 to TTL converter like a MAX 202, or otherwise you need some logic inverters after the voltage translation.
Oh dear, this is first of all not a schematic it is a physical layout diagram. But all the I missed this out because …l, makes it even useless as one of those.
A simple pen and paper drawing is all you need. Odd how a pen has all the symbols in the world in it.
That is certainly strange that you have all that circuitry. When I read the data sheet on the device, it tells me it outputs straight RS-232 signals with +-6 volts. Why do you not just use a RS-232 to TTL adapter?
Are you going to send the command to read to the device or use the trigger pin?
Paul
Now I can see the problem, it is that the way you have wired it up doesn’t actually invert the signal, it passes it straight through. Also it doesn’t prevent the optical isolator from negative voltage and thus potential damage. For protection you need a reverse diode across the input of the opto isolator.
For the signal inversion you need to wire the output of the opto isolator with a common emitter mode not the common collector mode you have now. That is with the resistor between the collector and the supply, and take the RX input from the collector.
Note depending on what type of opto isolator you have you might end up with a reduced range of baud rates you can use. These things are typically not fast.
I have done everything you said like so :schematic and the signal is now inverted.
I still don't receive anything on my serial monitor so I guess I think I wired it up wrong or my program isn't right.
The inverted signal is connected to the pin0(rx) is this right or do I need to use software serial?
Also, is it possible you could show a Arduino program to convert the incoming signal to show up on the serial monitor.
I made something myself but or it is wrong or I wired it up wrong.
Thank you so much I really appreciate this
Sorry but no.
The reverse bias diode should be in parallel with the diode in the opto isolator, you have it in series. This will drop the voltage available to light the opto isolator’s LED.
I bought a RSR232 to TTL convertor schild (DFrobot RS232 Shield V0.1) like you recommended but I still don't receive anything.
Did I wire it wrong or?
I wired the 232TX on the 232TXD pin on the shield.
I didn't wire the 232RX cable.
On the GND pin I connected the same ground as the RS232 device.
On the VCC I wired the 5V from the Arduino.
[quote="markd833, post:19, topic:933615"]
If so, did you try the sample code that they provide
[/quote].
yes, but when I upload I get nothing in the Serial Monitor.
I suspect that I wired the RS232 device (barcode scanner) wrong.
I'l upload a photo of how I wired it up:
This seems to be right because the RXD led on the shield lights up when I scan a code with the scanner but I still receive nothing on the serial monitor.
Can it be that the RX pin on the Arduino itself is broken and if so how can I test it.
Also is it correct that I connect 5V from the Arduino on the VCC pin and the - from the supply of the barcode scanner on the GND pin.