DFRobot tank servo control on Adafruit servo HAT
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
DFRobot tank servo control on Adafruit servo HAT
I am trying to attach the servo motors for the devastator tank (https://www.dfrobot.com/product-1477.html) but it doesn't seem to work using the 16 channel servo HAT for Raspberry Pi 3B+. The motor works when connected to power. I have somewhat successfully tested a different DF9GMS 360 micro servo and it works with this HAT but for some reason the pwm command does not behave the same with the tank motor. Also, when I plug the tank motor into the board and power it on (with a separate power supply than RPi), the motor start spinning slowly. I tried multiple pwm_set commands to no avail. Please point me in the right direction to find a solution. I searched but found nothing.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
Which servo motors? The main drive motors packaged with that kit are DC gearmotors. The Servo HAT won't drive those. You would need a Motor HAT to drive them.
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
Great. Can you suggest an Adafruit board to solve this issue and how it would be configured with the 16 Channel PWM Servo HAT?
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
The motor specifications from DFRobot are not complete. But they imply a stall-current of 2.3A. So you would need a motor driver capable of that. We have the DRV8871. https://www.adafruit.com/product/3190
You would need two of those boards - one for each motor. These can be driven directly from the GPIO pins on the Raspberry Pi. Or, if you prefer, you can use the outputs of the Servo HAT.
You would need two of those boards - one for each motor. These can be driven directly from the GPIO pins on the Raspberry Pi. Or, if you prefer, you can use the outputs of the Servo HAT.
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
Thank you adafruit_support_bill for the suggestion. The boards should be here tomorrow.
Since I'm connecting these motor boards to the Adafruit 16 Channel PWM Servo HAT, where can I find python code examples to address these motors? Or, do I use pwm.set_pwm(addr, 0, value) where addr are the pins I've used to connect the HAT to the motor controller and what are the values I should use?
Since I'm connecting these motor boards to the Adafruit 16 Channel PWM Servo HAT, where can I find python code examples to address these motors? Or, do I use pwm.set_pwm(addr, 0, value) where addr are the pins I've used to connect the HAT to the motor controller and what are the values I should use?
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
You would use the pwm.set_pwm(addr, on, off) function.
The on/off values to use depend on what you are trying to do. Setting IN1 HIGH and IN2 LOW makes the motor go one direction. Setting IN2 HIGH and IN1 LOW makes it go the other way.
To set a pin HIGH call
To set a pin LOW call
To go less than full speed, you can send a PWM signal instead of HIGH. To do that call:
where 'value' is a number between 0 and 4095.
https://learn.adafruit.com/adafruit-drv ... input-pins
The on/off values to use depend on what you are trying to do. Setting IN1 HIGH and IN2 LOW makes the motor go one direction. Setting IN2 HIGH and IN1 LOW makes it go the other way.
To set a pin HIGH call
Code: Select all
pwm.set_pwm(addr, 4096, 0)
Code: Select all
pwm.set_pwm(addr, 0, 0)
Code: Select all
pwm.set_pwm(addr, 0, value)
https://learn.adafruit.com/adafruit-drv ... input-pins
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
Thank you adafruit_support_bill. I'll give it a try after I get the hardware installed. I appreciate the quick response!
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
I have now installed the DRV8871 board on the HAT but I appear to be lacking a pin for both the IN1 and IN2 connectors. I have channel 0 power and ground connected to the VM and GND to run the motor but there is only one signal (third pin) off the HAT. I tried connecting that one to IN1 but got no action when testing with pwm.set_pwm(0,0,4096) or pwm.set_pwm(0,4096,0). I will be confirming that all solderpoints are correct using a voltage meter.
In the meantime, what am I supposed to connect to IN2 from the HAT? As you know the HAT has three pins per channel: Signal (IN1), Power (VM), and Ground (GND). Where does the other HAT pin connect to IN2?
In the meantime, what am I supposed to connect to IN2 from the HAT? As you know the HAT has three pins per channel: Signal (IN1), Power (VM), and Ground (GND). Where does the other HAT pin connect to IN2?
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
Please post a photo showing your connections.
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
Below are links to pictures.
Full Configuration:
https://drive.google.com/open?id=18h04A ... tfdQnkFCQD
RPi HAT Connections:
https://drive.google.com/open?id=1-7wXJ ... xOlbJM6X2f
DRV8871 Connections:
https://drive.google.com/open?id=1Z3aU5 ... _56CgBnVSG
Full Configuration:
https://drive.google.com/open?id=18h04A ... tfdQnkFCQD
RPi HAT Connections:
https://drive.google.com/open?id=1-7wXJ ... xOlbJM6X2f
DRV8871 Connections:
https://drive.google.com/open?id=1Z3aU5 ... _56CgBnVSG
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
We can't see the soldering on your HAT in the photos. But the soldering in the DRV8871 needs some work. The solder joints all appear to be cold joints. And none of them have flowed onto the solder pads at all.
A good solder joint should have a cross-section as shown below. Please have a look at this guide. It has some tips on identifying an correcting common soldering problems.
http://learn.adafruit.com/adafruit-guid ... n-problems
A good solder joint should have a cross-section as shown below. Please have a look at this guide. It has some tips on identifying an correcting common soldering problems.
http://learn.adafruit.com/adafruit-guid ... n-problems
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
The problem I'm reporting is that I am short a pin for N2. That has nothing to do with solder. Yes, I can perfect the solder but they all connect via solder and complete the circuit, although the pictures don't show this. Let's fix the missing pin then focus on the solder.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
There are 16 PWM channels on the HAT. You only need 2 to drive the DRV8871. You connect the PWM signal from one channel to IN1 and the PWM signal from another channel to IN2.The problem I'm reporting is that I am short a pin for N2
What the pictures show are solder joints that may or may not conduct at the moment - but are highly likely to fail.Yes, I can perfect the solder but they all connect via solder and complete the circuit, although the pictures don't show this.
- FrankGould
- Posts: 50
- Joined: Tue May 29, 2018 6:04 pm
Re: DFRobot tank servo control on Adafruit servo HAT
Then I suppose the code you responded with above is not correct, based on the different address for the different channels. If I use the signal pin on channel 13 to N2 along with the existing signal pin on channel 14, I will use N2 for the reverse motor direction? I've written what appears to be the right code, per your latest response:
To set the motor REVERSE pin LOW call: pwm.set_pwm(channel13, 0, 0)
To set the motor FORWARD pin HIGH call: pwm.set_pwm(channel14, 0, 4096)
To set the motor FORWARD pin LOW call: pwm.set_pwm(channel14, 0, 0)
To set the motor REVERSE pin HIGH call: pwm.set_pwm(channel13, 0, 4096)
NOT THIS:
To set a pin HIGH call: pwm.set_pwm(addr, 4096, 0)
As for the solder job, you already said it was cold solder and that means it may fail in the future due to weak connections. I will be addressing this today because I'm assuming the forward motor pin high should be running the motor but it's not.
If this motor will work forward and reverse, I can then build the wheel base; otherwise, if this motor doesn't work, I need to return the wheel base.
Thank you for your time helping with this issue.
To set the motor REVERSE pin LOW call: pwm.set_pwm(channel13, 0, 0)
To set the motor FORWARD pin HIGH call: pwm.set_pwm(channel14, 0, 4096)
To set the motor FORWARD pin LOW call: pwm.set_pwm(channel14, 0, 0)
To set the motor REVERSE pin HIGH call: pwm.set_pwm(channel13, 0, 4096)
NOT THIS:
To set a pin HIGH call: pwm.set_pwm(addr, 4096, 0)
As for the solder job, you already said it was cold solder and that means it may fail in the future due to weak connections. I will be addressing this today because I'm assuming the forward motor pin high should be running the motor but it's not.
If this motor will work forward and reverse, I can then build the wheel base; otherwise, if this motor doesn't work, I need to return the wheel base.
Thank you for your time helping with this issue.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: DFRobot tank servo control on Adafruit servo HAT
The code posted above correctly shows how to set the state of a pin as stated.Then I suppose the code you responded with above is not correct,
You need to substitute the pins you decide to use for the 'addr' parameter.
pwm.set_pwm(addr, 4096, 0) is the best way to set the pin HIGHTo set the motor REVERSE pin HIGH call: pwm.set_pwm(channel13, 0, 4096)
NOT THIS:
To set a pin HIGH call: pwm.set_pwm(addr, 4096, 0)
pwm.set_pwm(addr, 0, 4095) should work well for most applications
pwm.set_pwm(addr, 0, 4096) will set it LOW.
Please refer to table 7 of the PCA9685 datasheet and the setPin function in the MotorHAT library:
https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf
https://github.com/adafruit/Adafruit-Mo ... _Motors.py
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/