<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: tbphp Precision Tech</title>
    <description>The latest articles on DEV Community by tbphp Precision Tech (@tbphp_tech).</description>
    <link>https://dev.to/tbphp_tech</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4017874%2F0446d997-327b-4e5a-ba6c-7f6a98180f37.png</url>
      <title>DEV Community: tbphp Precision Tech</title>
      <link>https://dev.to/tbphp_tech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tbphp_tech"/>
    <language>en</language>
    <item>
      <title>We Built a Laser Displacement Sensor Test Rig for Stepper Motor QC</title>
      <dc:creator>tbphp Precision Tech</dc:creator>
      <pubDate>Mon, 06 Jul 2026 13:46:04 +0000</pubDate>
      <link>https://dev.to/tbphp_tech/we-built-a-laser-displacement-sensor-test-rig-for-stepper-motor-qc-3hpo</link>
      <guid>https://dev.to/tbphp_tech/we-built-a-laser-displacement-sensor-test-rig-for-stepper-motor-qc-3hpo</guid>
      <description>&lt;p&gt;We Built a Laser Displacement Test Rig for Stepper Motor QC&lt;br&gt;
We assemble about 500 stepper motor driver boards a month for microneedle pens. Every board gets tested before it ships. For the first two years, that test was simple — power it up, run the motor, listen for weird noises. If it sounded fine, it passed.&lt;/p&gt;

&lt;p&gt;That changed when a customer returned a batch because the pen felt "rough" at a certain depth. We could not reproduce the issue by listening. So we built a test rig that could measure what our ears could not hear.&lt;/p&gt;

&lt;p&gt;This is how we built it and what we learned.&lt;/p&gt;

&lt;p&gt;The problem with listening&lt;br&gt;
Human hearing is terrible at detecting sub millimeter positioning errors. A stepper motor that misses a few steps here and there sounds the same as a perfectly driven motor to anyone standing on the production floor. The difference only shows up in the patient experience — inconsistent needle penetration, micro tears in the dermis, longer healing times.&lt;/p&gt;

&lt;p&gt;We needed a way to measure the actual needle tip position cycle by cycle. A 12 micron error is invisible to the eye and inaudible to the ear. But it is enough to turn a comfortable treatment into a complaint.&lt;/p&gt;

&lt;p&gt;What we built&lt;br&gt;
The rig has four main components:&lt;/p&gt;

&lt;p&gt;A laser displacement sensor with ±1 micron resolution. We used a class 2 laser sensor mounted directly above the needle hub. The sensor beam reflects off the hub surface and reports position at 2000 samples per second.&lt;/p&gt;

&lt;p&gt;An Arduino board running the same firmware that ships on our production driver boards. It generates the STEP and DIR signals at 120Hz stroke frequency and 0.5mm depth — our standard test parameters.&lt;/p&gt;

&lt;p&gt;A CNC aluminum fixture that holds the pen body rigidly in place. The fixture sits on a vibration damping pad because we found that floor vibrations from nearby machines added about 4 microns of measurement noise.&lt;/p&gt;

&lt;p&gt;A Python script that reads serial data from the sensor and logs every data point to a CSV file. After the 10 minute run, it generates a jitter histogram and reports the max deviation, mean, and standard deviation.&lt;/p&gt;

&lt;p&gt;Here is the system diagram:&lt;/p&gt;

&lt;p&gt;Test rig system diagram showing PC, driver, motor, and laser sensor layout&lt;/p&gt;

&lt;p&gt;The firmware that runs the test&lt;br&gt;
The Arduino firmware is straightforward. It generates a constant 120Hz STEP signal with 5 microsecond pulse width. The DIR pin stays high for the full run. We run 2000 steps per cycle at 1/8 microstep resolution, which gives us smooth motion at the operating speed.&lt;/p&gt;

&lt;p&gt;The critical part is the sync signal. We added a digital output pin that toggles at the top of each stroke cycle. The laser sensor uses this signal to align its data capture with the mechanical position. Without this sync, the histogram would include data from both the upstroke and downstroke, which doubles the apparent jitter.&lt;/p&gt;

&lt;p&gt;The histogram that changed our QC pass threshold&lt;br&gt;
The first batch of data from this rig was sobering. Boards that passed our "sounds fine" test showed position deviations of up to 38 microns at the needle tip. That was well outside our ±25 micron target.&lt;/p&gt;

&lt;p&gt;Here is what a good board looks like after a 10 minute run:&lt;/p&gt;

&lt;p&gt;Motor jitter histogram showing normal distribution centered near 0 with ±22 micron max deviation&lt;/p&gt;

&lt;p&gt;The histogram above shows a board that passes. Mean deviation is +1.2 microns. Standard deviation is ±8.4 microns. Max deviation is 22 microns — safely inside our ±25 micron threshold.&lt;/p&gt;

&lt;p&gt;We run every board for a full 10 minutes at 120Hz. That is 72,000 stroke cycles and about 1.2 million position data points per board. The Python script compares the max deviation against our threshold and generates a pass/fail report automatically.&lt;/p&gt;

&lt;p&gt;What we changed after the data came in&lt;br&gt;
Three changes came directly from this rig.&lt;/p&gt;

&lt;p&gt;We tightened the driver board current trim. The first revision of our driver board had a potentiometer based current adjustment that drifted with temperature. We switched to fixed resistor dividers matched within 0.5% tolerance. The jitter histogram narrowed by about 6 microns after that change.&lt;/p&gt;

&lt;p&gt;We added a 100 millisecond warm up delay before data collection. The first 500 milliseconds of motor operation show higher jitter as the driver IC stabilizes its current regulation. We now let the motor run for 10 seconds before we start recording.&lt;/p&gt;

&lt;p&gt;We changed the fixture material from aluminum to a steel aluminum composite. The aluminum fixture transmitted vibration from the motor to the sensor mount. The composite damps those vibrations and reduced measurement noise from 4 microns to about 1.5 microns.&lt;/p&gt;

&lt;p&gt;The code&lt;br&gt;
The Arduino test firmware and Python analysis script are straightforward. The Arduino code generates the STEP signal and sync pulse. The Python script reads the serial stream, bins the position data, and draws the histogram. Total code is about 200 lines across both files.&lt;/p&gt;

&lt;p&gt;The key parameters the script tracks during each run: mean deviation, standard deviation, max positive and negative deviation, and the percentage of cycles that exceed the ±25 micron threshold. Any board with more than 0.1% of cycles outside the threshold gets flagged for manual review.&lt;/p&gt;

&lt;p&gt;What this rig costs to build&lt;br&gt;
Laser displacement sensor: about $400 to $800 depending on the brand and resolution. We use a Panasonic HG C1400, which runs about $550.&lt;/p&gt;

&lt;p&gt;Arduino board and driver electronics: about $35. We reuse the same driver board design that goes into production, so this cost is already sunk.&lt;/p&gt;

&lt;p&gt;Fixture machining: about $200 if you outsource it to a local shop. We have a CNC on site so our cost is materials plus about two hours of programming.&lt;/p&gt;

&lt;p&gt;Total rig cost: under $1,000. For a piece of QC equipment that caught a problem our human inspectors missed for two years. That is a good return.&lt;/p&gt;

&lt;p&gt;We published the full test protocol and firmware at tbphp. If you are building stepper motor driven medical devices or any application where sub 50 micron positioning matters, this rig gives you data instead of guesses.&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>embedded</category>
      <category>iot</category>
      <category>python</category>
    </item>
  </channel>
</rss>
