View unanswered posts | View active topics It is currently Wed Jul 30, 2014 1:58 pm






Reply to topic  [ 14 posts ] 
nMotorEncoder reset 
Author Message
Rookie

Joined: Mon Jul 06, 2009 2:59 pm
Posts: 13
Location: Baia Mare, Romania
Post nMotorEncoder reset
Hello,
I realised during my testing that the nMotorEncoder resets after the nMotorEncoderTarget command. My project requires a nMotorEncoder that never resets(unless I tell so). Can I do something about that?I tried to find the function in the include files to modify it but with no success. What I am needing is like "total tach" from the debugger window.
So far I built a task that keeps the count but in fast oscilative movements(with other tasks working) it skips some ticks :( .
Any help would be highly apreciated.

Best Regards,
George T.


Thu Jul 23, 2009 3:46 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: nMotorEncoder reset
The solution is to not use the nMotorEncoderTarget feature and do the tests yourself. I suggest creating your own array of target values and having a separate task that loops forever checking the position of each encoder and stopping any motor(s) that have met or exceeded their target. That way you can use it just like the built in behavior but without the reset feature. You will need to think about how to deal with the counters wrapping and other similar boundry conditions.

_________________
Jeff McBride
Benson Robotics Club


Thu Jul 23, 2009 6:41 pm
Profile
Rookie

Joined: Mon Jul 06, 2009 2:59 pm
Posts: 13
Location: Baia Mare, Romania
Post Re: nMotorEncoder reset
I understand what you say but nMotorEncoderTarget is very good because it has that slow-to-stop movement that skips in the worst case 1 tick. That is why I tried to change the nMotorEncoder.But how does nMotorEncoderTarget slows?that´s why I asked for the include.Is it using PID based algorithm?

Best Regards,
George T.


Fri Jul 24, 2009 2:41 am
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: nMotorEncoder reset
I don't know for sure what method it is using but I would guess that it uses PID. Are you using standard LEGO motors? The code for Tetrix motors is likely to be quite different since the encoders have about 10x the resolution of the LEGO motors.

_________________
Jeff McBride
Benson Robotics Club


Fri Jul 24, 2009 12:22 pm
Profile
Rookie

Joined: Mon Jul 06, 2009 2:59 pm
Posts: 13
Location: Baia Mare, Romania
Post Re: nMotorEncoder reset
I am using standard Lego motors. But one question still remains: Where is the file with the code of the nMotorEncoderTarget and nMotorEncoder?

Best Regards,
George T.


Fri Jul 24, 2009 1:29 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: nMotorEncoder reset
there is no certain file. It's a hidden obscured undocumented function, certainly a feature, not a bug ;)

_________________
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)}


Fri Jul 24, 2009 1:38 pm
Profile
Rookie

Joined: Mon Jul 06, 2009 2:59 pm
Posts: 13
Location: Baia Mare, Romania
Post Re: nMotorEncoder reset
:lol: Sarcastic as usual...


Fri Jul 24, 2009 1:43 pm
Profile
Rookie

Joined: Mon Jul 06, 2009 2:59 pm
Posts: 13
Location: Baia Mare, Romania
Post Re: nMotorEncoder reset
well I've built a PD algorithm that works theoretically. But when I try to add the Integral part everyting goes messy(the motor runs endlessly). I used the constants that were apearing in the robotc debugging window(450,50,650) and divided the whole PID ecuation by 100. Are these the correct constants that the nMotorEncoderTarget is using? If not I haven't found a good way of finding them. Trial and error sounds a bit to time consuming so if anyone knows a theoretical way of finding them(or a more theoretical trial and error) it would be really apreciated. I read about the Ziegler–Nichols algorithm but calculating the oscilation period of the motor is quite triky because it oscilates very fast. All in all this is what I wrote so far:

Code:
Void nMotorEncodeTargetNoReset(tMotor link, int nTargetNew){
  int nDtargetOld,nDtargetNew,nValue;
  float fIntegral;
  const float Kp=i will have to find out
  const float ki -//-
  const float kd -//-

  nDTargetOld=nTargetNew-nMotorEncoder[link];
  do {
    nDtargetnew=ntargetnew-nMotorEncoder[link];
    fintegral=fintegral+nDtargetnew;
    fValue=nDtargetNew*kp+integral*ki+(nDtargetNew-nDtargetOld)*kd;
    if (fValue>100)
       motor[link]=100;
    else if (fValue<-100)
       motor[link]=-100;
    else
       motor[link]=fValue;
    nDTargeOld=nDTargetNew;
  }while(nMotorRunState!=Run_State_idle);


There may be some syntax errors because I worte it from my rememberings(i don't have my laptop with my files right now).

EDITED by Miki to add code tags around code section


Last edited by miki on Thu Apr 26, 2012 6:26 am, edited 1 time in total.

adding BBCode tags around code section. Please use them :-)



Thu Jul 30, 2009 1:43 pm
Profile
Moderator
Moderator
User avatar

Joined: Thu Dec 22, 2011 7:42 am
Posts: 43
Post Re: nMotorEncoder reset
todorangrg wrote:
Where is the file with the code of the nMotorEncoderTarget and nMotorEncoder?
Hi todorangrg,
I would say this code is part of the firmware released with RobotC and can't be find (as source code) in programs running over it.
Miki.

_________________
Visit my project RainBot v0.11 on source forge, a 6 wheels robot featuring A* & Dijkstra's path finding, motors & sensors emulation, small font, fifo & sorted list libraries, using Xander's drivers for HT Compass, and documented with doxygen.


Thu Apr 26, 2012 4:39 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: nMotorEncoder reset
Um, not to be rude Miki, but why did you revive a thread of 3-years age?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Apr 27, 2012 10:09 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Thu Dec 22, 2011 7:42 am
Posts: 43
Post Re: nMotorEncoder reset
well :roll: just after I rescued my PC, I tested it a bit to check if everything was ok. I went on RobotC forum and answered to this new topic.
then I updated the PC clock :? :mrgreen:

Miki.

_________________
Visit my project RainBot v0.11 on source forge, a 6 wheels robot featuring A* & Dijkstra's path finding, motors & sensors emulation, small font, fifo & sorted list libraries, using Xander's drivers for HT Compass, and documented with doxygen.


Sat Apr 28, 2012 5:07 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: nMotorEncoder reset
Aha, I was wondering about that. I was curious that I'd never seen this thread before, and then I noticed Ford Perfect had posted, and after much surprise, I noticed the date. Does phpBB really work off of your system time? :shock:

_________________
sudo rm -rf /


Sat Apr 28, 2012 8:24 am
Profile
Moderator
Moderator
User avatar

Joined: Thu Dec 22, 2011 7:42 am
Posts: 43
Post Re: nMotorEncoder reset
Hum. you may be right. :wink: The fact my PC believed we were in 2002 doesn't explain anything. It is possible that I saw a new post (the one stamped April 24th, 2012, 12:41 pm) of todorangrg and then I navigate in his posts without paying attention to their date. :roll:


April 24th, 2012, 12:41 pm

_________________
Visit my project RainBot v0.11 on source forge, a 6 wheels robot featuring A* & Dijkstra's path finding, motors & sensors emulation, small font, fifo & sorted list libraries, using Xander's drivers for HT Compass, and documented with doxygen.


Sat Apr 28, 2012 10:41 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: nMotorEncoder reset
miki wrote:
Hum. you may be right. :wink: The fact my PC believed we were in 2002 doesn't explain anything. It is possible that I saw a new post (the one stamped April 24th, 2012, 12:41 pm) of todorangrg and then I navigate in his posts without paying attention to their date. :roll:


April 24th, 2012, 12:41 pm


I hereby award you the prize for longest unintended thread bump in history!!!!!

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sat Apr 28, 2012 10:53 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.