Yet another new Bit ... (stepper motor)

Hi @chris101, I am getting more and more interested in the basic design of stepper motors thanks to your project !
If you get into troubles about using a bipolar or unipolar stepper motor, I found an easy instruction to change your stepper motor from unipolar into bipolar:


Recently I bought the same motor (because very cheap) so I can try things out also…:smiley:

1 Like

That’s a very interesting link @alexpikkert!

Jangeox’ blog post has very easy to follow instructions. If I get more of these motors, I’ll give it a try, but I have only the one motor, which I’m not gonna dig into until I get everything sorted!. However, it’s good to know it’s easy to convert for a future project.

I like the idea of more power, but wouldn’t current usage double since both (longer) coils are energized all the time? Power consumption is already pushing the limits for a single bit. Mine draws up to 250ma while single stepping:

NOTE: it averages around 190ma. My module always runs in single step mode, to provide versatility within the littleBits model (that is, a single, 5 volt, low frequency analog signal for the input.) This preserves control, but sacrifices speed and amperage.

ANOTHER NOTE: I still plan on incorporating sbright’s stepper code, but the bottleneck will still be processing each analog pulse independently. Perhaps I should have a mode switch for running at full bore. That might cut the consumption in half.

Hi @chris101,
My 1st impression (without testing it) is that the windings used in bipolar mode are twice as long, thus having twice the resistance. I think when using the same torque the current will be lower.
In the blog the guy overloaded the 5V motor with 12V to get the extra torque…

Would it be an idea to use the Littlebits 5V VCC power line only for the control and pulses, and design separate voltage input terminals for powering the motor?
Many motor driver IC’s I found have this option of using two VCC connections, one for control and one for real heavy power. This will limit the risk of damaging (blowing up…) the sensitive tiny little littlebits…
I will also try to brainstorm a little about “how to connect the stepper motor into the Littlebits environment” ( how to control, how to use pulses etc)…:thought_balloon:

1 Like

That’s the same IC I used for my dual direction DC motor module. Works fine with the ATTiny85…

1 Like

Hi @chris101,
The internet is full of interesting information…
The following wiki explains 100% clear the basics of unipolar and bipolar stepper motors including nice animations.
It has a lot of interesting Arduino coding also and a simple method with two additional transistors to control a unipolar motor with only two control wires from the Arduino or Attiny.
Happy reading (maybe)…:blush:

1 Like

Thanks for burning a few more neurons on this @alexpikkert.

I didn’t really analyze the circuit of the modified motor. I just used the ‘no free lunch’ rule. Increasing the voltage pays most of the tab.


[quote=“alexpikkert, post:32, topic:22098, full:true”]

Would it be an idea to use the Littlebits 5V VCC power line only for the control and pulses, and design separate voltage input terminals for powering the motor?
…[/quote]

The idea of separate power and control voltages within a littleBits environment was discussed in Bruce’s Robot Arm thread. I posted a simplified littleBits/Arduino circuit to run a servo motor at 12 volts here:


The chip I have is a L293-98 dual full bridge. It’s part of a ‘shield’ for an Arduino uno (here). Interestingly, they give an example of driving a unipolar motor (it looks just like the one that I have) I’ll give it a shot, but EVERYTHING else I have read says the center-tap common (red wire/middle trace on the circuit board) needs to be cut. Next week I’ll get a uno and find another motor to hack, or maybe rip apart an old printer - I think they have bipolar motors in them (which probably use 12 or 24 volts.)

Hi @matthiasmwolf,

I am getting closer to abandoning the idea of a single input, and utilize a second input to determine the direction of rotation. That would make everything easier!

On the other hand, a single input is SO simple from the user’s point of view.

1 Like

Thanks @alexpikkert! That was a fun site to browse through.

So I was intrigued by the idea of running a unipolar motor as a bipolar motor. I guess they call these hybrid motors. Turns out that you do not need to cut any traces or wires! According to the example on the bottom of this page, all you need to do, is hook up the motor like a bipolar motor to an L293 using the 4 coil wires, and just ignore the common power wire. Waaay easier than doing surgery on my motor!

Here’s a movie of it working:

2 Likes

Hi @chris101,
Indeed, you are right !
I managed to get my little stepper motor turning this way exactly !
I used an L293D, an Arduino Duemillenove (I think this Arduino could be transformed into an Attiny including the sketch later on).
Using a standard library from Arduino I managed to let it turn and control the speed with a potentiometer. (Later maybe replaced by a littlebits dimmer).
The direction depends on the sketch I used and the number of steps also.
Next challenge is “how to select direction and number of steps with Littlebits.”
I found out that turning this little stepper motor a full circle of 360 degrees is done with 513 steps…
This is very usefull when you program the motor to perform a dedicated sequence in a project.
I will send a video and draft sketch asap tomorrow, it is too late now. Brain stops thinking. Needs some sleep. :disappointed:

2 Likes

Yes, I found it interesting that it took (well, I counted 512 steps, but I may have been off) so few steps. My bit form of the motor takes 2048 steps for a full circle. I guess that makes sense, since my driver takes half steps, and there are four coils instead of two. It seems to run slightly faster in bipolar mode - about 12rpm vs 10 with my setup.

Oh, by the way, I am working on a project that uses the stepper bit: The Magic 8-Ball Turner. No idea when I’ll get it done though, cause I don’t have a laser cutter :wink:

LASER CUTTER?!! Join in the adventure with me and Alex!

2 Likes

I won’t get mine (well, the Physical Science department’s, but that means it’s mine … :slight_smile: ) until September. :watch:

We can still design your idea together. I’m sure we can test tolerances, etc. :smile:

Indeed we can Jude - and I am glad for y’all’s help! As soon as time permits, I will put together a bare-bones model of my 8-ball flipper, and an idea for what kind of housing it should have. I think it should have a tongue-in-cheeky occultishness to it. I’m thinking Ouija Board kitsch.

2 Likes

Last night, while thinking about how to use this device in the 8-ball project, I realized that it’s time to change the design of this module. Part of the design anyway.

When using analog input, this module works perfectly as it is now. If it weren’t for that pesky Arduino, I would be done. But having the littleBits computer control of this motor is important, A stepper motor really show it’s stuff when controlled by a computer.

So I have decided that there will be two inputs. And a mode switch with two modes:

1) Analog mode: The way it is set up now is exactly how analog mode will work. Only one input will be used, and motor control will be done by varying the frequency and amplitude of the incoming pulses, just like it does now.

2) Digital, aka Arduino, aka PWM mode: When hooked up to the Arduino module for control, the second input will be used. The main input will have a series of pulses from one the Arduino module’s output pins, d5 or d9. The voltage (amplitude) will not matter (>1 volt). The second input (connected to the unused output pin) receives a digital signal - HIGH or LOW. High means one direction, and low means the other. If the switch is set to digital and the direction input is not used, the motor defaults to running in one direction only.

I think this is my simplest solution, two modes: analog vs digital. This way, I don’t try to fool the controller into thinking one is the other.

Hi @chris101,

Chris, thanks to your very interesting forum topic about this little motor (with much capabilities to become a member of the Littlebits family), I also tried to get this thing working.
I will try to explain what I did until now.
First I purchased the stepper motor and a driver IC called L293D.
The motor is a unipolar type and can be controlled by the L293D without problems, according to many internet discussions.
I had an original Arduino Duemilanove laying around so I woke up this guy and used it in my setup.
In the Arduino IDE software I found a library called Stepper.h which is designed to control the speed and directions and steps of unipolar and bipolar stepper motors.
I used this library in the hardware setup consisting of the stepper motor, the L293D and my old Duemilanove.
It worked and I added the neccessary control connections on two pins of the Duemilanove for the control of the motor:
D7 for the direction (a digital input that can be HIGH or LOW for left and right)
A1 for the speed (an analog input that accepts a value between 0 and 1023. This value is mapped to the driver as 0 to 57, beiing the maximum speed that the little motor could handle.
A higher speed setting made the motor unstable (jittering and stopping).
This analog value represents a voltage between 0 and 5V.
So I could connect a pushbutton to D7 for selecting the direction ( I added the Latch Bit to keep the selection after one push of the button).
And a dimmer on A1 defined the speed between 0 and maximum RPM.
It worked!
Everything connected from the outside world to the motor is in this design based on voltages between 0 and 5 Volt. All pulses, needed for the stepper motor to work, stay inside the combination of the driver and the Duemilanove. So no need to worry about them anymore.
The next step was to connect the Littlebits Arduino W6 to this setup.
I used The D1 digital HIGH/LOW output, connected to the D7 input of the Duemilanove for the selection of the direction.
I used the D5 output as an analog signal , connected to the A1 input of the Duemilanove for the speed control.
This D5 generates a number between 0 and 255, beiing 0 to 5Volt.
It worked also !

I put all these results in a video, showing the stepper motor, controlled by the dimmer and the pushbutton, and by the Littlebits Arduino W6 with a up/down sequence and a random (but programmed!) sequence…

About the power supply:
The documentation says in general that the control power supply should be separated from the motor power supply. At first I did this, but connecting all supplies together (The Littlebits and the Arduinos and the motor all need 5Volt), it worked also.
I checked the Littlebits design docs and they showed that the bitsnaps can handle max. 1 Amp.
The total design (stepper motor, L293D driver and two Arduinos) needs appr. 200 milliamps from the power supply…
So that’s OK too !

See here my little Arduino program files:
The one in the Duemilanove:

The one in the Littlebits Arduino for the up/down sequence:

The one in the Littlebits Arduino for the “random” sequence:

Hello @chris101,
I hope my experiments will help you to solve the existing issues in your today’s stepper motor design.
I am not going to submit a draft stepper motor bit myself to the Bitlab, You have put a lot of energy in it so I think it is 100% your topic.
I could not have done my experiments without your posts and discussions.
By trial and error I found out that using the official Arduino library for stepper motors solves the issues of the (bad) pulses you have in your design until now.
Maybe you can use my information to update your design. Please feel free to do so. I have no possibilities to program an Attiny, I really hope you can take it from here. Again, feel free to use my information from my previous post if you want.
Let me please know your opinion, if you have any additional questions, I will be more than happy to assist.

2 Likes

Hiya @alexpikkert,

I saw your post yesterday, but an entire day of meetings and a brand new faculty member took up my entire day. When I got home, I began to comment, but fell asleep instead! :sleeping:

I know it’s “my” topic, but I have posted everything I have done and discovered, just so that folks like you could follow - and improve - my design.

Which is exactly what you have done with your gadget. It’s very nifty, has nice smooth action and great controllability, but it doesn’t really solve my “bad pulse” problem. Your use of separate speed and direction inputs is what fixes that. (The first stepper motor circuit I made used Arduino’s Stepper library, and we still use that in our Intro to Engineering lab class. I have the students try to perform the same tasks with a stepper motor, a servo motor, and the mouse-trap driven wheel they built in their first experiment.)

I too have decided that a second inout is the only good solution for bad pulses. :wink: That was the theme of my last post.

But the single input, all analog mode is important because it is simple and intuitive. Beginning users of littleBits would be likely to just hook it up in a linear sequence, the way the servo or dc motors are done now. For users who program their Arduino modules, a mode switch would allow the module to accept two inputs the way your’s does. I also want to be sure it degrades nicely: that is, it still acts logically if one of the inputs is missing, or if the switch is in the wrong position.

This addition requires that I use a tiny 84 instead of the 85 I was using, and two more op-amps. I wonder if it is also time to switch driver chips? So a question I’d ask you is: What are the advantages of the L293D over a darlington? I like the Darlington because it can power up to a 24 volt motor using a second power supply, and it will increase the precision by doing half-steps without much programming. (Additionally, I understand the circuit - it’s quite simple. I should read up on the L293, because it’s just a black-box to me.)

Thanks as always for your amazing input to this project, and for your sensitivity about it’s ownership. Be assured that anything I put on a public forum, is there for everyone to use any way they like. If my module was to garner 1000 votes, I would have to outsource the final design anyway. Those littleBits’ docs are intimidating! I’m really making it because I want one, and as practice for my next bit!

Hey, you wanna have some fun? Hook up a Synth kit to one of the wires that connect your motor to its controller. My robots would dig that song!

2 Likes

Hi @chris101,
Thanks for your positive comments!
It is really great to sort things out on this subject. I really like it. You awoke the Gyro Gearloose in me after many years…


There are zillions of diagrams and descriptions on the internet, but many are incomplete or even wrong sometimes.
By searching and trying to understand things I learn quite a lot also.
It is nice to have you as a sparring partner to discuss the stepper motor!.
(My first thought yesterday was that you wanted to stop the project because you changed your data on the Trello board…)
About the driver IC designs:
The NTE2019 Darlington you are using is a typical straight foreward amplifier IC with 8 amplifiers.
The Darlington configuration was invented by Bell Laboratories engineer Sidney Darlington in 1953. He patented the idea of having two transistors on a single chip sharing a collector.

When one input is activated by+5V from a controller IC (arduino) then the corresponding output is pulled to GND. Thus a motor coil connected to it will be activated when the other side of this coil is connected to a VCC line. A unipolar stepper motor has this setup. See this diagram from a ULN2003 which is the same, it only has 7 amplifiers instead of 8:

When a normal DC motor would be connected, there is no way to reverse the direction via this IC.
But because you control the direction via the pulse sequence on the 4 inputs, this plays no role at all when a stepper motor is connected.
This IC can only pull a connection to GND and cannot supply power via its own VCC connection.
The diodes inside are to protect the IC against voltage surges coming from the coils.

Now the L293D:
This IC has a typical H-bridge setup. so it can control 2 normal DC motors in speed and direction. Or one stepper motor:



It also has these amplifiers in the output, so this works the same as the NTE2019.
But it can supply power from its output, so bipolar stepper motors can be energized. It has two VCC connections, one for the (arduino) control, beiing 5V and another for the motor power supply which can be higher when a high power motor is connected.
I connected my unipolar stepper motor to this IC and it works fine when I leave the interconnection between the coils (the red wire) floating (see diagram in the video of my earlier post).
I think I will also buy a ULN2003 just to tinker with it and see what the differences are.
I think in general there is no real difference in controlling a unipolar stepper motor with an NTE2019 or a L293D.
Only when you have a bipolar motor you must use a L293D.
OK, so far so good.

I still have the following question:
I like the idea of only one simple input when used in a Littlebits setup in analog mode. But how to control two parameters, speed and direction?
By pulses from a Synth bit, the frequency controlling the speed and the pulse amplitude controlling the direction (2V left, 5V right)?
A hardware switch on the bit for the direction L/R and/or a potentiometer for the speed setting ? What is your idea?

About the Littlebits design docs:
For me it is impossible to make a bit fully in accordance with these specifications. I think that is also not the intention of the Littlebits Bitlab team.
My soldering iron (and my fingers) are way too large to solder the requested SMD chips. No way.
I think it will be sufficient to design a bit with normal (maybe oldfashioned) components and submit it. They will take care of the full industrialisation I think.
The only things to care about are their standarized input/output impedances and the current load and the max. supply voltage. (My opinion).

PS:
I hooked up my Synth speaker to the L293D and it started speaking like R2D2. Nice!

:smile:

@alexpikkert Hey Alex!

You cover a lot of ground here, so let me take this a step at a time:

[quote=“alexpikkert, post:50, topic:22098”]
Hi @chris101,
Thanks for your positive comments!
It is really great to sort things out on this subject. I really like it. You awoke the Gyro Gearloose in me after many years…
<img src="/uploads/default/2194/90f71d8faef810dc.jpg" width=“80” height=“120”>

…[/quote]

Heh. I do remember Gearloose - I though he was a much better character than Ludwig von Drake, but I have always identified more with Clyde Crashcup:
I really do say things like, “That’s Ard for Ard and uino for Weeno, Arduino.”

All the ‘kids’ here are probably saying “Whaaaa?” Folks normally associate protests, LSD and the Beatles with the 1960s. Those of us who were there know it was the Golden Age of Saturday morning cartoons!


[quote=“alexpikkert, post:50, topic:22098”]

There are zillions of diagrams and descriptions on the internet, but many are incomplete or even wrong sometimes.
By searching and trying to understand things I learn quite a lot also.
It is nice to have you as a sparring partner to discuss the stepper motor!.
(My first thought yesterday was that you wanted to stop the project because you changed your data on the Trello board…)

…[/quote]

I have learned so much chasing this gadget, and it just keeps going! I look forward to your reply every time we interact, as well as the rest of the ‘hardware crew’. You ‘guys’ (you, Ryan, Matthias, Philip, Peter, Jude, Bruce, Syed, et. al.) are my professors in this endeavor.

I took down my Trello stuff out of frustration. I was looking for the best place to post my “breakthrough” idea (having a mode switch on the stepper bit). Trello suddenly felt very isolated, and competitive instead of cooperative and transparent. I will likely continue to explore that system, but in a different manner.

The forum here is set up differently than any other forum I have been involved with, all topics are presented to everyone. Most of the members here are not interested in ‘board-level’ hardware, and so they skip over our posts. But they are available to everyone, and occasionally new people chime in, answer questions, ask more questions, or turn the conversation in unexpected directions. These are invaluable to my creativity. We got none of that at Trello - it seemed to be a scorecard of bit submissions, with little or no incubation of ideas. So I flushed out my Trello. When/(if) I go back there, I’ll do so with completely different expectations.

But stop the project? I usually consider trashing all of it 3 or 4 time a week. I get over that quickly though, and I know this. A lot of my learning is crisis based. :scream:


[quote=“alexpikkert, post:50, topic:22098”]

About the driver IC designs:
The NTE2019 Darlington you are using is a typical straight foreward amplifier IC with 7 amplifiers.
The Darlington configuration was invented by Bell Laboratories engineer Sidney Darlington in 1953. He patented the idea of having two transistors on a single chip sharing a collector.

<img src="/uploads/default/2197/338c6c0d162a5bc5.jpg" width=“400” height=“200”>
When one input is activated by+5V from a controller IC (arduino) then the corresponding output is pulled to GND. Thus a motor coil connected to it will be activated when the other side of this coil is connected to a VCC line. A unipolar stepper motor has this setup. See this diagram from a ULN2003 which is the same:
<img src="/uploads/default/2195/48f381802680a1b4.JPG" width=“400” height=“250”>
When a normal DC motor would be connected, there is no way to reverse the direction via this IC.
But because you control the direction via the pulse sequence on the 4 inputs, this plays no role at all when a stepper motor is connected.
This IC can only pull a connection to GND and cannot supply power via its own VCC connection.
The diodes inside are to protect the IC against voltage surges coming from the coils.

Now the L293D:
This IC has a typical H-bridge setup. so it can control 2 normal DC motors in speed and direction. Or one stepper motor:
<img src="/uploads/default/2196/5aac4fee936b9d18.jpg" width=“300” height=“250”>
<img src="/uploads/default/2198/d09f3a27a346ed84.jpg" width=“154” height=“161”>
<img src="/uploads/default/2199/423323ce0fe291e8.jpg" width=“121” height=“228”>
It also has these amplifiers in the output, so this works the same as the NTE2019.
But it can supply power from its output, so bipolar stepper motors can be energized. It has two VCC connections, one for the (arduino) control, beiing 5V and another for the motor power supply which can be higher when a high power motor is connected.
I connected my unipolar stepper motor to this IC and it works fine when I leave the interconnection between the coils (the red wire) floating (see diagram in the video of my earlier post).
I think I will also buy a ULN2003 just to tinker with it and see what the differences are.
I think in general there is no real difference in controlling a unipolar stepper motor with an NTE2019 or a L293D.
Only when you have a bipolar motor you must use a L293D.
OK, so far so good.

…[/quote]

My folks bought me an electronics lab set in 1962 and of course, it featured the transistor. You remember those, right? With spring connectors for wires and component leads, to make solder-less connections. It was the predecessor of littleBits for our generation. So the Darlington device is something I understand down to the subatomic level - it just makes sense.

The 293 is a bit more esoteric to me, switches and patterns. So I went to Fry’s Electronics today and came across an Arduino motor shield with not one, but two of the H-bridge chips, and in sockets no less!

I especially like that the shield has the two 293 driver chips socketed! That way, I can make a sketch that works on a Uno, un-mount the chips and put them into my bit with the ATTiny, where the sketch will need only minor changes. The shield is this one, I gotta give OSepp kudos on an affordable and very versatile product.

I’m gonna play around with these chips, but I have the feeling that you are correct: the 2 driver chips are more similar than different in their application. I’ll end up using which-ever one is easier and better. Right now it’s the Darlington, but as I learn more about the 293, that could change …


[quote=“alexpikkert, post:50, topic:22098”]

I still have the following question:
I like the idea of only one simple input when used in a Littlebits setup in analog mode. But how to control two parameters, speed and direction?
By pulses from a Synth bit, the frequency controlling the speed and the pulse amplitude controlling the direction (2V left, 5V right)?
A hardware switch on the bit for the direction L/R and/or a potentiometer for the speed setting ? What is your idea?

…[/quote]

I have already submitted my analog controlled bit. I had a single input that controls both speed and direction. The frequency controls the speed (one step per pulse) and the amplitude dictates the direction (1-2 volts = anti-clockwise, greater than 2 volts = clockwise).

I’ve used the Synth oscillator, the pulse bit, a button, and even external pulses generated by a 555 timer. It works perfectly.

I am influenced by @matthiasmwolf’s exploration of his bi-directional motor. The direction switch on the dc motor bit is limiting. Direction is a parameter that should be handled by the circuit, so needing to attend to a switch on the controller board is not a good thing.

On the other hand, the circuit builder will know what the motor bit is being attached to, so I propose a mode switch. One mode for an analog driver as mentioned above. The other mode is if the stepper bit is hooked up to the arduino bit. A single switch with two modes: analog and digital.

But not a hardware direction switch!

The digital mode will use a second input to specify the direction, just like you did in your example with your Duemilanove. (that name sounds so … Romantic! (in the linguistic sense). But I get it: 2009.)


[quote=“alexpikkert, post:50, topic:22098”]

About the Littlebits design docs:
For me it is impossible to make a bit fully in accordance with these specifications. I think that is also not the intention of the Littlebits Bitlab team.
My soldering iron (and my fingers) are way too large to solder the requested SMD chips. No way.
I think it will be sufficient to design a bit with normal (maybe oldfashioned) components and submit it. They will take care of the full industrialisation I think.
The only things to care about are their standarized input/output impedances and the current load and the max. supply voltage. (My opinion).

…[/quote]

From my understanding of the littleBits documentation, the submitted ‘module’ (not a Bit yet!) design can be made any way that works. However if the design gets the 1000 votes, AND passes the littleBits review, the creator of the Bit then has some responsibilities. Reading the FAQ makes it clear that the deliverables to littleBits are of a rather high order. While only a working prototype is necessary for acceptance, a completely engineered design is needed before production can begin.

I have been doing as much as I can do during the initial design, but like you, I have technical limitations when it comes to using the littleBits specified technologies in my prototype.For example, littleBits uses LV321 op-amps, which only come as surface-mount packages. Like you, I can’t solder that! So I use a through-hole op-amp that is rail to (almost) rail. Zero to about 4 volts - it works fine for my applications.

I don’t think it will, but if my bit were to pass muster, I would likely find an engineering partner to attend those details.


A great extension to Robot Music! Rock on.

I’m gonna play with my new chips now. :smiley: :smiley: