This version of Internet Explorer is either no longer supported by Microsoft, or is obsolete and some features of our store may no longer be supported.
Please consider upgrading or use a different browser.
Cookies are not enabled on your browser.
Cookies are required for our site. Please enable cookies in your browser preferences to continue.
Our offices will be closed Friday, July 3rd, to celebrate Independence Day
For Thursday order cutoff times, see our shipping policies. Orders placed after the Thursday cutoff, will process on Monday, July 6th.
(VID-DM-0015) - Step by step instructions on how to setup and use a serial bar code scanner with the Do-more PLC on both the internal and external serial ports. Includes a Stage programming example too!
The bar code scanner used in this video is a Symbol LS2208 with the optional RS232 interface cable (Motorola part number CBA-R37-C09ZAR) which provides a Female DB9 for us to connect to.
We made a custom adapter to get from the LS2208 Interface Cable Serial connector output (Female DB9) to the Do-more PLC Serial Port (RJ12).
The final chain of cables and interfaces looked like this:
LS2208 .........RS232 Cable **.............. Custom ....... DoMore! PLC Bar Code....... Interface ....................... Adapter........ RJ11 Scanner.........(CBA-R37-C09ZAR) ...... Cable ........... RS232 Port
The custom adapter was wired like this:
Male ....... Male DB9........ RJ12 (6-pin) ..5............. 1 ..2............. 3 ..3............. 4
** Not an AutomationDirect part.
Note: The table in the LS2208 user guide on page 3-7 shows the pin out of the scanner, NOT the RS232 add-on interface cable that we are referring to above.
**Prices were valid at the time the video was released and are subject to change.
Getting a bar code scanner up and running on some PLCís can be a real hassle. The DoMore makes it so easy. Letís take a look: Step 1: Plug the scanner into the serial port on the front of the CPU. Step 2: Configure the hardware: Click on System configuration. Under Serial Port Mode, choose General Purpose and device Settings. Our device is running at 9600 baud, 8 bits, 1 stop bit, odd parity and no controls. Weíre good to go. Step 3: Ladder Code. You only need one instruction to read the bar code scanner: that would be STREAMIN. We want to select the Device that we are connected to ñ which is our internal serial port. And we want to determine when the message is complete. In our case we are going to be using a 10 character bar code with no delimiters. Note that you can delimit on a carriage return, line feed, or any character you want and look at this: You can even have the instruction trim the delimiters from the string that ends up in your result. We donít need that so we will turn that off. And we are also not going to have a timeout. Weíre just going to let this thing run continuously. Since this is a string, we are going to have it end up in a string structure. If you had numeric data coming in you would select this option. So thatís all you need. You just select the serial port you are plugged into, when the message is complete, and where you want the result to end up. Now you can tell from this little triangle here, that this message is edge triggered. Letís go ahead and put a control but in here, Iíll use C10 that we can use to enable the instruction with. Letís create a Data view so we can monitor some things. The first thing we want to see is the string result, which was a String Short 1 back here in our stream in instruction. Letís add a control bit, C10, so we can turn this thing on. And letís add one more thing. Iím going to add the internal serial port ñ dot ñ ìIn-queue.î That tells me how many characters are buffered up in the In Queue. Iím going to reach over here and run a couple barcodes into the bar code scanner. Ok, I just ran four in. And you can see, we collected 40 characters in our queue. That was four, ten character bar codes. To pull those bar codes out of the queue, we just enable C10. Letís turn on our edit mode. Make some room so we can view that string, and toggle C10. When we do that, we pull the first barcode out of the queue. The queue gets reduced by 10 characters, and we are good to go. Letís toggle C10 off, and back on, and my second bar code comes in and I dropped down another 10 characters. One more time, my third bar code, Iím down to 10 characters. And one more time. I see my fourth bar code and my buffer is empty. Thatís all there is to hooking up the bar code scanner to the Do-more. Letís do one more thing ñ letís put this in a code block that you can run to continuously retrieve bar code messages, without having to toggle that C10 bit. Letís go ahead and turn C10 off to get it out of our way. Weíll create a new Program, and weíll call this BarCode. And weíre going to use a simple stage program to implement this. Weíre going to come over here and say our first stage is going to be Stage 0. In that stage we want to do a STREAMIN. Weíre going to choose our internal serial port. We have a 10 character Barcode. No delimiters, no timeout. Donít need any of that. Weíll go ahead and put him in String StructureÖ weíll put him back in String Short 1. And this time we are going to exit on success ñ weíre going to jump to stage S0 - the same stage. If we have an error, we will jump to stage 1. Stage 1 ñ this is our error stage. Remember, if we have an error up here in STREAMIN weíre going to jump to stage 1. And all I want to do here is increment a counter so I can see if I have any errors. Once that is done, I am going to jump straight back to stage zero. Thatís it. So when we come into this stage, it automatically enables STREAMIN for us, pulls 10 characters out of the buffer. When that is complete, we jump back to stage zero and do it again. If we have an error, we jump down here to stage 1 where we increment a counter and then jump back to stage 0 where we will start the process all over again. Letís accept that new routine. Go back to main, and we want to run that routine. And for this example we are just going to run it on the first scan. Remember ñ this is a program code block. Once you initiate it, it continues to run until something shuts it down. So we only need to do that once. Weíll accept that change, save it, write it out to the PLC, and we are ready to go. So now in our program, we have our original STREAMIN which we are not going to use ñ weíll just leave C10 turned off. And we have our new program which got initiated on the first scan, and continues to run for the duration of our program. We can see right here, it ran this scan. Iím going to clear out our string, just so we can see changes. C10 is off, thatís good. Our serial In Queue is zero. Because this program is running on its own in the background, all I have to do is hit our barcode scanner with some bar codes, and if you watch carefully here ... each time I do that the bar code changes. My In Queue appears to be zero because each time the message comes in, it gets pulled right back out. Perfect. So thatís exactly what we were looking for. Every time a bar code comes in, it immediately gets put into the string structure SS1 and we can now use it anywhere we want in the program. What if you wanted to do this on an EXTERNAL serial port? Thatís easy. Just define the external serial port over here: System Configuration, Module Configuration, choose that serial port. And letís say we want to plug the bar code scanner into port A. As you can see, Iíve already given it a name. We select general purpose. Device settings and here are all the same settings we used before on our bar code scanner. Now that we have configured that external serial port for the barcode scanner, all we have to do is move the cable from our internal serial port to our external serial port. Change our program to point to that external serial port. Say OK, accept it, save it, write it out, and we are ready to go. Now if I run some bar codes through, it works just like before ñ EXCEPT this time it is coming from the external serial port. Very, very easy. That ought to be enough to get you up and running with the barcode scanner on the Automation Direct DoMore PLC. Be sure to check out the other videos in this series for more ways to get up and running quickly with this controller. And as always, please send us any comments you may have, we appreciate the feedback. Spend Less, Do More, from AutomationDirect.