Just another WordPress site

Menu

Full disclosure: I have no idea what I’m doing. If you arrived here by googling CONTROL LED NPN TRANSISTER then you probably know only slightly less about electronics than I do.

Frankly I’m not real clear on exactly what voltage is. People keep telling me charge is like a swimming pool, and the voltage is how much water pressure you have, and the current is how much water flows out of the pool, and resistance is how big the pipe is that the water’s flowing out of, but honestly that makes no intuitive sense to me. No sense at all.

Apparently resistors have something to do with Buddhism because ohms? What. Evs.

I’m a huge fan of getting things working first and understanding them later, so let’s just barrel right ahead and be willing to break stuff for science. These components are relatively inexpensive, so even if you burn a few bucks you’ve gained some knowledge from the carnage.

Here’s what you’ll need:

One. A power source. I’ve got an old 7.5V wall wart power adapter scavenged from what I’m guessing was a D-Link router at some point in the past. You can use any power source you like for this, just so long as you’re pushing somewhere around 5V. Four AA batteries will work great for this. Don’t get your power directly from the wall unless you’re seeking a new career as a fried ham.

The leads on this power supply are stranded wire, which doesn’t jam into breadboards very well. I’ve soldered them solid– not strictly necessary but helpful. If you do this yourself please don’t solder the leads while the power supply is plugged in. Is bad idea.

I’ve used blue painters’ tape to indicate the positive lead on this. Red’s the conventional color, but I ain’t got no red tape, son. Blue it is.

Two. An LED! You can buy these guys by the dozen for cheap, and some places will even sell you resistors in the package. I’m using a green LED. These tend to run somewhere around 3.3V (this matters, and you’ll see why in a moment.)

Any DIY project is improved by adding LED’s to it, so you really ought to have a few thousand of these at the ready. Making a Halloween costume? LED’s. Grade school diorama? LED’s. Bran muffins? LED’s, baby.

Three. Some resistors! Here’s why that 3.3V matters: remember that the power supply I’m using is 7.5 volts. Hook that puppy up to a dinky little 3.3V LED and kablooie– the LED will flash briefly and then die forever. The resistor’s going to limit the amount of juice flowing to the LED by turning excess electricity into heat and dissipating it into the air.

Trenchant insight alert: THIS IS WHY ELECTRONICS GET HOT WHEN YOU USE THEM.

I’m using a 12K and a 5.6K resistor for this project, which I picked at random from a pile of bent resistors in the bottom of my toolbox after a 100K resistor blocked too much current to light an LED.

Voltage calculations and predictions as to whether I will eventually burn up my components are left as an exercise for the reader. EE’s are free to leave helpful comments below.

Fo’. An NPN transistor! It’s tough to buy just one of these. Here’s a pack of one hundred, so you can screw up a bunch of times. We’re going to use one transistor as an electronic switch. What you do with the other 99 is up to you.

Five. A short length of hookup wire. Pretty much anything conductive will work for this– don’t worry about gauge as we’re not exactly building a space probe here. Use a paper clip if you’ve got nothing else.

Six. A solderless breadboard! (not pictured) You’ll probably want at least three of these in your house so that you can leave half-finished projects assembled while you attend to more pressing duties, but you only need one for this project.

The Basic LED Circuit

Let’s assume that you’ve never done this before. We’ll wire up a basic LED circuit to build confidence and then move on to adding the transistor.

Step 1: Connect the power to the breadboard. Plus to plus, minus to minus.

Step 2: Connect the 12K resistor to the + strip and somewhere else on the breadboard. We’ll use a second resistor later when we want to avoid frying the transistor.

Step 3: Connect the long lead of the LED to the free end of the 12K resistor.

Step 4: Connect the short lead of the LED back to ground with a piece of hookup wire.

And if all goes well, you should have glowing LED, with brightness dependent on your combination of resistor and power source.

So that’s LED’s 101. I still don’t know how this relates to swimming pools.

The Transistor Circuit

Let’s complicate things just a bit by adding the NPN transistor. Pro tip: It’s always helpful to remove all cats from the work area.

Let’s not dwell on the difference between NPN and PNP transistors: there are plenty of other places on the internets to explain that, full of confusing diagrams and weird-ass equations. For morons at our level it’s enough to understand that when electricty touches the middle pin of an NPN transitor, current flows through the transistor. Otherwise, the transistor acts like a closed gate, and no electricity passes through it.

I’m using a 2N4401 transistor, but any NPN should work for this little tutorial.

Step 6: Take out the LED and hookup wire and insert the transistor so the curved side is facing away from you.

Step 7: Connect the long lead of the LED to the rightmost leg of the transistor. Wire the transistor’s leg back to ground with your little piece of hookup wire. If you’re fortunate, nothing will happen.

The LED should still be dark, but if it’s glowing dimly then (I guess?) a little bit of current is passing through the transistor. You can use a more powerful resistor or lower your input voltage by swapping out your power supply.

Or just plow on ahead and don’t worry about incinerating your components. That’s what I’d do.

Step 8: This is where the magic happens! We’re going to apply current to the transistor’s middle leg, which will permit current to flow through the transistor and light up our LED.

Just to be on the safe side I put my 5.6K resistor in between the source voltage and the transistor’s middle leg. Of course you could read the datasheet and know for sure how much voltage that middle leg can handle (spoiler: it’s 6V read Andy’s comments below) but reading datasheets is for suckers who didn’t buy a 100-pack of transistors.

This Circuit is Stupid

Yeah, I know. But it’s a proof of concept, right? Instead of keeping an LED lit (lame) one might be using this transistor with an Arduino digital pin wired to the middle leg. One could toggle massively interesting circuts by writing HIGH or LOW to the circuit from the Arduino.

Or, OR! In theeeeeeeeeeory, one could use this basic circuit to resolve conflicts among I2C devices with identical hardware addresses by interrupting the SCA signal, if one had accidentally purchased A TSSOP multiplexer and SOIC breakout boards and had a week to kill while the proper components were being shipped to his lab and needed to feel like he was making forward progress on some front for the love of Pete, because none of us are getting any younger, you know, and Time is the enemy.

Share this:

So I’m back from a week travelling across the western half of Canada with the lovely and talented Mrs. Zheng3 and her parents. We now return you to your regular schedule of intermittent blog posts.

The trip began in Vancouver where I enjoyed the singular pleasure of spending a couple of hours meeting with the Pinshape team at their mothership. We discussed some of the more pressing questions facing 3D printing designers today, including but not limited to where one might obtain the best dim sum in BC’s fairest city.

Great bunch of folks, these Pinshapers. Sharp as tacks and friendly to boot. Take a look at their site and you’ll find a nicely-curated selection of models.

The Saskatoon train station is as bleak an outpost as you’ll find, but still a welcome diversion for a constipatedParasaurolophus who never quite got the hang of pooping in a cramped train toilet.

The long train ride from Vancouver to Winnipeg, made longer by frequent sidesteppings to allow freight trains to pass, allows for much contemplation and idea generation and idle sketching upon napkins, and by the time I returned home I was more than ready to jump into the next project: RGB color sensing with Arduino.

There are, presumably, roll-your-own RGB sensors cobbled from disposable contact lenses, photoresistors, and Oreo cream, but at some point one must accept that expedience takes priority over molecular-level knowledge of a process and you just can’t be mining your own beryllium all the time. So to Adafruit we go, and earlier this week a TCS34725 RGB color sensor arrived on the doorstep of Zheng Labs.

The Adafruit tutorial is remarkably easy to follow and we were up and running in less time than it took to print George Timmermans’ handy Arduino and half-sized breadboard caddy, including the time required to solder the sensor to some headers with long-unused and filthy soldering iron tips.

I’d link to the caddy directly except that WordPress is throwing some weird Unicode error and it’s too early in the morning to troubleshoot HTML errors. It’s on Thingiverse.

This little board contains a white LED that burns with the intensity of a thousand suns, so you may want to wire it to ground and turn it off while you’re experimentin’ or you’ll be seeing afterimages of your workspace for hours.

The book in the background is fellow Wisconsinite Jordan Ellenberg’s How Not To Be Wrong, which, 50 pages in, is so far a fun read. Any book that starts off with a humorous telling of statistical analysis of bullet holes in WWII airplane fuselages is going to be good.

Our engineering team ran into a little bit of trouble trying to get Unity3D to talk to the Arduino and settled for a temporary solution using Python code direcly cannibalized from 2012’s Etchasketchulator project:

That /dev/tty.usbserial-A700fjTr serial address is the currently free USB port on my MBP: if you’re using a PC you’ll likely replace that string with something that looks more like COM4. Check your Arduino IDE to see which port to use.

Looks like I need to make the serial communication a little more elegant; it’s timing out, throwing errors, is badly formatted, and generally a mess. But let us not let the perfect be the enemy of the good. Iterate now, fix later.

I used a couple of ball pit balls as test objects. In the interest of presenting properly-formatted data let’s go direct to the Arduino serial monitor for the output:

Offscreen I’m waving a red ball over the sensor and, wonder of wonders, the red values change over time.

Next step: communicating with a passel of these RGB sensors. This should be a challenge, since each one has an identical address and as far as I know they can’t be changed in hardware. Getting ready to hop on the I2C bus.

I’ll clean up the serial communication by next time, promise. And calibration. Gotta do some pre-read calibration of the sensors for ambient light levels, too.

Note to self: buy new soldering iron tips before we go down this road.#staytuned.

Too long has it been since the last post here at the blog. Well, there was yesterday’s short fiction about Milton, but that was just an amuse-bouche while I got the last of the unruly ducks in a row on The Next Thing.

So! The Next Thing.

After digging into forgotten tomes of PHP lore and dusting off my HTML and CSS (it’s amazing what one can do with CSS and HTML 5 these days) and taking my first tentative steps into SQL (ye Gods, people make a living programming this? poor bastards), and hacking away at .htaccess goblins and DNS bugbears I’m thrilled to announce The Forge, version 2.0.

It’s still located at forge.zheng3.com. Any links you might have to individual pages in Forge 1.0 will still work, but won’t be updated anymore. It’ll take me a few days to get the redirects up and running.

Some of the lamer models (cough)shaolinspadewacomnib have been culled from The Forge, and the upload process is much, much more straighforward on my end. My goal’s to reduce the time and fuss required to get a model file from my desk to yours. I’m not 100% thrilled with the way the Forge displays on mobile yet, but it’s functional enough and honestly, there’s only so many hours in the day to attend to every little detail.

I’ll put a B-team of kobolds on it, and maybe it’ll get done someday.

All this Forge work has slowed the production of new 3D models, but the ideas have been piling up in the hopper over the last six weeks. I’ll try and get to them ASAP and we’ll see just how powerful this fully armed and operational 3d model sharing site really is.

Milton shifted uncomfortably among the ferns, moving his weight from one haunch to the other. Pooping in an unfamiliar spot was always stressful, and the noise from the playground tightened him up even worse than usual. His hams were prickly from the heat and pins and needles brought about by a long squat. I really should be doing more yoga, he thought.

But going to class meant that other herbivores would see how inflexible and fat he was, and Milton always felt he was the poster child for Doing It Wrong. Maybe he could just stream yoga videos on his iPad and practice alone at home.

He pushed a little. Nothing. Pushed again. He could feel the first pellet six inches from freedom, stone-hard, stuck, and blocking its comrades from exit. Dehydration, probably, or possibly too many gingko nuts. If he could just get this plug out the rest would come easy, he was sure of it.

Fixing his brow, he pushed too hard, and strained a suprised warble from his crest by accident. Oh, God, if the children heard the sound they’d be on him in seconds.

Some of the other Parasaurolophus on the island loved the humans, but Milton preferred solitude, especially while pooping. The Settler children always begged him to toot little songs while they danced around him like a maypole. The children were cute, but Milton knew his songs weren’t any good and that was why none of the adults ever danced around Milton, the inflexible and fat maypole dinosaur.

Perhaps doing downward-facing dog would move things around enough to shake the pellet loose. He licked his beak and tried again. Mid-pose he contemplated his tail, which reminded him of the time he had knocked over the velvet ropes at the bank with it. Everyone looked at him (everyone was always looking at him) and then the ropes fell and made a tremendous crash, which only made everyone look at him some more.

The sound of crunching leaves told Milton that he was no longer alone. He looked up into the face of a little human, caked in slop and burrs. Milton couldn’t tell the males from females when they were this small, but he did notice the muddy turnip the creature held in one paw.

A turnip. Goodness! Eating a turnip might be just the thing to loosen up the sluices. He sniffed and clicked his beak hopefully. The child made a little warble of its own. “Toot!” it barked. “Toot!”

Milton reached forward and nipped at the turnip but the child pulled it out of reach and frowned. “Toot!”

Several other children had taken notice from across the schoolyard and started running towards him. The turnip bringer turned towards the approaching pack and shouted something in its chirpy stacatto language.

The child turned back to Milton, joined by a dozen similarly filthy companions. It beckoned towards the dinosaur, waving the turnip under Milton’s nose. It whispered slyly as its cold blue eyes met Milton’s gaze. “Toot.”

The ring of children began to chant. “Toot! Toot! Toot! Toot!”

Very well, thought Milton, a performance, then.

He inhaled deeply, expanding his ribcage as far as he could. The children fairly rippled with excitement as Milton’s mighty diaphraghm flexed in preparation for an epic bellow.

A chill suddenly swept over Milton’s body. Every scale from crest to shoulders seemed to prick up on its own, and, with a sickening slurch, something terrible shifted inside his gut.

Oh no. It was coming. Milton turned to run, but was blocked on every side by the tiny humans. He had no desire to trample the little brown creatures but perhaps if he could just nudge one of th–

A grapefruit-sized mass of moist fiber shot from between Milton’s legs and struck one of the children in the neck. The child collapsed, shocked, and Milton thought he saw a fragment of gingko nut stuck to the child’s lip. The other children burst into raucous laughter.

Milton whirled to apologize and the rest came forth in a torrent. Smaller lumps splattered the turnip bearer with chunky filth. A green liquid ribbon arced and danced as Milton turned, dousing a semicircle of children. The laughter turned to shrieks as the little humans fled, slipping and stumbling in the pool of waste. The turnip, long rendered inedible without a good washing, was mashed into a broken patty by panicked feet.

I’m sorry, Milton thought. So sorry. Forgive me. His knees trembled as the last trickles left his body and dripped onto the leaves below. With the children now silent, the pitter-plops were the only sounds left in the world.

The dinosaur turned and slunk away towards his swamp, keenly aware of the angry mob’s hot glare from the relative cleanliness of the schoolyard pond.

Share this:

The duergar have toiled in The Forge for months, taking only the briefest breaks for food and drink, hammering out new prototypes daily in preparation for this morning. Exhausted, exhilarated, they present a gift for you.

Oye! Oye! The 2015 Seej Starter Set bursts forth from its bonds!

Download it here, as a pay-what-you-like download; throw Lao Zheng a $5 bone and we’ll keep the Open Source designs a-flowin’. These models don’t make themselves, y’know.

Much labor, playtesting, and re-engineering was poured into the 2015 starter set, incorporating a great deal of community feedback and addressing many of the original models’ shortcomings.

First and foremost, the interval between downloading the models and playing a game has been shortened considerably. The geometry is streamlined and efficient; the entire 2015 Seej Starter Set is contained in a single megabyte. The Seej engines and bloxen are relatively quick, uncomplicated prints with plenty of surface area to assist with bed adhesion.

The catapult’s been reduced to six individual pieces, three of which are identical dovetailed crossbars. Flagrant stagecraft alert: there’s a piece of hookup wire holding the catapult arm in place.

The throwing arm now articulates directly with print-in-place cams, resulting in a far more accurate and deadly device than the first generation catapult. The faux wheels on the side braces lift the butt of the throwing arm off the ground, allowing it to swing freely for maximum momentum.

The atlas on the original catapult is no more; a little bit of engineering has moved the arm’s pivot center so that it lines up directly with the topmost crossbar at the end of its arc.

We’ve given up on throwing coins and instead have switched to 14mm marbles (A d20 will work nicely in the catapult’s cup, too.) Make sure you have a glazier in your contacts list, because even a ricochet with one of these marbles can crack a window. Eye protection is strongly recommended.

The improved force and accuracy of the new catapult required more robust defenses, so the bloxen now interlock on five sides. They should snap and unsnap with a minimum of fuss. These new bloxen make dandy building toys even if you’re not playing Seej.

Share this:

TL;DR summary: Lowpoly design is a reflection of modern artists’ nostalgia for 90s video games. Also, get off my lawn. Also also, download Rex’s pram here.

Months ago I designed Robber Rex as a replacement robber token for Settlers of Catan when we lost our original. He is, inexplicably, one of the more popular designs to emerge from The Forge in recent history.

In an effort to exsplick Rex’s success, I present a theory as to why low-poly design seems to be sweeping the 3D printing community lately and it boils down to nostalgia.

With no statistics or evidence to the contrary I’ll posit that the median age of artists doing enough 3D design work to get noticed by sites like Thingiverse and Pinshape is somewhere around 30 years old. Maybe a little younger.

These people would have been preteens right smack dab in the middle of the 90’s, when games like Quake and Final Fantasy VII were top-of-the-line entertainment. By today’s standards the polycounts of character models in these games were miniscule– I think a Quake character maxxed out somewhere around 200 triangles.

I’m convinced that many of us want to be twelve again, when we were at the top of our game as kids but not yet at the bottom of the ladder as teenagers. Life was pretty good back then, before the acne and taxes and hangovers and freaky stalker exes. It was all Crash Bandicoot, all the time, and maybe a Capri Sun after school with a little not-too-challenging math homework on the side.

It’s natural that these aging children of the 90’s would recreate the entertainment they loved so much as children, the same way their recent predecessors swept 3D design with 8-bit skeuomorphisms a couple of years ago. See here Moore’s Law, writ in plastic.

The current popularity of Minecraft will undoubtedly produce interesting design trends among the designers of 2030, who will be chipping meta-retro lowpoly designs from the silica mines to please our ever-demanding AI overlords.

Having worked through the tail end of this low-poly period, I’m familiar with the design compromises brutally enforced by the video cards of the day. My first gig as a video game artist had a poly limit of 150 per character. Our models were angular at best and blocky at worst, and you can bet your bippy I nearly wet myself with delight the first time I saw a bump map on a realtime shader.

So, freed now from the design constraints that marked my early career, I’ve got a habit of reveling in gratuitous geometry. Rex is anomaly in my portfolio. He’s low-poly (-ish, there are still microbevels you couldn’t get away with in 1998), totally unlike creations like the Bramble Bloxen.

Yeah, that’s like over 200K polygons right there.

But we’re big fans of Giving The People What They Want here at Zheng Labs, and The People clamored for a low-poly sequel to Robber Rex.

So I designed a print-in-place pram for Rex and his newphew, Pip. You can read a quick story about Rex and Pip here, but be warned: the language is a little salty and likely isn’t appropriate for our younger readers.

Maintaining the low-poly style was easy, but getting the wheels to turn reliably on a print-in-place model took a dozen prototypes and test prints. The numbers on the sides of the pram are cylinder diameters: the trick is to leave enough clearance between wheel and bearing that the wheels can turn, but not so much that the wheels fall out. 6.3 is too small– the first layer of plastic oozes together and locks the wheel in place. 7.5 is a little too loose, which makes the wheels wobble all over the place.

Oh, and here’s Pip. He’s almost an afterthought in this design, just a little low-poly hatchling tucked into his stroller for a day at the park.

There’s a new design bubbling in the cauldron, and it’ll be out in a couple of weeks. #staytuned. It’s-a-gonna-be-big. Lao Zheng out.

Maera bumped the tower door with her hip, held it open with her rump and eased out onto the wall-walk, taking care not to spill any grog from the dozen steaming mugs she bore like a serving girl on the inside of her shield. She puffed a wisp of mousy hair from her eyes and called to the sargeant of the watch. “Elias! Some help, if you would.”

Elias, still quick even at threescore and two, set down his spyglass and hustled over to relieve the chateliane of her burden. “Good morning, milady! Thankee much.” He distributed the hot grog around the wall and offered the last tankard to Maera. “Milady?”

She shook her head and smiled. “It’s yours, please. Still chilly up here, it is.”

The sargeant grinned and sipped daintily at the tankard, one pinky raised in silent mockery of his lady’s educated accent. “Chilly, but calm, at least. The night passed without incident, as they all do of late.”

Maera had taken a habit of posting a light guard in the last six months. Red hadn’t made noise since their victory and the other clans were too far away to mount an attack without messengers spotting them weeks in advance.

Peacetime it was, but of course there were Vile Things out there that weren’t Men and didn’t care a whit for clan politics. Elias continued. “Can’t say as I miss the war, though.”

He scraped the last bit of honey from his mug with a grimy finger, licked, and squinted out over the wall. “Hello, what’s this? Movement at the far marker, if these old eyes tell the truth?”

He unbuckled his spyglass and handed it to Maera. “What is it? Even with the lens I’d never know.”

Maera heard three sharp toots from a warning horn– another wall-walker had spotted the movement and sounded an alert. She sighed. Three notes were a bit excessive at this distance, but then again these men were fairly well starved for something to do lately. She lifted the spyglass to her eye and homed in on the intruder.

The image of a man pulling a two-wheeled cart filled her view. And what a man! A giant, standing tall as a rearing warhorse. His skin was lightly tanned, even so early in the year. His clothing was at once coarse and complicated, with swirls of embroidery up the sleeves and sides of his green… tunic? Robe? Hard to say. It went to his knees and he wore black leggings underneath.

Another man, younger, slept in a padded chair behind the giant. His skin and hair were similar in color, but his robe (yes, definitely a robe on this one) was clearly of finer quality. The man’s head tilted over the back of his seat and he loosely held the neck of a large gourd in his left hand. He wore stockings of the purest white, but only one sandal.

How odd the cart looked; more of a tent-covered chair on wheels than a proper cart, with barely any space for extra cargo. Not merchants, then, nor peddlers, and certainly not warriors, though a sword hung in its scabbard from the side of the cart. Slowly, canopy swaying left to right with each step, the giant and his snoozing master plodded ever closer to the Black Keep.

Maera lowered the spyglass as the wall began to bustle with activity. “Well,” she mused to no one in particular, “this should be a novelty.”