Addressable LEDs over distance – update – with pictures

Made progress. Have tested a number of different configurations and now have something (renderings) to show for it. Thank you http://3dbrdviewer.cytec.bg/ 3D Board Viewer for the images.

Reminder – long post about where this came from. Now it’s about building it.

The main board is simple with 2 LEDs on it. By default it receives serial data, runs it through the LEDs (Neopixels), and then out the other side again as serial (rs485). There is the need to source the signal from a micro controller. It was desirable to not make a special board for this. To that end there are different traces on the board that can be cut to change the behaviour of the one board. Cut a single trace and a pin (header of three pins) can be used as ttl data IN for the first LED. Cut a different trace and you bypass the LEDs but get the benefit of converting the ttl to serial for the benefit of the next board and so on in the chain. To make it even more fun cut a pair of traces and the IN and OUT of the board are now capable of driving an arbitrary local set of LEDs. To demonstrate this feature a mini shield board was designed with up to 8 LEDs on it. Solder pads on the shield can be used to select for the number of LEDs you solder to it.
Raw parts and board costs for the main board are ~$10 currently. A run of many many boards and part selection optimization could bring this price point significantly lower. Price is noted here but not yet a critical goal.

“top” of main board This is the functional top of the board where the two default LEDs are mounted. Power and data come in and out the left and right sides of the board.
“bottom” of main board This is the functional bottom of the board.  You can see the voltage regulator and the optional traces / pads that can be cut to modify the features the board provides.

Don’t those look just fantastic?  Here is the board layout before it is rendered.

The raw board design before sent to manufacturer.

The shield was a fun bit to try to make. Again these boards are working only in theory today. Parts and boards are in the process of being made and shipped. Once they arrive soldering and testing of these final solutions will commence.

Here is a rendering of the shield with the accompanying board design image.

Rendering of the LED shield with connection headers to join to the main board.
Image of the shield board design. These images are screenshots from the Eagle PCB CAD design tool (free you should get a copy).

Persistence is the plan – addressable LEDs over distance

This is a bit of a story – longer than your normal Internet consumable.  Book mark and come back when you have the time (you’ve been warned).

Been working on a project for some time now…  I want to have addressable LED lights (specifically NeoPixels) many feet apart.  One per fence post (66 posts @ 10 foot separation on average) and run Cylon like red lights and all sorts of animated fun back an forth.

Quick note: an addressable LED is the type you can have a long string of (or a grid or ‘each one on a fence post’) be a different color and you can change those colors to any other color any time.

I can get these pixels to work over 6 or even 10 feet apart but not for any significant distance when chained together.  Every large gap introduces errors – lights don’t glow the color you expect – random errors crop up often (1).  I have not found a product out there to help with this problem.  Either for connecting two stings (a distance apart) of addressable LEDs or for having single LEDs in a long string each separated by an arbitrary distance.  Two years ago I started to work on the problem.  I was thinking this shouldn’t be too difficult.  Sadly Google did not provide the instant satisfaction we all expect.  The results of Google searches suggested people live with this limitation of Neopixels and the quirky (not well understood) communications protocol.  The result seems to be to limit the design around a limitation.  That’s all I could find.  Not good enough!

Several people mentioned how there are specific timing issues with the bit banging that’s required to drive Neopixels,  and I agree there are limits and limitations.  Two specific Google results stood out.   Tim’s (2) work was the first I came across.  This told me I did not have to rely on the status quo.  There was more to it than what the popular opinion had gleened.  Then (very recently) I found Josh’s (3) epic posts that kicked me into high gear.  They both looked at the timing specifications of the chip.  Yeah ok. Those are the rules – don’t break them.  But are they the rules?  Suffice it to say these two showed me there was more to a data sheet than first meets the eye (Fine! I have no idea how to read most data sheets, but this one (4) is fairly short).  Now I knew (believed) timing was not going to be a limitation AND I had been looking at the wrong parameter assuming it was the timing causing the color issues.

Ok timing is important but was that my problem?  Actually no.  The issue I had was signal propagation over distance.  A nice square wave from your Arduino becomes a wavy wave when you try to make it 10 feet or more (many times in a row without error).  Some bits will be fine, some will be only a bit off (see the pun there).  The problem again is these little errors accumulate quickly (and randomly) and by 3 or 4 10 foot lengths out – you’ve got random blinking colors and no known state you can predict.  Mush.

Retrospective: How did it take two years to figure this out?  My initial budget was zero.  My initial goal was to light up 66 fence posts with an addresable led each 10 feet apart. So even at $5 a post I was in a bit deep for a $0 budget.  The designs and prototypes had to be very very cheap.  THAT (knowledge / thinking) was THE limitation.  Also I only really pick this up every few weekends.

Basically, to get where I’ve come, I gave up thinking I’d ever build the fence post lights I had originally envisioned.  Letting go of the project as a reality gave me the latitude to think more deeply on how to solve the problem.  Odd to think of it this way, but you may have to let something go to see it clearly.  It’s time to mention solar and wireless.  If I built this with solar the side effect would be each node also needed to be wireless.  If I just did it with power and wireless – still each node needed to be wireless.  This implies a very different way to communicate with the nodes and keep things in sync.  I am sure it is a project I’ll do some day (I have some crazy ideas for this) but it is not the goal of this project.  The goal here is to treat all the lights in the “string” just as if they were on one short 66 led strip.  So don’t say “hey how about wireless or solar”.  That said a solar power source for the entire system will be part of the final project – just not one per post.

CLARITY

More components are needed.  I was looking at serial communication protocols         to solve the problem (they’ve been doing this forever, right).  I went to my weak spot and reviewed all sorts of data sheets of serial chips.  None of the pictures (that’s all I really look at) showed a scenario that seemed like it solved the problem.  Now what is it about data sheets I learned earlier?  Ignore the status quo they don’t depict and consider the all cases.  The 485 serial buss communication chips is were I focused.  Why are all the chips bi-directional – is that a requirement of the buss electronics or just the way most people use them? Turns out; it’s how they use them.  You can take the transmit of a chip and send it to the recieve of another and then transmit from that chip to yet another chip’s recieve (not the original transmitter).  This now sounds like what I am looking for.  A one way, infinite, propagation of a signal to an infinite set of Neopixels!

So that looks a bit like this image.  Between pin 2 and 3 you put the LED and supporting items needed like capacitors and maybe resisters (not sure yet).  The chip provides the conversion of the TTL signal from the LED to serial 485 (5) signals.  The chaining of these together again and again is that thing I had not been finding in my searches.  I had no idea if this would work.  So I bought some chips, designed some cheap boards and tested it.  You can’t discount the need to be testing these things in real circuits – you’ll find issues to overcome every time.  Once I got past some learning curves and stupid mistakes I was able to get LEDs working reliably at least 70 feet apart from each other.  Yeah!

Now what

Build a more production ready board and order the surface mount chips and items needed to test this with 10 units over 100 feet (10 foot separation per node).  Bonus let’s put 2 LEDs per board for extra brightness and even more animation options!

One thing each board will have is a voltage regulator – this will certainly increase the cost (when I get to actual budgeting for this project).  It will be required (so far as I can tell).  5 Volts drives the LED no problem but voltage too has an issue over distance (it drops fast).  The test boards are designed to be linked together with 4 wires.  2 for power and 2 for data.  The regulator enables me to run up to 30 volts over the power wires.  The regulator enables me to run the chips and LEDs at the required 5 volts.  The board passes through the 30 volt power to the next board and the next and so on.  At some point the voltage reaching a board will be below 6 volts (the threshold for stable regulation down to 5 volts).  At this point we’ve either made it to 66 LEDs (660 feet) or something else needs to be done.  One option will be to inject the voltage in the middle – this means only 33 in each direction – helping the power distribute.  330 feet is still a distance so if that can’t be met then 2 or more points for power injection need to be arranged.  And there’s one more issue….

Current.  Volts I think I can manage as above but once you string a bunch of LEDs together they each use current and it all adds up.  2 LEDs at full brightness use 120 milli amps (60 each) – not a lot (and the voltage regulators can easily manage that per board).  Where it adds up in across the power lines and across the board’s copper traces that support the passthrough path.  Let’s say the voltage gets to the 66th LED without an issue — what total current (amperage will be required). 120 milliamps * 66 LED = 7920 milliamps or – 7.9 Amps.  Now maybe the math needs to account for the power usage @ 5 volts of the LEDs so let’s see what that might look like (we are in the” I don’t know for sure” zone here).  (0.120 Amps * 66 LEDs) * 5 Volts = 39.6 Watts.  That many Watts @ (let’s use) 24 volts, is only 1.65 Amps.  So my guess is if the boards and wires can handle this 1.65 Amps then 66 nodes (120 LEDs) should run without failures (failures = fires and melting of things).

Status – currently awaiting boards from the prototype manufacturer.  Still trying to figure out how to 2 side surface mount when they arrive.  Ordering surface mount parts once boards have a shipping date.  Also will order a solder stencil  once boards have a shipping date.  Boards have 2oz copper (more than 1oz) to manage the current better (I hope – no idea).

When they arrive I’ll run a load (lots of current) through a board until it fails.  Probably the best way to test the limit.  I hope for some spectacular flames or something worth reporting on.

Lastly once everything works check out etc, I need to figure out how to mount these on fence posts in a weather resistant manner.  Epoxy, silicon, hydrophobic coating – no idea there yet.  Proper defusing of the LED light is also to be considered.  Currently I’ve found translucent white water bottle caps to be very practical – they may get incorporated into the final design.

I’ll edit the above as I progress.

Foot notes:

1 – Adafruit best practices

2 – Tim’s Work

3 – Josh’s work

4 – Neopixel datasheet

5 – Serial 485 wikipedia

 

NeoPixel Link connector board

Building an array or grid of leds from Neopixel strips?  You might want one of these little boards I’ve come up with.  Here is a video (terrible) of me soldering together a few strips into a 3 x 42 array.  I found them to reduce the time and mistakes made when using individual wires.

 OshPark is where you can oder the boards.

Questions?  Please email me (ian @ mcyork.com)

 

What could you possibly use 8 relays on a board for?

I’ll be honest, today is payday and, I’ve been thinking about improvements to existing projects, surf’n the web look’n to buy!  Then I thought of my binary christmas tree display.  I remember seeing an 8 relay board on the web a long time ago, and thinking what could I use THAT for?  I had to come up with an excuse to buy it of course.  I convinced myself I could build a holiday light display with a twist.  I decided I’d flash the lights in binary.  Check it out if you have not watched it yet.

Now that was a fun project.  How do I expand on that in the context of “the farm”.  There’s a solar array in the field  – ideas?

I can’t say I bought this one below – but they all look about the same.  When you are just having fun with an Arduino you can afford the 8 pins to drive these things.  I suspect some have a BCD to relay decoder chip built in.  That would reduce the number of pins you need to dedicate.  Or you can use a shift register (those are fun. Look em up if you have not considered them in your project yet).


5V Eight 8 Channel DC 5V Relay Switch Module for Arduino Raspberry Pi Arm AVR | eBay

So now you’ve got a project for yourself to figure out.  The code for an Arduino to do the above binary tree display was fairly simple.  You can get fancy if you want.  Where you’ll want to be careful is how you wire up the high voltage side of the system.  I took a lot of care modifying a power strip.  This had the advantage of 8 sockets ready to plug into.  Go for it – be safe.

Your kids will love you this summer

There is a program in place that can help you and I get kids excited about Making.  Buy your kids a subscription to Make Magazine, via our link, and this summer there will be great projects you’ll find they are inspired by.  If you use our link here to buy your 1 year subscription 50% of that will be available to McYork to spend on electronic bits and bytes. These will ALL be given to kids and people who show an interest in electronics or projects that will incorporate them.  Use it or lose it rules apply – so the recipients of the parts will need to express what they plan to do with the various parts and show us the project working by summer’s end (we love youtube for that part).  If you and your kids build the fun projets in Make Magazine we’d also love to hear from you and or watch your youtube video of the fun you had.

https://readerservices.makezine.com/MK/Subscribe.aspx?PC=MK&PK=2B79Z82

The keyboard helper

I was talking with a friend who has a big problem.  His son can’t use a keyboard but loves to play computer games.  He can only use a mouse and only with his right hand.  He has very limited abilities in his left.  It became clear after our conversation that if we put our heads together we could make something that might enable him to play the different computer games with more ease and enjoyment.

New video link added at the end of this posting.

We imagined a joy stick that could be used to maybe send different keystrokes to the keyboard via some device.  I took this problem home and below is what became “the keyboard helper”.

KeyHelper1

The Leonardo has a great capability; It can emulate a keyboard and mouse.  Using this as the core of the new device I tested a number of code snippets   I was able to send words and keystrokes to Notepad, what fun!  The next thing was to read analog ports connected to a joystick.  There are a ton of examples on the web, I got this running quickly.  To wire up the joystick I needed to tie in some resistors.  I’ll try to explain why they are in the circuit later.  The last part was to add an LCD display for some visual feedback.  I thought it would be important and we found out after the fact that it ended up having a very different function than what I had first envisioned.  LCD displays can be hooked up in a few different ways the most common are parallel (all pins) or via some type of intermediate device that you to talk to via a serial or i2c interface.  I had an i2c to LCD kit from an old project and decided to re-use this (the link is to a more recent iteration).  The LCD display itself was pulled out of an old PBX phone, it had some odd pinouts but normal LCDs you find on the web will be simple to wire up.

On a 2 hr flight I crafted most of my notes on how I felt the “system” would work.

KeyHelper5

I’d present a grid on the 2 line display of the characters Q W E R.

________Q__W______

________E__R_______

Something like the above. When you tell the LCD to use a blinking cursor and then move to a position over top of a letter – it looks selected.  By moving the cursor over each letter as the joy stick moves – you can see what letter is available to be typed to the computer.  Great visual feedback.  In the above diagram suppose Q is high lighted.  The movement UP or LEFT on the joy stick would then send the letter Q to the keyboard.  A movement DOWN would select E but not send E.  Once on E a movement LEFT or DOWN would send E to the keyboard.  Scroll to the letter needed then move -off- the screen to send it to the computer.

KeyHelper6

That’s how the 1.0 version functioned. There was some immediate feedback as the game being played changed.  It would be preferred to hold the key down and not just type one letter.  Selecting the letters became less critical as now it was a matter of just holding down the key and there were only 4 to send.  Here is the resulting logic main loop of the program that shows this modified approach.

void loop()
{
 center = 1; 
 up = map(analogRead(0),0,1023,0,1);    // Q MoveTo(0,9); 
 left = map(analogRead(1),0,1023,0,1);  // E MoveTo(1,9); 
 down = map(analogRead(2),0,1023,0,1);  // R MoveTo(1,11);
 right = map(analogRead(3),0,1023,0,1); // W MoveTo(0,11);

 if (up) {
 Keyboard.press('q');
 MoveTo(0,9);
 center = 0;
 }
 if (left) {
 Keyboard.press('e');
 MoveTo(1,9); 
 center = 0;
 }
 if (down) {
 Keyboard.press('r');
 MoveTo(1,11);
 center = 0;
 }
 if (right) {
 Keyboard.press('w');
 MoveTo(0,11);
 center = 0;
 }
 if (center) {
 Keyboard.releaseAll();
 MoveTo(0,0);
 }
}

The letters are now being sent as lower case. What’s nice about this approach is the MAP function.  It has a lot of uses.  Here it converts the range 0 to 1023 into the range 0 to 1.  This enables the code to read both momentary switch type joysticks or analog potentiometer joy sticks (we’ve used both in our prototypes).

Mental Note: if two states are on at the same time does the keyboard function send both or does the last one sent win?  Think moving on a diagonal in a game and how the code above may or may not enable this.

I am working on a wiring diagram it is going to be a while until I either build a second version or I can borrow back the one I’ve built for a day to recall the exact details.  Like I said above – examples for each element of this are easy to find on the web – you should not have much trouble.

A working version of the code (assuming you use the right pins with your LCD and such) is here.  As my LCD and I2C are probably different from yours – there will need to be some adjustments in the commands sent to the LCD (maybe).

I liked this project for a number of reasons.

  1. Jerry is a much happier camper now. UPDATE BELOW
  2. I had no idea how great that would make me feel.
  3. Game control is vastly improved.
  4. The project was small in scope and I was clear on the goal.

Thank you for reading.  There is not too much more to say about this project at this time.  It will be a while but the circuit will be doodled up some day.

Go make stuff.

The LCD took on an unexpected use:  It happens that the joystick needs to be positioned just right.  Exactly right.  Such that the limited motion of the left hand can move in the 4 directions.  It takes some time to get this center point just right.  The LCD will be highlighting the direction of the “problem” and my friend can use this as visual feedback until he gets both the joystick and hand centered.

UPDATE. The fine film crew at work put together this video of the project’s impact.

 

 

 

Chip programmer with a twist

I am working on 1000 projects all the time.  You may already know that of me.  This one will be a fun adventure.  I’ve started by shrimping.it this is a site where they show you how to build a bare bones Arduino.  I went and ordered the part for 4 kits via the electronics seller http://www.taydaelectronics.com/ it was under $30 for all the parts I needed.  I did not get boards as I plan to design my own at a later phase. Shrimp + SPI to 8 pin chip  Here’s the shrimp built with an 8 pin chip holder where it can be used to program the little chip.  This is an Atmel ATTiny 85 ready to be programed.

Now the hard part.  Let’s say I want to program a lot of these little chips.  Wouldn’t it be nice if the Arduino held in memory all the code and capabilities to program the chip without an attached USB link to a computer?  That’s goal #2.

random blickers

Here is an ATTiny 85 running code that was pushed through the Arduino in the traditional manner (Goal #1).  What I like about the Tiny line of chips is there is little to no supporting hardware required to have them run.  This makes them a lot of fun for all kinds of little builds.  They will even run off three or 4 AAA batteries and for quite some time.

Blinking LEDs with a 556 timer chip (beyond the basics)

This is not a how to. I am learning in broad daylight how to do this.  You are welcome to watch. Not sure how this will go but using Upverter to design this simple circuit seemed like one way to go about it. The goal is to use a 556 timer and a limited number of additional parts. Learning electronics and the tool both at the same time may be a mistake – I am aiming for a wonderful mistake 🙂

Stock Bot to Arduino

The original StockBot was built on the Netduino platform.  I’ve been working on the code for the Arduino platform and have now assembled working code.  I can’t claim it is stable yet but it’s doing the job for now.

I am using the Ethernet Arduino.  As I explore a number of things all the time, I have also made a shield for the Arduino to see if this project could become a kit for others to build.  A little stuck on a source for Numitron tubes so I am trying to make the board generic enough to take a tube or a normal led display (still puzzling that through).

Let me clean up the code – I’ll take a hard look at it over the next month.  Maybe after the skis hit the slopes in Whistler I’ll have something to post and walk everyone through. Early December if you don’t ski or board.

What’s StockBot – here’s the beginning post

Here’s the prototype boards I had made.  They have a nasty bug but I learned something (and could fix it so all is good).

Arduino IDE and Google Drive

Under the heading of “mental notes”:

The Arduino IDE has a setting for your sketch directory.  I have recently created a directory on my Google Drive and pointed the IDE to that directory.  Also in the Arduino directory I have created /libraries (lower case, plural) and put there the class files and libraries I download.

Now on any MAC (or PC) I can edit, compile and test code and no longer need to haul around a USB drive with projects.  More importantly I no longer have version splatter across the different machines – I am always working with the current versions.

To get the google drive as a native element of your MAC (or PC) you will need to download and install the Google Drive application.