Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   encoder counting and onscreen feedback *ASAP (http://www.chiefdelphi.com/forums/showthread.php?t=55053)

Greg Needel 27-02-2007 10:58

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.

EHaskins 27-02-2007 11:46

Re: encoder counting and onscreen feedback *ASAP
 
1 Attachment(s)
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.

Kingofl337 28-02-2007 09:11

Re: encoder counting and onscreen feedback *ASAP
 
Greg, did the encoder win or did you?


All times are GMT -5. The time now is 04:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi