3Dlab
Posts: 3
Joined: Fri Mar 22, 2013 10:27 am

Stepper motor problem

Fri Mar 22, 2013 10:46 am

Sorry if this has been discussed, I searched for similar problem but could not find it.

So, I am fairly new to programming and robotics so excuse my ignorance. I got a driver ULN2003 with stepper motor connected just like here:
http://www.scraptopower.co.uk/Raspberry ... spberry-pi
Then I got a stepper.py script I copied from users but still get the same result - driver LED's showing signal coming through but motor is not rotating, instead only VIBRATES (can only sense this when I touch it).
http://www.youtube.com/watch?v=w7-4ly_U ... e=youtu.be

I have everything updated (Gpio, python...) and have two same step motors 28BYJ-48 and both give same result. Py script I am using in video is on of these: http://raspberry-python.blogspot.com/20 ... -step.html but as I said, other scripts give the same result.

What am I doing wrong?

PS1981
Posts: 445
Joined: Wed Dec 12, 2012 4:11 pm

Re: Stepper motor problem

Fri Mar 22, 2013 10:57 am

In this recent post:
http://www.raspberrypi.org/phpBB3/viewt ... 37&t=37870
I feel the discussion appears to have moved towards the same thing you are doing, might be worth a look. Other suggestions: if your timing of the steps is too quick (quicker than the motor can handle) then you will get the problem you describe. If you are supplying 5v, but not enough amps, you will also get that problem.

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: Stepper motor problem

Fri Mar 22, 2013 11:09 am

Daft question, but have you got your stepper leads connected to the right LED / GPIO pins? My turtle motors used to do a right fandango on the desk until I sorted it out.

Power is another concern as previously mentioned - low voltage steppers probably need a good amp to drive them - hence the need for a buffer such as ULN2801 between the GPIO pins and the motors themselves.

The buffers also allow the 3.3V GPIO pins to drive a motors rated for a much higher driver voltage.

Cheers.

Hove

http://www.pistuffing.co.uk
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

3Dlab
Posts: 3
Joined: Fri Mar 22, 2013 10:27 am

Re: Stepper motor problem

Fri Mar 22, 2013 11:27 am

Thanks both for quick replies!

I checked and rechecked connections to GPIO and seems fine (connected as on schematics provided in link in first post). Power might be an issue here, will try to figure it out. Also tried connecting power supply from USB cable directly to driver board and not directly from raspPI but with same result. Still to try is with a power adapter 5V and more amps connected directly to driver board (power adapter connected on raspberryPI now is 5V 1.2A)
If this don't work I'll get a ULN2801.

Meanwhile, anyone had similar issues?

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: Stepper motor problem

Fri Mar 22, 2013 11:38 am

To give a bit more detail, my turtle is driven by a 7.4 V lithum ion battery so it's got enough oomph (potentially 3A may be needed). That's regulated down to 5V with a switching regulator so as not to waste power. This drives both the motors (at high current through the ULN2801) and also feeds into the GPIO pin 2 to power the Pi instead of the micro USB port. The 74HC595 runs on 3.3V from the GPIO pin 1, and it's 8 3.3V outputs are used then to switch the ULN2801 to allow the huge current through the selected motors coils.

Hope that helps

Hove
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Stepper motor problem

Fri Mar 22, 2013 6:36 pm

I am confused, you have a stepper motor that as far as I can see is rated at 12V and you are driving it with 5V. Datasheet I found is here

You do realise the starting current inrush of inductive loads is many times the rated current especially with gearing after the motor. You do have diodes to battery supply on all pins to stop back EMF when the step is complete probably at higher rating thans what is in a ULN280x series chip.

You doi realise that if you need several Amps of current at 12V you need more Amps if you drop the voltage to 5V.

You do realise that the ULN280x series are rated at 500mA (0.5A) on ONE pin driving multiple pins at once means the TOTAL current in the GND pin (sum of the pins 'on') must be less than 1A to 1.5A depending on manufacturer and many other factors.

Without seeing your FULL circuit as a diagram it will be difficult to determine what you are trying to do.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

btidey
Posts: 1623
Joined: Sun Feb 17, 2013 6:51 pm

Re: Stepper motor problem

Fri Mar 22, 2013 7:06 pm

The 28BYJ48 motors come in different voltage ratings. Quite a lot on eBay are 5V and are normally clearly marked as such. Each winding of the 5V model takes about 130mA when driven. At any one time two out of the four coils are on so the currrent drain is about 250mA. This is well within the ULN capabilities. If the ones you have are 12V models then you have to power them from a separate 12V supply. However they have higher coil resistance so they take less current and are still within ULN capabilities.

A single 5V motor is normally OK from the Pi power supply providing there are no heavy duty USB peripherals as well. Two 5V motors might be pushing it if the power is through the normal micro USB connector (with the polyfuse in line). If the power supply was a good 1.2A or above and went via the GPIO pins then 2 motors would be OK.

The stalling / vibration could be either that you do have the 12V model and it is not getting enough power to step or, if you have the 5V model, then that may be caused by the coils not being driven in the correct sequence. Have you checked the pin allocation in the software against how you have connected the coils. If the right pins are defined then you can try swapping the coils around on the outputs

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Stepper motor problem

Fri Mar 22, 2013 7:20 pm

Depending on your Pi system setup 250mA may be borderline for what the PSU can supply to the Pi and USB and anything else.

I would always drive motors from a seperate PSU to ensure less noise gets into controlling sytem, and current surges have no effect on the main system.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

3Dlab
Posts: 3
Joined: Fri Mar 22, 2013 10:27 am

Re: Stepper motor problem

Fri Mar 22, 2013 8:41 pm

Thanks again for your replies.

It works now, thanks to btidey, I checked and changed pin allocations in the software and that fixed it!
btw. motor is 5V so it had enough amps.. I plan to connect more step motors to it but i'll use external power supply for them.

What is the maximum number of this kind of step motors I can hook up to raspberryPi and have each do its own thing?
Did anyone here try to control step motors from Blender? My plan is to hook couple of motors to raspberry and simulate a robot arm that I would control in blender through armatures. I saw couple of examples on internet but seems that here is the place to ask about it.

Thanks again!

Miro

btidey
Posts: 1623
Joined: Sun Feb 17, 2013 6:51 pm

Re: Stepper motor problem

Fri Mar 22, 2013 11:46 pm

Good to hear you got it working.

The number of steppers has a hardware aspect and a software aspect.

Hardware: If you use the 4 pin per motor scheme then you will run out of GPIO pins quite quickly. There are 17 pins you could use so a max of 4 motors and I guess you want some pins for other purposes. If you switch to a 2 pin per motor scheme which needs slightly different wiring then you can obviously double the number of motors for a given number of pins. Beyond that you'd need some sort of port expansion scheme of which there are a number of possibilities.

Software: The processing load for controlling the steps is not that high so shouldn't be a limit but you have to consider the best way of organising it for multiple motors so that you are not wasting too much time. You also have to bear in mind that the step rate might have an additional delay every now and again when linux takes a breather but providing you don't lose steps that doesn't affect the positioning. One method would be to use a central step control that performs stepping synchronously for all the motors each of which has a separate step counter. The step control is scheduled to execute at the step rate and checks the step counter for each motor. It skips over any motors where the step counter is zero otherwise it performs a step and decrements the counter.

A completely different approach, depending on what else you want the Pi to do, is to offload the hardware and software driving of all the motors to a Arduino like processor (example is on the Gertboard) and leave the Pi to do high level management and issue high level step commands as required.

QueenstownFisher
Posts: 1
Joined: Mon Apr 22, 2013 8:17 am

Re: Stepper motor problem

Mon Apr 22, 2013 8:49 am

Hi All,

I have been having a bit of a play with the same stepper motors. Started off running one stepper directly powered from the pi and that works fine. Next I wanted to try running two motors at the same time, however when I try running this (through a vnc connection), I loose my connection and everything seems to die. I guess this is because I am sucking away to many amps from the pi?

Anyway.. I want to try connecting the two motors to the pi while using a separate power supply, which I have tried. When I did this I just connected the 5v straight to the ULN2003 board where it says. but when I run the code I get lots of flashing LEDs but no movement on my motors. I think this is because the ground pin of the Pi isn't attached into the circuit. I tired connecting it to the negative pin of my separate power supply (just because it seemed like a good idea) but that didn't help... and I'm out of ideas. can anyone help?

Thanks
Iain

phennigor
Posts: 11
Joined: Tue Apr 09, 2013 9:56 pm

Re: Stepper motor problem

Wed Apr 24, 2013 10:13 pm

Yes. you need to connect the ground signal (negative) of the Pi, ULN chip, and external power supply all together. If the ULN chip has a common pin with a bunch of internal diodes, that common pin should be connected to your external power supply Positive.

digitalForest
Posts: 7
Joined: Sat Jun 01, 2013 10:19 am

Re: Stepper motor problem

Tue Jul 02, 2013 10:29 pm

Hi,

I had the exact same problem, but found an interesting solution to it: in those simple programs, the time interval is usually 0.5 secs. However, the 28BYJ-48 only makes a fraction of a degree turn per step. Hence, if you decrease the interval to e.g. 0.05 or less, you actually get an observable motion.

hope this helps

dF

Return to “Automation, sensing and robotics”