encoder counting and onscreen feedback *ASAP

Hey,
I am working on a project and need some help. I am using a vex wheel encoder connected to a shaft which I need to see # of revolutions and RPM on my computer. I was thinking I could do this through the real time link with the controller. I really have no idea where to start and I have a signifigant time crunch on this. Also what is the max RPM that the encoder can detect, I am planning on using it at about 450 RPM.

Thanks…

P.s. this is for 5:00 tonight (2/27) any help would be appreciated.

The vex encoder ticks 90 times per revolution. That is ~700 ticks a sec. at 450 rpm. The vex controller may be able to handle that, but I haven’t tried it.

You could use the terminal built into IFI/Intelitek Loader. I assume you will want to use EasyC if you’re on a tight schedule. If you are not familiar with MPLab, interrupts, and timers, then you want to use EasyC.

I would suggest somthing like this(this is easyC).


void Main (void)
{
  unsigned long count = 0;
  unsigned long old_count = 0;
  unsigned long timer;
  unsigned long old_timer;
  int rpm;
  int diff;

  StartEncoder(1);
  StartTimer(1);
  while(1)
  {
     timer = GetTimer(1);
     if (timer - old timer >= 1000) //only do the calculation once a second.
     {
        old_timer = timer;
        count = GetEncoder(1);
        diff = count - old_count;
        old_count = count;
        rpm = (diff * 60) / 90; //# of ticks * 90 secs / 90 ticks per rev.
        PrintToScreen("RPM = %d
", (int)rpm;
     }
  }
}  

I have not tested this code, but it should at least get you started.

I have attached an EasyC pro project(vex) with this code.

RPM Test.zip (1.9 KB)


RPM Test.zip (1.9 KB)

Greg, did the encoder win or did you?