I just aquired a Mega 2560 board with multi serial ports. Great right? Just one little problem for me at least. I need to be able to invert the logic of a byte sent by a LS2208 bar code scanner.
In the past I used a SoftwareSerial port assigned (10, 11, 1); it was that little "1" that was inverting the logic bits. Without it I would get nothing or trash.
Is there something like this for say Serial1 that I can add to it to make it invert the logic bits?
Thanks
Paul
Worse case I will have to go back to using a SoftwareSeril port again.
I don't know the answer - and I have looked at the Atmel datasheeet which does not seem to mention it.
As it is a rather specialized question I suggest you change your title to include "invert logic". You can change the title by modifying your Original Post.
Post a link to the datasheet for your barcode scanner
First answer that seems to be addressing my problem. But concerned cause I dont know poo about some of this code still. I am needing to read in from the buffer the Bar Code serial data. If I am reading your code right. Your talking about transmitting or writing out data from the Mega. Am I correct?
I don't think simply inverting the data byte will work. The start/stop bits are always expected to be low/high by the UART. SoftwareSerial can invert those too but I don't believe that's an option in the Atmega328 UART hardware. In a long string of continuous bytes you might be able to get away with swapping start/stop bits and inverting the data in software but this approach would fail for the first and last bytes, or if the stop bit is longer than one bit width.
Hi Robin, As stated before the last Arduino (Pro Mini) this was working just fine after much reading and I swear I cant find the thread again. I came across this one reply showing how to set up a SoftwareSerial port with the one at the end of the pin parameters. Took off flying and reading everything just fine.
2 Days ago I wired up a Mega 2560 board and its been hell sence. The 4D Display not talking to the Mega nor is the scanner. I have double check and found a few wiring errors, but they have been corrected. I can put in code and make the #13 DIO LED blink so it is not a bricked board.
Well if worse comes to worse. I will just put back in SoftwareSerial and set up a few of those comm ports. Seems that the display and bar code scanner worked just fine on those types of ports. Heck the Mega has more than enough Digital pins that are not being used.
As for the spec sheet. Not sure what your looking for. They really dont get into what the signal is like. They sell these to go on cashregisters and inventory devices, not makers projects. When I called, ended up talking to a level 2 tech and he was of no help either.
I just remembered from that post that was so helpful. The Author said something about how the Arduino had some kind of inversion on its Digital pins. I would love to hear from more people who have the Mega 2560 boards.
No I have not aarg. I live out in the country (abt 60 miles to local electronics store). Will make the trip in when I go to work Tuesday.
Here is the thread I have been talking about. Note 1st paragraph from #1 replay. I say again if you read the whole post. I have a TTL cord on the LS2208.
And replay #2 is the fix.
Note that professor chaos states how the Arduino UARTs are inverted. That makes me wonder if my 4D display is inverted to match. Wondering what is going on between the SoftwareSerial and the Hardware serial ports? What kind of inputs are the two expecting?
Oh what wicket webs are woven when playing with these microprocessors.
Might take a few days but will get this working again on the Mega 2560
Since when are Arduino UARTs inverted? That is news to me. RS-232 is sometimes though of as inverted since -V is a 1. TTL to TTL shouldn't be a problem, just a direct connection.
I don't see a TTL serial cable available for that scanner, only RS232. Please post a link to the cable you are using.
If you are connecting a RS232 device to a TTL serial device, the inverted signal is only one of your problems. You are putting a negative voltage into the Arduino serial rx line. That may eventually cause you some problems, either on the Arduino or the scanner.
NOTE This scanner uses TTL RS-232 signal levels, which interface with most system architectures. For system architectures requiring RS-232C signal levels, we offer different cables providing the TTL to RS-232C conversion. Contact support for more information.
I really dont know. All I do know is that the display worked just fine when on a software serial port. But now it is on a hardware port it does not work. What changed between the two ports? And I do know that the scanner did not work on software port till I added the "1" to the parameters. Can you explain that? What does the number one do?
If you dont know, thats ok, but please do not muddy the waters with wild guesses.
The same goes for all of the others who just jumping in without understanding what is going on. PLEASE NOTE I SAID IT WAS WORKING BEFORE. only change is from software serial to hardware serial. And I might have screwed up and gotten the scanner RX and TX swapped on the board. Thats something else I might have to check on the scanner. Cause it is hard wired I was going with the possibility that there was something I missed on the software side such as inverting the logic bits.
Thanks if nothing else, its been a sounding board to help me think and one good hardware fix.
The hardware UART on the Arduino is configurable for word length, parity and stop bits, but not for inverted data.
I don't know if that holds for a "Mega".
Paul1958:
As for the spec sheet. Not sure what your looking for. They really dont get into what the signal is like. They sell these to go on cashregisters and inventory devices, not makers projects. When I called, ended up talking to a level 2 tech and he was of no help either.
Yes, they do get into what the signal is like. TTL is not listed in the interface specs for the scanner:
"Interfaces Supported: USB, RS232, Keyboard Wedge, IBM 468x/9x"
So it probably worked for you before because you had the RS232 connected to the logic levels on the board. The "1" in softserial was necessary because RS232 levels are inverted. But it won't always work, as you have discovered, and yet you seem to be uninterested in this, even as a possibility.
Others have hinted strongly that this is your problem. Then later you accuse me of "muddying the waters". Some people just can't be helped.
@Paul1958, if the link in Reply #15 is the correct one for your device it is quite clear from Page 57 onwards that it has a standard RS232 output.
You cannot connect that directly to an Arduino. You need something like a MAX232 level-shifter. And with that it will work perfectly normally with the USARTs on the Mega.
I did ask YOU for the link to the device in Reply #2 and if you had provided it then the whole problem might have been solved by Reply #5 or #7.