Hello,
I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using
my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms
(clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the
motor, but it only ever spins in 1 direction and I can not make it stop spinning
even if I try to calibrate it.
Any help is appreciated. Here is my current code.
PWMPOL = 0x01; // High at beginning, low at end (active high).
PWMPRCLK = 0x03; // Prescaler.
PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
PWMCAE = 0x00; // Sets left aligned PWM.
PWMCTL = 0x10; // Sets up ch0+1 16bit.
PWMPER01 = 5000;
PWMDTY01 = 225;
PWME = 0x02;
Controlling a Servo with the HC12?
Started by ●November 20, 2009
Reply by ●November 20, 20092009-11-20
There is a trim screw in the side of the servo. Set the pwm to 1.5ms and adjust
the screw so that the servo stops moving. Then adjust the pwm and your servo
will change directions properly.
Andrei
(code style police)
On 2009-November-20, at 12:55 PM, d...@gmail.com wrote:
> Hello,
>
> I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
> Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
---------------------
Andrei Chichak
Systems Developer
CBF Systems Inc.
4-038 NINT Innovation Centre
11421 Saskatchewan Drive
Edmonton, Alberta
Canada
T6G 2M9
Phone: 780-628-2072
Skype: andrei.chichak
Andrei
(code style police)
On 2009-November-20, at 12:55 PM, d...@gmail.com wrote:
> Hello,
>
> I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
> Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
---------------------
Andrei Chichak
Systems Developer
CBF Systems Inc.
4-038 NINT Innovation Centre
11421 Saskatchewan Drive
Edmonton, Alberta
Canada
T6G 2M9
Phone: 780-628-2072
Skype: andrei.chichak
Reply by ●November 20, 20092009-11-20
I have been doing that. It refuses to turn any direction aside from clockwise.
Do you see any issues with my code. This is what I have now.
PWMPOL = 0x01; // High at beginning, low at end (active high).
PWMPRCLK = 0x06; // Prescaler.
PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
PWMCAE = 0x00; // Sets left aligned PWM.
PWMCTL = 0x10; // Sets up ch0+1 16bit.
PWMPER0 = 0x09; // Sets up ch1 @ 43Hz w/ .000064 count.
PWMPER1 = 2499;
PWMDTY01 = 187;
PWME = 0x02;
PWMSCLA = 0x00;
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
PWMPOL = 0x01; // High at beginning, low at end (active high).
PWMPRCLK = 0x06; // Prescaler.
PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
PWMCAE = 0x00; // Sets left aligned PWM.
PWMCTL = 0x10; // Sets up ch0+1 16bit.
PWMPER0 = 0x09; // Sets up ch1 @ 43Hz w/ .000064 count.
PWMPER1 = 2499;
PWMDTY01 = 187;
PWME = 0x02;
PWMSCLA = 0x00;
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Reply by ●November 20, 20092009-11-20
Do you have an oscilloscope (to verify the length and frequency of your
pulses)?
Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131
"In theory there is no difference between theory and practice. In practice there is." -- Yogi Berra or Jan van de Snepscheut
________________________________________
From: 6... [6...] On Behalf Of d...@gmail.com [d...@gmail.com]
Sent: Friday, November 20, 2009 4:44 PM
To: 6...
Subject: [68HC12] Re: Controlling a Servo with the HC12?
I have been doing that. It refuses to turn any direction aside from clockwise. Do you see any issues with my code. This is what I have now.
PWMPOL = 0x01; // High at beginning, low at end (active high).
PWMPRCLK = 0x06; // Prescaler.
PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
PWMCAE = 0x00; // Sets left aligned PWM.
PWMCTL = 0x10; // Sets up ch0+1 16bit.
PWMPER0 = 0x09; // Sets up ch1 @ 43Hz w/ .000064 count.
PWMPER1 = 2499;
PWMDTY01 = 187;
PWME = 0x02;
PWMSCLA = 0x00;
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131
"In theory there is no difference between theory and practice. In practice there is." -- Yogi Berra or Jan van de Snepscheut
________________________________________
From: 6... [6...] On Behalf Of d...@gmail.com [d...@gmail.com]
Sent: Friday, November 20, 2009 4:44 PM
To: 6...
Subject: [68HC12] Re: Controlling a Servo with the HC12?
I have been doing that. It refuses to turn any direction aside from clockwise. Do you see any issues with my code. This is what I have now.
PWMPOL = 0x01; // High at beginning, low at end (active high).
PWMPRCLK = 0x06; // Prescaler.
PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
PWMCAE = 0x00; // Sets left aligned PWM.
PWMCTL = 0x10; // Sets up ch0+1 16bit.
PWMPER0 = 0x09; // Sets up ch1 @ 43Hz w/ .000064 count.
PWMPER1 = 2499;
PWMDTY01 = 187;
PWME = 0x02;
PWMSCLA = 0x00;
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Reply by ●November 20, 20092009-11-20
If your servo is chattering in its rotation, I would say that the frequency is
wrong.
If your servo continues to rotate, I would say that the PWM duty cycle is wrong (or upside down).
The numbers are based on the xtal frequency, so adjust appropriately.
This is the code that I used on my 24MHz DP512.
void PWMInit(void) {
/*
* Function Name: PWMInit
* Returns : void
* arg1 : void
* arg2 :
* arg3 :
* Created By : andreic
* Date Created : Dec 11, 2006
* Description :
* Notes :
*/
/*
* Bits 0 and 1 provides a 500kHz. PWM that is modulated in the one wire communications system
* Enable PWM on bit 0, set up the period as 24MHz/0.5MHz = 48 and duty cycle of 50% 0.5(48) = 24
*/
PWME_bit.PWME0 = 1;
PWMPER0 = 48;
PWMDTY0 = 24;
PWME_bit.PWME1 = 1;
PWMPER1 = 48;
PWMDTY1 = 24;
}
void PWMAlter(INT8U period) {
/*
* Function Name: PWMAlter
* Returns : void
* arg1 : period - divisor assuming a 24MHz clock
* arg2 :
* arg3 :
* Created By : andreic
* Date Created : Dec 11, 2006
* Description :
* Notes :
*/
PWME_bit.PWME0 = 1;
PWMPER0 = period;
PWMDTY0 = period/2;
PWME_bit.PWME1 = 1;
PWMPER1 = period;
PWMDTY1 = period/2;
}
A
On 2009-November-20, at 3:44 PM, d...@gmail.com wrote:
> I have been doing that. It refuses to turn any direction aside from clockwise. Do you see any issues with my code. This is what I have now.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x06; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER0 = 0x09; // Sets up ch1 @ 43Hz w/ .000064 count.
> PWMPER1 = 2499;
> PWMDTY01 = 187;
> PWME = 0x02;
> PWMSCLA = 0x00;
>
> Hello,
> >
> >I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
> >
> >Any help is appreciated. Here is my current code.
> >
> > PWMPOL = 0x01; // High at beginning, low at end (active high).
> > PWMPRCLK = 0x03; // Prescaler.
> > PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> > PWMCAE = 0x00; // Sets left aligned PWM.
> > PWMCTL = 0x10; // Sets up ch0+1 16bit.
> > PWMPER01 = 5000;
> > PWMDTY01 = 225;
> > PWME = 0x02;
> >
> >
>
---------------------
Andrei Chichak
Systems Developer
CBF Systems Inc.
4-038 NINT Innovation Centre
11421 Saskatchewan Drive
Edmonton, Alberta
Canada
T6G 2M9
Phone: 780-628-2072
Skype: andrei.chichak
If your servo continues to rotate, I would say that the PWM duty cycle is wrong (or upside down).
The numbers are based on the xtal frequency, so adjust appropriately.
This is the code that I used on my 24MHz DP512.
void PWMInit(void) {
/*
* Function Name: PWMInit
* Returns : void
* arg1 : void
* arg2 :
* arg3 :
* Created By : andreic
* Date Created : Dec 11, 2006
* Description :
* Notes :
*/
/*
* Bits 0 and 1 provides a 500kHz. PWM that is modulated in the one wire communications system
* Enable PWM on bit 0, set up the period as 24MHz/0.5MHz = 48 and duty cycle of 50% 0.5(48) = 24
*/
PWME_bit.PWME0 = 1;
PWMPER0 = 48;
PWMDTY0 = 24;
PWME_bit.PWME1 = 1;
PWMPER1 = 48;
PWMDTY1 = 24;
}
void PWMAlter(INT8U period) {
/*
* Function Name: PWMAlter
* Returns : void
* arg1 : period - divisor assuming a 24MHz clock
* arg2 :
* arg3 :
* Created By : andreic
* Date Created : Dec 11, 2006
* Description :
* Notes :
*/
PWME_bit.PWME0 = 1;
PWMPER0 = period;
PWMDTY0 = period/2;
PWME_bit.PWME1 = 1;
PWMPER1 = period;
PWMDTY1 = period/2;
}
A
On 2009-November-20, at 3:44 PM, d...@gmail.com wrote:
> I have been doing that. It refuses to turn any direction aside from clockwise. Do you see any issues with my code. This is what I have now.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x06; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER0 = 0x09; // Sets up ch1 @ 43Hz w/ .000064 count.
> PWMPER1 = 2499;
> PWMDTY01 = 187;
> PWME = 0x02;
> PWMSCLA = 0x00;
>
> Hello,
> >
> >I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
> >
> >Any help is appreciated. Here is my current code.
> >
> > PWMPOL = 0x01; // High at beginning, low at end (active high).
> > PWMPRCLK = 0x03; // Prescaler.
> > PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> > PWMCAE = 0x00; // Sets left aligned PWM.
> > PWMCTL = 0x10; // Sets up ch0+1 16bit.
> > PWMPER01 = 5000;
> > PWMDTY01 = 225;
> > PWME = 0x02;
> >
> >
>
---------------------
Andrei Chichak
Systems Developer
CBF Systems Inc.
4-038 NINT Innovation Centre
11421 Saskatchewan Drive
Edmonton, Alberta
Canada
T6G 2M9
Phone: 780-628-2072
Skype: andrei.chichak
Reply by ●November 20, 20092009-11-20
I do no have an oscilloscope. I am still looking at the code.
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Reply by ●November 20, 20092009-11-20
The wheel turns in one direction regardless of the frequency I set.
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008) using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest), 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin the motor, but it only ever spins in 1 direction and I can not make it stop spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Reply by ●November 20, 20092009-11-20
Its the mark to space you need to change, not the frequency.
Regards,
Darren
From: 6... [mailto:6...] On Behalf Of
d...@gmail.com
Sent: Saturday, 21 November 2009 10:33
To: 6...
Subject: [68HC12] Re: Controlling a Servo with the HC12?
The wheel turns in one direction regardless of the frequency I set.
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008)
using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest),
1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin
the motor, but it only ever spins in 1 direction and I can not make it stop
spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Regards,
Darren
From: 6... [mailto:6...] On Behalf Of
d...@gmail.com
Sent: Saturday, 21 November 2009 10:33
To: 6...
Subject: [68HC12] Re: Controlling a Servo with the HC12?
The wheel turns in one direction regardless of the frequency I set.
Hello,
>
>I am trying to control a Parallax Continuous Rotation Servo (#900-00008)
using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest),
1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can spin
the motor, but it only ever spins in 1 direction and I can not make it stop
spinning even if I try to calibrate it.
>
>Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Reply by ●November 21, 20092009-11-21
Can't verify all your settings, you didn't specify bus frequency. But
if
period setting is 5000 for 20ms, then duty cycle setting should be not 225,
but 1.5/20*5000 = 375 for rest, 325 for clockwise and 425 for ccw.
Edward
----- Original Message -----
From:
To: <6...>
Sent: Friday, November 20, 2009 9:55 PM
Subject: [68HC12] Controlling a Servo with the HC12?
> Hello,
>
> I am trying to control a Parallax Continuous Rotation Servo (#900-00008)
> using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest),
> 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can
> spin the motor, but it only ever spins in 1 direction and I can not make
> it stop spinning even if I try to calibrate it.
>
> Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
period setting is 5000 for 20ms, then duty cycle setting should be not 225,
but 1.5/20*5000 = 375 for rest, 325 for clockwise and 425 for ccw.
Edward
----- Original Message -----
From:
To: <6...>
Sent: Friday, November 20, 2009 9:55 PM
Subject: [68HC12] Controlling a Servo with the HC12?
> Hello,
>
> I am trying to control a Parallax Continuous Rotation Servo (#900-00008)
> using my MC9S12C128CFUE. I need to to use PWM to give a pulse 1.5ms(rest),
> 1.3ms (clockwise), and 1.7ms (counter-clockwise) every 20ms/50Hz. I can
> spin the motor, but it only ever spins in 1 direction and I can not make
> it stop spinning even if I try to calibrate it.
>
> Any help is appreciated. Here is my current code.
>
> PWMPOL = 0x01; // High at beginning, low at end (active high).
> PWMPRCLK = 0x03; // Prescaler.
> PWMCLK = 0x00; // Sets clock A to be ch 1 clock.
> PWMCAE = 0x00; // Sets left aligned PWM.
> PWMCTL = 0x10; // Sets up ch0+1 16bit.
> PWMPER01 = 5000;
> PWMDTY01 = 225;
> PWME = 0x02;
>
Reply by ●November 21, 20092009-11-21
If only the answer was so simple. I've tried various methods. My bus runs
at 2MHz.
I did try that for the duty cycle. I've tried various different prescaler settings. I can not get the motor to turn more than 1 way. I've also tried another motor with the same issues.
I have the servo connected to 3 double A batteries, tied the ground with the microcontroller ground. The microcontroller is running off of USB power from my computer. I have PWM channel 1 connected to the pulse in of the servo.
--Original Message--
>Can't verify all your settings, you didn't specify bus frequency. But if
>period setting is 5000 for 20ms, then duty cycle setting should be not 225,
>but 1.5/20*5000 = 375 for rest, 325 for clockwise and 425 for ccw.
>
>Edward
I did try that for the duty cycle. I've tried various different prescaler settings. I can not get the motor to turn more than 1 way. I've also tried another motor with the same issues.
I have the servo connected to 3 double A batteries, tied the ground with the microcontroller ground. The microcontroller is running off of USB power from my computer. I have PWM channel 1 connected to the pulse in of the servo.
--Original Message--
>Can't verify all your settings, you didn't specify bus frequency. But if
>period setting is 5000 for 20ms, then duty cycle setting should be not 225,
>but 1.5/20*5000 = 375 for rest, 325 for clockwise and 425 for ccw.
>
>Edward