Technology

You are currently browsing the archive for the Technology category.

tl;dr

The ESP-12F ADC pin appears to consistently read higher values at times when the processor is not as busy. I worked around this by taking the average of multiple reads, and discarding any averages where the number of samples varied dramatically from expectations.

My Application

I’m using an ESP-12F and a TEMT6000 module to measure brightness in an area that also has PWM-modulated LED lighting. I have an AMS1117 providing pretty consistent 3.3V to the circuit and it draws about 41mA. The ESP doesn’t have hardware PWM, so I’m suing the software version with analogWrite(), and I have the PWM frequency set down to about 200Hz because that seems to resolve some flickering issues.

I’m using MQTT (PubSubClient) and the AutoConnect library in my project. I take a brightness measurement every 5 seconds, and, if the resulting value has changed since the previous measurement, I publish the result to a related MQTT topic.

I’m using a 10k/4.7k voltage divider to step down the output of the TEMT6000 module to 1.055V. This circuit switches a separate 12V source that drives the LEDs, and that switching is optically isolated.

ADC analogRead() averaging with PWM LEDs

Because the LEDs turn on and off repeatedly to give the effect of dimming, I sample the ADC pin repeatedly for two PWM wavelengths (100Hz) and average the results. This seems to work out pretty well and is reasonably consistent. I get typically about 45 samples during that time in production. I’ll refer to this average in this post as “the value” or “the brightness” — it’s not an instantaneous value, but an average of several samples. This value is scaled to 0-1000 to approximate the number of mV read. I yield() inside of the sample loop as well.

Stability Techniques Already Employed

I have a 0.1uF tantallum across the ADC pin and GND, and when I sample the ADC pin, I do it twice in a row, ignoring the first sample, because I read somewhere that the first sample can be a bit inconsistent sometimes.

The Problem

From time to time I observed pretty erratic ADC fluctuations, notably right after start-up, and then periodically throughout the day. I haven’t taken the time to figure out if there’s a larger pattern here, but while I was debugging this I started writing out the number of samples actually taken when calculating the brightness value. That’s when I discovered a positive correlation between samples taken and brightness value.

Brightness value on the left, and sample count on the right

The PWM duty cycle is consistent, as is the length of time I take samples for each reading. In this graph, I was doing some extra serial communication, so the number of samples per 100Hz period is lower than the ~45 or so I consistently get in production.

I used my KORAD KA3005P to feed 0.05V to the ADC pin for this test. Note that a value of 61 is usually read when the number of samples is lower than 40, but that value goes up to 68 when the number of samples if over 70. I ruled out a math error — each individual reading does in fact average 68 when more samples are taken.

The Diagnosis

Although I wasn’t able to correlate things like WiFi status with this variation, my guess is that the power used for wireless communication is affecting the ADC readings — when the ESP12F isn’t very busy and can take more samples in the allotted time, then the voltage it reads is a tiny bit higher (~7mV). It’s not a lot, but when you values you expect to see only range 1-60 or so, then it’s significant.

The Work-around

I still haven’t nailed down the exact problem, and I’m not sure I even want to spend the time doing that if this work-around works out, but here’s how I chose to resolve this:

  • I’ve added some code that compares the number of samples actually taken to the number of samples I expect (those that provide a more consistent result).
  • If this “expected sample count” value is zero, then I’ll let the circuit operate normally, and report out the number of samples taken with each reading. This will allow me to figure out how many samples to expect in production.
  • When the “expected sample count” value is greater than zero, I basically just ignore the reading and pretend it hasn’t changed from the previous reading.

This seems to do a great job of smoothing out these erratic ADC fluctuations and providing more consistent brightness readings for my application. I hope others will find this helpful, too, and I’ll update here if I decide to look into it further.

I picked up a $9 Comidox logic analyzer for some ESP8266 work I’m doing, and so far it works great. You really can’t beat the price. Plus, it’s not just for Linux. Here’s how I got it up and running on Windows 10.

  1. Install PulseView software (it’s free). You can find it at sigrok.org. Navigate to Downloads, scroll down to Windows, and select the appropriate PulseView nightly build installer. (I used 64 bit.) Then install the software. This also installs the Zadig USB driver installation tool.
  2. Plug in the logic analyzer — it’ll probably show up as an unrecognized device.
  3. From the Start menu, type Zadig to run the driver installer, select the unrecognized device. Click Edit to change the name to something you recognize like Comidox Logic Analyzer. Be sure WinUSB is selected and click Install. This part can take a few minutes.
  4. From the Start menu, type PulseView. At the top, click where it says Demo Device, change the driver to fx2lafw, choose USB, and then Scan for devices. Select Saleae Logic with 8 Channels and click OK.
  5. Hook up the wires — don’t forget GND — and click Run in the software to start capturing.

We just remodeled our kitchen. A few months ago we had an electrician come out to give us an idea of what it would cost to add in under-cabinet lighting. Five fixtures came in at about $1,800 with a few hundred of that going to a circuit extension. I’m a tinkerer, and that just seemed excessive to me, so I decided to do it myself and saved over 95%.

Now, for about $56 plus time, I have a much better lighting system with three zones of under-cabinet lights, each with its own dimmer, and in-cabinet lighting for some of the deeper cabinets. Here’s how I did it.

The Plan

Here’s the main part of our kitchen. The plan is to add lighting in zones in the following order of priority: 1, 2, 5, 7, 8, 4, 3, 6.

This image has an empty alt attribute; its file name is image.png
  • Zone 1: There’s an outlet for the microwave in here, and I added one for a 12V power supply, which will power all of the kitchen LED lights.
  • Zone 2: These five cabinets (in three distinct sections) should get bright white double-row 5730 LEDs, and will all be controlled by a single dimmer knob in the middle section.
  • Zone 3: Optionally, the drawers should get single-row 5730 lighting when the deeper drawers are opened.
  • Zone 4: Also optionally, each deep cabinets should get single-row 5730 LED lighting when the cabinet doors are opened.
This image has an empty alt attribute; its file name is image-1.png
  • Zone 5: This is a coffee station, so bright white, double-row 5730 LEDs here, on its own dimmer.
  • Zone 6: Optionally, single-row 5730 LEDs to light the lower cabinet — one on each side, that lights when the door is opened.
  • Zone 7: This is a desk, and a computer lives here. We’ll install double-row 5730 LEDs for consistency, and keep them on their own dimmer so they’re not too bright for the monitor.
  • Zone 7: This is our pantry, so I’ll install single-row 5730 LEDs on each side that light up when that side’s door is opened, plus a main switch that can cut these lights off entirely should either of the door switches fail. The bottom doors definitely need it, but these are optional on the top.

Sourcing the Supplies

I order a lot of tinkering supplies direct from China, and this project is no exception. It can take some time for the supplies to arrive that way, but I’ve never had a problem with the quality. With the exception of the one power supply everything is 12V.

From Amazon.com:

Home Depot:

From various AliExpress vendors: (I actually ordered a lot more than I needed for the kitchen here because I’m adding lighting to other areas of the house, too…)

Mounting the LEDs

I cut tiny squares of 1/4″ plywood and screwed the LED channel mounting brackets to them, and then I hot gorilla glued those plywood spacers at the front of the cabinet, directly behind the face frame. This extends them just enough so that the shadow of the face frame falls just outside of the countertop itself and provides a little more opportunity for air cooling. (You can’t just hot glue the LED sticks to the cabinet because the LEDs will just melt the glue. Even with the wood to insulate it, hot glue fixing the bracket to the cabinet failed occasionally.)

Hiding the Wires

The wires are pretty well hidden and they look tidy. For the upper cabinets, the wires usually enter the top cabinet right behind the face frame at one side, travel all the way down through the cabinet fastened to the back of the face frame, and exit at the bottom. There, they enter either one of the 70x45x18 boxes if the zone needs a dimmer, or one of the 50x28x15 boxes if I’m just hiding the connectors.

Reworking the Dimmers

I used the 70x45x18 project boxes when I needed to include any of the dimmer electronics, and basically drilled holes where I needed them based on what wires were present and where they needed to enter for each specific location. The original boxes were pretty big and ugly, and the result is much cleaner.

These photos are for the desk lighting (Zone 7). You should probably be comfortable with a soldering iron before you try this modification, that that’s really easy to do.

Zone 1 – Power Supply Cabinet

This cabinet contains the 12V, 33A power supply, which will be the sole power source for all the LEDs in the kitchen. (The currently installed lighting draws 11.73A with everything on.) This cabinet also contains most of the the dimmer electronics for Zone 2, but not the dimmer knob.

Exiting this cabinet are:

  • three dimmer-controlled 12V wires for each of the three sections of Zone 2
  • one 12V wire leaves goes through the wall and into the lower cabinets in order to power Zones 3 & 4
  • three strands of a Cat5 network wire so the dimmer knob can be positioned on the bottom of the corner cabinet. These are very low current wires, and the length does not affect the dimmer functionality.
  • two additional 12V wires go to the different areas of the kitchen defined below (Zones 5 & 6, and 7 & 8).

Zone 2 – Main Kitchen Under-Cabinets

The three network wire strands and the dimmer-controlled 12V wire enter the top of the corner cabinet at the left and exit at the bottom front left. There, they enter one of the 70x45x18 boxes, where the dimmer knob is mounted and the wires are connected. Remember that the dimmer electronics are actually in the power supply cabinet (Zone 1), because this cabinet is the most convenient location to serve the three distinct areas of the zone (left of the microwave, the corner, and right of the sink).

In the box, the 12V line is split to power the 12 segments under Cabinet 2 (on the left), and the 12 total segments for Cabinets 3 & 4 on the right. (When possible feed the power into the middle of a run like this or else you might start to notice that the LEDs at the end of a run are not quite as bright as the others.)

This zone uses a total of 48 segments (four 50cm LED sticks, with one cut into two parts), and draws 5.23A (62.8 watts) when fully on. This is 0.11A/segment.

  • Cabinet 1 (left of microwave): One 12-segment (50cm) U-shaped LED bar with double-row 5730 LEDs
  • Cabinets 2, 3, & 4 (in the corner): One 12-segment bar of the same for Cabinet 2, and then another cut into one 7-segment bar for the corner, and one 5-segment bar on the right
  • Cabinet 5 (right of the sink): Another single 12-segment (50cm) U-shaped LED bar with double-row 5730 LEDs

Zones 3 & 4 – Main Kitchen Base Cabinets

I haven’t installed these yet, apart from running a single 12V wire from the power supply cabinet through the wall, and then entering the back of the drawer cabinet to the right of the oven. It’s capped off there for later use.

Zones 5 & 6: Coffee Station

The un-dimmed 12V wire from the Power Supply Cabinet is split above the cabinet, with one branch enters the cabinet at the top left and going through to the bottom left, and another branch going through the wall to the back of the lower cabinet (where it’s capped off for later installation). The wire for the under cabinet LEDs enters a 70x45x18 box containing a dimmer (both the electronics and the knob), and the dimmer-controlled output that that feeds the LEDs.

Zone 5 uses a total of 21 segments (1.75 50cm LED sticks), and draws 2.36A (28.3 watts) when fully on. This is 0.11A/segment.

  • One 21-segment U-shaped LED bar with double-row 5730 LEDs, made by joining a 12-segment (50cm) bar with three segments cut from another bar.

Zone 7: Desk

An undimmed 12V wire from the Power Supply Cabinet enters the left glass cabinet at the top left and goes through to the bottom left, where it enters a 70x45x18 box. The box splits the undimmed 12V into two branches: One goes behind the LED strips to the left and into the pantry (described in the next section), and the other goes into the dimmer housed in the same box.

The dimmer has two outputs: One serves a 6-segment bar on the left, and the other serves a 15-segment bar on the right–both made from original 50cm stock. (Note that our kitchen actually ended up with three glass doors instead of four, which is why the cabinet on the left is smaller than the one on the right.)

This zone uses a total of 21 segments (1.75 50cm LED sticks), and draws 1.74A (20.9 watts) when fully on. This is 0.08A/segment. This seems a little lower than it should be, so I still need to debug that. Like before, I try to run the power to the middle of the zone.

  • One 6-segment U-shaped LED bar with double-row 5730 LEDs, made by cutting a 12-segment (50cm) bar in half.
  • One 21-segment U-shaped LED bar with double-row 5730 LEDs, made by joining a 12-segment (50cm) bar with three segments cut from another bar.

Zone 8: Pantry

The pantry wire enters straight into the lower part of the pantry from the junction box in the middle of Zone 7. The wire first goes through a switch that can be used to cut the power to the whole pantry in case any of the limit switches fail closed (on). Then it splits into two: one wire for the bottom left of the pantry, and one for the bottom right. (The upper pantry doors get more natural light than the lower ones, so we didn’t wire those up.)

The wire for each side of the lower pantry first goes through a limit switch wired up as normally closed (NC). This means that when the switch is pressed when the door is closed, the circuit will open and cut the power, and when the door is open, the circuit will close and the lights will turn on.

The in-cabinet lighting doesn’t need to be as bright, so it’s just used single-row 5730 LED bars for these, but two on each side, and again with power going to each set instead of stringing them together. I used V-shaped channels, too, mounted vertically along the inside of the face frame so that the light is projected into the middle of the cabinet instead of toward the back.

This zone uses a total of 48 segments (1.75 50cm LED sticks), and draws 2.4A (28.8 watts) when everything is on. This is 0.05A/segment.

  • Four 12-segment V-shaped LED bar with single-row 5730 LEDs, two for each side.

Conclusion

Not all zones are complete, and I’m not even convinced that we need more lighting at this point. I think I will try to add some of the lower cabinet lighting, though, just for kicks.

Although I spent a more in total on supplies (because I ordered more than I needed for just the kitchen, and there’s still more to install), the total cost of the supplies I’ve actually used in this project is about $56 — just over 3% of the original $1,800 quote. It’s a lot more functional that what was originally quoted, has more fixtures, and probably looks a lot more custom… and I had a lot of fun doing it.

Get comfortable using basic tools

  • Safety first. Each disassembly should be supervised. There are sharp and springy parts, so take proper safety precautions. Adults should NOT let the kids make safety mistakes.
  • Always use the proper tool. For example, don’t try to use a flat-head screwdriver to loosen a Phillips head screw. Use the right size screwdriver tip.
  • Use the tool properly. For example, hold screwdrivers straight so screws don’t get stripped.

Solve disassembly problems

  • Disassemble — don’t break, deform, tear, or cut. Wires, for example, usually don’t need to be cut because they’re often attached to connectors.
  • Take time to infer how parts are assembled — don’t rush disassembly, and in most cases, you shouldn’t need to force anything.
  • Printers can be MESSY! There’s usually a giant ink-filled sponge in them. Use gloves and paper towels to remove this.
    Identify parts that could cause problems before you work on them. (e.g. sharp parts, messy parts, etc.)

Explore how the machines work

  • Again, don’t rush it.
  • For every component you see, try to figure out what it might be for. (This includes circuit boards.) Manufacturers don’t add stuff that’s not required, so there’s usually a reason for everything.
  • Identify subassemblies. One machine will usually disassemble into several subassemblies, each with a particular purpose.

[sc:3dclub-intro]

Here’s a quick update on some of the projects we’ve been working on this year:

We went to the 2014 USA Science and Engineering Festival up in Washington, DC, and we wanted to share it with our fellow school Maker Team members. Here’s the video we produced to do that.

USA Science & Engineering Festival
Washington, DC
April 24-27, 2014
http://www.usasciencefestival.org/

SPECIAL THANKS to: Lockheed Martin, Snap-On, K’Nex, Lulzbot, U.S. Naval Academy, Natasha, NASA, and Printrbot.

MUSIC: “Saturdays Basement” by cdk, 2014 – Licensed under Creative Commons Attribution (3.0) http://ccmixter.org/files/cdk/45072

There are live links on the youtube page for the video for each of these segments:

0:09 Introduction
0:33 Scenes from the Festival
0:53 Lots of 3D Printers!
1:05 Lockheed Martin Large Robot Arm 3D Printer
1:52 Lockheed Martin F35 Lightening II Cockpit Simulator
2:23 Snap-on Racecar
2:33 Huge K’Nex Ferris Wheel
3:14 Lulzbot 3D Printing
3:50 U.S. Naval Academy Robotic Arm
4:52 Natasha the Maker
5:23 NASA Astronaut Alvin Drew
5:57 Brook at Printrbot
6:43 Summary with More Scenes from Exhibits

In this video, Jacob shows an easy way to set up a PCB heatbed for your 3D printer — a method that allows the entire surface of the heatbed to be used for printing. He also shows how to cut inexpensive certificate frame glass to size with some simple tools. We’ve had printers with a heatbed setup just like this running without incident for over a year.

Supplies used: PCB Heatbed (with high-temperature wire attached), glass (same size as heatbed), scissors, kapton tape, four M3 nuts and screws (12-16mm), screwdriver & pliers, thermistor, thermistor lead insulation (kapton tape works, too), and pipe insulation tape. See below for glass cutting tools.

Glass Cutting Tools & Materials: Safety glasses, sheet glass (certificate frame glass works well), glass cleaner, paper towels, permanent marker, ruler, cutting oil, straight edge, glass cutting tool, breaking edge, leather gloves, and sandpaper.

A project-based RepRap build is the perfect way to bring STEM and many other disciplines to your school. To learn more about starting a 3D printer build at your school, visit http://www.thefrankes.com/wp/?page_id=2766.

Music

[sc:3dclub-intro]

Here’s a video to the team from software developer and RepRap expert Alessandro Ranellucci, the creator of the extremely popular Slic3r software.

Random wires are ugly, so we decided to ask for some spare spiral binding coil at the local office supply store and walked away with a handful of 6mm and 10mm coils. They make for very nice wire wrap.

Spiral Binding Coil Wire WrapSpiral Binding Coil Wire Wrap

Spiral Binding Coil Wire Wrap

We made a video to show the difference in noise between the Pololu A4988 Stepper Motor Driver Carrier, which has 1/16 steps, and the DRV8825 Stepper Motor Driver Carrier which has 1/32 steps. These drivers are common in RepRap 3D printers. The resistor soldered onto the DRV8825 is not required on their latest versions of the board.

The goal for this video was originally to capture the difference in sound that I noticed when I switched from one driver to the other, and this test seemed to do that. I updated it to be a bit more scientific than it was originally by carefully setting the current limit, adjusting the steps per unit, and including details about the setup.

For this test:

  • 12.17V DC 
  • Kysan 1124090 (1.8°, 1.5A/phase) stepper motor
  • 18T Aluminum GT2 2mm Belt/Pulley
  • PLA bushings on W1 tool steel smooth rod with white lithium grease
  • 1.3A current limit using VREF method

« Older entries