HI! I have a project I am bringing over to PIC from Arduino that controls a self-aquire satellite dish. There are no limit switches so I am performing a homing procedure using velocity, specifically, a sudden decrease in velocity, to determine the edge of range of motion. ie, "When the motor starts to significantly bog and slow down, STOP, and call this 0. The current code looks something like this..
(Obviously, it's looped in the program. About every 1/4 second or so..)
newposition = encoder0Pos;
newtime = millis();
if(newposition > oldposition)
{
newvel = (newposition-oldposition) * 1000 /(newtime-oldtime);
}
else if(oldposition > newposition)
{
newvel = (oldposition-newposition) * 1000 /(newtime-oldtime);
}
oldposition = newposition;
oldtime = newtime;
My question is the newtime=millis().... How do I get an equivelent in PBP? Since I am not looking to output this in any terms of RPMs or anything, it doesn't have to be absolute. Could be time, clock cycles, or whatever, it really doesn't matter as long as its accurate relative to itself.