Multiextrusion 3D Printing and OpenSCAD

In a recent posting called Liar’s 3D Printing, I showed you how you can print with multiple filament colors even if your printer only has one extruder and hot end. It isn’t easy, though, and a lot of models you’ll find on sites like Thingiverse are way too complicated to give good results. An object with 800 layers, each with two colors is going to take a lot of filament changes and only the most patient among us will tolerate that.

What that means is you are likely to want to make your own models. The question is, how? The answer is, of course, lots of different ways. I’m going to cover how I did the two models I showed last time using OpenSCAD (seen below). The software is actually really well suited for this hack, making it easy for me to create a framework of several models to represent the different colors.

About OpenSCAD

I’m not going to say much about OpenSCAD. It is less a CAD package and more a programming language that lets you create shapes. We’ve covered it before although it changes from time to time so you might be better off reading the official manual.

The general idea, though, is you use modules to create primitives. You can rotate them and translate them (that is, move them). You can also join them (union) and take the difference of them (difference). That last is especially important. For example, look at the callsign plate above. Forget the text for now. See the two holes? Here’s the OpenSCAD that creates that shape:

 difference() {
 // cut holes
 translate([4,basel/2,0]) cylinder(r=2,h=basez+2);
 translate([basew-4,basel/2,0]) cylinder(r=2,h= basez+2);

The cube “call” creates the base. The cylinders are the holes and the difference “call” is what makes them holes instead of solid cylinders (the first thing is the solid and everything after is taken away). One key point: instead of numbers, the whole thing uses (mostly) variables. That means if you change the size of something, everything will adjust accordingly if you wrote the script well. Let’s look at applying these techniques for multiple colors.

Continue reading “Multiextrusion 3D Printing and OpenSCAD”

Cheating at 5V WS2812 Control to Use 3.3V Data

If you’re looking to control WS2812 (or Neopixel) LEDs using a microcontroller running at 3.3 volts, you might run into some issues. The datasheet tells us that a logic high input will be detected at a minimum voltage of 0.7 * Vcc. If you’re running the LED at 5V, this means 5 V * 0.7 = 3.5 V will be needed for the WS2812 to detect a ‘1’ on the data line. While you might get away with using 3.3 V, after all the specification in the data sheet is meant to be a worst case, it’s possible that you’ll run into reliability issues.

So usually we’d say “add a level shifter to convert 3.3V to 5V” and this post would be over. We even have a whole post on building level shifters which would work fine for this application. However [todbot] at CrashSpace came up with a nifty hack that requires fewer components yet ensures reliability.

bigbutton-front-backFor the Big Button project at CrashSpace, [todbot] used an ESP8266 running at 3.3 volts and WS2812 LEDs running at 5 V. To perform the level shift, a signal diode is placed in series with the power supply of the first LED. This drops the first LED to 4.3 V, which means a 4.3 V * 0.7 = 3.01 V signal can be used to control it. The logic out of this LED will be at 4.3 V, which is enough to power the rest of the LEDs running at 5 V.

This little hack means a single diode is all that’s needed to control 5 V LEDs with a 3.3 V microcontroller. The first LED might be a little less bright, since it’s operating at a lower voltage, but that’s a trade off [todbot] made to simplify this design. It’s a small part of a well-executed project so be sure to click-through and enjoy all the thought [todbot] put into a great build.

Hackaday Dictionary: Open- and Closed-Loop Systems

Today on Hackaday Dictionary, we’re going to talk about the two basic types of control systems: open-loop and closed-loop. We’ll describe the differences between them and explore the various advantages and disadvantages of each. And finally, we’ll talk about what happens when you try to draw a line between the two.


And there was much rejoicing. Image via Racoon Valley Electric Cooperative

Control Systems

Control systems are literally all around us. They’re illuminating our rooms, laundering our unmentionables, and conspiring to make us late for work. Most of us probably use or interact with at least five control systems before we’re even out the door in the morning. Odds are you’re using a control system to read this article.

When we say ‘control system’, we’re speaking broadly. A control system is defined as any system that exhibits control over a function. It doesn’t matter how big or small the function is. A standard light switch is a simple type of control system. Flip it back and forth and the light is either on or off with no in between. Too bright? Too bad. There is no way to account for light intensity preference, use duration, energy output, or anything else.

A humble clothes dryer. Image via Showplace Rents

Another common example in discussing control system theory is the clothing dryer. Set the timer on the dryer and it will run until time expires. Will it run long enough to dry everything without shrinking anything? The only way to know is to open the door and check.

Both the light switch and the clothes dryer are open-loop systems. The process is a straight line from start to finish, and they operate without concern for their output. Once the light switch is flipped to the on position, current will flow until the switch is reversed. The switch doesn’t know if the bulb is burned out or even screwed into the socket to begin with. And the clothes dryer doesn’t care if your clothes are damp or dry or totally shrunken when time runs out.


Stay in the Loop

In a closed-loop system, the process begins the same way it does in an open-loop system. But a closed-loop system has one or more feedback loops in place that can adjust the process. Sometimes the feedback will simply cause the process to repeat until the desired result is achieved.

Both of our open-loop control system examples above could easily be converted to closed-loop systems. A more advanced light switch might take input from a photo cell, or it could poll a motion detector and turn the lights off after a period of no detectable activity in the room. The clothes dryer could be improved with the addition of a moisture sensor. Since the humidity level in the dryer will change during the cycle, why not poll a DHT22 and re-run the process until a predetermined humidity level is reached? Then the dryer becomes a closed-loop system. No more reaching in and fondling the towels and shirt collars to make sure everything is dry. Well, at least in theory.

What are they telling you? xkcd #1116

Some control systems exist in both forms. Traffic lights are a good example of this phenomenon. Some lights are open-loop and simply run on a schedule. Many more of them are closed-loop and will cycle differently depending on traffic flow or information received from other traffic lights. The really smart ones have Emergency Vehicle Preemption (EVP) receivers. This is the system that allows fire trucks and some other emergency vehicles to change the lights in their favor. A device in the vehicle strobes a specific pattern at the receiver module on the light post, and the light changes as soon as possible.


Cruise control via Wikipedia

Advantages and Disadvantages

The main advantage of closed-loop systems is fairly obvious: using feedback means more and better control. But there are trade-offs. It’s almost impossible to deal with all the what-ifs in creating any system, and this generates unforeseen issues. They aren’t all bad, though. Maybe you’re sitting peacefully in the corner engrossed in a book, and the motion detector-driven lights shut off because you aren’t moving around enough.  That isn’t ideal, but it’s easy enough to turn the lights back on and keep reading.

The unforeseen issues can be so much worse than sudden darkness. Case in point: robotic vacuum cleaners. Here you have a complexly closed-loop system to take care of one of life’s drudgeries. Should be awesome, right? Yes, but because it is blind to everything but its pre-programmed boundaries, it doesn’t know not to spread messes around.

A lot of closed-loop control systems look great on paper, but their imperfections become clear in execution. Take cruise control for example. Here is a system that’s better at its job than humans are. It will maintain the set speed until you hit the brakes or run out of gas. It will perform as intended whether there is a headwind or a tailwind or you’re towing a boat or transporting rowdy children. But cruise control isn’t aware of cliffs or guard rails or deer darting out in front of the car. Cruise control keeps its head down and does its job until it can’t go on.

Open-loop systems may not be as smart as closed-loop systems, but they often shine in their simplicity. For the most part, they do what you expect them to do. Light goes on, light goes off. And they are arguably more dependable since there are fewer things that can go wrong. Of course, a “simple” open-loop control system can mean a steeper learning curve. It’s not easy to learn to drive a manual transmission. But if you don’t know how to drive one, you’re missing out on some nice advantages, like the ability to push start the thing if you have to, and the option to downshift instead of pumping the brakes in icy conditions. So the question is this: is an open-loop system more valuable than a closed-loop system if it means having more control over the process? Does it depend entirely on the process in question?

This tricycle is simultaneously safe and unsafe. Image via Apple Door

Open-Loop vs. Closed-Loop

So where exactly does open-loop end and closed-loop begin? The line seems clear for some systems, but muddy for others. How much feedback is enough to qualify? Add just about anything to a light switch and it seems safe to say that you took it from open- to closed-loop.

More often than not, the line between the two is blurry. Think of a motorized garage door.  You push the button and the door either opens or closes. Push it again and the door moves in the opposite direction. Most modern garage doors have a fail-safe in place to stop the garage door in the event of an emergency. If the door encounters any resistance, it will stop and reverse direction.

The break beam detector is supposed to keep people and their tricycles from being crushed if they happen to be in the way while the door is closing. But it only works if the person or thing breaks the IR beam. There’s only one beam, and it sits about six inches off the floor. The motorized garage door system is actually quite limited because it has no positional awareness. It doesn’t know where it is on the track, it’s just going up and down blindly, waiting for input or resistance.

Not all doors can be counted on to stop if they feel resistance—I tested mine and it kept on going. So if I don’t pull far enough into the garage and then put the door back down, it might hit the protruding rear end of my hatchback. It’s in the way of the door closing, but it sits way too high to break the beam. So is the garage door really, truly a closed-loop system?

New Lathe Day is Best Day

As [Quinn Dunki] rightly points out, modern industrial civilization was probably conceived on the bed of a lathe. Turning is an essential step in building every machine tool, including lathes, and [Quinn] decided it was time to invite one into her shop. But she discovered a dearth of information to guide the lathe newbie through that first purchase, and thus was born the first installment in her series on choosing and using a new lathe.

As for the specifics of the purchase, [Quinn]’s article goes into some depth on the “old US iron” versus “new Asian manufacture” conundrum. Most of us would love an old South Bend or Cincinnati lathe, but it may raise practical questions about space planning, electrical requirements, and how much work is needed to get the old timer working again. In the end, [Quinn] took the path of least resistance and ordered a new lathe of Chinese heritage. She goes into some detail as to what led to that decision, which should help other first-timers too, and provides a complete account of everything from uncrating to first chips.

Nothing beats the advice of a grizzled vet, but there’s a lot to be learned from someone who’s only a few steps ahead of her intended audience. And once she’s got the lathe squared away, we trust she’ll find our tips for buying a mill helpful getting that next big shipment delivered.

“All the best things in life arrive on a pallet.” Have truer words ever been spoken? Sure, when the UPS truck pulls up with your latest Amazon or eBay treasure, it can be exciting. But a lift-gate truck rolling up to the curb? That’s a good day.

Sentry Robot Turns Bad Cat to Good

The household of [James Watts] has cats, and those cats have decided that various spots of carpet are just great for digging up with their claws. After some efforts at training the cats, [James] enlisted a robotic cat trainer with remote wireless sensors. The automated trainer does only one job, but it does that one job reliably and tirelessly, which is just what is needed in this case. A task like “automate training the cats to stop clawing the carpet” is really made up of many smaller problems, and [James] implemented a number of clever ideas in his solution.

First of all, the need for an automated solution has a lot to do with how pets form associations, and the need to have the negative reinforcement be in the right place at the right time to be effective. A harmless spritz of water in this case is used for correction and needed to be applied immediately, consistently, and “from out of nowhere” (instead of coming from a person.) Otherwise, as [James] discovered, spraying water when the cats clawed the carpet simply meant that they stopped doing it when he was around.

There were a number of tricky problems to solve in the process. One was how to reliably detect cats actually clawing the carpet. Another was how to direct the harmless spray of water to only the spot in question, and how to rig and manage a water supply without creating another mess in the process. Finally, the whole thing needed to be clean and tidy; a hackjob with a mess of wires strung everywhere just wouldn’t do.

base_frontTo achieve all this, [James] created a main sprayer unit that is wirelessly connected to remote sensor units using NRF24L01+ serial packet radios. When a remote senses that a trouble spot is being clawed, the main unit uses an RC servo to swivel a spray nozzle in the correct direction and give the offending feline a watery reminder.

The self-contained remote sensors use an accelerometer to detect the slight lifting of the carpet when it’s being clawed. [James] programmed the MMA8452Q three axis accelerometer to trigger an external pin when motion is sensed above a certain threshold, and this event is sent over the wireless link.

For the main sprayer unit itself, [James] cleverly based it around an off-the-shelf replacement windshield washer tank. With an integrated pump, tubing, and assortment of nozzles there was no need to design any of those elements from scratch. If you want to give the project a shot, check out the github repository — probably worth it it since one night is all it took to change the cat behavior which explains the lack of any action video.

Pet projects usually center around automating the feeding process, but it’s nice to see other applications. For something on the positive-reinforcement end of training, check out this cat exercise wheel that integrates a treat dispenser to encourage an exercise regimen.

Recapture Radio’s Roots with an Updated Regenerative Receiver

Crystal radios used to be the “gateway drug” into hobby electronics. Trouble was, there’s only so much one can hope to accomplish with a wire-wrapped oatmeal carton, a safety-pin, and a razor blade. Adding a few components and exploring the regenerative circuit can prove to be a little more engaging, and that’s where this simple breadboard regen radio comes in.

Sometimes it’s the simple concepts that can capture the imagination, and revisiting the classics is a great way to do it. Basically a reiteration of [Armstrong]’s original 1912 regenerative design, [VonAcht] uses silicon where glass was used, but the principle is the same. A little of the amplified RF signal is fed back into the tuned circuit through an additional coil on the ferrite rod that acts as the receiver’s antenna. Positive feedback amplifies the RF even more, a germanium diode envelope detector demodulates the signal, and the audio is passed to a simple op amp stage for driving a headphone.

Amenable to solderless breadboarding, or even literal breadboard construction using dead bug or Manhattan wiring, the circuit invites experimentation and looks like fun to fiddle with. And getting a handle on analog and RF concepts is always a treat.

[via r/electronics]

Optimizing Linux for Slow Computers

It’s interesting, to consider what constitutes a power user of an operating system. For most people in the wider world a power user is someone who knows their way around Windows and Microsoft Office a lot, and can help them get their print jobs to come out right. For those of us in our community, and in particular Linux users though it’s a more difficult thing to nail down. If you’re a LibreOffice power user like your Windows counterpart, you’ve only really scratched the surface. Even if you’ve made your Raspberry Pi do all sorts of tricks in Python from the command line, or spent a career shepherding websites onto virtual Linux machines loaded with Apache and MySQL, are you then a power user compared to the person who knows their way around the system at the lower level and has an understanding of the kernel? Probably not. It’s like climbing a mountain with false summits, there are so many layers to power usership.

So while some of you readers will be au fait with your OS at its very lowest level, most of us will be somewhere intermediate. We’ll know our way around our OS in terms of the things we do with it, and while those things might be quite advanced we’ll rely on our distribution packager to take care of the vast majority of the hard work.

Linux distributions, at least the general purpose ones, have to be all things to all people. Which means that the way they work has to deliver acceptable performance to multiple use cases, from servers through desktops, portable, and even mobile devices. Those low-level power users we mentioned earlier can tweak their systems to release any extra performance, but the rest of us? We just have to put up with it.

To help us, [Fabio Akita] has written an excellent piece on optimizing Linux for slow computers. By which he means optimising Linux for desktop use on yesterday’s laptop that came with Windows XP or Vista, rather than on that ancient 486 in the cupboard. To a Hackaday scribe using a Core 2 Duo, and no doubt to many of you too, it’s an interesting read.

In it he explains the problem as more one of responsiveness than of hardware performance, and investigates the ways in which a typical distro can take away your resources without your realising it. He looks at RAM versus swap memory, schedulers, and tackles the thorny question of window managers head-on. Some of the tweaks that deliver the most are the easiest, for example the Great Suspender plugin for Chrome, or making Dropbox less of a hog. It’s not a hardware hack by any means, but we suspect that many readers will come away from it with a faster machine.

If you’re a power user whose skills are so advanced you have no need for such things as [Fabio]’s piece, share your wisdom on sharpening up a Linux distro for the rest of us in the comments.

Via Hacker News.

Header image, Tux: Larry Ewing, Simon Budig, Garrett LeSage [Copyrighted free use or CC0], via Wikimedia Commons.