I am building a machine that swings a 4' aluminum rod with 24 LED's embedded.
I am attempting to make something similar to a POV display by lighting the LED's at the right moments as it swipes back and forth.
I am using a mid size stepper motor with the Accelstepper library.
Here is an image the should help explain what I am trying to do.
I have everything working pretty well!
The only thing I am having trouble with is getting the thing to swing consistently.
Any pendulum swings at a specific rate and trying to move it faster or slower is fighting its kinetic motion and uses much more energy then my motor can handle.
I can move around numbers in accelstepper including the acceleration and the max speed of the stepper to try to get it closer to the resonant frequency of the swing but I was wondering if anyone had any suggestions about how to get closer to the natural frequency of the swinging beam.
I am unable to get the beam to swing all the way up to 0° or 180° SO I assume that it is skipping steps. It also does not hit the same angle on every swing, fluctuating between higher and lower angles.
Let me know if this does not make any sense and if you have any suggestions on what I should do.
Persistence of vision relies on a relatively high refresh frequency. Is your stepper motor capable of moving fast enough to produce a display frequency sufficient for persistence of vision effects to occur? How big is this device, and what sort of frequency are you aiming for?
Well this is not exactly a persistance of vision but similar,
I am using Glow in the Dark paint on the wall behind the LED strip.
As the strip passes over the painted wall, it illuminates it and that is what Holds the image.
The retention time of glow in the dark paint is longer then our eyes so the frequency does not have to be as quick as other POV type displays.
Each angle/step on the stepper motor is calculated as it moves, it then is able to reference an array of numbers and turn on or off certain lights at every angle.
It is not the light + motor connection that I am having trouble with. I am having more trouble mechanically, getting the timing of the motor and the timing of the natural swing to correspond.
Just thinking: In current mechanical setup small angular error of the stepper would produce big position error, proportionally to the radius. Probably, you need to implement position sensors on the outer (external to ring) side, optical or magnetic. Than "feed" data to the stepper depends on current position, like in a clock, where pendulum is in free motion, and anchor just "supply" portion of energy at right moment
harveymoon:
It is not the light + motor connection that I am having trouble with. I am having more trouble mechanically, getting the timing of the motor and the timing of the natural swing to correspond.
Can your stepper motor move fast enough to match the natural movement of the pendulum at the bottom of the swing? If so, I don't see anything stopping you from calculating the speed of the pendulum versus time while it is swinging freely. I don't suppose it's going to make any difference whether you get the speed exactly right, is it?
Why don't you add a counterweight to move the center of gravity to the axle? Then you would only have to deal with momentum which gives much simpler equations.
PeterH:
Can your stepper motor move fast enough to match the natural movement of the pendulum at the bottom of the swing? If so, I don't see anything stopping you from calculating the speed of the pendulum versus time while it is swinging freely. I don't suppose it's going to make any difference whether you get the speed exactly right, is it?
The stepper moves fast enough, but it is an issue of Phase!
It is very important that the speed and acceleration are in tune with normal swing of the beam or they will mess each other up.
It may be hard to imagine, but there is only one frequency that will move the beam with little effort. getting slightly off of that sequence is moving against the natural swing frequency of the beam and a lot of energy is lost.
I had an idea just now, to add an LED to the Arduino to flash at the exact moment it thinks it is at the peak (calculated 0° and 180° steps). Film the entire swing to see how close the perceived LED flash is to the swing peak.
Going frame by frame, If the beam reaches the top of its swing before the LED flashes, then the stepper sequence needs to be quickened. if it flashes during the swings rise, then the stepper is behind in its movement.
how does this sound? good idea? bad idea? can't hurt much to try?
adding a counterweight even a very small one makes dramatic changes to the code. everything about the swing changes when just a little weight is added.
Stepper motor is really going to be fighting the natural swing all the way I fear as you have massive moment of inertia in that long arm. I can't see an easy way to measure the torque and provide feedback to the driver.
A non-stepping gearmotor (with encoder?) might fare a lot better and be much easier to drive - provide torque till it stalls then reverse the drive... You know you are always putting energy into the arm (with a stepper you have to be just a fraction ahead or risk mistepping). You might get away just measuring the current to determine "stalling".
Even simpler: balance the arm with a counter-weight and just rotate it continuously.
MarkT:
Stepper motor is really going to be fighting the natural swing all the way I fear as you have massive moment of inertia in that long arm. I can't see an easy way to measure the torque and provide feedback to the driver.
A non-stepping gearmotor (with encoder?) might fare a lot better and be much easier to drive - provide torque till it stalls then reverse the drive... You know you are always putting energy into the arm (with a stepper you have to be just a fraction ahead or risk mistepping). You might get away just measuring the current to determine "stalling".
Even simpler: balance the arm with a counter-weight and just rotate it continuously.
You are right!
using a simple motor with an onboard encoder would be much better.
I was considering putting a potentiometer into the mix. But I am away from my shop and time is extremely short.
I would much rather rotate it continuously! that would be much cooler. but it is an LED strip and there is no easy way to spin 11 wires continuously!
I think I am going to try to give it a push, closer to a pushing someone on a swing situation.
I won't know exactly where it is at all times, but at least I can make sure its consistant movement.
harveymoon:
It may be hard to imagine, but there is only one frequency that will move the beam with little effort. getting slightly off of that sequence is moving against the natural swing frequency of the beam and a lot of energy is lost.
Not hard to imagine at all - but the questions is, does this matter (and why)?
Do you want a pendulum that looks as if it is swinging freely? If so, the stepper-motor approach should look convincing as long as you calculate the timing reasonably well - and that calculation isn't hard to do.
The stepper motor solution can get as close as you want to the natural frequency of the pendulum but will never be perfect. If you really want it to be free swinging then you could couple the stepper motor to the arm with a spring so that the arm isn't forced to follow the stepper motor exactly. As long as the spring is stiff enough to add enough momentum over the whole swing to overcome losses in the system, it would keep going. If this was going to be a clock etc, you would replace the stepper motor with something that just gave the arm a slight kick at the end of its travel. That would be more energy efficient, but probably harder to design and build. The 'brute force' stepper motor approach seems easier to get working.
Well this is in the direction of my point. It is very much easier to build and design if you do NOT use a stepper motor. Just a coil and some magnet. Just give a small tick at each swing. That's the way clocks work.
I know now that it could be a better solution with simpler components. but I am very short on time. I have one week to finish this project.
I am considering finding a DC motor somewhere to try a time delay pulse instead of using a stepper at all.
I had it working very well! as you can see in this video it does exactly what I wanted!! :
Unfortunately, i have been unable to repeat these results!
now the motor will not even move the beam a few inches, I have spent all day trying to figure it out and am only frustrating myself.
The stepper seems to just skip steps every time barely doing anything.
I replaced every part that could have been a problem, the motor, stepper driver, power supply have all been swapped and there is no change!
I am really not sure what to do!
Any Help?
[edit]After thinking for a bit, I think I am going to try to add a counterweight as Udo Klein suggested, I can then reduce the force on the motor significantly and hopefully get it to move easier.[/edit]
If it was working before then either you've got a hardware failure, or you've changed something. What changed? If you don't know, this is a clue that you need to have a journal and have your sketch source code under change control.
Does your stepper motor actually work? To make sure, you probably want to remove the arm. If you asked the stepper motor to generate more torque than it's capable of then it will slip and you'll get erratic movement.
The stepper works.
I take the arm off with set screws and the motor runs as it should.
Once the arm is re-attached, it skips almost every step.
it seems like it has less and less torque. Not sure its difficult to measure with just my fingers holding the motor shaft.
Regardless, everything that could have been the problem as been replaced and no change.
I don't think there was any change to the software before my problems arrose, but I wen't through my versions of code with no success. I am really baffled!
I tried an alternate and desperate approach.
I bought a $20 battery powered DC drill from the hardware store and some relays to switch the polarity.
I coded it so that it would accelerate back and forth. The gearing in the drill head adds a huge amount of friction so I cannot release the motor like is possible with steppers. There is no easy way of just Push-and-Glide as I would have liked. (a clutch like on a bicycle would be great right about now.)
This solution ended up being much more finicky. Since the motor can't know where it is it always ends up in a different place.
I am considering a mechanical solution where the motor is attached to a cam or something, and hits the side of the beam at the right interval. then all I would need to do is get the motor to spin at a slow enough revolution so that it hits the arm at the right time.
the problem now is that I can't seem to get the cheap drill motor to move slow enough!
Reducing the voltage too much just locks up the motor and it won't move at all.
I am leaving tomorrow and cannot believe that I have come so far only to fail at making a pendulum swing!
any last minute suggestions before I throw in the towel?
harveymoon:
The stepper works.
I take the arm off with set screws and the motor runs as it should.
Once the arm is re-attached, it skips almost every step.
it seems like it has less and less torque. Not sure its difficult to measure with just my fingers holding the motor shaft.
Regardless, everything that could have been the problem as been replaced and no change.
I don't think there was any change to the software before my problems arrose, but I wen't through my versions of code with no success. I am really baffled!
Either the stepper motor or the circuit driving it has failed, or the mechanical characteristics of the arm have changed so that the stepper is being required to apply more torque, or the sketch has changed so that it is driving the stepper motor faster than before.
If it was me, I'd write a simple sketch that very slowly turned the stepper motor through a few revolutions. At each step, confirm that the stepper motor is stepping firmly to the new position and then held there. If you had blown one of the driver circuits then the stepper motor would be very weak in some positions.
If that works, write a sketch that moves the stepper motor slowly far enough for your arm to complete one swing. Attach the arm. Is the stepper motor strong enough to actually move the arm and hold it in position for each step? I don't know anything about your arm or stepper motor, but it's conceivable that the motor is too weak and simply relied on the arm naturally swinging at about the right speed. In that case, any simple change such as moving weight, adding wires, extra friction in a bearing, could change the system enough to stop the arm swinging at the expected frequency. That would cause the stepper motor to slip, with the consequences you describe.
I was super short on time so I ended up using a microwave AC motor and separating it entirely from the arduino.
A microswitch (also from the microwave) clicks once a revolution and triggers the light strip to start iterating angles.
Not as controlled as the previous ideas, but a simpler solution is sometimes better.
It does not have the 0° to 180° range or the speed of the stepper technique but for my project, it may be a better solution.
Thanks for all of your comments, it really helped in this project!