Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/28/04 11:55
Read: times


 
#78258 - Encoder Direction
Responding to: ???'s previous message
Sorry to add one more problem. This about the encoder.

I have an encoder from HONTKO (HTR-M2-500-2-C)

This encoder have two outputs 90 degree out of phase. Now with this I can have a direction sensing. So I took both the outputs on the external interrupts.

O1 -- INT0
O2 -- INT1

The interrupt routings are as follows

bit Int_accept;
unsigned char counted_pulses[6];

void int0(void) interrupt 0 using 0
{
if(Int_accept)
{
pulse_count++;
increment();
Int_accept=0;
}
}

void int1(void) interrupt 2 using 1
{
if(P3_2)
{
Int_accept=1;
}
else Int_accept=0;
}

void increment()
{
if(counted_pulses[0]>=9)
{
counted_pulses[0]=0;
if(counted_pulses[1]>=9)
{
counted_pulses[1]=0;
if(counted_pulses[2]>=9)
{
counted_pulses[2]=0;
if(counted_pulses[3]>=9)
{
counted_pulses[3]=0;
if(counted_pulses[4]>=9)
{
counted_pulses[4]=0;
if(counted_pulses[5]>=9)
counted_pulses[5]=0;
else
counted_pulses[5]++;
}
else
counted_pulses[4]++;
}
else
counted_pulses[3]++;
}
else
counted_pulses[2]++;
}
else
counted_pulses[1]++;
}
else
counted_pulses[0]++;
}

With this the encoder pulses should be accepted only in one direction and other direction should be ignored.

But actually the pulses are accepted in both directions. In one direction (required dir) all pulses are accepted and in the other only few are accepted.

say in required direction if I get 500 pulses for one revolution then in other direction I will get may be only 6-7 pulses.

I want to have the programe which wil not miss the direction track and will not count in reverse direction.

Kindly help. Also let me know the HTML tags for pasting the code:-)


Thanks
Sachin




List of 26 messages in thread
TopicAuthorDate
Keil strncpy function doubt?????            01/01/70 00:00      
   RE: Keil strncpy function doubt?????            01/01/70 00:00      
      RE: Keil strncpy function doubt?????            01/01/70 00:00      
   RE: Keil strncpy function doubt?????            01/01/70 00:00      
      RE: Keil strncpy function doubt?????            01/01/70 00:00      
         RE: Keil strncpy function doubt?????            01/01/70 00:00      
            Encoder Direction            01/01/70 00:00      
               RE: Encoder Direction            01/01/70 00:00      
                  RE: Encoder Direction            01/01/70 00:00      
                     RE: Encoder Direction            01/01/70 00:00      
                        RE: Encoder Direction            01/01/70 00:00      
                           RE: Encoder Direction            01/01/70 00:00      
                              RE: Encoder Direction            01/01/70 00:00      
                     RE: Encoder Direction            01/01/70 00:00      
                        Thanks a *            01/01/70 00:00      
                        Need help for low ESR Capacitors            01/01/70 00:00      
         RE: Keil strncpy function doubt?????            01/01/70 00:00      
      RE: Keil strncpy function doubt?????            01/01/70 00:00      
   RE: Programming style            01/01/70 00:00      
      RE: Programming style            01/01/70 00:00      
      RE: Programming style            01/01/70 00:00      
   RE: Keil strncpy function doubt?????            01/01/70 00:00      
      RE: Keil strncpy function doubt?????            01/01/70 00:00      
         RE: Keil strncpy function doubt?????            01/01/70 00:00      
   Copying structures            01/01/70 00:00      
      RE: Copying structures            01/01/70 00:00      

Back to Subject List