martinmmps
Posts: 44
Joined: Fri Apr 29, 2016 5:47 pm

Motors - What Type, How to use?

Sat May 04, 2019 7:34 am

I have 2 motors. Each one has 2 bunches of cables. In each bunch of cables there is a Black, Red, and White wire. Anybody seen these before? The Red wire is in the middle. Which cable do i power via the pins or is there not enough power to do them. When using the RPi.GPIO module, if i power the pins that the motors are plugged into, the pi crashes. Any Ideas or hints on what type of motors these may be?

Thanks!
Ubuntu users are apt to get this joke

scotty101
Posts: 3562
Joined: Fri Jun 08, 2012 6:03 pm

Re: Motors - What Type, How to use?

Sat May 04, 2019 7:42 am

Could be almost anything and we'd only be guessing without seeing a picture of the motor or knowing whether there is any text on the motor.

3 wires may mean a servo motor but could also be other things.

If the Pi is 'crashing' it means that the mysterious motor is drawing to much power and causing the Pi to reset. Don't connect it again until you are sure that this type of motor is safe for the Pi.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

martinmmps
Posts: 44
Joined: Fri Apr 29, 2016 5:47 pm

Re: Motors - What Type, How to use?

Sun May 05, 2019 7:14 am

After taking apart some bits and bobs i have found the motor online: https://www.parallax.com/product/900-00025
Is there a tutorial for these types of motors?
I have found a helpful grid on some documentation (https://www.parallax.com/sites/default/ ... e-v1.1.pdf):
Look at the top of Page 2
Ubuntu users are apt to get this joke

MarkR
Posts: 152
Joined: Fri Jan 25, 2013 1:55 pm

Re: Motors - What Type, How to use?

Sun May 05, 2019 2:28 pm

Right, these are continuous servos. Continuous servos are great because they don't need a separate motor control board, the electronics is built-in.

The red and black wires connect the power (positive and negative respectively). Do not connect this through the Pi gpio header, but instead connect it directly to your power source (e.g. connect a power bank to a terminal block). The black wire (negative) must be connect to the same negative rail as the Raspberry Pi.

The white wire is the servo pulses wire. You can connect this to any GPIO pin on the Pi.

I've used these quite successfully with pigpio.

Set up the pigpio according to the instructions, then you can send servo pulses of between 1000 and 2000 microseconds, e.g. using the "pigs" command

pigs s 24 1800

Where 24 is the gpio number.

Normally, 2000 microseconds gives full speed forwards, 1000 full reverse, and 1500 (or somewhere in approximately the middle) is "stop" position. The motors will also stop if you turn the pulses off completely, but after a short delay (typically 100ms).

The downside of continuous servos is that it's often difficult to control them precisely, the neutral point is not usually (in my experience) at exactly 1500us, and two servos from the same batch will still behave slightly differently. This makes steering tank-steering robots with them somewhat error prone.

martinmmps
Posts: 44
Joined: Fri Apr 29, 2016 5:47 pm

Re: Motors - What Type, How to use?

Mon May 06, 2019 11:15 am

Right,
I've got the motors to spin. My setup is as follows:
  • The white wires of the motors are connected to Pin 38 & 40 (GPIO 20 & 21).
  • The motors are drawing power from my laptop USB.
  • The USB cable I have soldered headers to the Red and Black wires and are powering the motors without problem.
The install process worked with pigpio and all the checks passed. When i run the command:

Code: Select all

pigs s 40 1800
I get this error:

Code: Select all

socket connect failed
The same happens with sudo.
Am i meant to use the pin number (e.g. Pin 38 or 40) or the GPIO number (e.g. GPIO 20 & 21)?
Both numbers have the same outcome.

What does:
MarkR wrote:
Sun May 05, 2019 2:28 pm
The red and black wires connect the power (positive and negative respectively). Do not connect this through the Pi gpio header, but instead connect it directly to your power source (e.g. connect a power bank to a terminal block). The black wire (negative) must be connect to the same negative rail as the Raspberry Pi.
Mean?
Ubuntu users are apt to get this joke

pootle
Posts: 317
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: Motors - What Type, How to use?

Mon May 06, 2019 11:41 am

Have you started the pigpio daemon?

Code: Select all

sudo pigpiod

MarkR
Posts: 152
Joined: Fri Jan 25, 2013 1:55 pm

Re: Motors - What Type, How to use?

Tue May 07, 2019 5:41 pm

"The black wire (negative) must be connect to the same negative rail as the Raspberry Pi."

I said that, because you can run the motors from a separate power supply from the Pi, but they need to be referenced to the same "ground" level.

Two batteries which are not connected in any way, are just "floating" relative to each other with no particular voltage between them, and circuits can't interact (unless you use a special component such as an opto-coupler or relay) as they don't have a common reference voltage. There is no return path even for the small amount of current needed to send signals.

In most cases, this means you need to connect the GND or negative terminals together somewhere in the circuit - it really doesn't matter where, because hopefully very little current will flow back through this path.

If, for example, you put two power banks in your robot, and use one to drive the pi and the other for the motors, it won't work unless the negative is connected together.

Also, yes, pootle is correct, you need to run the pigpiod process.

martinmmps
Posts: 44
Joined: Fri Apr 29, 2016 5:47 pm

Re: Motors - What Type, How to use?

Wed May 29, 2019 6:10 pm

I have finally got everything to work. It took a while as i needed some more solder but after fixing the grounds and calibrating the motors, i made a python script to run everything with pigpio (http://abyz.me.uk/rpi/pigpio/python.htm ... pulsewidth). Now i am working on a Apache Server.

Thanks! :D :D :D
Ubuntu users are apt to get this joke

Return to “Automation, sensing and robotics”