Go to Post If you promote not only the growth of your own team but of other teams at other schools you are successful. - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-05-2016, 20:25
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 235
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Continuous Feedback Sensor on CANTalon

Does anyone know if the CANTalon PID supports continuous feedback like the PIDController does?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #2   Spotlight this post!  
Unread 08-05-2016, 21:41
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Continuous Feedback Sensor on CANTalon

Hey Tim
Actually the sensor feedback is continuous by default.

AnalogEncoder is continuous (over and under wraps are tracked so 3.3V=>0V equates to sensor pos 1023=>1024).

Same is true for PulseWidth sensors and the CTRE Magnetic Encoder.

AnalogPot is not continuous (meant to be used with analog sources that cannot wrap).
Reply With Quote
  #3   Spotlight this post!  
Unread 08-05-2016, 22:31
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 235
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Continuous Feedback Sensor on CANTalon

Quote:
Originally Posted by ozrien View Post
Hey Tim
Actually the sensor feedback is continuous by default.
So if the sensor is at 200 and I want it to go to 1000 it will go backwards 223?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #4   Spotlight this post!  
Unread 09-05-2016, 16:41
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Continuous Feedback Sensor on CANTalon

Quote:
Originally Posted by TimTheGreat View Post
So if the sensor is at 200 and I want it to go to 1000 it will go backwards 223?
So assuming 1024 units per rotation (analog sensor), if you want to go "backwards" set the target to -23. This will move backwards by -223 (since your current position is 200), instead of moving forward by 800 (pos200=>pos1000).

The basic idea is if you want to move forward, use the appropriate multiple of your target position in the positive direction. If you want to move reverse, use the appropriate multiple in the negative direction. If you want to servo using the shortest distance, calculate how far the target is moving forward, and moving backwards, pick the shortest one, and use that as the final set point.

Attached is an excel sheet demonstrating a few examples of how to do this.
Attached Files
File Type: xlsx continuous_wheel.xlsx (13.2 KB, 15 views)
Reply With Quote
  #5   Spotlight this post!  
Unread 09-05-2016, 17:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,059
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Continuous Feedback Sensor on CANTalon

Quote:
Originally Posted by ozrien View Post
Attached is an excel sheet demonstrating a few examples of how to do this.
If I may:

Let P be your present angle sensor reading (converted to degrees)

Let T be your desired angle position (in degrees)

the angle between them (let's call it ERR) is found by the equation:

ERR = (T-P) - 360*floor(0.5+(T-P)/360);

the above returns a value for ERR between -180 and +180 degrees,
the shortest angle path to the target.

So it tells you which direction to rotate as well as how much to rotate.

So compute your setpoint:

SetPoint = P + ERR


Reply With Quote
  #6   Spotlight this post!  
Unread 09-05-2016, 17:36
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,059
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Continuous Feedback Sensor on CANTalon


Or in native units do this:
Code:

double P=200;
double T=1000;
double SetPoint;

void main(void){
SetPoint  = T - 1024*floor(0.5+(T-P)/1024);
printf("P=%f  T=%f   SetPoint=%f \n",P,T,SetPoint);
}
Output:
Code:
P=200.000000  T=1000.000000   SetPoint=-24.000000
If the sensor goes from 0 to 1023, then you have to go backward 224 steps (not 223) from 200 to get to 1000.

(Because 0 is equivalent to 1024, just as 0 is equivalent to 360 degrees).



Last edited by Ether : 09-05-2016 at 18:08.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-05-2016, 18:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,059
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Continuous Feedback Sensor on CANTalon


If your compiler supports the REMAINDER function "x REM y" per IEC 60559 as specified on Page 235 Section 7.12.10.2 of ISO/IEC 9899:TC3 (which java does I believe), then the following single line of code should work:

Code:
SetPoint = P + Math.IEEEremainder(T-P,360.0);
or in native units:

Code:
SetPoint = P + Math.IEEEremainder(T-P,1024.0);

Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:05.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi