View Single Post
  #2   Spotlight this post!  
Unread 27-02-2007, 11:46
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: encoder counting and onscreen feedback *ASAP

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).
Code:
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\n", (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.
Attached Files
File Type: zip RPM Test.zip (1.9 KB, 63 views)
__________________
Eric Haskins KC9JVH