How to control two dc motors on an old mobile robot?

Thread Starter

TheRoBoTBiLL

Joined May 26, 2020
16
Hello!

I have an old construction mobile robot, wherein this robot the main controller has been removed, and I put in its place a Raspberry pi 4.
I found this here, and I want to know how to control the motor wheels using Python.

The old mobile robot has two motor drives on it, each of which leaves 3 twisted cables (black, red, and white). How can I connect them to the Raspberry so that nothing is damaged?

If you wish, I can upload photos from the motor drives.

Thanks in advance!
 

Papabravo

Joined Feb 24, 2006
21,159
I think we need to establish what kind of motors we are talking about and what kind of drive electronics remain. AFAIK an Rpi4 running Python cannot do much without some kind of controller and drive electronics.
 

Papabravo

Joined Feb 24, 2006
21,159
That is a start. If we have DC motors and motor drive boards with four(4) TO-220 packages each, I'm guessing that is a Bridge Driver for the DC-motor. That allows for forward, reverse, and stop. A schematic of those drive boards would be helpful, can you reverse engineer one for us?

There is a 28-pin chip which could be a microprocessor or a PAL (Programmed Array Logic) device and a 20-pin device which could be a driver for the power transistors in the four(4) TO-220 packages.
 

Thread Starter

TheRoBoTBiLL

Joined May 26, 2020
16
Hello!

Unfortunately, the circuit has no schematic; it is pretty old, at least 15 years old.
But, I found this py code, from here https://abyz.me.uk/rpi/pigpio/examples.html :
Python:
#!/usr/bin/env python

# servo_demo.py
# 2016-10-07
# Public Domain

# servo_demo.py          # Send servo pulses to GPIO 4.
# servo_demo.py 23 24 25 # Send servo pulses to GPIO 23, 24, 25.

import sys
import time
import random
import pigpio

NUM_GPIO=32

MIN_WIDTH=1000
MAX_WIDTH=2000

step = [0]*NUM_GPIO
width = [0]*NUM_GPIO
used = [False]*NUM_GPIO

pi = pigpio.pi()

if not pi.connected:
   exit()

if len(sys.argv) == 1:
   G = [4]
else:
   G = []
   for a in sys.argv[1:]:
      G.append(int(a))
 
for g in G:
   used[g] = True
   step[g] = random.randrange(5, 25)
   if step[g] % 2 == 0:
      step[g] = -step[g]
   width[g] = random.randrange(MIN_WIDTH, MAX_WIDTH+1)

print("Sending servos pulses to GPIO {}, control C to stop.".
   format(' '.join(str(g) for g in G)))

while True:

   try:

      for g in G:

         pi.set_servo_pulsewidth(g, width[g])

         # print(g, width[g])

         width[g] += step[g]

         if width[g]<MIN_WIDTH or width[g]>MAX_WIDTH:
            step[g] = -step[g]
            width[g] += step[g]

      time.sleep(0.1)

   except KeyboardInterrupt:
      break

print("\nTidying up")

for g in G:
   pi.set_servo_pulsewidth(g, 0)

pi.stop()
 

Papabravo

Joined Feb 24, 2006
21,159
The code is worse than useless if you have no way to talk to the electronics. Without a schematic for those driver boards, I'm afraid you are at sea.
 

Thread Starter

TheRoBoTBiLL

Joined May 26, 2020
16
With the pigpio library, I was able to send pulses to two GPIOs and drive the wheels.
E.g.
1000μs - fast clockwise
1250μs - clockwise
1500μs - stop
1750μs - counterclockwise
2000μs - fast counterclockwise


My question is, how will I be able to find out what speeds these are?
To learn V_right and V_left to calculate the linear and angular velocities.

Any idea?
 

MrSalts

Joined Apr 2, 2020
2,767
The code is worse than useless if you have no way to talk to the electronics. Without a schematic for those driver boards, I'm afraid you are at sea.
The 28-pin chips are PIC16F680. They are in sockets so it would be easy to pull them out and reprogram them.
there is too much glare on the 20-pin chips to make those out.
 
Top