This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connecting to PWM and GPIO makes my motor to start
#1
I have connected a simple DC motor to my Tinker Board using a motor driver here:
LINK 

When I connect this driver to my ASUS Tinker board pins :
1. ASUS.GPIO pin 238 also known as pin 33 PWM
2. ASUS.GPIO pin 163 also known as pin 18 GPIO

My motor start to function straight away.

When I take off the driver from GPIO pin, I can use ASUS.GPIO software to post a frequency of 50 hz to PWM pin 238 and the motor starts slowly at that rate and when I close the software it stops.

Why is it?
Reply
#2
I think it's rather correct that when the program quits will stop any function over the controlled hardware. If you want to keep that running the you should launch your program in background like
Code:
$ sudo python <my_pgm> &
If you expect to control the the program, running in background, then you should write it as daemon and send the messages to it buy UDP o d-bus.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#3
(01-01-2019, 04:35 AM)Im4Tinker Wrote: I think it's rather correct that when the program quits will stop any function over the controlled hardware. If you want to keep that running the you should launch your program in background like
Code:
$ sudo python <my_pgm> &
If you expect to control the the program, running in background, then you should write it as daemon and send the messages to it buy UDP o d-bus.

Yes but it is not a problem with a software quitting and stopping the motor. It is that when I connect PWM and GPIO pins the motor start to drive straight away ai its maximum speed. Why is that?
Reply
#4
(01-01-2019, 09:29 AM)stevemartinov Wrote: the motor start to drive straight away ai its maximum speed. Why is that?
According to that Polulu product the speed is controlled by analog input, correct me if I'm wrong.

The PWM output from the TB is not really analog. To make it so, it'd be preferred to add a small capacitor to filter and level the off state from the PWM output.
Furthermore the TB maximum output is only 3.5 V, so you can't get 11 Volts from Tinker board to drive the Polulu module.

If you plan to control the speed by the TB PWM, you should do first:
  • You need a MOSFET with logic level gate. It may be a small module like this. The TB will drive the MOSFET gate and then you may supply the motor up to 40V and maybe 150 W of power.
  • You should have any instrument to check the output on the PWM. It's supposed to use an oscilloscope.
  • It might be helpful to see your code, perhaps we can understand better what is trying to accomplish. Small oversights may be caught by more eyes looking at them.
  • Perhaps add some picture of your wiring Wink
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#5
(01-01-2019, 11:10 PM)Im4Tinker Wrote:
(01-01-2019, 09:29 AM)stevemartinov Wrote: the motor start to drive straight away ai its maximum speed. Why is that?
According to that Polulu product the speed is controlled by analog input, correct me if I'm wrong.

The PWM output from the TB is not really analog. To make it so, it'd be preferred to add a small capacitor to filter and level the off state from the PWM output.
Furthermore the TB maximum output is only 3.5 V, so you can't get 11 Volts from Tinker board to drive the Polulu module.

If you plan to control the speed by the TB PWM, you should do first:
  • You need a MOSFET with logic level gate. It may be a small module like this. The TB will drive the MOSFET gate and then you may supply the motor up to 40V and maybe 150 W of power.
  • You should have any instrument to check the output on the PWM. It's supposed to use an oscilloscope.
  • It might be helpful to see your code, perhaps we can understand better what is trying to accomplish. Small oversights may be caught by more eyes looking at them.
  • Perhaps add some picture of your wiring Wink

I think 3.5V is enough as it is to drive the motor driver only! The motor itself requires from 2V to 7V and I have connected that to 5V Tinker Board input.
Here is the motor driver pinout:

LINK

I did not connect the second motor yet as I want to test with 1 motor at the moment. 

Here is my connected pins on my ASUS Tinker Board:

LINK

Now I will explain how I connected my motor controller to TB:
 LEFT SIDE of a motor controller:
1. GND is connected to pin 14 (GND)
2. VCC is connected to pin 17 (3.3)
3. BIN2 is connected to pin 19 
4. BIN1 is disconnected but I connect it to pin 18 and the motor starts to run instantly.

RIGHT SIDe of a motor controller:
1. GND is connected to pin 6
2. VIN is connected to pin 4 (5V).
two other pins are connected to the motor.

My code:

Code:
import ASUS.GPIO as GPIO
import time

GPIO.setmode(GPIO.ASUS)
GPIO.setwarnings(False)

myservo = 238

GPIO.setup(myservo,GPIO.OUT)
pwm = GPIO.PWM(myservo,10) # 
pwm.start(100) # 0 derece
t = 8
t_end = time.time() + t
while time.time() < t_end:
    print "hey"

pwm.stop()
GPIO.cleanup()

I just run the motor at full speed, wait for 8 seconds (prints hey for that time) and then shutdown the motor. Works well.


Attached Files Thumbnail(s)
       
Reply
#6
Now I understand better. I saw the datasheet and that tells the chip is made to pilot a H bridge for the motor. So the internal logic are to drive the on chip MOSFET.
If you set the PWM at 50% how will do the motor ?

BTW I don't feed advertisement, I use ads blocker, therefore I can't see your pictures. You may find simpler if you attach them here.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#7
(01-02-2019, 01:07 PM)Im4Tinker Wrote: Now I understand better. I saw the datasheet and that tells the chip is made to pilot a H bridge for the motor. So the internal logic are to drive the on chip MOSFET.
If you set the PWM at 50% how will do the motor ?

BTW I don't feed advertisement, I use ads blocker, therefore I can't see your pictures. You may find simpler if you attach them here.

If I set the PWM to 50% motor just runs slower with some lags.

Some update:
I have managed to set the GPIO pin on TB to be a digital pin (0 or 1) and the motor no longer runs if I connect the motor driver to the GPIO pin 18. It was probably running PWM at 100% or something. Now, I am able to run the motor in both directions, by setting 0 to GPIO pin 18 it moves forward and by setting 1 to GPIO pin 18 the motor moves backward.
Reply
#8
(01-02-2019, 01:07 PM)Im4Tinker Wrote: Now I understand better. I saw the datasheet and that tells the chip is made to pilot a H bridge for the motor. So the internal logic are to drive the on chip MOSFET.
If you set the PWM at 50% how will do the motor ?

BTW I don't feed advertisement, I use ads blocker, therefore I can't see your pictures. You may find simpler if you attach them here.

Now the biggest problem I have at the moment is that the GPIO pins are reset back to the original values and the motor spins again when I restart the TB. How can I permanently make GPIO pin 18 to be a digital PIN? Or should I use a diffrent pin number for that?
Reply
#9
So the most problem is the initial power on state. I can't tell much about the TB hardware, I suppose that the chip must be configured in a way that won't enable any output prior some configuration. Therefore these pins must be on high impedance.

Perhaps the module needs a small delay before to be powered on so TB will be ready. I think you might add an additional capacitor to the VCC module pin, but with a little resistor that is coming from the TB board.
This may ensure a slight delay. Even better if that pin is supplied by an output TB pin. So until that pin is not set the module shouldn't get ready, from the input side.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#10
(01-02-2019, 11:09 PM)Im4Tinker Wrote: So the most problem is the initial power on state. I can't tell much about the TB hardware, I suppose that the chip must be configured in a way that won't enable any output prior some configuration. Therefore these pins must be on high impedance.

Perhaps the module needs a small delay before to be powered on so TB will be ready. I think you might add an additional capacitor to the VCC module pin, but with a little resistor that is coming from the TB board.
This may ensure a slight delay. Even better if that pin is supplied by an output TB pin. So until that pin is not set the module shouldn't get ready, from the input side.

Would you mind sharing some kind of a diagram that I can implement using the Capacitor to delay?
[-] The following 1 user Likes stevemartinov's post:
  • jkljkl1197
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)