gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

2 motors and 16bit pwm...

Mon Jan 15, 2018 3:34 pm

I want to drive 2 motors (not stepper) , backwards and forwards, using 16bit pwm.

Will using one of these https://www.adafruit.com/product/1455 with its output wired to a L293D work?

Gordon

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

Re: 2 motors and 16bit pwm...

Mon Jan 15, 2018 4:55 pm

Well reading the specifications for the pwm driver board, the only thing I can see that you might need to take into accound is this
If you want to drive something that requires a digital input, you must use a pullup resistor from the drive pin to your logic level to create the full waveform.
now seeing as you will be driving the 2 enable inputs on the L293D for speed control using pwm you will be needing a digital input signal.

other than that I think you should be good.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

Re: 2 motors and 16bit pwm...

Mon Jan 15, 2018 5:00 pm

Thanks. Are there any drivers for the Pi?, all examples seem to be for Arduino.

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

Re: 2 motors and 16bit pwm...

Mon Jan 15, 2018 5:07 pm

It does not look like it , looking at the learning downloads and links page for the product all I can see are Arduino Libraries, no mention of the pi at all.

https://learn.adafruit.com/tlc5947-tlc5 ... -and-links
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

IanS
Posts: 164
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 9:41 am

Do you really need 16bit PWM hardware control for driving two motors?
I have a python script which just uses pigpio to control the speed of up to four motors simultaneously through L298N drivers by pulsing the enable line. The direction lines are hardwired in my case as I only need a single direction, but I could control the direction too through additional GPIO pins.

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

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 10:45 am

I've just started playing with a couple of micrometal geared motors to drive a mini robot vehicle through a https://shop.pimoroni.com/products/explorer-phat and they work very nicely. I did end up writing my own drivers via pigpio as the standard pimoroni library put a standing load on (a pi Zero) of around 20%, whereas using pigpio the standing load is closer to 10%.

Of course any old H bridge will do - just be careful not turn turn on both paths at the same time!

I also wanted an interface that gave me something approximating to linear response, rather than the asymptotic response to increasing %age duty cycle that is the natural way of a pwm controlled DC motor.

And to run at low speed I found that very slow pulse rates work much better than higher pulse rates.

I've put the module on github here.

I did look for a python module to do a nice job of dc motor control, potentially even with feedback to give accurate control of speed / distance, but all I found were really noddy examples.

gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 6:01 pm

IanS wrote:
Tue Jan 16, 2018 9:41 am
Do you really need 16bit PWM hardware control for driving two motors?
I have a python script which just uses pigpio to control the speed of up to four motors simultaneously through L298N drivers by pulsing the enable line. The direction lines are hardwired in my case as I only need a single direction, but I could control the direction too through additional GPIO pins.
I want to control the RA and DEC on a telescope so would like as much accuracy as possible.
Will your code run in the background? Any chance of seeing your code?

I thought using hardware would leave the processor to do other things and give better stability.

User avatar
joan
Posts: 12985
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 6:37 pm

I'm not sure PWM is going to help much in achieving accurate position with a DC motor. Are these a special type of motor?

gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 6:57 pm

joan wrote:
Tue Jan 16, 2018 6:37 pm
I'm not sure PWM is going to help much in achieving accurate position with a DC motor. Are these a special type of motor?
No just dc motors, need to move at an accurate speed which can be adjusted.

User avatar
joan
Posts: 12985
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 7:36 pm

It's a pity you don't have steppers.

Is there any feedback about the position? You may need to re-calibrate the PWM at each and every use as I'm not sure how a DC motor may be affected by load and temperature.

gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 7:52 pm

joan wrote:
Tue Jan 16, 2018 7:36 pm
It's a pity you don't have steppers.

Is there any feedback about the position? You may need to re-calibrate the PWM at each and every use as I'm not sure how a DC motor may be affected by load and temperature.
Yes you are correct, it will be (auto) guided by a camera tracking a star and adjusting speed accordingly.

User avatar
OutoftheBOTS
Posts: 496
Joined: Tue Aug 01, 2017 10:06 am

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 8:01 pm

To getr DC motors to turn at an accurate speed or degress then you need a feed back loop. You need to have a sensor on the motor reading how much it is turning then based upon this weather it is turning at the right speed you increase or decrease the PWM duty cycle.

Google "closed loop servo motor"

The sensor used to read the shaft speed rotation is called a quadrature encoder you can see an explanation here https://www.youtube.com/watch?v=p4BCFhIuC88&t=25s

And a little extension of how to solve the problems of reading these encoders https://www.youtube.com/watch?v=41ogu0U ... 0681570184

User avatar
joan
Posts: 12985
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 8:11 pm

Fine. It's probably worth mentioning that you could use the Pi's hardware PWM channels

gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 8:32 pm

joan wrote:
Tue Jan 16, 2018 8:11 pm
Fine. It's probably worth mentioning that you could use the Pi's hardware PWM channels
Thanks, is that using pigpio and is 8 bit?

User avatar
joan
Posts: 12985
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 2 motors and 16bit pwm...

Tue Jan 16, 2018 8:47 pm

gordon77 wrote:
Tue Jan 16, 2018 8:32 pm
joan wrote:
Tue Jan 16, 2018 8:11 pm
Fine. It's probably worth mentioning that you could use the Pi's hardware PWM channels
Thanks, is that using pigpio and is 8 bit?
pigpio general PWM (for want of a better term) is DMA timed and defaults to 250 steps, not quite 8 bits.

I meant the hardware PWM channels used to drive audio which I guess you wouldn't be using for your application.

pigpio does support those channels as does other software.

pigpio's implementation lets you choose a frequency which fixes the number of steps between on and off.

The number of steps is 250 million / frequency.

If you want 16 bit resolution that means the frequency would have to be 250,000,000/65536 or 3815Hz.

IanS
Posts: 164
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: 2 motors and 16bit pwm...

Wed Jan 17, 2018 11:24 am

I assume you are driving the motors in the telescope mount, so there will be be a gear chain following it, which means that you can drive the motor at a moderate speed and the gears turn this into the very slow motion required. Higher speeds would be used to slew to a new target. Trying to drive a normal motor accurately at a very slow speed is difficult, and stepper motors would be better, with micro-stepping to smooth out the motion.
If you are using an equatorial mount then most of the tracking will be in a constant direction on just the RA motor, so there is no need to worry about gear-chain backlash once the motion has started. Any tweaks on the Dec axis could be in either direction, so you may need to allow for taking up the backlash when reversing direction. You may also find that there are imperfections in the gearing which lead to the mount movement slowing/jumping at particular points. I know mine does, which has ruined many a photo. Some controllers are smart enough to learn about these points and compensate for them, but you then have to only move the mount via the controller, or it loses track of where it is in relation to the problem areas.

I did once see a demo of a direct driven (no high ratio gear chain) scope mount that could take a 20kg telescope, slew from one side of the sky to the opposite in under 2 seconds, and still maintain tracking accuracy at the arc-second level. Just what I was looking for. Shame about the £30,000 price tag.

gordon77
Posts: 3110
Joined: Sun Aug 05, 2012 3:12 pm

Re: 2 motors and 16bit pwm...

Sat Jan 20, 2018 4:44 pm

IanS wrote:
Wed Jan 17, 2018 11:24 am
I assume you are driving the motors in the telescope mount, so there will be be a gear chain following it, which means that you can drive the motor at a moderate speed and the gears turn this into the very slow motion required. Higher speeds would be used to slew to a new target. Trying to drive a normal motor accurately at a very slow speed is difficult, and stepper motors would be better, with micro-stepping to smooth out the motion.
If you are using an equatorial mount then most of the tracking will be in a constant direction on just the RA motor, so there is no need to worry about gear-chain backlash once the motion has started. Any tweaks on the Dec axis could be in either direction, so you may need to allow for taking up the backlash when reversing direction. You may also find that there are imperfections in the gearing which lead to the mount movement slowing/jumping at particular points. I know mine does, which has ruined many a photo. Some controllers are smart enough to learn about these points and compensate for them, but you then have to only move the mount via the controller, or it loses track of where it is in relation to the problem areas.

I did once see a demo of a direct driven (no high ratio gear chain) scope mount that could take a 20kg telescope, slew from one side of the sky to the opposite in under 2 seconds, and still maintain tracking accuracy at the arc-second level. Just what I was looking for. Shame about the £30,000 price tag.
I'm just driving the motors in an old Meade LX10, I did it with an Arduino and a L293, with 8 bit pwm, l wanted to see if 16bit improved it. Not worth £30,000 :D

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 12 guests