Skip to main content

An Arduino Controlled Spooling Machine

Using the Arduino Motor shield and a stepper motor to spool set lengths of thread onto bobbins.

In the post Arduino Stepper Motor Control I wrote about what a stepper motor is, how it works and the different types of stepper motors; I connected a stepper motor to the Arduino Motor shield, which I had mounted on an Arduino Uno board and got a basic sketch up and running.

The motor which I used in that post was geared, so it didn’t turn as fast as I would have liked for the project which I had in mind. In this post I cover using a different stepper motor to spool thread onto a wooden bobbin, and also adding switches which would control how much thread is spooled.

Max Motor Speed

I connected up the new stepper motor, with one wire to each channel on the motor board and uploaded the same sketch which I knew was working last time. The steps per revolution were altered accordingly in the sketch for the new motor and everything appeared to work fine.

The new motor seemed to move much faster than the stepper motor used in my previous post. I assumed this is because this motor isn’t geared, however, although it was faster than the previous it was still very slow. I began altering the speed in the sketch from 5 to 10 and this made the rotations faster and smoother, but it seemed like the motor could go much faster. I upped the speed to 50 and again this worked, but seemed like it was capable of going even faster still.

I continued increasing the speed until I got to 200 – this was quite fast. I wanted to determine the max speed before it could be driven any faster. Once I had reached a speed of 300 the motor didn’t turn at all, so I figured the top speed must be somewhere between 200 and 300. I tried several intermediate speeds to see what the maximum actually was:

250 – Worked fine
275 – The motor moved, but wasn’t completing a full rotation, only about 20 degrees.
260 – Worked fine
265 – Worked, but only completed 180 degree rotations

At this point I concluded that the top speed for this motor must be 265, but to be safe I decided on 250. As I knew what the top speed of the motor was this would now help when I wanted to set it for different numbers of rotations for spooling thread.

Determining the Switch Pins

The switches I had chosen to use for this project were SPST, Momentary Miniature Push Button Switches which have an LED in them. There are four pins: two for the LED and two for the switch. On the data sheet for these switches there are markings which indicate which pins belong to the LED and switch, however, when looking at the underside of the switch I couldn’t see these markings.

I found the switch contacts by using a multimeter set to continuity, pressing and releasing the switch.

I next referred to the data sheet once again for the rated voltages for each colour LED so that I could power these to find the anode and cathode. I had both red and green switches, so I used a bench top power supply and set it to 2.1v with current limiting set to 20mA for red and 1.95v with current limiting set to 20mA for green. When the LED illuminated I knew the correct orientation of the pins for the LED and put a mark on the anode so it was clear when it came to wiring these later on. As it happens the LED pins were the longer two of the four.

As I had identified the pins I next needed to find two free inputs for the buttons and two outputs for the LEDs on the Arduino. From looking at the schematic for the Arduino Motor Shield I could see that pins 10, 7, 4 and 2 were free, as well as the two orange TinkerKit connections (pins 5 and 6), pin 1 (Tx) and pin 0 (Rx). I decided to use pins 10 and 4 as inputs for the buttons and 7 and 2 as outputs for the LEDs. I added pull-up resistors on the inputs so that these would never be in a floating state, in addition to the corresponding resistors required for the LEDs.

To begin with I wired up one switch and LED to check that I had the wiring correct and then next added these to the sketch. The schematic below shows how I wired one button and LED up.

I managed to get this working after a fixing a few initial minor mistakes in the code and then connected the second button and LED up like so:

Here is a breadboard view of the circuit.

Implementing a State Machine

When the button is pressed the LED should illuminate and the motor spins for four rotations. This happened but it didn’t work quite as expected and when the button was activated, it started on the high from the button press (red oval), whereas I wanted it to be activated as the button press was going low (green oval). After speaking to a colleague I was told I needed to include a state machine in my code.

A state machine is “a device which can be in one of a set number of stable conditions depending on its previous condition and on the present values of its inputs”. The idea being that if the current state of the button is low and it was previously high, then turn the LED on and spin the motor.

Once I had implemented the state machine I had my prototype working as I wanted it to and could move on to designing a plate to mount the Arduino, motor and spool of thread on.

Making the Design Robust

I wanted to make something a little more permanent than a breadboard design and to do this I used an Arduino prototyping shield which would simply mount onto the Motor Shield on the Uno board. Once I had mapped out where the switches and resistors would connect to on the shield I soldered all the relevant components in place, before moving on to designing the mounting plate. This was far more compact and neater than the breadboard version of the circuit, and it also meant I could wire the switches I had chosen directly to the shield.

Mechanical Design

I designed the acrylic plate to mount the parts in Inkscape, which would be laser cut and then heated and bent on the front to hold the push buttons.

Once the plate was designed I cut a prototype of this in MDF to be sure everything fit where it should and all the hole sizes were correct. Unfortunately because the prototype is made from MDF, I was unable to bend the front of the panel as I intend to do so with acrylic.

Everything fit where it should on the prototype and looked as I imagined it would, with the exception to the bent lip that couldn’t be bent on MDF. Since this was OK I then proceeded to cut the mounting base from 3mm clear colourless acrylic and bent the lip for mounting the switches.

Next I could assemble the switches, with the four pins I tied the cathode of the LED and one switch pin together to form a common GND and then connected the LED anode to the pin header on the Arduino prototype shield. This was done for both switches which came to a total of six leads from the prototyping shield.

The Arduino boards, stepper motor and thread bobbin were all secured down to the board and the switches were pushed into place on their lip. Once all this was done I tested everything together and it worked exactly as intended.

Future Revisions

There a just a couple of things I would change in future designs on the mounting plate. The first being the orientation of the Arduino boards, since they are oriented with the jack and USB sockets to the right hand side the cables are pretty squashed, and there isn’t enough room to connect the Arduino to USB without unscrewing it from the mounting plate first. An alternative to this would be to leave more of a gap between the Arduino and the stepper motor, but I think that unless the gap is rather large it would still be fiddly getting fingers in and out to connect the arduino to USB, Unfortunately I didn’t recognise this issue on the prototype mounting plate.

The only other thing I would change is the bobbin: since this is quite loose, when it is spooled around the MDF it is quite baggy. I think this is because there isn’t enough resistance on the bobbin and it continues to reel off thread once the motor has stopped due to momentum. I think this may be overcome by placing the bobbin further away from the motor or adding more panels of acrylic with threading holes at different heights to introduce resistance to the bobbin.

Other than these two minor changes I’m very happy with the way the Arduino controlled spooling machine! I think the clear acrylic looks really nice and mounts all the components well. I’ve learned a lot about stepper motors over this process too, from barely knowing anything about them to understanding the code of how one works and using the arduino motor shield, I’m quite pleased with how this project has turned out.

Trainee Electronics Engineer, currently studying towards my degree in Electronic Engineering at the University of Hudderfsield. Completed my HND in Electrical & Electronic Engineering from Bradford College 2017. Love to try new things and build interesting projects!
DesignSpark Electrical Logolinkedin