# Thread: PWM Motor Control with Soft Start, Soft Stop Example Please

1. ## PWM Motor Control with Soft Start, Soft Stop Example Please

Hi All,

It has been a while!

I need to drive a small 12v motor with PWM speed control to include soft start and stop. I would like to keep the circuit board small and I have a bunch of 675's at my disposal. Ultimately I would like to use a single pot to determine both speed and direction with half-way being the motor stop position. Can you point me to some fairly simple code examples (it has really been a while :-) to get me going?

Thank you!!!

Ross

2. ## Re: PWM Motor Control with Soft Start, Soft Stop Example Please

Ross

Here's a snippet of some old code that might get you started with the pot control:

Code:
```DEFINE ADC_BITS     8   ' Set number of bits in result
DEFINE ADC_CLOCK    3   ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50  ' Set sampling time in uS

Speed   VAR WORD
Wait_1  VAR WORD

' Turn ON every other output varying speed with pot from center
Pots:

IF Speed < 128 THEN       'Checks if pot in CCW position range
wait_1 = ABS(Speed-128)   'Sets pot value to increase in CCW direction
PORTC = \$50               'Turn outputs 4 and 6 ON
ENDIF
PAUSE wait_1              'Pause with new pot value
PORTC = \$0                'Turn OFF all outputs

IF Speed >= 128 THEN      'Checks if pot in CW position range
wait_1 = (Speed-128)+1    'Sets pot value to increase in CW direction
PORTC = \$A0               'Turns outputs 5 and 7 ON
ENDIF
PAUSE wait_1              'Pause with new pot value
PORTC = \$0                'Turn OFF all outputs

GOTO Pots```
This routine sets the pot to a plus/minus from center position for direction and speed value. Change the A/D to 10 bit for better resolution.
It doesn't have dead band gap in center for the OFF position but you can change that.
Then instead of using the A/D value for the "PAUSE wait_1" control, use it to adjust your PWM signal.

3. ## Re: PWM Motor Control with Soft Start, Soft Stop Example Please

Thank you for replying Louie!

Soooo... I'm leaning towards ditching the dead-band and throwing in a DPDT slide switch on the board edge. The switch determines motor direction and that leaves me with PWM motor speed and Soft Start/Stop. To get up and going, I'm going to put a resistor/capacitor timer between the pot and the A/D pin. Power to the pot will be through a foot switch. When power is supplied, the capacitor charges through the pot position and resistor. When power is removed, the capacitive charge drains back through the resistor and pot. That gives me soft start/stop. I'll get that going first then move to writing code to eliminate the RC circuit.

Any thoughts, suggestions, wise-cracks?

Ross

4. ## Re: PWM Motor Control with Soft Start, Soft Stop Example Please

Your method simplifies it enough to get it started, especially after a long break.
I'm guilty of diving fingers first with "intentional coding" then get stuck with paralysis of analysis.

5. ## Re: PWM Motor Control with Soft Start, Soft Stop Example Please

Amen to that brother!

6. ## Re: PWM Motor Control with Soft Start, Soft Stop Example Please

Since you have the software, why would you put extra hardware for the soft start part?

Consider a loop with maybe a for-next to increase the PWM to the set point gradually.

Ioannis

#### Members who have read this thread : 28

You do not have permission to view the list of names.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts