Encoders aren't changing correctly
Author |
Message |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Encoders aren't changing correctly
Like I said, your loop time is not constant. You really need to divide the delta by time to get the real speed. Your "rate" should be calculated by (Array[Index] - Array[Index - 1])*1000/Array4[Index] Also note that even with this calculation, the data should look reasonable but may still be fluctuating a little bit probably due to unbalanced wheels etc.
|
Sat Jan 04, 2014 10:26 pm |
|
 |
kitbear23
Rookie
Joined: Thu Jan 02, 2014 11:04 pm Posts: 15
|
 Re: Encoders aren't changing correctly
Thank you. I will try the new equation. also i don't believe it is because of an unbalanced wheel because we are using treads on our robot
Thanks again, kitbear23
|
Mon Jan 06, 2014 6:18 pm |
|
 |
Ford Prefect
Guru
Joined: Sat Mar 01, 2008 12:52 pm Posts: 1030
|
 Re: Encoders aren't changing correctly
there is nothing harder to balance or to synchronise or do odometry stuff with like dealing with tank treads. 
_________________ regards, HaWe aka Ford #define S sqrt(t+2*i*i)<2 #define F(a,b) for(a=0;a<b;++a) float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}
Last edited by Ford Prefect on Tue Jan 07, 2014 12:46 pm, edited 1 time in total.
|
Mon Jan 06, 2014 7:01 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Encoders aren't changing correctly
You will be surprised. In the past, I have logged data that has a periodic speed slow down. It turns out the motor has some mechanical binding only at a certain angle. So the motor turns fine until it hits that angle and it slowed down a bit. And it showed in the data log.
|
Mon Jan 06, 2014 8:09 pm |
|
 |
kitbear23
Rookie
Joined: Thu Jan 02, 2014 11:04 pm Posts: 15
|
 Re: Encoders aren't changing correctly
Ok so there might be something mechanically wrong in the motors or something? that kind of explains it because it fluctuates a little when we go slow but the faster it gets the more fluctuation.
|
Mon Jan 06, 2014 8:54 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Encoders aren't changing correctly
You should be able to turn the wheels by hand and feel the resistance at a certain angle.
|
Mon Jan 06, 2014 8:57 pm |
|
 |
Ford Prefect
Guru
Joined: Sat Mar 01, 2008 12:52 pm Posts: 1030
|
 Re: Encoders aren't changing correctly
sry, OT: what is nPgmTime ?
_________________ regards, HaWe aka Ford #define S sqrt(t+2*i*i)<2 #define F(a,b) for(a=0;a<b;++a) float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}
|
Tue Jan 07, 2014 11:48 am |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Encoders aren't changing correctly
nPgmTime is the system timestamp in msec.
|
Tue Jan 07, 2014 3:36 pm |
|
 |
Ford Prefect
Guru
Joined: Sat Mar 01, 2008 12:52 pm Posts: 1030
|
 Re: Encoders aren't changing correctly
and what is nSysTime opposite to it?
aah - I assume:
nSysTime is time since the sys_timer (the NXT) was switched on (sort of ANSI C: time(0) )
nPgmTime is time since the program was started (ANSI C: clock() )
correct?
_________________ regards, HaWe aka Ford #define S sqrt(t+2*i*i)<2 #define F(a,b) for(a=0;a<b;++a) float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}
|
Tue Jan 07, 2014 5:54 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Encoders aren't changing correctly
Direct cut and paste from RobotC help:
|
Wed Jan 08, 2014 4:17 am |
|
 |
Ford Prefect
Guru
Joined: Sat Mar 01, 2008 12:52 pm Posts: 1030
|
 Re: Encoders aren't changing correctly
thank you!
_________________ regards, HaWe aka Ford #define S sqrt(t+2*i*i)<2 #define F(a,b) for(a=0;a<b;++a) float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}
|
Wed Jan 08, 2014 5:49 am |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Encoders aren't changing correctly
BTW, I don't quite trust the documentation I cut and pasted because I know for a fact that nPgmTime is actually unsigned long and I believe it's actually 32-bit not just the low 16-bit. You can easily test that though. If it were really 16-bit even unsigned, it would roll-over in 65 second. I am very sure the time did not roll-over in a little over one minute. My intention of cutting and pasting the doc was to show you the difference between nPgmTime and nSysTime that one is cumulative since powering up and one is cumulative since program start. That's all you should trust.
|
Wed Jan 08, 2014 5:57 am |
|
 |
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 620
|
 Re: Encoders aren't changing correctly
Everything used to be 16-bits until 3.0 and the overhaul with pointers/etc. They're now 32-bits.
We also looked at making int's by default 32bits, but too many weird things were occurring so we forced them back to 16-bits for the time being.
We're overhauling the help documentation with the loss of data on the Wiki - so we'll be reviewing all of this content in the coming months.
Thanks.
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
Thu Jan 16, 2014 3:52 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|