Yet another new Bit ... (stepper motor)

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:

ps, the 2019 Darlington Array has 8 amplifiers, so it will run two steppers. The 2003/2004 have 7 amps. Like when you go to a Korean restaurant with three people and they have 8 Kalbi ribs on the appetizer plate. … Really? :expressionless:

1 Like

Ho @chris101,

I will keep following your progress, if I have additional info I will post it.
I found an extreme detailed source of information about all this at Adafruit


When I can find the time to do so, I will build my stepper motor driver on a perf board and publish a project with it, just for fun.
ps
I also think the best way to use Trello board is as a scorecard only and keep the discussions in the Littlebits forum, for the reasons you mentioned.

1 Like

Hi @chris101,
Additional info:
I made an Arduino sketch to control the little stepper motor completely with only ONE input!
Connect a dimmer bit to analog input A2 and you can control speed and direction.
When the speed is zero, then the direction changes. Huh?
This sketch could very easy be loaded into your ATtiny chip.
(I have seen you have 4 outputs for the motor and only one input for control).
Sketch:


Video:

:smile:

3 Likes

That’s pretty awsome Alex, (@alexpikkert)

It would make a great analog of the “swing” mode of the servo bit. You have used the littleBits’ design concept of “immediate control [over[ complete control” very nicely with this design.

Some of my project ideas need more control though, so I determined that I will need a second input when under digital control, so I switched over to a Tiny 84 with ten* IO pins. I hope to have some show & tell in a day or two.

2 Likes

… Teaser:

I’m done designing and building the stepper module for now. It performs as specified in this post, above (with a single input analog mode, and a dual input ‘arduino’ mode). The motor runs flat out at slightly less than 12 RPM, with plenty of torque at 5 volts. The design allows a motor input voltage of up to 36 volts. This means that motors much bigger than the diminutive 28byj48 can be used. However, this one runs at 5 volts, which is supplied through the input bitSnap connector(s).

I’ll post an awesome project using this module soon!

2 Likes

:bow: Hi @chris101,

Great teaser diagram! I think a new bit is born ! Mr. Stepper.
After careful studying your drawing:
Maybe it is safer to put blocking diodes in the VDD line and in the VCC line in the area of the jumper. (to avoid that someone can put 36 Volt on VDD and keeps the jumper in so our poor Littlebits will be fried). Using a diode in each line (VDD and VCC) will protect against this unwanted interference.
To be able to connect a VDD power source, I think you also need a GND connection.

What is the function of the “OUT” connection on d8?

Do I read your diagram correctly?
Analog control:
When da5 is low, pulses on sig are going to da6 via opamp 2.
frequency determines speed, amplitude determines direction.
Aux is not important here. when left floating it is pulled to HIGH

Digital control:
When da5 is high, pulses on sig are going to da4 via opamp3
frequency determines speed.
and aux is high or low, determining direction via opamp1 to da7.
If aux is left open, it is pulled to high.

Great work!

1 Like

@chris101 This image is so pretty. I love how you color coded the diagram wires. That’s really handy for when you need to return to your design after clearing your head for a few days. :slight_smile: Plus, you get extra style points for that breadboarded micro-switch!

@Arjun, check out this pic! :arrow_up:

1 Like

Your analysis of the circuit is correct @alexpikkert. Op-amp 3 is set up so the pulses are fixed - they have sharp leading and falling edges - anything greater than 1 volt is output at 4 volts, less than 1v, stays at zero. (That is the reason for the 1 volt divider you see on the minus input.)

Op-amps 1&2 are normal followers - they are there to get the impedance right and isolate the circuit. The LM324 amps go down to ground just fine, but only go up to 4 volts (that’s what the oscilloscope says - although I measured it at 3.9 volts with a littleBits circuit.) Either way it’s fine, since it is read as a HIGH signal.


I also thought about diodes for the power into the motor. I didn’t do it because the diodes I have (1N4001, '04, '07, 1N914 and 1N4148) all drop the voltage by almost a volt. With the diode in, the little 28byj48 motor had a hard time running on 4.05 volts. The speed dropped a lot, and it stalled often. So, for now, I won’t use anything except 5 volts without a diode, and I will probably leave it that way. As a “Bit”, I think it is more in line with the rest of the system, operating at 5 volts anyway. (It’s nice to know that the design is amiable to higher voltage motors though.)


As for the output connection …

So far, it doesn’t do anything. The standard is to just pass the pulses from the main input through, but I’d like to be a bit more creative with it. Perhaps it could indicate the position of the motor, relative to it’s position at the start of operation. Pin 8 says it’s pwm, so I.m thinking about outputting a voltage that is proportional to the angle of rotation. (adding/subtracting according to the direction.) But the motor is more granular than is the Tiny’s output precision (1024 steps per revolution, vs 256 discrete output values.) So far, I haven’t used the module as anything except the terminal Bit, so this hasn’t come up yet …

By the way, I have been playing with the timing of the coil energizing today, and have the speed up to 14 rpm! And I think I may be able to squeak a little more too. It seems that if I optimize for highest speed, the reliability at very low speeds suffers. I don’t fully understand why.


Hold on to your horses!

Thanks again for your interest and very valuable assistance with this project Alex! I will try to post a fun project later tonight* or tomorrow using the stepper bit!

  • EDIT: it’ll have to be tomorrow or so, I discovered that I need a vital part, and the stores are all closed.

1 Like

Thanks Jude! I almost like the wiring diagram as much as the actual circuit, although the diagram does not move. :wink:

You’re right that a clear, annotated picture helps me understand what I was thinking. I also wanted this to be a project for anyone else who wanted to build one for themselves. In the unlikely event that this would get all the way through the bltlab process, it would still be a very long wait until it was available.

I originally had a bigger switch, but it was SPDT, and I really needed a DPDT. When I saw the little switch at the parts store, I got it only to discover the ‘feet’ were WAY too close together to plug in, so I made an extender board for it. And that made it possible to stack components. Here’s what is going on under the switch:

2 Likes

Hi Chris @chris101,
There are diodes with a voltage drop much lower than the ones you mentioned, Schottky diodes. (WOW, 0.2 Volt !)
See:
http://www.radio-electronics.com/info/data/semicond/schottky_diode/power-rectifier.php

2 Likes

I have just posted a project made with the ‘completed’ stepper bit:

World Time Clock!

2 Likes