Running stepper motors on 12v

So today I’ve continued hacking an ATX PSU into a power supply for my laser cutter, and I thought I’ld give the stepper motor a try on the 12v bus.

I used the same code as in but this time I managed to get it rotating with 2ms between steps, as opposed to 4ms on 5v supply. I have 200 steps per revolution so

1/200*0.004 = 1.25rps = 75rpm for 5v,
1/200*0.002 = 2.5rps = 150rpm for 12v.

This is an obvious improvement. This will be further improved I imagine after trying a different driving arrangement for the stepper motors with micro-stepping. I did try 1ms, however the stepper motor didn’t really appreciate the speed.

12v stepper motor arrangement

12v stepper motor arrangement

CNC router no more. I’ve decided….

… to make a laser cutter instead.

I’ve always wanted a laser cutter, but I’ve never really been able to afford one.

So i’m putting the CNC router on hold for the time being and building a laser cutter. It’ll have around a 1W laser and have a cutting bed of 600 by 800mm… which is quite big for a starter project.   I want to build it spending less than £300 on parts…. so cheaper than the CNC router too.

How hard can it be? Here’s a quick Google sketch up of my idea’s

my laser cutter

my laser cutter



Arduino based DMX DeMUX – Analogue – part 2

I realised I’ve left this project hanging a while now and that’s partly to do with he fact that the chips I was hoping to use didn’t arrive quickly then other things got in the way.

I’ve also hit upon two other snaggs,

  • The power supplied from the dimmers is not 10v, so this means adding in two power regulator circuits (one for 5v data and the other a 10v reference),
  • The chips will only do 0-5v, which obviously is no good for the 0-10v that’s required.

Never mind – this is still a project i’m working on – just a little more complex than I first thought.


New to Stepper Motors

So as part of a few projects I’m attempting soon I thought I best actually get a stepper motor and all the jiggery pokery to control it working.

Parts I have to play with:

  • Arduino Uno SMD,
  • “Dual H Bridge DC Stepper Motor Controller Board Shield L298N”
  • Nema 17 stepper motor.

Great, so lets get started.

What’s a Stepper Motor?

So a stepper motor is a special type of motor. Unlike other motors such as DC and AC motors, it has a discontinuous cycle, or it moves in steps. This is due to the internal structure of the motor. It has advantages and disadvantages as with everything in life. The main advantages of stepper motors are that they are easy to control precisely without having a feedback loop, and they have a high holding torque. This makes them ideal for precision control. Unlike servo’s stepper motors will not correct their position if moved, without additional components.

There are two types of stepper motor, Unipolar and Bipolar. I’m using a Bipolar stepper motor. More information on the differing types can be found in the references at the bottom of this page.

How do we control a Stepper Motor.

We control stepper motors by setting the polarity of different coils inside the motor to different states. Tom Igoe Has a good in depth page here about how we can do this and differing methods. IMO the best method is 4 wire control and a dual H bridge. It’s simple and has the advantage that you can turn the stepper motor completely off (which you can’t do with the 2 wire method).

So here’s how I’m wiring it up (for experiment purposes).

Pins 8,9,10,11 are wire 1 thru 4. obviously Arduino needs 5v and gnd too…
The Dual H bridge takes a pair (wire 1+2) for one H bridge and a pair (wire 3+4) for the other H bridge.
My stepper motor has red and blue wires for one coil, and green and black for another coil. I’ve wired these into the outputs of each H bridge. Note that each H bridge and coil is operated completely independently of the other in terms of electronics. The H bridge will also need 5v, gnd and a voltage for the stepper motor (I’m using 5v throughout for my experiment)

H bridge wired to a bipolar stepper motor

H bridge wired to a bipolar stepper motor – has a good diagram of how to wire a bipolar stepper motor up to a H bridge. – The first ten mins or so explains a bit more on how a H bridge is wired.

One question I came up with is which wires go with which coil? – well just use a multimeter to find this out (or maybe a datasheet?). And other is what happens if I get the order of the stepper muddled up, polarity of each coil or the coils the wrong way? The simple answer, without going into detail, is the direction of movement will change. (Easy to fix in software/firmware or swap a coils polarity at a latter point.)

Anyway here’s a simple bit of code showing how you can drive a stepper motor without any additional libraries (assuming wired as above). Change time to be the milliseconds between steps (I started at 500 and worked down to 4 (the lowest I could get to work with 5v)).

void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(13, OUTPUT);

int time = 4;

void loop() {
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(13, HIGH);

digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(13, LOW);

digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);

digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);

Failing this you can use the example in File>Examples>Stepper>forward reverse. (OWTTE.)

I wont go into depth on using the Stepper commands that Arduino have in the library.


Had a tripping weekend…

So this weekend just gone, there was an incident when an artist decided that pouring beer into a 4 way on stage was a good idea. Safe to say it wasn’t and it tripped the RCD for stage power. But it also tripped two more upstream RCD’s, taking out monitor world.

This has got me thinking about the best possible way to avoid this in the future.

The first thing to understand is what happened on this gig, why it failed and why it took out all of the stage and mon’s power.

  • The main distro there was a 63a 30mA RCD over 2 32A outputs,
  • One fed the monitor racks and the other fed a small distro, 
  • The small distro had 30mA 16a RCBO’s on 4 16A outputs, powering the monitor desk, the stage power, and most importantly the fridge and kettle,
  • Stage power had a further distro with one 16a RCD/BO with 4 16A outputs running to various on stage 4ways.

On this gig, the main PA was fed from the other 2 phases and FOH power was ran from a 16a on the distro on a differing RCD. The main RCD on the main distro was of a higher trip rating than 30mA. This was lucky as loosing FOH power or PA power would have been significantly more of an issue.

The key thing here is that the water/beer in the 4way caused a cascade of RCD/BO trips, firstly the stage power distro, then the small distro then the main distro. When powering back up to identify where the fault was (not knowing where at that time) the RCBO’s caused an issue of upstream tripping.

The key thing I’ve learnt from this is that RCBO’s should NOT be used for stage power as isolators to fault find, and as such they should not be used for stage power. It’s a better idea to have RCD’s with separate MCB isolators. This allows you to isolate the circuit before resetting the RCD, then when resetting the MCB, if the earth leak still exists, it’ll trip that RCD and not an upstream one (assume your discrimination between RCD’s is correctly set up).


re-visiting racks

Today I’ve been tidying up some paperwork and I came across some old cut plans for making racks. The thing that I was working on was – how much can I get from a 8 by 4 sheet of 18mm ply?

My initial rambling drawings show that I can get 3 4u racks from a sheet or a 14u rack from a sheet. But I thought seeing as I have a few spare moments I’ll draw up the cut sheet and then I thought why not actually work out what the maximum size I could get would be? Lowe and behold apparently I can get 3 5u racks from a sheet or 1 18u rack, which is better than I thought possible.

Anyway – here’s a quick model I knocked up in SketchUp, and a pdf cut sheet for making three of the racks (with lids) from one sheet of ply.

5u rack model

5u rack model

5u cut sheet

Arduino Mega2560 with 3.2″ TFT LCD Touch Display

I received today in the post an Arduino Mega with 3.2″ TFT LCD Display made by SainSmart, from Amazon. Click here

I was impressed how easy it was to assemble – however it isn’t exactly a robust set-up. The screen board is attached at one end, so it’d be quite easy to bend the pins between the LCD PCB and the Arduino Shield .

To use the screen you need to use a library which I found on SainSmart’s website. However – there is an issue (in my Arduino IDE anyway) with this library. Namely that it refers to another library WProgram.h which has been renamed to Arduino.h. You’ll need to rename this once extracted or download my copy with the mod to your arduino/libraries/touchscreen directory (you’ll have to make one). Without this mod you’ll get an error when you compile;

In file included from ITDB02_Graph16_Demo_Landscape.cpp:18: C:\Program Files\arduino-1.0\libraries\touchscreen/ITDB02_Graph16.h:69:22: error: WProgram.h: No such file or directory

But once that’s done, it should work fine and dandy. There are two example sketches in the library – one uses the touch screen to make a sort of etch a sketch and the other displays some of the more advanced graphics that could be displayed.

Below’s a video of that second example running on the device. (sorry it’s a tad blurry)


Intelligent fixtures as follow spots part 2

I tried my Lego prototype today with a moving head. The results weren’t as good as I was hoping. After a bit of tweaking and jiggery pokery, managed to get the moving head to move in sync with me moving the tracking system. By ‘in sync’ I mean the same directions and speeds, but not scale yet (although it was close), and managed to use both of the handle encoders to change the dimmer of the fixture (individually and not both at the same time – that would be silly!).

Rite now there is one problem – it’s Lego. The problem is accuracy of movement to encoders and there is an error here. As you move the Lego, you have some play in the parts before the pots sense the movement, and this means it is not accurate. So until a more accurate device in the real world (out of laser cut wood, with 20bit or more AD’s) can be made, this project is on the back burner. (Plus I need to focus on my studies.)


For those interested in where I got to, have a look at the pictures in this post, and the code below – it is similar to the code for the simple DMX desk here.

 #include <DmxSimple.h>

// this is the code for a track pod idea and it takes 4 analogue ins to
// a number of analgue outs.

// this code channels is for a mac 250 mode 2
// 1 strobe
// 2 dim
// 3 colour
// 4 gobo
// 5 gobo rotate
// 6 focus
// 7 prism
// 8 pan
// 9 pan fine
// 10 tilt
// 11 tilt fine

// two in’s are for pan and tilt – so the 10bit will need to be translated
// to 16 bit and split up and sent on channels 8+9/10+11,
// one will be used for dim and one will be used for focus. both will need
// 10->8bit reduction.

void setup() {

void loop() {
// read the value from the sensors:
int value1 = analogRead(A1);
int value2 = analogRead(A2);
int value3 = analogRead(A3);
int value4 = analogRead(A4);

//need to change from 10bit to 8bit
value3 = value3 / 4;
value4 = value4 / 4;

//spliting the 8bit output from the 10bits.
int valuep = value1 / 4;
int valuet = value2 / 4;

//spliting the 2bit output from the 10bits.
int valuepf = (value1 – (valuep * 4)) * 64;
int valuetf = (value2 – (valuet * 4)) * 64;

DmxSimple.write(2, value3);
DmxSimple.write(6, value4);

DmxSimple.write(8, valuep);
DmxSimple.write(9, valuepf);
DmxSimple.write(10, valuet);
DmxSimple.write(11, valuetf);