Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | Encoder Integration

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

Encoder Integration - Paul Williams - Jul 31 8:05:50 2006

I am having trouble integrating an encoder into my code for a MC9S12D64. I
am using ICC12 and am using a combination of C and assembly.

I have tried using a timer interrupt with a table lookup and have got less
than adequate results. Ie < 20 Hz

I am looking to get a quadrature encoder input of approx 2Khz.

My question is will a HCTL 2020 or equivalent using a PWM output (8Mhz CPU
CLK) from the MCU be able to cope with the sample rate and evaluation of the
position adequately to be able to update a fuzzy control algorithm to
control the position of a servo motor

Thanks for any advice

Paul

[Non-text portions of this message have been removed]



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: Encoder Integration - Rob Milne - Jul 31 11:03:01 2006

Yes. My inverted pendulum fuzzy routine executes in 10.5usec at 24Mhz
(I'm using a C32). A 2KHz servo rate would uses only approx. 2% of
processor time. Since the fuzzy ops are interruptible (worst case
appears to be 8 cycle loop inside WAV) it is possible to use the input
timer interrupts for the encoder - no encoder chip is required if the
max rpm is reasonable.

If you check all edges (max resolution) then the interrupt rate for a
400 count encoder at 5 rev/sec is 8000 interrupts/sec or 125usec. My
input timer interrupts execute in 1.75/1.83 usec at 24MHz depending on
branching. This leaves a lot of time per interrupt for fuzzy algo and
pid setup. I've not spent the time to calculate the max rpm possible
since the system is fast enough for my requirements (only so many hours
in a life).

-rob

Paul Williams wrote:
> I am having trouble integrating an encoder into my code for a MC9S12D64. I
> am using ICC12 and am using a combination of C and assembly.
>
> I have tried using a timer interrupt with a table lookup and have got less
> than adequate results. Ie < 20 Hz
>
> I am looking to get a quadrature encoder input of approx 2Khz.
>
> My question is will a HCTL 2020 or equivalent using a PWM output (8Mhz CPU
> CLK) from the MCU be able to cope with the sample rate and evaluation of the
> position adequately to be able to update a fuzzy control algorithm to
> control the position of a servo motor
>
> Thanks for any advice
>
> Paul
>
> [Non-text portions of this message have been removed]



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

RE: Encoder Integration - Paul Williams - Aug 1 4:31:52 2006

Thanks for the help

I will give it a go using the edge detection. I was previously using a Timer
7 interrupt and a table lookup for the encoder state. But as you have stated
the edge detection should be able to handle the encoder adequately.

Thanks for the help
Paul

-----Original Message-----
From: 6...@yahoogroups.com [mailto:6...@yahoogroups.com] On Behalf Of
Rob Milne
Sent: Tuesday, 1 August 2006 1:04 AM
To: 6...@yahoogroups.com
Subject: Re: [68HC12] Encoder Integration

Yes. My inverted pendulum fuzzy routine executes in 10.5usec at 24Mhz
(I'm using a C32). A 2KHz servo rate would uses only approx. 2% of
processor time. Since the fuzzy ops are interruptible (worst case
appears to be 8 cycle loop inside WAV) it is possible to use the input
timer interrupts for the encoder - no encoder chip is required if the
max rpm is reasonable.

If you check all edges (max resolution) then the interrupt rate for a
400 count encoder at 5 rev/sec is 8000 interrupts/sec or 125usec. My
input timer interrupts execute in 1.75/1.83 usec at 24MHz depending on
branching. This leaves a lot of time per interrupt for fuzzy algo and
pid setup. I've not spent the time to calculate the max rpm possible
since the system is fast enough for my requirements (only so many hours
in a life).

-rob

Paul Williams wrote:
> I am having trouble integrating an encoder into my code for a MC9S12D64. I
> am using ICC12 and am using a combination of C and assembly.
>
> I have tried using a timer interrupt with a table lookup and have got less
> than adequate results. Ie < 20 Hz
>
> I am looking to get a quadrature encoder input of approx 2Khz.
>
> My question is will a HCTL 2020 or equivalent using a PWM output (8Mhz CPU
> CLK) from the MCU be able to cope with the sample rate and evaluation of
the
> position adequately to be able to update a fuzzy control algorithm to
> control the position of a servo motor
>
> Thanks for any advice
>
> Paul
>
> [Non-text portions of this message have been removed]



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )