cancel
Showing results for 
Search instead for 
Did you mean: 

CAPCOM T0 Counter mode

suranjan
Associate II
Posted on December 15, 2004 at 11:20

CAPCOM T0 Counter mode

4 REPLIES 4
suranjan
Associate II
Posted on December 13, 2004 at 13:08

Hello all,

I am a newbie in microcontroller programming. I am using ST10 microcontroller. My problem is

to determine the speed of a BLDC motor by using three hall sensors.The hall sensors are

connected to ports P8_2,P8_3 and P8_4.My idea is to use only one hall sensor (if possible)

to count the number of pulses in a certain period of time. Each hall sensor remains high for

180 electrical degree and low for the other 180°.My motor has 3 pole-pairs. So, three

electrical cycles are needed for the completion of a mechanical cycle.From this information

I can calculate the speed if I can count the number of pulses.If I am right, for one

mechanical cycle, 6 pulses (3 high, 3 low) can be detected.

I would like to use CAMCOM T0 in counter mode:

//CAPCOM T0 counter mode

void Capcom0Init(void)

{

T01CON = 0x0009;

T0 = 0x0000;

T0REL = 0x0000;

T01CON |= 0x0040;

}

To be true, I got this code from a DC motor control code. I am not sure,how and which port

can be associated with the above code to give T0 values.

The following skeleton (taken from the same source) function calculates the speed:

// Function: GetSpeed

// Purpose: Counts the number of pulses over a given time interval. Uses this value to

calculate the speed

// It uses CAPCOM 16, which is connected to P8_0. CAPCOM 16 is timed with Timer 7.

// Input conditions: P3_0 configured as input (in initialize).

// Destroys: P3_0

// Returns: Speed (m/sec)

float GetSpeed(int ticks,float timeInterval)

{

-----

}

Would be please anybody be kind to clarify my doubts?

Thanks

suranjan
Associate II
Posted on December 14, 2004 at 10:45

Hi Neila,

Thank you very much for your reply. I am trying to undestand your explanation. I would ask you my questions later.

Thank you again.

suranjan
Associate II
Posted on December 15, 2004 at 09:15

Hi Neila,

I have a question--what value does CAPCOM Timer 0/1 or 7/8 Register give--an integer value or a floating value or anything else?

If I want to use this time value for other calculation (e.g. speed) , how can I use this value?

Thanks

suranjan
Associate II
Posted on December 15, 2004 at 11:20

Hi Neila,

Thanks again

Regen