View Single Post
  #10   Spotlight this post!  
Unread 30-10-2003, 14:47
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Code:
if (F_Count < MAX_FUNC)
{
    counter ++;

    if (counter > Func[F_Count][2]*58)
    {
        counter =0;
        F_Count ++;
    }

    if (F_Count == MAX_FUNC) 
    {
        F_Count = 0;
    }
    pwm03 = Func[F_Count][0];
    pwm04 = Func[F_Count][1];

}
Notice that in the above code, the outer conditional tests to see if F_Count < MAX_FUNC. Assume F_Count is one less, and that the counter has elapsed. Okay, so the F_Count++ line gets executed, and F_Count == MAX_FUNC, so the second inner conditional is true, and sets F_Count to 0. Then pwm0[34] are set with the new F_Count value, which is 0. This means that the last function values never get used. You might try puting the second inner conditional AFTER the pwm assign statements.

And to get finer granularity using decimal values, just change the '58' in Func[F_Count][2]*58, to something smaller. It won't be very precise, and you'll have to find out the Func[F_Count][2] numbers empiracally, but it should be able to emulate the behaivor with using floats currently pretty well I'd imagine.