Help designing "smart home" doll house

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Help designing "smart home" doll house

Post by jonyo »

Hi, so my main goal is to have a working elevator on a dollhouse, controlled with small touchscreen attached to a pi.

I have a Lulzbot stepper motor lying around that I was hoping to put to use for the elevator. Maybe overkill for a dollhouse elevator but I had it already just collecting dust. I already ordered the mechanical parts needed, a v-slot system with belt to raise/lower the elevator, now I'm trying to figure out the electronics part and it is turning out harder than I thought haha..

Anyways, so I need to control the Lulzbot stepper motor. I got them second hand so all I know is what is on the side, which says SY42STH47-1504A. I also stumbled on this link (in these forums from a post a few years back): https://shop.lulzbot.com/nema-17-steppe ... escription - the box UPC number matches what is in that picture. So I think they are rated at 2.8 V and 1.5A.

My idea was to use a pi zero, hooked up with DRV8833 to control the stepper motor. Also wanted to use a touchscreen connected to the pi to control it. And still trying to decide what sensors to use, maybe endstops or distance sensor, to figure out where the elevator is (what level) and when to stop. That is maybe a different discussion but I wanted to mention it here to give a full picture.

So would that setup work? Pi zero hooked up to DRV8833 which is hooked up to my existing stepper motor? And would it allow adding more things over time (maybe voice control, maybe doorbell, that sort of thing)? Like it would not take up pins in a way that would not allow adding that later? Maybe a silly question lol, I'm new to using the IO pins..

If the DRV8833 will work with a pi, what power supply do I need to give the right amount of power for the above stepper motor?

Thanks!

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

I just stumbled on this before, I had not seen the feather products before... It seems like the base project is just what I was thinking of doing:

https://learn.adafruit.com/touch-deck-d ... ontrol-pad

Would that work? If so what are all the parts I need (what driver / hat or whatever, what power supply, etc) on top of that project's parts, to hook it up to the before mentioned nema 17 stepper motor?

To be clear I'm open to any suggestions that would let me control the elevator stepper motor "and more" in the future, with a touchscreen that I can customize the interface for. Just spouting off ideas based on what I could find, but I don't know enough about driving steppers to know for sure, so asking here... Thanks!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help designing "smart home" doll house

Post by adafruit_support_mike »

The touchscreen project should work as an input system for your project. If nothing else, it will get you started.

For the stepper motor, you will need a current limiting driver like the DRV8833. You’ll need at least a 5W power source for the motor, and it’s best to keep the motor power separate from the RasPi’s power. Motors generate lots of voltage spikes that would do bad things to the RasPi.

For starters, just get the motor moving. Once you’re comfortable with that, you can add code to make it stop at specific places, and move from one location to another. Servos have pretty good repeatability when they operate open loop.. just counting steps without getting feedback from sensors.. but you may want to add sensors later. There are lots of options you can play with.

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

Hi Mike,

Thanks! I agree, it would be good just to get the stepper motor working first. And once I have the base hardware I can play with it to see what it is able to do, will know more about what I could add to it maybe.

For the power supply, is this a good option for that stepper rating? https://www.adafruit.com/product/276 I want to make sure I don't burn anything out getting the wrong thing.

I did try reading about how to match the driver to the stepper, but it was confusing when chopper drivers come into play since at that point you can go above the motor's rating and the driver will just cut off supply... It said you could go above the rating but not by how much.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help designing "smart home" doll house

Post by adafruit_support_mike »

jonyo wrote:For the power supply, is this a good option for that stepper rating? https://www.adafruit.com/product/276 I want to make sure I don't burn anything out getting the wrong thing.
That should be a good starting point, but follow it with this:

https://www.adafruit.com/product/4920

Any voltage the motor doesn’t use is lost as heat, and dropping 5V to 2.8V is a big drop, proportionally. The 3.3V step-down converter will turn 1.7V of excess voltage into about 50% more current. The remaining step from 3.3V to 2.8V is more acceptable.
jonyo wrote: did try reading about how to match the driver to the stepper, but it was confusing when chopper drivers come into play
That’s a good summary of the subject. ;-)

Inductors are confusing.. partly because the physics itself is weird, and partly because the vocabulary is a junk drawer of old terms that don’t fit together as well as we might like.

You can imagine a chopper as someone with a switch and an ammeter that measures current flowing into the coil. It throws the switch to connect power to the motor, then watches the ammeter to see how much current goes to the coil moment by moment. If the current stays below the ‘no more than this’ limit, the chopper just waits for the signal that tells it to open the switch. If the current reaches the ‘no more than this’ level, the chopper says “whoa nelly!” and opens the switch immediately.

Crazy thing is, that can be a good choice. The torque generated by the motor is proportional to the current flowing through the coil, so a strong kick at the beginning generates a stronger twist than the same amount of charge moving more slowly.. just the thing you need for quick changes in speed. Letting the current rise gradually can be better for a motor operating under a steady load though.

That level of control is for the seriously determined though, so feel free to ignore it. In simpler terms, a chopper keeps the motor coil from getting too much current.

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

Hi,
The 3.3V step-down converter will turn 1.7V of excess voltage into about 50% more current. The remaining step from 3.3V to 2.8V is more acceptable.
So I would put it between the driver and the stepper motor right? Or would it go between the power supply (motor side) and the driver? The former makes more sense to me but wanted to double check.

Also the driver puts out 1a, but really it's putting out more then cutting it off once it "reaches" 1a right in a given time frame right? So I guess the 1a rating is the average over time. What would get to the step down and the motor is 2a in bursts since that is what the power supply is trying to supply?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help designing "smart home" doll house

Post by adafruit_support_mike »

jonyo wrote:So I would put it between the driver and the stepper motor right? Or would it go between the power supply (motor side) and the driver? The former makes more sense to me but wanted to double check.
Put it between the power supply and the DRV8833.

It takes a while (a few milliseconds) for a swicthing converter to get working properly. It’s much better to PWM its output than its input.
jonyo wrote:Also the driver puts out 1a, but really it's putting out more then cutting it off once it "reaches" 1a right in a given time frame right?
Not exactly.

The basic unit of stuff in electronics is ‘charge’.. usually electrons because they’re easiest to move around. Voltage is the energy that makes charge move, and current is the amount of charge that actually does move.

The unit of charge is the Coulomb.. about 6.25e18 electrons. The unit of electrical energy is the Volt.. 1 Joule of energy per Coulomb of charge. The unit of current is the Ampere, which is figured by counting the flow of electrons through a hypothetical surface. 1 Ampere is a flow rate of 1 Coulomb per second.

Ohm’s Law (V=IR) defines a relationship among voltage, current, and anything that makes it harder for electrons to move. If 1V of applied energy makes charge more at a rate of 1A, the ‘resistance’ to the current is 1Ohm.

The DRV8833’s chopper measures current, an ‘at the moment’ value, which we usually measure as the voltage across a low-value sense resistor. If we say the DRV8833 has a 10mohm sense resistor, 1A of current flowing through it will produce a voltage of 10mV.

The DRV8833’s chopper watches that voltage, and cuts the current off if the sense resistor voltage hits 10mV (or whatever the actual sense resistor voltage is).

It would seem that the peak current should happen at the moment the switch closes, but that isn’t the case because of inductance.

We use the term ‘electromagnetics’ because under general relativity ‘electric’ and ‘magnetic’ are just two different views of the same thing. Every moving charge has a magnetic field around it, and the strength of the magnetic field is proportional to the current: every 1A current has a magnetic field that holds 1 Joule of energy.

The tradeoff between ‘energy as voltage applied to an electron standing still’ and ‘energy in the magnetic field around a moving electron’ is one of the deep concepts in electromagnetic theory. The easy part is that conservation of energy always works: 1 Joule as voltage turns into 1 Joule as magnetic field, and vice versa.

That applies to what you’re doing because the DRV8833’s chopper stops and starts current through the motor coil.

When the chopper connects current to the coil, we have a situation where the electrons are standing still with an external voltage trying to make it move. It takes a little while for the magnetic field to absorb enough energy for the current to flow at the rate it wants, so the current ramps up gradually.

Left to itself, the current might get high enough to damage the motor, and the chopper keeps that from happening.

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

Thanks for the awesome overview! I was not expecting that much of an in-depth reply, I really do appreciate it!

Ok, so I got the first wave of parts. Now I'm following this:

https://learn.adafruit.com/adafruit-drv ... s?view=all

A quick tangent on the guide: The raspberry pi wiring section does not show up in the table of contents. I've looked at that page over and over the last week and just now scrolled far enough to see the pi section, I was trying to infer how to wire it up based on the arduino steps. The guide is awesome but with so much on the same page, it would be helpful if that was included in the TOC on the left side (if possible using whatever software that uses). Or even just a mention in the first arduino section "tip: see the raspberry pi and other sections below for more examples!".

Anyways, so I got it wired and working!!! Using the circuitpy method :) Wellll almost...

So at first, it kind of hummed and sounded scary. I had the "wire groups" for the 2 coils correct from a schematic I found online for my stepper, but I was not sure if the 2 wires for each were correct or reversed. So I tried reversing the 2nd coil wires, that was the one I was most suspicious of. And now (almost) success! It now goes forward and backward! Well sort of, at the default of .01 delay and 200 steps, normal speed seems to work, double has trouble (my guess, maybe not enough amps?), like it will go some, then back then forward, then back, sometimes it would progress some... It seemed like it was missing steps. Interleave seemed to work, it went slower.

I experimented adjusting delay, but anything larger than .01 it misses a lot of steps, just keeps going back and forth in various ways (when it should just be rotating).

I believe from here I need to get PWM outputs working. But also suspect, maybe I need to adjust the amp output on the driver??? Thought I would try PWM first. Are there any docs specific to using PWM on a pi with circuitpython? I've read that you have 2 unique hardware PWM out pins and 2 mirrors, and on the pi "any" io pin can be used as a software PWM.

I tried just setting microsteps to 2 but get this error so I guess there is more, I need to do:
AttributeError: 'DigitalInOut' object has no attribute 'frequency'
tl;dr: looking for docs / guidance on getting PWM working on pi with the `circuitpython-motor` libraries (or any other guidance for the behavior mentioned above). Thanks!

PS: how is everyone holding up with the recent storms? I imagine some of the staff are remote but from the message it sounds like HQ is in New York? I hope everyone is ok!

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

So, I figured out the PWM... Turns out I just needed to change the pin definitions to use:

Code: Select all

pwmio.PWMOut(board.D19),
instead of...

Code: Select all

digitalio.DigitalInOut(board.D19),
Also, had to import pwmio.

But it still did the same thing on double speed. Then I was trying to measure the A across the 3v out and gnd on the buck converter, and for a split second I think I shorted 2 of the pins. After that, now somehow that fixed it? (never did get any A reading, think my multimeter fuse is blown for the A readings)

My guess is the split second short (if there was one) did not do much and it was just the process of poking it, maybe helped make one of the connections more solid or something. It is currently wired up with a breadboard.

This is it:
project2.jpeg
project2.jpeg (757.25 KiB) Viewed 120 times
Anyways just wanted to post a follow up since it seems to be working now. It does still periodically skip or miss steps, I suspect that may just be a non-solid connection somewhere though, but maybe I do need to adjust the driver output...

I'm still figuring out PWM and frequencies and things to control the speed but now I have things initially working. Thanks again for the help!

edit: To be clear, when I was saying maybe it still needs the A adjusted, I'm talking about the DRV8833 output, it comes preset for 1a, peak 1.5, but can be adjusted. And my stepper is rated 1.5a (not sure if that is peak or continuous though). But I'm not doing that unless it becomes clear that it is more than just a shoddy breadboard connection causing it to still miss steps randomly. I was just saying I suspect maybe that needs to be adjusted but wasn't sure. :)

edit 2: Hmm, maybe the rare random missed steps are just artifact of using the pi's software PWM instead of hardware and there is a few MS delay every once in a while...
Last edited by jonyo on Sat Sep 04, 2021 1:15 pm, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Help designing "smart home" doll house

Post by adafruit_support_bill »

Well sort of, at the default of .01 delay and 200 steps, normal speed seems to work, double has trouble (my guess, maybe not enough amps?), like it will go some, then back then forward, then back, sometimes it would progress some... It seemed like it was missing steps. Interleave seemed to work, it went slower.
"DOUBLE" is not double speed. It is called "double" because it energizes both coils at the same time. Usually that gives better performance than the default mode which only energizes one coil. DOUBLE does require twice as much current, so that might be an issue.

I would try omitting the 3.3v regulator and letting the DRV8833 handle the current limiting. The "Rated Voltage" spec for stepper motors is somewhat confusing to many. It is the maximum continuous DC voltage that the windings can handle without overheating. But the voltage is not "DC" while stepping. It is reversing with every other step and at high step-rates, the inductance of the windings will limit the current flow and the strength of the resulting magnetic field.

LulsBot typically drives these same motors with a 12v or 24v power supply and a chopper type driver to limit the current. This gives them good performance at high step rates. Using the DRV8833 with your 5v supply, you should still get reasonable performance at moderate speeds.

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

LulsBot typically drives these same motors with a 12v or 24v power supply and a chopper type driver to limit the current. This gives them good performance at high step rates. Using the DRV8833 with your 5v supply, you should still get reasonable performance at moderate speeds.
Ah good to know, I was so focussed earlier on trying to figure out the specs on the stepper, I didn't think of just looking at how lulzbot powers it...

It is now working great using micro steps set to 2, and I removed the 3.3v converter like you suggested, it seems to run fine. Since this is a "barbie elevator", it doesn't need to go too fast or have that much torque, just enough to lift some dolls and maybe their "shopping bags" lol... And I don't imagine it needing to run continuously for any length of time. I was originally going to use them to "electric brake" by engaging the stepper to keep it at a level, so maybe that would have started heating up the motors. But now I'm thinking of making a mechanical brake, like maybe a peg that retracts with electro magnet that stops it from going down once it gets to a level. But I digress...

What you said about how lulzbot powers it got me thinking, I have 5 more of these steppers sitting here just waiting for a project that might need steppers. A friend had them for some reason and was going to throw them out so I took them :).

Just for future reference, if/when I want to drive another one... Think I would be better off using TB6612 with something like a 12v 2a power supply? I already have a few of those in my "random power brick" drawer... Or if I'm using a pi again, just go with the motor hat plus 12v 2a brick, just to make things easier? I won't do it for this project since it is 90% there, but thinking maybe we don't need to keep the volts down like I thought after looking at the specs... From what you said it sounds like it would allow more torque and/or faster speeds with a higher voltage.
Last edited by jonyo on Sat Sep 04, 2021 1:59 pm, edited 3 times in total.

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

Oh by the way, if anyone stumbles on this thread, one of my takeaways: don't cheap out on breadboards! These cheapo ones I got online (not from this site) sometimes have the worst connections. When I first wired it up nothing was working, turned out even though the barrel jack seemed fully seated, it was not a good connection, when I pressed down on it more things lit up and started working. Then later after poking and prodding wires the issues I was having just went away... Live and learn I guess :)

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Help designing "smart home" doll house

Post by adafruit_support_bill »

I was originally going to use them to "electric brake" by engaging the stepper to keep it at a level, so maybe that would have started heating up the motors.
The DRV8833 will keep them from overheating, but they will still get pretty hot. You probably don't need full holding torque for your current application. What you can do is use PWM on the control pins with a reduced duty-cycle to give you some holding torque, but with less heating.
Think I would be better off using TB6612 with something like a 12v 2a power supply?
That will not work because the TB6612 is not a 'chopper' driver so it will not limit the current. 12v into 2.8 ohms will try to pull more than 4A, so you would be overloading the motor, driver and power supply all at once. My guess is that the TB6612 would be the first of those to go up in smoke.

For a wider range of current-limiting stepper drivers, I'd check out www.pololu.com.

User avatar
jonyo
 
Posts: 36
Joined: Thu Oct 15, 2020 6:12 pm

Re: Help designing "smart home" doll house

Post by jonyo »

What you can do is use PWM on the control pins with a reduced duty-cycle to give you some holding torque, but with less heating.
Yeah but would that be good for extended periods? Since it will be used by kids, I could see it getting moved to the second floor and left there for a week. Even without the heat it seems like that would add up on the electricity. So I was thinking of some kind of physical doodad that would hold the elevator up even if it was powered down, it would pop out to hold the elevator at that level..

But now I thought of a flaw though... If they don't retract properly when going down it would cause issues. it might be better to just do like you said to hold it with the motor, then turn the motors off after 5 minutes and let it coast to the first floor.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Help designing "smart home" doll house

Post by adafruit_support_bill »

You can experiment with the PWM duty cycle to find the minimum level that will hold the elevator in place. Your idea of adding a timer in the code is a good one also.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”