Thanks for the explanation. Below is the first attempt...
NOTE: I varied 'j' value frm 10 to like 150 or so to see if they were any changes, but no change
#define shaftencoder 1
float get_spd()
{
int count, j= 0,b = 0;
float rev,delta, ft_per_sec, srtT, stT;
enable_encoder(shaftencoder);
reset_encoder(shaftencoder);
srtT= seconds();
while (j<10){
b = read_encoder(shaftencoder);
j=j+1;
}
stT= seconds();
delta = stT-srtT; // Time Revolutions were recoreded
rev = ((float) b)/17.0; // One complete revolution equals b/17;
return ft_per_sec = (rev/delta)*(2.0/3.0); // ft/sec
}
float get_spd()
{
int count, j= 0,b = 0;
float rev,delta, ft_per_sec, srtT, stT;
enable_encoder(shaftencoder);
reset_encoder(shaftencoder);
srtT= seconds();
while (j<10){
b = read_encoder(shaftencoder);
j=j+1;
}
stT= seconds();
delta = stT-srtT; // Time Revolutions were recoreded
rev = ((float) b)/17.0; // One complete revolution equals b/17;
return ft_per_sec = (rev/delta)*(2.0/3.0); // ft/sec
}
and the second time I modified to a little bit .......to
NOTE: the function is the same as above but with an exception that I am reading encoder's output multiple times and then taking the average of them for my output value.........but even this did not give a smooth constant value over time. I did one more thing here I kept the Ts constant.
reset_encoder(shaftencoder);
servo0=3500;
bAvg=0.0;
for (k= 1; (k< 20 ); k++){
reset_encoder(shaftencoder);
i=0;
while(i<10){
b = read_encoder(shaftencoder);
i = i+1;
msleep(1L);
}
bAvg= ((float)b)+bAvg;
}
//T[j]= s2-s1;
Ts=0.03103492;
Rev[j]=((int) (bAvg)/19);
ftPerSec[j]= 0.75*((float)(Rev[j])/(104.0*(Ts)));
servo0=3500;
bAvg=0.0;
for (k= 1; (k< 20 ); k++){
reset_encoder(shaftencoder);
i=0;
while(i<10){
b = read_encoder(shaftencoder);
i = i+1;
msleep(1L);
}
bAvg= ((float)b)+bAvg;
}
//T[j]= s2-s1;
Ts=0.03103492;
Rev[j]=((int) (bAvg)/19);
ftPerSec[j]= 0.75*((float)(Rev[j])/(104.0*(Ts)));
Let me know what you guys think. Any help is greatly appreciated...thanks in advance.
Jim Peterson <jimcp@...> wrote:
Actually I was suggesting you post to the board. What I think needs to be shown is how you are transforming the encoder counts to RPM, You need to have the time between samples, and the count delta, and then compute the RPM. If you are using IC to do the programming, the mseconds() returns milliseconds, if your loop averages 10ms the potential delta calculation will vary by 10% in actual time elapsed. The variation will be even larger if the encoder tics are more than 2ms apart. Lets say they are 4ms between tics and our program loop is 10ms. That means some loops will count 2 tics and some 3 so you will see a 33% variation is speed calculations. These problems can be reduced if you force the rate calculation to be at some larger interval like every 100ms at the 4ms per tick rate expanding the sample interval should get the rate calculation error down to 4%. If we get more than one tick per ms we should be able to compute to around 1% accuracy.Hope that helps,Jim-----Original Message-----
From: Sumo11users@yahoogroups.com [mailto:Sumo11users@yahoogroups.com] On Behalf Of Belal Ahmad
Sent: Thursday, July 20, 2006 8:03 PM
To: Sumo11users@yahoogroups.com
Subject: RE: [Sumo11users] Re: Error Messages when downloadingSure, I have no problem sharing my code. Infact, I would prefer that to make sure that I am not making any mistakes. Do you want me to sent it to this address as an attachment?
Jim Peterson <jimcp@...> wrote:I am sure your programming is beyond reproach, everyone’s is. but would you mind sharing your actual logic for the RPM calculation with the encoders? I really suspect that is the issue. Also, you should confirm that the physical encoders are working correctly. That is mount them on an axel and verify that one revolution always produces the correct number of ticks for the resolution of the devices…Jim -----Original Message-----
From: Sumo11users@yahoogroups.com [mailto:Sumo11users@yahoogroups.com] On Behalf Of Belal Ahmad
Sent:Thursday, July 13, 2006 6:02 PM To: Sumo11users@yahoogroups.com
Subject: Re: [Sumo11users] Re: Error Messages when downloading Thanks Dan, I appreciate your help. Please let me know if you run accross a fix for the encoder problem. It is hindering with my control system, I hope there is fix for it.
Dan Gates <topazx2@...> wrote:Hi,
Sorry for the delayed response. Please note that the error message
has absolutly no ill effect on Sumo11 functionality and can simply be
ignored. However it is annoying and can be fixed fairly easyily by
overwriting the lib_sumo11.frm file with the one found in the files
section of this groups message brd.
There was a mixup in communication with the last release of IC, I was
told that the new version would be defined as IC 5.0 and built the
Sumo11 firmware under that assumtion. I sent my files in to be
compiled with the new release of IC and found out later that the
revision did not go to IC 5.0 but 4.301 instead. Anyway, it was
Botball season and the developers of IC did not want to make any
changes at that time, so the Sumo11 gets the error.
As for the encoder issue, I'll have to look into that some more. I do
seem to remember a similar issue I had with the Handyboard, but it was
something to do with the way I set up the encoders in my code. More on
this later.
-Dan
--- In Sumo11users@yahoogroups. , "bxa1322003" <bxa1322003@com ...> wrote:
>
> Hello,
>
> Whenever I download a program, I get the following error that reads...
>
> "Please note that the version (430) of the library currently in use
> does not match the version (501) of the firmware on the controller on
> the board. This can result in undefined behavior"
>
> Is there a fix for this?
>
> Also, I have an encoder reading the rpms of dc motor, the value never
> reaches a constant value. The voltage and current of the dc motor are
> constant, but never reaches a steady-state-value. Any ideas?
>
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1˘/min.Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2˘/min or less.
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.