Picaxe18X to motor controller

Dippy

Moderator
Answer part 1. From just below the diagrams you cut'n'paste.
"If you are using a filtered PWM signal from a microcontroller to generate the analog voltage, an R-C filter with component values 10k ohms and at least .1uf is recommended as shown in Figure 4.1. This will provide a fast response to changes in duty cycle, and is suitable for PWM rates of 20+kHz.
Using a larger value filter capacitor such as 47uf (Figure 4.2) will result in smoother motor
operation and greater efficiency. However, the transient response will be slower. This extra
capacitance is strongly recommended when using slower PWM frequencies – as low as 1kHz.
Tweaking the value of the capacitor to suit your individual needs is safe way to optimize your robot’s performance."
Sounds pretty clear to me.

Answer part 2.
Get a handful of components and give it a go. You may like a response somewhere in between. Is there a problem in simply trying it out?

Note: Don't forget that the values you choose will also be a function of the PWM, which I would imagine should be fairly high for smoothness.

Or you could use the serial input?
 
Last edited:

eclectic

Moderator
@George.

Not a definite answer, but a couple of suggestions:

1.In the datasheet, p.10, it suggests testing.

“Tweaking the value of the capacitor to suit your individual needs is safe way to optimize your robot’s performance.”

Well, you could also adjust the PWMout frequecy.


2.To “see” the testing, and for the future,
get yourself a free soundcard 'scope.
Not perfect, but brilliant for the price. :)

See, for example, post #3 here:
http://www.picaxeforum.co.uk/showthread.php?t=7963&highlight=oscillo*+free

There are several others on the Forum.

e
 
Last edited:

GeorgeC47

Senior Member
Thanks for the replies. I will certainly be giving it a go but I wanted to check in case there was an easier way. All too often after completing a task someone will say 'very clever, but why on Earth did you do it that way? Wouldn't it have been easier to etc etc...'

I originally thought that the Picaxe would have a DAC function since it already has an ADC. When I discovered that it didn't I considered getting a simple DAC chip similar to the ones I used to employ about 30 years ago. Then I saw the PWM method.

The free oscilloscope suggestions look good. I will investigate!
 

westaust55

Moderator
I originally thought that the Picaxe would have a DAC function since it already has an ADC. When I discovered that it didn't I considered getting a simple DAC chip similar to the ones I used to employ about 30 years ago. Then I saw the PWM method.
Nothing wrong with the PWM method as a method.

I too have started experimenting with digital potentiometers and separate DAC chips as a means of achieving analogue voltages and controlling volume, gain and similar characteristics with op-amps. Does mean an extra chip but also set and forget while the PICAXE goes about other tasks.
If you are interested some info on digital pots (but not DACs as yet) have a look at:
http://www.picaxeforum.co.uk/showthread.php?t=14087
 

Dippy

Moderator
Unless I have misread the Data Sheet.... as I said before you do have the option of serial control if you are not happy with PWM methods. Saves a couple of components and some board space (oh, sorry, board Real Estate).

"Mode 3: Simplified serial.
Simplified serial mode uses TTL level RS-232 serial data to set the speed and direction of the motor."
 

GeorgeC47

Senior Member
The PWM command works well. I used a 10uF capacitor for the smoothing.
To ramp the speed gradually I used:
Code:
PWMOUT 3,100,100
pause 500
PWMOUT 3,100,200
pause 500
PWMOUT 3,100,300
wait 5                                'drive motor 5 seconds
PWMOUT 3,100,200
pause 500
PWMOUT 3,100,100
pause 500

PWMOUT 3,0,0
and the motor responds quite smoothly.

Is there a better way of producing a smooth start/stop?
 

Andrew Cowan

Senior Member
Code:
For w1 = 0 to 300 STEP 1
   PWMOUT 3,100,w1
   pause 1
next b1
Should give you a gentle ramp up. Change 'STEP 1' to 'STEP 2' for a faster increase, 'STEP -1' for a decrease, and increase the pause to slow the increase.

A
 
Last edited:

GeorgeC47

Senior Member
This does the job very well:
Code:
for w2 = 90 to 300 step 2
   PWMOUT 3,100,w2
   pause 20
next w2

wait 4 

for w2 = 300 to 90 step -2
   PWMOUT 3,100,w2
   pause 20
next w2

PWMOUT 3,0,0
I start w2 off with a value of 90 which removes dead time before the motor starts to rotate.
 

cactusface

Senior Member
DAC's etc..

Hi,
I have a couple of MAX518 these are dual 8 bit DAC's in an 8 pin DIP and are also i2c, think I will put one of these on my PicTest board. I too has had ideas of using DAc's, way back in the old Z80 days. But if we now have PWM do we need them?? As I take it you can dim a lamp, motor speed, etc, with PWM!
Regards
Cactus
 

BeanieBots

Moderator
It depends on what you want to do, how fast you need it to do it and to what resolution.
Dimming an incandescent lamp can be done with PWM perfectly OK in most cases. However, if that lamp is being used to illuminate a camera based image recognition system, then the precision camera will also detect the lamp PWM fluctuations even with slow large filament lamps (first hand experience).

If you want to replicate audio using PWM, then your RC filter will introduce distortion and bandwidth issues.

Each method has its pro's ans con's. A bit like the difference between using screws, nails or glue to hold things together. Sometimes the best is obvious, somethimes any method can be used.
 
Top