A Low-Cost Laser Measurement System
A couple years ago, I randomly stumbled on some Micro-Epsilon laser triangulation sensors on eBay for very cheap. Conveniently, these sensors have a 4-20mA analog output making them easy to interface to other instruments. This project shows the PCB I made to interface two of the sensors to a Digilent Analog Discover 2 USB data acquisition system.
Introduction
Probably the best place to start is to answer the question: why do I need this? The answer has a few parts. First, measuring things with lasers is cool. Furthermore, being able to measure very small displacements without actually touching the thing that’s moving is really cool, and useful for some projects I have in mind. For example, I could measure the excursion of a loudspeaker cone. I also think that being able to measure very small, and potentially very slow, movements could be useful for seismic instruments.
Figure 1: Laser triangulation sensors can be used to measure very small movements, such as the motion of a loudspeaker cone.
Figure 2: A simplified diagram of a laser triangulation sensor by Keyence. Movement of the measurement surface from position one to position two changes where the reflected light hits the light receiving element.
The Sensors
The Keyence website has a great page with diagrams for multiple laser displacement sensors. Their simplified diagram for a laser triangulation sensor is shown in Figure 2. The sensor consists of a diode (semiconductor) laser, detector (“light receiving element”) and focusing optics. The diode laser is collimated through the transmitter lens and impacts a surface. The light reflected from the surface passes through the receiving optics and lands on the detector which is most often an array of sensors. This detector could be a linear array of photodiodes, a position sensitive detector (PSD, essentially two photodiodes), or a CCD or CMOS image sensor. Notice from the diagram that when the distance between the surface and the sensor changes (moves from location 1 to location 2) the angle at which the reflected light passes through the receiving lens changes, and the location that it hits the light receiving element changes. Using a large number of very small pixels in the detector allows these sensors to detect extremely small displacements over a relatively large measurement range.
ILD1302-20 Sensor Specifications
Some of the datasheet technical specifications for the sensors that I have (Micro-Epsilon ILD1302-20) are shown in Figure 3. I have the -20 variant and outlined those specs in red. From the table, you can see that the sensors have a measurement range of 20 mm, and a resolution down to 4 microns (when averaging over 64 samples)! The measurement rate is 750 Hz, so hopefully I can measure vibrations up to 375 Hz. It’s also useful to note that they need 11 to 30 VDC and 50 mA of current.
Figure 3: Selected specifications from the datasheet of the Micro-Epsilon ILD1302-20 laser triangulation sensors used in this project.
ILD1302-20 Sensor Pinout
This sounds simple but really needs it’s own section because I screwed it up the first time I tried to connect to these things. In Figure 4, I’ve put a pinout for the sensor, viewed as if you’re looking at the back of the sensor like I show in the picture. I’ve tried to orient the sensor in the picture in the same manner as the pinout diagram (notice the notch for the cable connector at the top right) and I include an arrow showing pin 1 in the picture.
Figure 4: Modified pinout diagram for the sensor with pin numbers assuming you are looking at the sensor as shown in the image on the right. Pin 1 is called out in the image for further clarification.
Figure 5: Pin description table from ILD1302-20 sensor datasheet. The pins I will be using are outlined in red.
Now you might be thinking, “Hey! That image is mirrored from the pinout diagram in the datasheet!” And you’d be right. The pinout in the datasheet includes the totally vague caption “pin side male cable connector” which I, of course, interpreted to mean the orientation which I show in the picture above and is definitely incorrect. Here’s a tip: notice in the pinout table from the datasheet that pins 3 and 4 are internally terminated with a 120 Ohm resistor for an RS-422 interface. You can use a multimeter to confirm the correct pinout orientation by measuring the resistance between (what you think are) pins 3 and 4. I put a red box around the pins that I’m going to be using in this project. Since I’m going to be using the 4 to 20 mA output (pin 11), I won’t need to connect to pins 3-6 for the RS-422 interface. The function of the rest of the pins is given in the table.
Figure 6: Cables for the sensors were made from 6 ft ethernet cables with the original connectors removed. A circular connect was added to one end and the wires at the other end were simply stripped and tinned.
Sensor Cables
In order to connect to the sensors, I decided to make some custom cables from 6 ft ethernet cables I had lying around (shown in Figure 6). Micro-Epsilon does make cables to connect the sensors to their own instrumentation, but I’m guessing they’re expensive and I needed something more versatile since I would be connecting the sensors to my own interface PCB. I cut off the ethernet connectors and on one side I soldered this circular connector. Conveniently, the connectors come with a ferrule that screws onto the laser triangulation sensor to hold the cable in place. On the other side of the cable I just stripped and tinned the wires to make it easier to connect to a PCB with screw terminals. Heat shrink tubing was put on both ends of the cable to protect the connections and the cable jacket itself. Figure 7 below shows one of the laser triangulation sensors in a mount with the cable connected. Figure 8 shows the screw terminals on the interface PCB with both cables connected. In the future I will likely make some cables with a proper connector for the interface PCB since the screw terminals are a bit of a hassle.
Figure 7: Laser sensor with mount (description below) with cable attached to it.
Figure 8: Stripped end of the sensor cables are inserted into screw terminals on the interface PCB.
Sensor Mounting
Given the sensitive nature of these measurements, I needed a secure fixture to hold the sensors when making a precise measurement. Figure 7 shows the solution I came up with. I had the idea of using the magnetic-base holders for dial indicators that machinists use. These can be found for very cheap on Amazon, are relatively stable, and allow for small adjustments to be made of the sensor position. These holders have a magnetic base that can be switched on to securely hold the fixture to a metal surface, but the base is heavy enough to keep the mount stable even when not on a metal surface.
To secure the sensor to the magnetic base, I had a mounting plate laser cut from 4mm acrylic at Ponoko (Figure 9). The plate includes holes to mount the sensors in multiple orientations (Figure 10), and a larger hole at the top which allows the plate to be affixed to the dial indicator stud that comes with the base. There are also two notches in the side of the plate which would allow it to be bent at a 90 degree angle (using a heat gun) to change the sensor orientation further.
Figure 9: Sensor mounts were laser cut from 4mm acrylic. The mount on the right still has the backing paper on. Hardware (nuts, bolts, washers) were purchased at my local hardware store.
Figure 10: Sensor mounted in a vertical orientation rather than horizontal.
Figure 11: Interface PCB for the Analog Discovery 2 (not shown).
Interface PCB
The interface PCB which connects the sensors to a Digilent Analog Discovery 2 (AD2) USB data acquisition system is really the “meat” of this project and is shown in Figure 11. The PCB has several functions:
Provide power to the sensors from a 24V “wall wart”. The barrel connector for the wall wart, and power indicator LED can be seen at the top of of the PCB in Figure 11.
Terminate the 4-20mA output of the sensors with a suitable resistance to convert the current output into a voltage that can be measured by the AD2.
Allow for the laser state and “teach” functionality of the sensors to be toggled using the GPIO pins of the AD2.
Indicate the fault state of the sensor when the measurement surface is out of range.
Provide BNC outputs for the waveform generator channels of the AD2.
The schematic for the PCB is shown in Figure 12. Schematic capture and PCB layout were done in KiCad which was a learning experience for me since I’ve only used Altium and Cadence in a professional setting previously. KiCad is a fantastic piece of software and I highly recommend it! I’ll walk through some of the highlights of the PCB. First, J10 is the power connect for a 24V “wall wart” power supply. There is some filtering capacitance right at the connector and a green indicator LED (D3) as well. I like having an indicator LED like this because it makes answering the “is the power on?” question super fast. I will say that despite R15 being 10k Ohms, D3 is BRIGHT! In future versions of this PCB, I’ll increase R15 for sure. J9 is the connector to the AD2 and you can see the connections I’m using labeled on the schematic. J9 is actually soldered on the backside of the PCB, which allows for the AD2 to sit flat on a surface when standoffs are on the interface PCB.
Figure 12: Schematic for the interface PCB. Schematic capture and PCB layout were all done in KiCad.
J1, J2, J3 and J4 are each 2-terminal screw connectors for the 4-20mA output from the sensors. J1 and J2 combine for 1 sensor (channel 1) and J3 and J4 combine for a second sensor (channel 2). I used 2x 2-terminal connectors rather than a single 4-terminal connector because these connectors can snap together to make any number of connections needed. By only purchasing 2 and 3 terminal blocks, I can save on Bill of Materials (BoM) items and money.
Since the analog inputs for both channels are the same, I’ll concentrate on J1/J2. Pin 1 of J1 is the power connection for the sensors and therefore has an additional filter cap, C1, at the connector. The next two connections (pin 2 of J1, pin 1 of J2) are the 4-20 mA connections from the sensor. 1k Ohm resistors R1 and R5 are in parallel to form the recommended 500 Ohm resistance (converts 4-20 mA to 2-10 V) when using a 24Vdc power supply. JP1 allows these resistors to be disconnected if a more generic connection of the PCB to a voltage source is required. The AD2 features differential inputs on the analog channels. IN1+ and IN1- are routed on the PCB directly to the termination resistors (R1/R5) and the jumper JP1. Jumper JP2 shorts IN1- to ground. If floating the differential inputs is preferred for other uses, JP2 can be removed.
Connectors J7 and J8 handle the logic level signals to and from the sensors. Pin 1 of both connectors connects to the “laser off” pin of the sensor. This pin is held low to keep the laser turned on. Pin 2 handles the “teach” functionality of the sensors. Both of these pins are connected to GPIO pins of the AD2 in case I want to use them in the future. Pin 3 of both connectors is the error flag, which is an open-drain output on the sensor. These pins have a red LED connected to the 24Vdc supply through a 10k Ohm resistor. When the pin on the sensor is pulled low, indicating a fault condition, the red LED lights up.
Lastly, J5 and J6 are BNC connectors for the waveform generator outputs of the AD2. The two 100 Ohm resistors in parallel on each output is my lazy/cheap way of implementing a standard 50-Ohm termination with resistors I already had.
Putting it all Together and Making Measurements
The complete system is shown in Figure 13, including two sensors on mounts, the interface PCB, AD2, and a laptop. A close-up image of the interface PCB and AD2 is shown in Figure 14. For taking measurements, I’m using the “Waveforms” software from Digilent that is included with the AD2. In the future, I might write some custom code in Python for this setup, but for now Waveforms is fine. I did tweak the “Logger” window to display measurements in mm directly from the sensor (instead of volts).
Figure 13: Complete laser measurement system showing two sensors in their mounts (different orientations) connected to the interface PCB and AD2 connected to a laptop via USB.
Figure 14: Close-up image showing the interface PCB connected to the AD2
In order to demonstrate the overall functionality and sensitivity of this system, I took a few basic measurements. The first measurement I made was to slide a penny under a sensor pointed at my desk while running the data logger. The measurement setup is shown in Figure 15, and the resulting data is displayed in Figure 16. The data logger reads out the absolute distance from the front of the sensor which makes it difficult to see very small variations. I should probably zero the measurement first…Any way the cursors show the variation over the surface (Lincoln’s face) to be about 111.2 microns. It’s pretty cool to be able to measure that at a distance of 43 mm without actually touching the penny!
I did a similar test with a single sheet of paper, sliding it back and forth on the desk in and out of the measurement spot. The measurement is shown in Figure 17. The measured thickness of the paper changes quite significantly based on how flat I could press it against the desk. I measured 280.7 microns. A quick google search gives a value of 100 microns for standard printer paper, so obviously I didn’t get it very flat against the desk.
Figure 15: Sensor pointed at a penny in order to measure the height variation over the surface
Figure 16: Data logger graph of a penny moving under the sensor
Figure 17: Data logger graph of a piece of paper moving under the sensor
I wanted to try measuring the change in loudspeaker cone excursion over frequency for a given signal (voltage) level. These sensors make this measurement fairly easy to do. The setup is shown way back in Figure 1. Since the interface PCB has BNC outputs for the waveform generator, I could connect the board to an audio amplifier using BNC-to-RCA adapters. The network analyzer built into waveforms handled the frequency sweep and graphing the output however I had to send the raw data to a spreadsheet to convert it from Vrms to mm.
The graph is shown in Figure 18, and I’ll apologize right now for not writing down what signal voltage I used for this test. There’s a couple interesting things to note, first there is a dip in excursion around 55 Hz, which I believe is the port tuning frequency of the enclosure. Second, notice that the excursion declines as frequency increases which is exactly what would be expected.
Figure 18: Graph of loudspeaker cone excursion vs frequency for the woofer on my DIY desktop computer speakers.
Closing Thoughts
I’m really happy with how this project turned out. An impulse purchase on eBay turned into a really useful and capable instrument for my lab at a reasonable cost. It also gave me a good reason to learn KiCad for PCB layout which really is a fantastic piece of software.
Some things I would change if I were to re-do the project, or update it in the future:
Run the sensors off of 12V instead of 24V. Initially I was thinking 24V would allow for larger signals to maximize the signal-to-noise ratio of the system. But everything is limited by the 12-bit DAC in the sensor output, the wider signal range actually forces the AD2 into a lower performance mode.
Higher value resistors on the LEDs. Holy crap are they too bright!
Use a dedicate connector for the sensors instead of screw terminals on the interface PCB. Screw terminals make disconnecting and reconnecting sensors tedious.
There’s a ton of things I’d like to use this setup for and I really only scratched the surface here. But my goal here was just to summarize the system and give tips to anyone else that happened to purchase these (or similar) sensors. Hopefully you got some value out of this write-up, check back for my next project!
Figure 19: I’d like to acknowledge the contributions of my supervisor to making this project a success.