Nixie clock prototype

Lasercut nixie clock prototype

This caught my eye at yesterday’s Open Hackspace session: Alex wired up the nixie clock he’s been prototyping, and got it mounted in a lasercut case. As good at it looks here, the phone camera doesn’t do it justice!

Other projects being worked on yesterday included a pedal-powered phone/GPS charger for an upcoming cycling holiday (which now works perfectly!), an improved bed for the lasercutter, some wooden shelf units, a network-controlled table lamp/sensor package, and the usual mix of teaching, swapping ideas, and terrible jokes.

What do you want to make? Turn up to one of our open sessions, or get in touch by email, and see what your local Hackspace can do for you!

Hacking De-bounce and Rotary Encoders

Prototype console interface for embedded projects

Prototype console interface for embedded projects

At the UK Makerfair during a brief lul the conversation turned to rotary encoders, simply as I had ordered a paw full from china for one of my many projects that simmer along in the background. The picture here shows the initial prototype that I used for this article. The feedback about rotary encoders that I received was that they were terrible and to be avoided. Principally as the switch contacts were very noisy and produced way too much bounce. I was still interested in using them firstly as having done embedded stuff for years bounce is something I consider trivial and fixable, secondly as they make a really cool, easy and feature full user interface using the minimum of pins.

De-bounce circuits

De-bounce circuits

The circuits I most commonly use for de-bouncing simple switch contacts are shown in the picture here. I ran this up in Kicad for the article. Something worthy of note is that Arduino’s and a number of other micro controllers have internal pull-ups that you could use. Do not use these when de-bouncing your inputs. They vary very widely in effective resistance value and the results will be massively variable when used with the same external components. Indeed a quick search of the internet shows a range of circuits and values mostly with a string of comments along the lines of someone found a different value or combination to work better. What is happening here, and why so much variability of what should be a trivial, bread and butter type, of interface circuit.

No de-bounce

No de-bounce

Time to dig out the Bitscope I bought from Pimoroni a while back and capture some waveforms. It will work as a capable enough DSO for this investigation. On the left is the A output of the rotary encoder from the previous picture set-up as a switch with pull-up as per the schematic above. The value of the pull-up resistor in this case is 10K Ohms a fairly typical pull-up value. The large nice square pulses are the outputs from the encoder and the very narrow horrible pulses are the switch noise and bounce. This looks reasonably what I would have expected although the switch looks to be more noisy than bouncy. I spun the input shaft quickly by hand to get enough pulses into shot and it is noticeable that the rubbish pulses produced are proportional to the speed of spin. The other thing that is noticeable is the duration of the pulse are quite short. With a standard press button you can not move your finger that quick and a de-bounce period in software of around 10mS is not uncommon. In this case though, if you did this it is clear that you would be missing a lot of steps from the encoder. Each one of those noise pulses is a full logic value in height and will trigger an interrupt, giving you a wildly incorrect count and wasting a whole shed full of precious processing cycles. I can see why you might think they were to be avoided if you had not de-bounced them in any way.

100nF De-bounce Capacitor

100nF De-bounce Capacitor

Adding a 100nF capacitor as per the above schematics produces the results below. This produces a very large reduction in the height of the noise pulses but they are still large enough to trigger some interrupts, the amount of processor time we waste though is reduced. The number of incorrect counts is also reduced but there are still some present. Also look at what is happening to the corner of the rising edge of the pulses that we want to work with. They are no longer square and are being rounded off. So a big improvement but still not as good as we would like. In a simple switch this rounding etc is not a problem. We are working with a rotary encoder though and the relative position of the edges in each channel is important to us. Where an edge curves too much it becomes unclear where the micro controllers input will decide it has switched from logic 0 to logic 1. If we got such a big improvement for adding in 100nF, will adding in some more be helpful?

200nF De-bounce capacitor

200nF De-bounce capacitor

So lets add in another 100nF capacitor in parallel across the one we put in last time. Taking the total up to 200nF. Yes the noise is reduced much further and we could probably work with that at a push. But look at the state of the rising edges. As we increase the capacitance we increase the loss of definition of the rising edge and consequently our ability to correctly resolve the direction of the encoder. The faster the encoder is turned the more problematic this becomes as the curve remains the same width but the width of the pulse we are relying on has become narrower. We could have kept the capacitance value the same but increased the resistance to say 20K and we would get exactly the same result. The RC network that is cleaning up our signal has a time constant that is proportional to the ratio of the resistance and capacitance that makes up the circuit. It is this time constant that is low pass filtering the pulses and giving us the effects we can see on the scope. Bearing this in mind if we check out the Atmel AVR data sheet, as this is the most popular micro-controller in the Arduino series, we see that the internal pull-ups have a value of between 20K and 50K. So a massive variation in the pull-up value and consequently a massive variation in the de-bounce action and on our pulse edges is produced by this, hence why de-bounce circuits that use the internal pull ups are to be avoided. We need results that are consistent.

For a simple press button a simple RC network as shown in the above works great as it is a very slow logic signal, but what can we do to recover nice square edges on our fast, encoder signal pulses, and get rid of the noise pulses. The answer is to use a Schmitt Trigger which increases the level at which a rising edge will be consider to have switched from low to high and reduces the level at which a falling edge will have switched from high to low. This circuit will ignore the noise pulses that we have reduced in height leaving us with a clean pulse train and nice square edges from our encoder. Check out the linked wikipedia article, ignore the over complicated mathy explanations and control theory waffle look closely at the wave form diagrams at the top right of their page. What is more this circuit is so useful that it comes already built in to a number of inexpensive logic gates. You don’t need to make one.

Unfortunately I don’t currently have the parts to hand to show the fully processed pulse train but the procedure is to add in a Schmitt Trigger logic gate (ie a 74LVT14 or similar)  as per the diagram above, pick the pull up resistor value for your chosen application 10K is good for most applications, looking at our scope waveforms you may want to go to somewhere conveniently around 20K. Then starting with a small capacitance for the de-bounce capacitor increase it until all your noise pulses on the output of the schmitt gate have gone. Using your scope to see when this happens. Once you have achieved this you know what the correct values are and can pick the nearest off the shelf value to use every time and get repeatable results. What’s more you will not be wasting any precious processor cycles on clever de-bounce code and unnecessary interrupts.

Take away points from this are:-

  • Do not use the internal pull-ups with de-bounce circuits it is a false economy.
  • Simple RC circuits are plenty good enough for simple push buttons and switches.
  • You need a logic gate with a schmitt trigger input to clean up the faster logic pulse trains from rotary encoders.
  • You can do a lot of electronics and get an intuitive grasp of what is happening by laying on a scope and laying off the math.
  • Clean up your signals before trying to code them clean, crap in equals crap out.
  • Rotary encoders are great if you know how to work with them.

We won Sheffield Soup Funding for our expansion!

Sheff Soup Case of Money

Earlier this week I (Bugs) went along to talk at Sheffield Soup, a local crowdfunding event. A sell-out crowd of 150 Sheffield locals, plus representatives of local media, got together to hear four people pitch their ideas for a project to benefit the city. After each group gave a four minute talk and answered four questions for the crowd, there was time to eat, drink, listen to some great live music, and wander around chatting before the final vote.

Bugs speaking at Sheffield Soup

The attendees made for a very welcoming and insightful audience, with some great questions asked of all four projects, and a lot of interest in what we do and how to join. We’re looking forward to welcoming a lot of new people to the hackspace over the next few weeks! (If you’re one of them, look at our Calendar and just call into any of the Open Sessions. Or if you prefer, contact us to say hi and ask any questions.)

In the end, the audience voted to give us the £800 prize money, to fund our upcoming Hackspace expansion project! Expanding into the cellar beneath our current space with roughly double the amount of room we have to work in, and give us a dediated “dirty workshop” for stuff like woodworking, metalwork, glasswork, screen printing… anything our members want to try that needs a lot of space and makes a mess! Just as well: our weekly sessions are starting to feel decidedly crowded, which is a great problem to have and a sign that the hackspace project is going well.

So, look out for an upcoming post with more about our expansion plans. If you want to have a say in what those are, join the group and start chatting! And, of course, as we’re completely volunteer-run, we’d appreciate all hands on deck when it comes time to scrub the cellar walls and start building some workbenches…

 

Homemade smoke machine liquid!

A quick experiment by one of our members, in preparation for making a gun that shoots smoke rings.

(for anyone playing along at home: Mix 30% glycerol (also called glycerin) with 70% distilled water, and heat. Ideally, don’t do it in a small hackspace where the windows don’t open and other people are trying to make stuff. Oops.)

Mini PIR Sensor

Mini PIR Sensor

Mini PIR Sensor

I bought some of these mini PIR sensors on aliexpress, for the occupancy detector part of my ongoing NoTLamp project. They can be found for just under 1 UKP each. I want the NotLamp to work efficiently as it will be powered all the time. I also want it to all work from a single simple power supply and have chosen 3v3 as the lowest common denominator. I am taking the decision to work at 3v3 more often than 5V these days as so much is produced with 3v3 in mind. A big annoyance is the amount of 3v3 boards etc that are made 5V compliant and then used with other micro-controllers (ESP8266) or Pi’s that are 3v3. Very wasteful of both parts, and electrons. This picture shows the mini PIR sensor on top of a business card and next to a 20p piece so you can get a feel for how mini it really is. These little units are very simple with nothing to adjust and no daylight sensing, they are aimed at whole raft of people sensing switches etc and are designed to work across a wide voltage range from 4.5V up to around 20V. They have the part number DYP-ME003SE-V1 but can also be found online as an HC-SR505. These look to be almost identical bar the addition of a single capacitor on the front. I could not find any schematic for them which was disappointing, all the links claiming to point to a schematic take you to a schematic for the HC-SR501 the bigger brother to this one which uses a larger BIS0001 PIR chip.

Mini PIR Detail

Mini PIR Detail

These pictures show both sides of the board close up and side by side. In the left one you can see a 3v3 linear regulator and polarity protection diode, Those and the PIR detector at the top of the board look to be the only parts that are common between the two types of PIR sensor mentioned above. The IC is half the size of the BIS0001. The output is a 3v3 logic signal. Looking at the left hand image there is an unpopulated footprint to mount an S8050 NPN transistor for switching a relay or level translating the signal. You will also need to remove R1, just next to it if you want to do this. The presence of the 7133 3v3 regulator though is promising for my application as it shows that the circuit itself actually does run at 3v3. Just for the hell of it I tried the PIR at 3v3 and 5v to see how it did. It preferred 5V and worked reliably but dropping the voltage to 3v3 (Actually the test Arduino was putting out 3.73V) gave some interesting results. The device powered up and seemed to work OK but after triggering the detector the first time it re-triggered itself cycling on and off for its pre-set delay period. I counted the delay and it was around 10 seconds give or take a bit. Probing the underside of the board I found that for 3.73V in the protection diode was dropping about 0.2V giving 3.55V and the low drop-out (LDO) 3v3 regulator appeared to be dropping nothing. This was not very promising as the board should run at 3v3, given the presence of the regulator. Time to warm up the hot air pencil and iron then perform some surgery.

Modified PIR

Modified PIR

I first removed the regulator, and consulting a data sheet for the pinout, shorted the Vin to Vout pads where the regulator used to be. You can see how I did this in the before and after shots in this picture. Powering it up from the same source I checked the voltages but found it was performing exactly the same cycling of off to on all the time. So the cycling problem was not the regulator struggling with the low voltage. The voltage on the board side of the protection diode now measured 3.55V so given that PIR detector draw crazily low currents it should be working. But wasn’t. Given it was not looking very promising but I could not figure out why I removed the protection diode and placed a short across those two pins. Completing the modifications in the pictures. Now It worked fine exactly as it had done at 5V but now at 3.7V. So these were the mods that were needed to make the units I have functional at 3v3. Given the strange results we had been getting I hooked up the board to my bench PSU and an accurate multimeter and set the voltage for a real 3v3 and also took the board down to 2.9V in both cases it worked fine. So the issue had not been the actual voltage level as such. I can only think that there is insufficient capacitance across the power rails on the board and at low voltages the turn on/off glitches were enough to re-trigger the detector. Odd, not seen this problem before, but there you go.

In summary a nice little unit, very cheap, hours of fun can be had with them in your projects, watch out for the self re-triggering and it will work comfortably down to 3v3 if you remove the regulator and diode, then short the correct pads to make a straight through path for the supply voltage.

A few lasercut pieces…

Did we mention we have a lasercutter? We have a lasercutter. It runs off the open source LAOS controller board, and couldn’t be simpler to get your designs into.

We’ve been getting to grips with it, and our members are turning out things like leather bookmarks
IMG_20160116_194938[1]

…project boxes, tensegrity balls…
IMG_20150926_170234[1]
Tensegrity Ball

…rubber stamps
SHHM Logo stamp

…and quite a few other bits and pieces. What do you want to build? Come along to one of our scheduled sessions and say hello!

Quadrant 3D Printer Cabinet

With the Hackspace having a collection of three different 3D printers and with them all being kept in one multi use workshop, it soon came apparent that we needed a way to keep the dust of of them all whiles also allowing us to gain easy access to them for maintenance. There was an ideal place in the workshop between the workbench and tool board where a cabinet would sit nicely.

With this in mind I took some measurements of the area and make a few rough sketches on paper. The cabinet would be 1200 x 600 x 2000 it would be divided up in to 6 quadrants, the top 4 quadrants will be where the 3D printers would be housed and the bottom two would

3D model of the cabinet

3D model of the cabinet

create storage space for reels of filament and other consumables. At the rear of each of the 4 printer quadrants there would be a 2G plug and RJ45 socket as each of the printers will run of OctoPi allowing the printers to be controlled remotely on the network. Once I had a feel for what the cabinet was going to look like on paper I drew up a 3D model using Free CAD.

 

The material of choice was 18mm construction ply, for the method of joinery I went for rebate joints. Each of the panels that the shelf’s and back would sit in had a rebate grove in the width of the ply routed down the width of the panel at the corresponding heights of the shelf’s the rebate was half the depth of the material. The cut away below shows half of the cabinet and how it is assembled. With the CAD design complete I got to work ripping all of the ply down to size ready for routing.

Cut away of the cabinet showing the rebate joints

Cut away of the cabinet showing the rebate joints


To ensure that all of the rebates where routed consistently I used a straight edge to guide the router on all the parts. By scoring each side of the rebate joints with a sharp knife before routing prevents tear out from the spinning cutter leaving a nicer and smoother finish. For routing the rebate on the perimeter of the back the router was used with it’s fens, the fens was set to the correct width from the cutter to the edge of the work piece and run down the edge.

To assemble the cabinet the shelf’s where first glued and nailed on to the two sides, this step was completed first because  you could only get a run of nails in one side of the middle. The middle and top where then joined the same way followed by the back. After a sand and coat of varnish the cabinet was ready to be moved in to the workshop.

The assembled cabinet in place ready for the doors to be hung.

The assembled cabinet in place ready for the doors to be hung.

Once the assembly was complete I decided to add some pull out shelf’s on rails, this would make it easier to remove things from the print bed and gain access to the back of the printer for maintenance.

door frame glued up

door frame glued up

To make the door frames I created a central groove using a table saw in several lengths of 20 x 35mm PSE timber. This grove would be where the perspex in the centre of the door would sit. The rails and stiles where cut to the correct length and a tenon was made on the end of both of the horizontal rails. The perspex sheet was cut to size and the frame was glued up using a pair of sash clamps. I used piano hinge to hang the doors, this was mounted on to the cabinet first.

The first door mounted

The first door mounted

All that was left to do now was install the rest of the doors, give them a coat of varnish, wire in the electrics and mount the pull out shelves. With the 3D printer cabinet approaching completion there where a few things that I could have done differently and some things that could be improved or even added on. One thing that could be different is the method of joinery, there are a multitude of different ways that it cold be done the other witch I looked in to was finger joints. Finer joints provide a larger surface area for glue to stick to but are more time consuming. I ended up using rebate joints because they where more suited to the design, not only that but would also give me more experience for the next job where I could attempt something a little more complex with the skills I have learnt.

The completed quadrant 3D Printer cabinet with pull out shelfs.

The completed quadrant 3D Printer cabinet with pull out shelfs.

Something else that would have helped during the build process is to have made a jig that could be set over the rebate and clamped down that the router would sit in and slide across, making the process of routing the rebates much more efficient and accurate quicker. A later addition that I intend on adding is a set of castor boxes for the bottom two quadrants witch will make it easier to retrieve consumables. Overall it has been a fairly successfully build. The cabinet itself is very sturdy and provides the purpose it was intended for it also provides more storage areas both on top of the cabinet and down below in the two quadrants.

img_0294_23699572839_o

 

img_0297_23699569539_o

 

For more images please visit here.

The Hunt for J5

Pi Zero J5 Connections

Pi Zero J5 Connections

J5 is alive, and is definitely not called johnny or a robot in a kids sci-fi film. J5 is the mystery connector footprint on the bottom of the Pi Zero. I have been puzzling over what it was intended for since getting my Pi Zero from Pimoroni.  Asking around amongst those who would know more than me about it (Not difficult to find) the hot favourite was a JTAG port but no one was entirely sure and there was no pinout. An extensive google around was surprisingly information free.

Time then for some reverse engineering, first stop was a USB microscope and a look see for obvious pin functions, gotta tackle the low hanging fruit first. Taking pin 1 to be the pin nearest the J5 ID we can see the footprint is for an 8 pin connector and the body or screen is not connected. 1 is the Pi system reset or run pin as it is labeled, 4 and 7 are ground connections. OK that leaves 5 pins to go. I visually traced the connections and lost them in to the maze of CPU via’s. As other than the reset they did not go to the GPIO pins I could rule out an easy hit as to what they were. The up side is if they were JTAG, it would have to be dedicated pins, not GPIO pins, and therefore projects could be debugged even with a phat in place. Hmmm what were those other 5 pins for. Normally at this point I would start on in with a multi meter or a scope and see what I could find out next. But serendipity smiled upon me, in that way it never normally does.

B+ J5 Connections

B+ J5 Connections

Putting some time into a side project (building a Graphite graphing server) I was working with a Raspberry Pi B+. Purely as I tend to mostly use Pi2’s now and was using up any older ones that were lying around. Embedding them irretrievably into other things. Fiddling with the board during one of many mental luls, I noticed the same mystery footprint on the board directly under the HDMI video connector. In fact it is so much the same it is also labelled J5. Cross referencing the ground pin outs that we know from the Pi Zero we get a match. What is more the 5 pins we had not identified are broken out to pogo pin pads bang next to the footprint. All along with nice labels. Combining the data we have then gives us the following table:-

J5 Pin Information
Pin No Pi Zero Function Pi B+ Function Comment
1 Pi System Reset ? Pull low to reset the Pi
2 ? TRST_N TAP Reset pull low to reset the TAP
3 ? TDI Test Data In
4 Gnd Gnd Signal Gnd
5 ? TDO Test Data Out
6 ? TMS Test Mode Select
7 Gnd Gnd Signal Gnd
8 ? TCK Test Clock

Some further technical info on TAP & JTAG can be found here worth a look at to illustrate some of the concepts behind JTAG. OK, all well and good, what is left to do, identify what sort of connector J5 actually is and make up a JTAG lead for it then connect it up and see if we are right.