enesbcs / rpieasy

Easy MultiSensor device based on Raspberry PI
GNU General Public License v3.0
157 stars 33 forks source link

Feature Request - 28BYJ-48 Stepper Motor #58

Closed happytm closed 5 years ago

happytm commented 5 years ago

I have been working on Pan/Tilt platform for my Sony camcorder using PI and following inexpensive motors.There will be 2 motors for pan and tilt.

https://www.ebay.com/itm/ULN2003-28BYJ-48-5V-Step-Motor-Gear-Stepper-Motor-4-Phase-Step-Motor-for-arduino/372633711963?hash=item56c2b3355b:m:m54JzxcGoAzTjBQwmzYBy6Q

I found couple of people on youtube who are using these motors with python code.

https://www.youtube.com/watch?v=Dc16mKFA7Fo

https://www.youtube.com/watch?v=zuiYdYUgyXk Python Code : https://github.com/Basch3000/raspberry-pi-projects

Is it possible to make plugin for rthese motors ?

Thanks happytm

enesbcs commented 5 years ago

Hi, Yes i think it is absolutely possible, i just have ordered it for testing. The python code seems good, do you have any ideas about the necessary (Rules) command semantics? Such as "motor,[motorname],[direction],[degree]"

happytm commented 5 years ago

I think it would be better if we use command structure like below:

Following video explains different modes in detail to adjust torque at the end of video. I think full stepping is the highest torque according to this video:

https://www.youtube.com/watch?v=B86nqDRskVU

by the way I came across this video just today which shows another use of this motor with a hardware hack to use other type of stepper driver but I think this motor is powerful enough to use it as it is without hack to run on pan/tilt platform :

https://www.youtube.com/watch?v=1O_1gUFumQM

Another usage:

https://www.youtube.com/watch?v=srDDkkhh3NE

Yet another use:

https://www.youtube.com/watch?v=0TNBxt5hF-g https://www.youtube.com/watch?v=3VTcL2hMDdA

Using rotary encoder: https://www.youtube.com/watch?v=e5p7wGEC0Xc&t=722s

Thanks

enesbcs commented 5 years ago

I'm currently playing with this stepper motor, but as i read at many places (and experienced that) "Steppers don't have a home position". So this will be a little tricky, if not impossible. I can try to maintain the relative position, but the home position might be the one that seems 0 at the program startup. As i see, i can make commands like i wrote before: set position to a specific angle/direction (can be made some alias like N, S, W, E...) and speed of motion. Continous slow loop between two position is also seems an achievable goal.

enesbcs commented 5 years ago

Support added in commit https://github.com/enesbcs/rpieasy/commit/f96254db0554a803df1949f2400d39882e4bcee4

Commands: motor,"taskname",pos,"angle" - Set the motor named "taskname" to "angle" (0-360) position from a fixed ZERO position, angle can be number between 0-360 or HOME,LAST,N,E,S,W

motor,"taskname",setzero - Set the current position of the motor as ZERO

motor,"taskname",left,"angle" - Rotate the motor named "taskname" with "angle" (0-360) from current position - Anti-clockwise

motor,"taskname",right,"angle" - Rotate the motor named "taskname" with "angle" (0-360) from current position - Clockwise

motor,"taskname",pan,"startangle","stopangle","delay","speed"

motor,"taskname",off - Sets the motor off - pull all 4 gpio to low (otherwise it consumes energy while standing)also stops panning immediately but relative position can be messed if used, use panstop instead

motor,"taskname",panstop - Sets the motor stop panning after finishing it's current move

enesbcs commented 5 years ago

Issue is closed, please feel free to reopen in case of related bugs.

happytm commented 5 years ago

I tested all the command available and it works fine. For pan motor movements the position of motor shaft has to be pointing down for right clockwise and anticlockwise moves to work properly.

It will be useful to add following 2 commands to conserve power if it is possible:

motor,all,off motor,all,stop

Thanks.

enesbcs commented 5 years ago

The simple off and panstop commands is not enough? You mean "motor,all" as a command that scans through every enabled Stepper plugin and executes the off or panstop command each of them? Otherwise If needed i can modify the stepper motor to accept floats... :)

happytm commented 5 years ago

When I think about it for solar tracker or camera pan/tilt there are only 2 motors so in rules all I have to do is issue off command for each motor separately so that will be enough.

Thanks

enesbcs commented 5 years ago

After today commit https://github.com/enesbcs/rpieasy/commit/154d6f3bb9dd7848ad8c1b96b1626a7a32575062 the "angle" parameter can be float and motor,all,off and motor,all,panstop commands works on all enabled stepper motors at the same time.

happytm commented 5 years ago

Thank you for float value.Also both new commands works as expected.It will save some lines in rules code.

Thanks again