Wednesday, 9 April 2014

Adding LM741 model to LTSpice

I find myself coming back to this page every so often when I'm playing with opamp models in LTSpice.

Annoying how LTSpice doesn't ship with the 741 model pre-installed.  Annoying but understandable since they'd be promoting someone else's IP I suppose.

Tuesday, 8 April 2014

Home-brew Milling Machine Tacho

For my Clarke CMD10 milling machine I wanted to add a tachometer so that I could better judge the appropriate cutting speeds for various materials, rather than doing the whole thing by ear (literally).

The CMD10 has many failings.  It's sloppy, the ways are rough, the tool head nods like an amused donkey.
The list goes on.  But one of it's great features is it's speed control.  A fairly decent quality potentiometer governs the spindle speed from stall speed (60RPM or so) up to a stated 2000 (mine tops out at 1975).  Within that range you can pick any speed you like to a fine resolution.  This really does feel nice to use since the machinist can simply use their ears to sense the changes in spindle speed.  Quite a pleasant way to use the machine.  But I like accuracy, so I wanted a tacho to tell me the precise speed of the tool's rotation in real-time.

Why buy a tacho when you can build one?  I thought it would be a cool project and there happens to be a convenient spot on top of the machine for a tacho to live.  I fired up my pen and paper and wrote some code to do the requisite calculations.  Then threw a board together and did a bit more code to drive a 4 digit LED display.  Actually this is a fair amount of coding to do but it's a lot of fun to do some serious coding in PASM.

To bring this blog up to date for once (!!!), today I managed to motivate myself to get this build into a state where the RPM sensing and display code is fully operational and made a quick video of it...

Next I plan to find a way to add X and Y axis position readings to the display.  Watch this space.

Thanks for reading, comments welcome. :)

Saturday, 5 April 2014

Lighting rig for Photographing Paintings

My old man's a dustman an artist.  He's rather good, and I suggested that we record his paintings for posterity in digital format.

This poses a problem - how does one go about providing favourable lighting for photographing a painting?

I have not tried to photograph paintings before so this was rather a new challenge.  I felt it important to give good, neutral white light as far as possible and to distribute that light evenly around the painting.

A few months ago I bought some colour cycling LED xmas lights - five metres worth!  The LED strip came complete with an IR remote control with a colour selection feature that lets you pick from 16 colours or so.

I built a rectangular framework out of MakerBeam parts and cable-tied the LED strip to the frame so that they all face the same direction with a fan out pattern to illuminate the canvas.

Finally I rigged up the framework to attach to my tripod's leg using a scope clamp.  Long story short here are some pictures...

lighting rig for photographing paintings

Tuesday, 11 March 2014

Propeller Hacking: WAITPEQ timeout

Random thought of the day:

If you're using either the WAITPEQ (or WAITPNE) instructions on the Parallax Propeller (P8X32A) chip then you can add a high resolution configurable timeout to it in the following way...

Set up your WAITPEQ instruction like normal but also configure your mask and state values to include an additional IO pin (call it PIN X).  Then configure either CTRA or CTRB to use "NCO single-ended" mode on PIN X with a duration that makes sense for your project.

Since CTRA (or CTRB) are running in the background autonomously then they will be able to cause a pin transition even the cog is still blocked by a WAITPEQ (or WAITPNE) instruction.  Thus you can set up your chip so that it never spends more than a certain amount of time in a WAITxxx state.

Here's a quick code sample to demonstrate this.

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
PUB main
  coginit(0, @ASM_ENTRY_POINT, 0)

'Circuit: * put an LED on P13
'         * connect P0 to VCC
'         * leave P1 unconnected

              org       0
              or        dira, LED      'output
              andn      dira, SENSOR   'input 
              or        dira, TIMEOUT  'output

              or        outa, LED

              mov       time, cnt
              add       time, ONE_SECOND
              waitcnt   time, #0

              andn      outa, LED

              mov       FRQA, #1
              NEG       PHSA, FIVE_SECONDS 'timeout period is set here
              mov       CTRA, CTRA_MODE    'start counter

              'now pins P1 and P0 are both HIGH
              'when the timeout elapses, P0 will go low and cause the WAITPNE instruction to exit

              waitpne   PINS, PINS   

              or        outa, LED                 

              waitpeq $, #0 'sleep forever

ONE_SECOND    long      80_000_000
FIVE_SECONDS  long      400_000_000

LED           long      |< 13

SENSOR        long      |< 0
TIMEOUT       long      |< 1

PINS          long      000011

CTRA_MODE     long      %0_00100_000_00000000_000000_000_000001

time          res       1


Sunday, 9 March 2014

Wind Tunnel Project: Welding drinking straws

For the wind tunnel I need to bunch together hundreds of 2" sections of drinking straws to form the flow guides that will hopefully force the air flow to become approximately laminar.  I thought about using spray adhesive but I figured that using glue would be extremely messy and would probably cause more turbulence than it would have eliminated.

Then I tried using my soldering iron to weld the straws together and it works very well...

Look closely at the ends where the straws contact each other.  At those points I quickly touched the hot iron on the plastic of both straws and they instantly fused together.

This is really handy because I can simply pack hundreds of straws into a cardboard jig (a cereal box will work perfectly) and just use the iron to weld all the straws into a single piece!  I have only tried this with a few straws but I think this will work fine for a large mass of straws.  The welds hold strongly although they do tend to ruin the smoothness of the plastic.  I will only do the welds on one end of the straw block, the other end will have to be held in place by another means in order to have a good surface for the air flow to exit the straw bundle.

Try this for yourself and see just how strong drinking straws become when welded together.  I am sure this would be an excellent construction technique for model aircraft makers.  The bundle of 8 straws you see in the picture can hold 8 kilos of longitudinal compressive force without deforming!  And since you're not adding the weight of adhesives, it's incredibly light.  

The bundle above weighs about a gram or so but can support 8000 grams.  Pretty amazing.

Saturday, 8 March 2014

New Project: Wind Tunnel

To my eternal shame I do not possess my own personal aerodynamics test laboratory. Remiss of me I know. But instead of frittering away several million quid on buying one I have decided to build one for cheap.

Here's a concept drawing...

It will be about 900mm long, 300 high and 300 wide.  It will be constructed from perspex and pine beams.
The fan and speed controller have already been completed (that was today's job, see below).

I will be using an idea I saw on a tv advertisement (one aimed at encouraging people into a career in high school teaching) in which a teacher had constructed a wind tunnel for his classroom.  He had used drinking straws and other simple and cheap parts to affectively make a fully functional model.

I will also be using some car washing sponges to baffle the incoming and outgoing air in order to decouple the rotating fan blades from the linear air flow.  I have found a beefy 12V, 1Amp case fan from a scrap computer.  I am controlling it using a simple, low-part-count circuit which uses a microcontroller to read a rotary potentiometer and drive a power MOSFET using PWM to regulate the speed of the fan.  This works very well and gives good, granular control of the motor speed.

I hope to make this wind tunnel interesting in one respect.  I will be able to up-end the entire thing and do vertical (in opposition to gravity) drag tests for evaluating paper parachute designs!  This might prove difficult but it should be fun finding out.

Here's a couple of pics of the speed controller circuit... (the source code for the ATTiny85 microcontroller can be found here).

The fan connects to the 4 pin header.  The unit requires a 12V PSU such as a wall wart or a laptop power brick.  I can upgrade this design to add a second fan if I decide that a single fan isn't up to the job.

The ATTiny85 is a fantastic chip for small simple projects like this.  I could have done this with a 555 timer of course but I like having the flexibility of the ATTiny85 which gives the potential to add automation features such as soft-starting the fans or setting thresholds on the max/min speeds allowed.

I'll be building the rest of this project this week and I'll put more pics and videos up here soon.

Stay tuned.

Monday, 6 January 2014

Finished XMas tree decoration code

A few weeks back I finished the ATTiny85 code for driving a 16 NeoPixel Ring and all over the Xmas break it shone like a majestic beacon of festive cheer atop the Xmas tree.  It looks lovely.

There is no schematic for this project, mainly because it's trivial and anyone can work it out themselves with a bit of thought and secondly I couldn't be arsed drawing one.  PB0 on the Microcontroller goes to the data in pin on the first led in the chain.  Both the micro and the LEDs run from a regulated 5V rail.

I will hint that you'll need something at least as good as a LM317 to provide the 5V rail for the LEDs and the microcontroller.  The LEDs chew up a fair bit of current if you drive them at full brightness.  I recommend running them rather dimly because they do get hot and are migraine-inducingly bright at maximum intensity anyway.  For an Xmas tree you'll appreciate the colours more in the dark anyway.

I'm going to adapt this code to drive the 1 metre (30 pixel) strips soon, so stay tuned :)

Thursday, 19 December 2013

Multiplexing high frequency digital signals using a Parallax Propeller

While contemplating the Counter features of the Propeller chip, an interesting idea occurred to me.  Since each "Cog" has it's own CTRA and CTRB counters, and given that they run at the system clock (after PLL) speed AND run "in the background" without requiring any particular interaction with running code....

It should be possible to feed in a high(ish) frequency digital signal into an input pin and arrange the CTRA/CTRB features such that the signal is redirected out of an output pin with very little latency and without needing to execute any instructions at all (apart from a small number to set up the features to begin with).

Furthermore, one input pin could supply both CTRA and CTRB simultaneously while two outputs are driven (one for each CTRx).

Even more furthermore, I theorise (but have not yet implemented) that all 16 CTRx features in a Propeller could feed from a single input pin and supply 16 output signals simultaneously!!!

The output signal would be inverted and one master clock cycle behind the input signal.  If multiple output signals are generated, then they would all be exactly in phase with eachother (but still inverted and trailing slightly behind the input signal).

"This doesn't sound very useful!" I hear you cry.  Well it could be used for the following purposes:

  1. Re-routing UART data to alternative destinations, or multiple destinations.  You'd simply need to re-invert the inverted outputs to get your signal the right side up but this is cheap to do.
  2. Clock distribution without having to use expensive additional components.
  3. Simply inverting a digital signal.
  4. All of the above at up to 80MHz (or more if you like overclocking your Propeller)!
Even if you do have 16 outputs running at a time, you'll still have 12 IO pins (16 minus the pin used for programming the chip and I2C to the EEPROM) free to do other stuff with and you're still not actually running a single instruction of code yet.  The only code involved is run once and it only involves setting a couple of registers, but after that your code can forget all about what its counters are up to and get on with other things.

Sunday, 8 December 2013

Xmas decoration

"Winter drawers on", as they say.  Xmas is almost upon us.

In the light of my recent carpentry failure, I turned my attention to improving the electronics for my NeoPixel project.  Nothing fancy here, just an ATTiny85 microcontroller with some home brewed NeoPixel driver code on it, running from an ST L7805 5V regulator and taking power from a 7.5V 1.5A wall wart supply.

Here's a badly made, artefact riddled, crappy video...

Wednesday, 27 November 2013


Purpleheart clock enclosure has been destroyed.  ****.  However it does appear to be possible to mill this material down to around than 1mm thin without it fracturing.

Nevermind, onward and upward.  I'll try again.  Good job I have a backup workpiece that was cut out at the same time as the first!

What doesn't kill us... simply disintegrates in a milling machine.