birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 9:10 pm

ok, so i've got the pi up and running. its a RPi 2 model B. I'm trying to use pins 4 and 14 as described in an official tutorial. My goal is to control a motor. I'm confused by this because on arduino the motor controller uses 3 pins. the 3rd being pwm. But with the motor library its only using 2 pins. So I decided to simply go back to using the pin as a generic output and measuring the voltage. I get 0. Not sure what i'm doing wrong.

this is the pin layout i'm using. http://pi4j.com/pins/model-2b-rev1.html
this is my code

Code: Select all

from gpiozero import OutputDevice
from time import sleep
#from gpiozero import Motor
a = OutputDevice(4)
b = OutputDevice(14)
#motor1 = Motor(4, 14)
#motor2 = Motor(17, 27)

print("starting")
a.on()
#motor1.forward(0.5)
sleep(999999999)
#motor1.backward(0.5)
#sleep(1)
#motor1.stop()
#sleep(1)
#motor1.forward()
#sleep(1)
#motor1.backward()
#sleep(5)
thanks

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 9:27 pm

It would help if you showed us which tutorial you are following and which motor controller you are using.

If your motor controller requires 3 inputs you probably have enable and then 2 direction pins, you will need to pull the enable high or low depending on the motor controller you have before the motor will respond to the direction commands.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 9:42 pm

pcmanbob wrote:
Fri Jan 18, 2019 9:27 pm
It would help if you showed us which tutorial you are following and which motor controller you are using.

If your motor controller requires 3 inputs you probably have enable and then 2 direction pins, you will need to pull the enable high or low depending on the motor controller you have before the motor will respond to the direction commands.
Well. Atm im just trying to figure out which pins are r and 14. I sent the code to make pen for on wait one second turn off and then back on. I get a pulsating effect that I can measure with a voltmeter. I have found pin for. I cannot find pin 14

For I can worry about a motor controller I need to find out which pins are what

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 9:57 pm

Well. I think i have found pins 4 and 14. from a diagram for version 1 pi. Now I need to figure out how to use the controller. its like any other controller, there should be a left and right signal that you turn off and on respectivly, and a pwm line that is a variable for speed.


pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 10:03 pm

gpiozero uses BCM numbering, so 4 and 14 are next to each other 4 being on the left row and 14 being on the right of pins

Image

if you read the documents it tells you the pin numbers in there

https://gpiozero.readthedocs.io/en/stable/recipes.html

I would not recommend using 4 and 14 as both have other functions, 4 = 1-wire interface ( not active by default ), 14 = UART transmit pin ( active bu default ) which could interfere with you intended use.

if you look at this site it will tell you what other uses all the gpio pins have.

https://pinout.xyz/#
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 10:43 pm

pcmanbob wrote:
Fri Jan 18, 2019 10:03 pm
gpiozero uses BCM numbering, so 4 and 14 are next to each other 4 being on the left row and 14 being on the right of pins

Image

if you read the documents it tells you the pin numbers in there

https://gpiozero.readthedocs.io/en/stable/recipes.html

I would not recommend using 4 and 14 as both have other functions, 4 = 1-wire interface ( not active by default ), 14 = UART transmit pin ( active bu default ) which could interfere with you intended use.

if you look at this site it will tell you what other uses all the gpio pins have.

https://pinout.xyz/#
Thank you. I've got all the pins working and tested. now to try and figure out where exactly they go on this H Bridge. The tutorial just uses a board that goes right on the pi. doesn't even talk about pin placement.

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 10:48 pm

now to try and figure out where exactly they go on this H Bridge
As I said tell us which motor driver board you have ( link to supplier ) and we can help.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Fri Jan 18, 2019 10:51 pm

pcmanbob wrote:
Fri Jan 18, 2019 10:48 pm
now to try and figure out where exactly they go on this H Bridge
As I said tell us which motor driver board you have ( link to supplier ) and we can help.
Sorry. Been a stressful day. New kid. Life stuff.

This is the one im using. I am using it on an Arduino project. While it only controls one motor it's nice because it goes up to 43 amps https://www.amazon.com/HiLetgo-BTS79 ... 0WSN98DC

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Sat Jan 19, 2019 12:23 am

Well the pin out seems a bit confusing as all the pins starting with R seem to indicate forward all the pins starting with L seem to indicate reverse, so you will have to make sure you don't enable both at the same time if you intend to use both directions.

So holding the controller in front of you with the green connector on the furthest side away from you the connection for the gpio is on the 8 pins like this.


Image

7. VCC: +5 V power output, 5V power supply connection with the microcontroller Do not connect this to your pi

8. GND: signal common low end Connect to any gpio gnd pin



5. R_IS: forward drive current alarm output Do not connect to pi for now may be 5v output which will damage you pi gpio

3. R_EN: forward drive enable input, high-level enable, low level off Connect to one of the output gpio pin to enable forward for motor

1. RPWM: forward level or PWM signal input, active high Connect to one of the output gpio pin to control forward speed


6. L_IS: forward drive current alarm output Do not connect to pi for now may be 5v output which will damage you pi gpio

4. L_EN: forward drive enable input, high-level enable, low level off Connect to one of the output gpio pin to enable reverse

2. LPWM: forward level or PWM signal input, active highConnect to one of the output gpio pin to control reverse speed

So to control 1 motor in both directions you need 4 gpio output pins and one ground pin.

This is all based on the picture of the board

Image

and this information taken from the web page
1.RPWM: forward level or PWM signal input, active high
2.LPWM: Reverse level or PWM signal input, active high
3.R_EN: forward drive enable input, high-level enable, low level off
4.L_EN: Reverse drive enable input, high-level enable, low level off
5.R_IS: forward drive current alarm output
6.L_IS: Reverse drive current alarm output
7.VCC: +5 V power output, 5V power supply connection with the microcontroller
8.GND: signal common low end

Hope that helps, but I would check the board you have in your hands matches what the web page indicates before connecting to the pi, Its down to you to check its all correct as I don't have the board in my hands to do any testing.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Sat Jan 19, 2019 12:44 am

pcmanbob wrote:
Sat Jan 19, 2019 12:23 am
Well the pin out seems a bit confusing as all the pins starting with R seem to indicate forward all the pins starting with L seem to indicate reverse, so you will have to make sure you don't enable both at the same time if you intend to use both directions.

So holding the controller in front of you with the green connector on the furthest side away from you the connection for the gpio is on the 8 pins like this.


Image

7. VCC: +5 V power output, 5V power supply connection with the microcontroller Do not connect this to your pi

8. GND: signal common low end Connect to any gpio gnd pin



5. R_IS: forward drive current alarm output Do not connect to pi for now may be 5v output which will damage you pi gpio

3. R_EN: forward drive enable input, high-level enable, low level off Connect to one of the output gpio pin to enable forward for motor

1. RPWM: forward level or PWM signal input, active high Connect to one of the output gpio pin to control forward speed


6. L_IS: forward drive current alarm output Do not connect to pi for now may be 5v output which will damage you pi gpio

4. L_EN: forward drive enable input, high-level enable, low level off Connect to one of the output gpio pin to enable reverse

2. LPWM: forward level or PWM signal input, active highConnect to one of the output gpio pin to control reverse speed

So to control 1 motor in both directions you need 4 gpio output pins and one ground pin.

This is all based on the picture of the board

Image

and this information taken from the web page
1.RPWM: forward level or PWM signal input, active high
2.LPWM: Reverse level or PWM signal input, active high
3.R_EN: forward drive enable input, high-level enable, low level off
4.L_EN: Reverse drive enable input, high-level enable, low level off
5.R_IS: forward drive current alarm output
6.L_IS: Reverse drive current alarm output
7.VCC: +5 V power output, 5V power supply connection with the microcontroller
8.GND: signal common low end

Hope that helps, but I would check the board you have in your hands matches what the web page indicates before connecting to the pi, Its down to you to check its all correct as I don't have the board in my hands to do any testing.
All that sounds about right. But u think im going to need to find 5v somewhere :( i already tried powering from pi. Nothing happened, so maybe the board is being underpowered

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Sat Jan 19, 2019 12:05 pm

This is were I said you needed to do some testing, as the information says its an output that would imply that the board has its own 5v regulator on board that is powered from the motor supply.

I would connect your motor power supply to the motor driver board and then measure between VCC and ground pins to see if there is actually 5v output.

I thought you said you had used this motor driver board ?
I'm confused by this because on arduino the motor controller uses 3 pins. the 3rd being pwm.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Sat Jan 19, 2019 1:21 pm

pcmanbob wrote:
Sat Jan 19, 2019 12:05 pm
This is were I said you needed to do some testing, as the information says its an output that would imply that the board has its own 5v regulator on board that is powered from the motor supply.

I would connect your motor power supply to the motor driver board and then measure between VCC and ground pins to see if there is actually 5v output.

I thought you said you had used this motor driver board ?
I'm confused by this because on arduino the motor controller uses 3 pins. the 3rd being pwm.
Yes the board came off an arduino project. The vcc i just feed from the 5v output from arduino. The en pins i just feed 5v. And i swap power to the 2 pwm lines. Im pretty sure this is how im doing it. I should be able to get the same thing going on pu except swap the power going to en pins so i can control speed.

The vcc pin i now have i am connecting to the 5v supppy from pi.

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 6:51 pm

pcmanbob wrote:
Sat Jan 19, 2019 12:23 am


and this information taken from the web page
1.RPWM: forward level or PWM signal input, active high
2.LPWM: Reverse level or PWM signal input, active high
3.R_EN: forward drive enable input, high-level enable, low level off
4.L_EN: Reverse drive enable input, high-level enable, low level off
5.R_IS: forward drive current alarm output
6.L_IS: Reverse drive current alarm output
7.VCC: +5 V power output, 5V power supply connection with the microcontroller
8.GND: signal common low end

Hope that helps, but I would check the board you have in your hands matches what the web page indicates before connecting to the pi, Its down to you to check its all correct as I don't have the board in my hands to do any testing.
I decided to hook this up to a laptop power supply and linear actuator. I got it working. So I'm thinking that its the power i'm using. I have 3 D batteries taped together. measures just below 5 volts. Is this board using all 5 volts and leaving nothing for the motor? that seems like a lot, especially when i'm powering it with 5v from the RPi. Non the less, if i wire it to the laptop charger and linear actuator, it runs. Hook it to the batteries and a small 12v rc motor. nothing. what gives?

second question

I have 4 wires at a time (plus 5v power and ground). I light up the R_EN and L_EN. then choose which of the PWM wires i want to light up for direction and speed. This does not seem right. Shouldn't I be lighting up only ONE of the R_EN and L_EN wires along with the same PWM? In fact on my arduino project using this h bridge i have simply powered the R_EN and L_EN pins with the 5v from the arduino and don't even deal with them in code. They both just stay energized and I turn the PWM on and off for forward and reverse. I ask because the tutorial tells me to use the motor library (correct term here?) but it only gives the option to control 2 at a time. I presume I would control L_EN and LPWM at the same time or R_EN and RPWM at the same time. But that doesn't make sense to me. I Should have 3 wires to control.

maybe its because this motor driver only controls 1 motor whereas most controll 2?

thanks

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 7:19 pm

birddseedd wrote:
Mon Jan 21, 2019 6:51 pm
I decided to hook this up to a laptop power supply and linear actuator. I got it working. So I'm thinking that its the power i'm using. I have 3 D batteries taped together. measures just below 5 volts. Is this board using all 5 volts and leaving nothing for the motor? that seems like a lot, especially when i'm powering it with 5v from the RPi. Non the less, if i wire it to the laptop charger and linear actuator, it runs. Hook it to the batteries and a small 12v rc motor. nothing. what gives?
So you are trying to run a 12v motor from 3D batteries which will only give you 4.5 v under load, I am not surprised the motor does not work did you try measuring the voltage at the motor terminals ?

I have 4 wires at a time (plus 5v power and ground). I light up the R_EN and L_EN. then choose which of the PWM wires i want to light up for direction and speed. This does not seem right. Shouldn't I be lighting up only ONE of the R_EN and L_EN wires along with the same PWM? In fact on my arduino project using this h bridge i have simply powered the R_EN and L_EN pins with the 5v from the arduino and don't even deal with them in code. They both just stay energized and I turn the PWM on and off for forward and reverse. I ask because the tutorial tells me to use the motor library (correct term here?) but it only gives the option to control 2 at a time. I presume I would control L_EN and LPWM at the same time or R_EN and RPWM at the same time. But that doesn't make sense to me. I Should have 3 wires to control.

maybe its because this motor driver only controls 1 motor whereas most controll 2?
The motor library referenced in the tutorial you are following is for a totally different motor controller, you can't expect it to work with the one you have as it controls the driver in a totally different way, you will need to write your own program for controlling the motor via your driver board, or find one specifically written to work with that motor driver board.

If you want to follow a specific tutorial and use ready made library's then you also need to use the specific hardware they were written for.

what you are trying to do is like playing cricket while using the rules for football, it will never work.
Last edited by pcmanbob on Mon Jan 21, 2019 8:20 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 7:41 pm

pcmanbob wrote:
Mon Jan 21, 2019 7:19 pm
birddseedd wrote:
Mon Jan 21, 2019 6:51 pm
I decided to hook this up to a laptop power supply and linear actuator. I got it working. So I'm thinking that its the power i'm using. I have 3 D batteries taped together. measures just below 5 volts. Is this board using all 5 volts and leaving nothing for the motor? that seems like a lot, especially when i'm powering it with 5v from the RPi. Non the less, if i wire it to the laptop charger and linear actuator, it runs. Hook it to the batteries and a small 12v rc motor. nothing. what gives?
So you are trying to run a 12v motor from 3D batteries which will only give you 4.5 v under load, I am not surprised the motor does not work did you try measuring the voltage at the motor terminals ?


when i hook them up directly, they spin. not as fast as if they were at 12v. but spins enough to know the motor is working

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 7:43 pm

I have 4 wires at a time (plus 5v power and ground). I light up the R_EN and L_EN. then choose which of the PWM wires i want to light up for direction and speed. This does not seem right. Shouldn't I be lighting up only ONE of the R_EN and L_EN wires along with the same PWM? In fact on my arduino project using this h bridge i have simply powered the R_EN and L_EN pins with the 5v from the arduino and don't even deal with them in code. They both just stay energized and I turn the PWM on and off for forward and reverse. I ask because the tutorial tells me to use the motor library (correct term here?) but it only gives the option to control 2 at a time. I presume I would control L_EN and LPWM at the same time or R_EN and RPWM at the same time. But that doesn't make sense to me. I Should have 3 wires to control.

maybe its because this motor driver only controls 1 motor whereas most controll 2?
The motor library referenced in the tutorial you are following is for a totally different motor controller, you can expect it to work with the one you have as it controls the driver in a totally different way, you will need to write your own program for controlling the motor via your driver board, or find one specifically written to work with that motor driver board.

If you want to follow a specific tutorial and use ready made library's then you also need to use the specific hardware they were written for.

what you are trying to do is like playing cricket while using the rules for football, it will never work.
[/quote]

got it. ill pick out a different controller when i get further along in the project.

thank you

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 8:22 pm

birddseedd wrote:
Mon Jan 21, 2019 7:41 pm

when i hook them up directly, they spin. not as fast as if they were at 12v. but spins enough to know the motor is working
So you only have 4.5v to start with and there will be some volt drop across the motor drive board, which is why I asked if you measured the voltage at the motor terminals, I would bet its below 4.5v
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 8:26 pm

birddseedd wrote:
Mon Jan 21, 2019 7:43 pm
ill pick out a different controller when i get further along in the project.
Each motor drive board will have is own control requirements so you need to choose and understand how to control it before you start writing software or you could well end up having to re-write the software for the motor driver board when you get round to selecting one and you may not have the spare gpio pins should it require more than you planned for.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 8:30 pm

pcmanbob wrote:
Mon Jan 21, 2019 8:22 pm
birddseedd wrote:
Mon Jan 21, 2019 7:41 pm

when i hook them up directly, they spin. not as fast as if they were at 12v. but spins enough to know the motor is working
So you only have 4.5v to start with and there will be some volt drop across the motor drive board, which is why I asked if you measured the voltage at the motor terminals, I would bet its below 4.5v
i measured 0v

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 8:31 pm

pcmanbob wrote:
Mon Jan 21, 2019 8:26 pm
birddseedd wrote:
Mon Jan 21, 2019 7:43 pm
ill pick out a different controller when i get further along in the project.
Each motor drive board will have is own control requirements so you need to choose and understand how to control it before you start writing software or you could well end up having to re-write the software for the motor driver board when you get round to selecting one and you may not have the spare gpio pins should it require more than you planned for.
I thought that I had read that it takes 2v which should give me almost 3 volts when the motor is powered.

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 8:34 pm

That would suggest your motor drive board is dropping 4.5v or more across the transistors that are on it.

If you tried the same test on the laptop power supply and linear actuator and you measure the input voltage to the motor drive board as well , taking one from the other would tell you how much voltage is being dropped across the motor driver board.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Mon Jan 21, 2019 10:07 pm

pcmanbob wrote:
Mon Jan 21, 2019 8:34 pm
That would suggest your motor drive board is dropping 4.5v or more across the transistors that are on it.

If you tried the same test on the laptop power supply and linear actuator and you measure the input voltage to the motor drive board as well , taking one from the other would tell you how much voltage is being dropped across the motor driver board.
No luck. I attached the laptop power supply and linear actuator again. I measured 19.7v across the power supply input, positive to negative and i measured 19.7v across the positive and negative output to the motor. It should have dropped?

pcmanbob
Posts: 7254
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Don't seem to be getting any output from pins. what did i do wrong?

Tue Jan 22, 2019 1:22 pm

birddseedd wrote:
Mon Jan 21, 2019 10:07 pm
pcmanbob wrote:
Mon Jan 21, 2019 8:34 pm
That would suggest your motor drive board is dropping 4.5v or more across the transistors that are on it.

If you tried the same test on the laptop power supply and linear actuator and you measure the input voltage to the motor drive board as well , taking one from the other would tell you how much voltage is being dropped across the motor driver board.
No luck. I attached the laptop power supply and linear actuator again. I measured 19.7v across the power supply input, positive to negative and i measured 19.7v across the positive and negative output to the motor. It should have dropped?
Was the motor connected to the output and running at the time you measured it ?

you could try the batteries on the motor driver board with just the meter connected on the output so the load is nil and see if you get 4.5v then.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: Don't seem to be getting any output from pins. what did i do wrong?

Tue Jan 22, 2019 2:26 pm

pcmanbob wrote:
Tue Jan 22, 2019 1:22 pm
birddseedd wrote:
Mon Jan 21, 2019 10:07 pm
pcmanbob wrote:
Mon Jan 21, 2019 8:34 pm
That would suggest your motor drive board is dropping 4.5v or more across the transistors that are on it.

If you tried the same test on the laptop power supply and linear actuator and you measure the input voltage to the motor drive board as well , taking one from the other would tell you how much voltage is being dropped across the motor driver board.
No luck. I attached the laptop power supply and linear actuator again. I measured 19.7v across the power supply input, positive to negative and i measured 19.7v across the positive and negative output to the motor. It should have dropped?
Was the motor connected to the output and running at the time you measured it ?

you could try the batteries on the motor driver board with just the meter connected on the output so the load is nil and see if you get 4.5v then.
I tried it with the motor not spinning fir whatever reason. Ill try it with the motor disconnected.

The power supply im pretty sure was running the motor. I can doubke check

Return to “Beginners”