Learn how to sense distance using ultrasonic and laser sensors with a Do-more PLC industrial automation controller in this brief, hands-on demo.
For this demo we’ll be using an Ultrasonic distance sensor that outputs 4-20mA and a Laser Distance sensor that is configured to output 0-10V dc. Watch the Tech Tip videos to see how to setup and configure those sensors. We just take those outputs and wire them into the Analog Inputs of the PLC. The DoMore has several modules we could use for this, but we’re going to use the modules I happen to have handy – a 4 input analog current module and an 8 input 4 output voltage module. For this video we only need one current input and one voltage input. The cool thing about the Do-more is it automatically detects all the installed modules without you having to do anything. Let’s create a new project, and we’ll be connecting to this style Do-more. When we connect to the PLC, we get this dialog that allows us to pick a Do-more that was previously found, or add a new one. This is the one we want so we’ll select that and we see a dialog that says the software is reading the system configuration. We want this blank project, and just like that we’re connected. And if we click on the System configuration and this base, then we see all the modules we currently have. This is the 4 input current module and here is the 8 input and 4 output voltage module. So think about that – we didn’t have to do anything – the software automatically discovers every module in the base. Very cool. If we click on the I/O mappings we can see that the 4 input current module starts at WX0, and the 8 input voltage module starts at WX4. So we’ll wire the Ultrasonics current output into channel WX0 and the laser sensors voltage output into channel WX4. Both of these modules require 24 volts. Here it is on the hardware: 24 Volts on both modules, here’s input WX0 and 1 and here’s input WX4 and 5. The datasheet recommend grounding all unused channels. We didn’t do that for this quick demo, but in your applications you will definitely want to do that. By the way, do we HAVE to accept this I/O mapping? No, not at all. If you hit MANUAL here, you can assign these anything you want. For us and for most of your applications, Auto is just fine. Great, we are wired up and the hardware is configured for us so there’s really not much for us to do except write this configuration to the PLC. Let’s bring up a dataview and watch the Ultrasonic that’s coming in on WX0 and the Laser that’s coming in on WX4. If I put my hand in front of the Ultrasonic we see that respond and do the same for the laser sensor, we see that respond. Perfect. These are 12 bit A to D convertors, so the values range from 0 to 4095. That’s ok, but I really prefer to work in inches, so let’s bring up a scale function. We just enter the source, and its min and max. Then what do we want that to represent? Well, this sensor is setup for 3 to 12 inches so we enter that. Before we setup the Laser, let’s add some nicknames just to make our lives a little bit easier. I’ll bring up the documentation editor and add some stuff. Let’s make D0 the Ultrasonic sensor in inches, D1 the Laser sensor in inches, WX0 is the Ultrasonic sensor raw input to us and WX4 the Lasers raw input to us. Now when we bring up the scale function we don’t have to remember memory locations, we just use the nicknames. This is the Laser sensor. His raw output range, which represents 2 to 16 inches and the result goes in Laser Inches. Perfect. So now in our ladder code, we can just use the inches version of the sensor to make our lives easier – if the laser detects something closer than 10 inches turn on c0. If the Ultrasonic is greater than 8 inches, the turn on c1, for example. Let’s accept those changes and write that to the Do-more. And sure enough, if I wave my hand in front of the sensors, we now see all the results in inches. Exactly what we want. Let’s look at those on the trend view. I’ll create two panes, one for each sensor. On pane 1 we’ll add the Ultrasonic in inches and on pane 2 we’ll look at the laser in inches. Let’s make the Ultrasonic Green and fatter, and let’s make the laser red and a little bit fatter. Close that, wave our hands in front of the sensors and we can see how the sensors respond visually. That’s nice. So between the hardware being automatically configured, the use of nicknames to keep things easy to read and the scale function to convert raw data into stuff we can understand, the Do-more makes PLC programming easy. And the best part – it just works the way you expect it to. If you have any questions, please don’t hesitate to contact automation directs free award winning tech support during regular business hours. They will be happy to help you. And don’t forget the forums. There are lots of folks there that love to share their years of experience. Just don’t post any support questions there. AutomationDirect’s support staff doesn’t monitor the forums on a regular basis.