|AutomationDirect Live Chat|
Learn how to sense distance using ultrasonic and laser sensors with a CLICK 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-10 Volts. 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. We’re going to use a FOUR input analog current module and a FOUR input analog voltage module. We only need one current input and one voltage input for this video. As a side note, could we have used one of the Analog Click PLCs here? Sure. They come with 2 analog current inputs and two analog voltage inputs. The only issue is the voltage inputs are 0-5Volts, but our sensors are 0-10Vdc. So for this example we could only eliminate the extra current module. We’re using external current and voltage modules in this video because this test rack is also used for other videos and was already setup this way. In a real application would I probably use one of the CLICKs with the built in analog ports just to save about 50 bucks and DIN rail space. But for this video this is the hardware we will be using. We have two of the current inputs wired and two of the voltage inputs wired even though we are only using one of each. And here’s the 24vdc required by both modules. These zero volt points are electrically connected to this zero and are provided for your convenience to tie off the sensor common. Our test setup has the commons tied together off screen on some DIN rail terminal blocks which are electrically connected to these so we’re in good shape. While we’re looking at these modules, I should probably point out that the pricing on these modules is crazy – it’s one of the least expensive PLC’s you’ll find anywhere. And that there are lots of options. For example, these are dedicated analog input modules. There are also dedicated analog output modules and even combo modules that do both analog in and analog out. It’s amazingly flexible and inexpensive. The cool thing about the CLICK is it automatically detects all the installed modules without you having to do anything. Let’s create a new project, connect to the CLICK PLC – this one is on com 5 – we don’t want the project that is currently in the CLICK PLC, and just like that, all the modules in the CICK PLC are automatically discovered. We can see that in the System configuration. It’s reminding us to select the power supply and that we need to configure the analog modules. Let’s go ahead and select the power supply – we’re using the 01 version. Do you have to select the power supply? Not really, but having that selected, the software can now automatically calculate the power budget and warn you if you don’t have enough power, so it is a good habit to get into. Here we see our CPU and the two analog modules, the 4 input current module and the 4 input voltage module. Click on CONFIG to setup the current input module. Our input range is from 4 to 20 ma, that represents 3 to 12 inches and we’ll put that result in DF1. How cool is that – the CLICK automatically does the scaling for you! The raw value we get in the ladder code will already be in inches. We don’t have to use a separate ladder function to do it. I love that. Because this continuous address is selected, the software automatically assigned DF2 to DF4 to these guys even though we are not using them. So when we do the Voltage input module, which will run from 0-10 volts, which represents 2 to 16 inches, we need to put that result in DF5 – the next available location. As we exit out of here, we get a reminder that the system configuration has changed and we need to send it to the CLICK. It also reminds us that analog module nicknames are assigned automatically. That’s fine. Let’s add an END and then write the project out to the CLICK PLC. Save it. Say ok, yes we want to over write the current project. Let’s bring up a dataview and see what the Ultrasonic and Laser sensors are doing. If I put my hand in front of the ultra sonic sensor, we see it respond and the same for the laser sensor. Perfect. To use that in the ladder code, we just grab a compare contact and compare the ultrasonic output to some level in inches because remember - the CLICK has already scaled the value for us, and then we use that to enable an output coil. If you prefer nicknames for the memory addresses, just go to program, address picker. Select the DF memory type we are using, and give them a name. We’ll label DF1 Ultrasonic and DF5 Laser. Now the name of the memory location appears on the ladder code making it much easier to understand. We’ll have that drive output coil y2 and we’ll add an end. Transfer that to the CLICK PLC. And if I put my hand in front of the sensors we see the result. Perfect. If you have any questions, please contact AutomationDirect’s 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. Don’t post any tech support questions there, AutomationDirect’s support staff doesn’t monitor the forums on a regular basis.