Introduction: MICRO MIDI STEPPER TouchOSC TIMELAPSE DOLLY

Picture of MICRO MIDI STEPPER TouchOSC TIMELAPSE DOLLY

This Instructable will be about building a timelapse dolly thats "programable" via MIDI protocol.

It will cover the following steps:

  • Building the dolly hardware
  • Using the 28BYJ-48 stepper
  • Building the MIDI interface
  • Programming the Arduino
  • Using the Touch OSC Editor

For the dolly you will need:

  • 2x 28BYJ-48 steppers like those: https://www.adafruit.com/products/858
  • a PCB for the chassis around 10x10 cm
  • 3mm and 8mm drills
  • a jigsaw
  • a few M3 bolts nuts and shims
  • 2x M8 bolts, 2xM8 shims and 2xM8 nuts
  • 4x skateboard bearings

For the arduino control unit you will need:

  • Cables obviously, i used a flat cable with 14 lines to connect to the dolly.
    • Four lines per stepper and two lines for power
  • An Arduino obviously. I used a micro, but any Arduino will do the job.

For the MIDI interface please go to another Instructable i made:

Step 1: BUILDING THE DOLLY HARDWARE

Picture of BUILDING THE DOLLY HARDWARE

As you can see on the photos, the dolly is made from two PCBs that form the two sides, connected by two M8 bolts that function as axles for the free spinning wheels.

One of the steppers represents the third (powered) wheel.

On the photos there is a beltwheel mounted to it, but you can also use a rubberized wheel with more traction to use it without the belt like on the servo powered microdolly i made earlier: https://www.instructables.com/id/MICRO-ARDUINO-GOP...

I used the 3mm drill for all holes except the axles.

I will add a drawing where you can count the holes in the PCB to get the dimensions.

The drivers of the two steppers are mounted with M3 bolts too, as you can see on the photo from above, you could also use longer bolts for the drivers and use the same on both.

I cut the cables that connect the stepper with the driver, shortend them and soldered them directly to the rear side of the drivers.

Both power lines of the stepper driver boards are soldered to two respective strips of the chassis PCB.

As you can see on the photos, there is a third cable soldered to to that area, i plan to use it for a camera trigger on a later point.

Step 2: USING THE 28BYJ-48 STEPPER

Picture of USING THE 28BYJ-48 STEPPER

The 28BYJ-48 is a very small and very inexpensive (bought mine for 4€/piece on amazon) stepper motors, that come with a small (around 1"x1") driver board.

They are unipolar steppers, which are not that common nowadays, but can be converted to bipolar steppers.

You would need a different driver if you would convert them, so i didn't do it.

They use 5V and i power them directyl from the 5V pin of my Arduino micro, which makes it a very small package.

From the 5 motors i ordered, two got damaged gears which made them unusable.

Thats a payoff to the price, but still.

One important thing with these steppers is, that the power-lines to the motor are not in the correct order.

It took me an afternoon to find that out, no idea why no one mentions that.

Later on in the script you will see its easy fixable, by defining the pins in a different order.

Another thing to mention is, that the motor has 64 steps per revolution, plus has a gearbox attached that has 1/64 ratio, which makes the whole setup a 4096 steps/rev stepper.

Step 3: BUILDING THE MIDI INTERFACE

Picture of BUILDING THE MIDI INTERFACE

As i said earlier, for the MIDI interface, please go to another Instructable i made earlier:

https://www.instructables.com/id/MIDI-TO-ARDUINO/

Step 4: SETTING UP THE ARDUINO

Picture of SETTING UP THE ARDUINO

The Setup Arduino-wise is pretty straight forward.

We need:

  • Four pins for motor A
  • Four pins for motor B
  • The Rx pin as MIDI in
  • 5V/GND pins as power for the motor drivers

You can either use a development board and short patch wires, or hardwire it on a shield.

I made a small doublesided stripboard PCB and soldered the micro on that board.

After that i used a dual row connector to get all the micros pins out and also can use patch wires like on the UNO.

On my setup i use the pins as following:

  • Motor A :
    • PIN 9
    • PIN 10
    • PIN 11
    • PIN 12
  • Motor B
    • PIN 5
    • PIN 6
    • PIN 7
    • PIN 8
  • MIDI Data Pin connects to Rx. Be careful to unconnect this PIN when uploading, if not its getting you errors.

Step 5: PROGRAMMING THE ARDUINO

Picture of PROGRAMMING THE ARDUINO

For the Arduino Script, make sure you got the following libraries:

  • MIDI.h
  • STEPPER.h

Before looking at the code, whats the point of the script?

It uses a technique called MIDI callbacks. There are documented examples that come with the library, in short words, a midi callback means that in the void loop() there is only this function to look at the Rx PIN and see if there is some kind of MIDI information coming in. Nothing more.

That makes the script as low latency as possible, because there is no other stuff in the void loop() that take processing power/time.

IF there is a midi message coming in, it calls the midi handler to identify the message.

In our script we are looking for MIDI #CC messages on MIDI channel 1 and #CC on number 20 and 21.

A MIDI#CC message can be a value between 0-127, and we use number 20 for turning and number 21 for driving the dolly.

I can't screenshot the whole script, and when pasting it in the text it doesn't show me formated code, so i will screenshot them in tiles. Just watch the numbers on the left side to fit them back together.

  • Line 1 -24

In this part i define the motor outs and a counter per motor, also both libraries get included, and the Steppers defined. 4096 steps is one revolution.

Be careful on the motor PINS, instead of 1_2_3_4 it's PINOUT system is: 1_3_2_4

So the pins in our script are 9_11_10_12 and 5_7_6_8.

  • LINE 24 - 80

As we are using midi callbacks, this part is where the stuff goes in that you want to do if a certain MIDI input gets detected.

In line 28 it looks if the incoming MIDI message is sent on MIDI cannel 1

In line 30 it looks if the MIDI #CC number is 20, and if its on #CC20 it turns the motor for 20 STEPS depending on if its higher or lower then the counter.

In line 52 it does the same for MIDI #CC21.

  • LINE 81 - 116

The last part is the void setup() and void loop()

We set the AmotA etc pins to outputs, and set the Speed of the steppers.

As is mentioned earlier the void loop() only consists of the MIDI.read().

I added a PIN called "pin" on PIN 13 (LED pin) to see if MIDI messages are coming in, but you do not need that for it to run.

Step 6: USING THE TOUCH OSC EDITOR

Picture of USING THE TOUCH OSC EDITOR

First of all you have to download and install the free editor from : http://hexler.net

I added a few screenshots, three of them represent my current plan of an interface, with adding stepsize etc.

One of the screenshots is from the touchOSC editor, on the left side you can see the values for a rotary control on MIDI channel 1 and MIDI #CC 20.

I added the touch OSC file to the Instructable.

Last things last:

Why MIDI you ask ?

That's where the last screenshot gets on the stage, and its called MIDI sequencer.

The screenshot is made in Apples LogicX, but can be setup in any DAW thats capable of MIDI.

Also you can play with a speed as low as 5bpm.

So any DAW except protools :)

You can see its also in #CC20 and #CC21.

Last but not least, there is a video of the dolly in a testride : http://youtu.be/fUlXWdZDtRo

Comments

Phoephoe (author)2016-11-03

Hi! Great tutorial!

I'm pretty new to the arduino coding, so I guess my question is a pretty simple one ;)

I'm using nema 17's with a pololu driver so I only use two pins for the motor,

is there a chance you could point me on how to set up the counter and define the motors in that case?

Cheers! :)

Hi, the best way to learn how to count steps imho is the "one Revolution" example, that came with the stepper library

Its in the Arduino IDE under:

File>Examples>Stepper>stepper_OneRevolution

Also take a look at the stepper_oneStepAtATime example

Basically what you do is set an integer with 200 Steps (most NEMA 17 motors) and then count +/-1 step.

If you didnt find that helpful or failed trying it out, you can post your code here and we can take a look together ;)

have a nice day

Thanks for a quick reply! :)

I think I got it figured out, so now I'm almost done with the code, to se if I'm correct ;P

Tho I'm getting a hangup at 112: error: 'HandleControlChange' was not declared in this scope

MIDI.setHandleControlChange(HandleControlChange);

Phoephoe (author)Phoephoe2016-11-03

A bit messy posting the code here I guess, but here goes ;)

#include <MIDI.h>

#include <Stepper.h>

#include <Arduino.h>

int pin = 13; //MIDI IN

byte Acounter = 0;

byte Bcounter = 0;

byte Ccounter = 0;

// MOTOR OUT begin

int AmotA = 3;

int AmotB = 4;

int BmotA = 6;

int BmotB = 7;

int CmotA = 8;

int CmotB = 9;

Stepper Amot(800, 3, 4);

Stepper Bmot(800, 6, 7);

Stepper Cmot(800, 8, 9);

// MOTOR OUT end

MIDI_CREATE_DEFAULT_INSTANCE();

void HandlecontorlChange(byte channel, byte number, byte value) // SEARCH FOR CC

{

if (channel == 1) // SEARCH FOR MIDI Ch. 1

{

if (number == 20) // FOR MIDID CC Ch 20

{

if (value < Acounter)

{

Amot.step(-5);

Acounter = value;

// Serial.write(value);

digitalWrite(pin, HIGH);

}

else if (value > Acounter)

{

Amot.step(+5);

Acounter = value;

digitalWrite(pin, HIGH);

}

else if (value == Acounter)

{

Amot.step(0);

Acounter = value;

digitalWrite(pin, HIGH);

}

}

else if (number == 21) // FOR MIDID CC Ch 21

{

if (value < Acounter)

{

Bmot.step(-5);

Acounter = value;

// Serial.write(value);

digitalWrite(pin, HIGH);

}

else if (value > Acounter)

{

Bmot.step(+5);

Acounter = value;

digitalWrite(pin, HIGH);

}

else if (value == Acounter)

{

Bmot.step(0);

Acounter = value;

digitalWrite(pin, HIGH);

}

}

else if (number == 22) // FOR MIDID CC Ch 22

{

if (value < Acounter)

{

Cmot.step(-5);

Acounter = value;

// Serial.write(value);

digitalWrite(pin, HIGH);

}

else if (value > Acounter)

{

Cmot.step(+5);

Acounter = value;

digitalWrite(pin, HIGH);

}

else if (value == Acounter)

{

Cmot.step(0);

Acounter = value;

digitalWrite(pin, HIGH);

}

}

}

else // WRONG MIDI CHANNEL

{

digitalWrite(pin, HIGH);

}

}

//--------------------------------------------------------------------------------------

void setup()

{

pinMode(pin, OUTPUT);

MIDI.setHandleControlChange(HandleControlChange);

MIDI.begin(MIDI_CHANNEL_OMNI);

//motor A

pinMode(AmotA, OUTPUT);

pinMode(AmotB, OUTPUT);

//motor B

pinMode(BmotA, OUTPUT);

pinMode(BmotB, OUTPUT);

//motor C

pinMode(CmotA, OUTPUT);

pinMode(CmotB, OUTPUT);

//motorSpeed

Amot.setSpeed(4);

Bmot.setSpeed(4);

Cmot.setSpeed(4);

}

void loop()

{

MIDI.read();

digitalWrite(pin, LOW);

}

ok i just looked at it a second time, i think you mixed up some stuff, like steppers and DC motors.

But on the other hand i dont know the polulu driver, probably its correct :)

it's an a4988 driver, so it converts the pairs to pin Step and Direction so that's the pins driving the motion, in this case step 3 dir 4, / 6,7 / 8,9.

Hi, i ll copy that in the IDE and see whats happening :)

One thing i saw, is you set the stepper to 800 steps per round, is that correct? 200 steps is what a common nema 17 takes per round.

I will look at the code when iam back at work and bored, which means tomorrow 8AM aka in 12h haha

Awesome! :)

Thank you!

I'm also a bit confused by this since as you say 200 should be the standard full step, but when playing around with the steps it seems 800 is correct.

I think you might be correct about the mix up, I'm not certain that the code will count the steps, feels like there should be other data fed to it for it to work, but I'm not sure :P

But otherwise I think that should do it for the movement,

How would you go about driving the Nemas if not by driver?

Cheers!

doesnt take the video for some reason ..

youtube.com/watch?v=mBHtifzMJFQ

PhilippeG1 (author)2016-10-19

très complet, il y avait cette pae pour comprendre le brochage avec arduino

https://arduino-info.wikispaces.com/SmallSteppers

english please :)

antima (author)2016-01-27

great work man! i really liked it!

thanks man :)

About This Instructable

4,990views

83favorites

License:

Bio: I'm a 36 year old DIY enthusiast from Vienna Austria with a strong background in mechatronics/automation. My DIY field is mainly video/audio ... More »
More by InevitableCraftsLab:ELECAM 360 - BLADE 200 QX - FRP QUAD CHASSISARDUINO_ POLAR V PLOTTER ARDUINO 433MHz _ SERVO.h vs VIRTUALWIRE.h
Add instructable to: