Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Swing.h
- Committer:
- DeguNaoto
- Date:
- 2015-11-17
- Revision:
- 40:aed70f4dcd06
- Parent:
- 24:6d2573d6f2b6
File content as of revision 40:aed70f4dcd06:
#ifndef SWING_H
#define SWING_H
/***Swing.***/
PID contSwing(5.917 ,30.0 ,0.0 ,RATE);
//PID contSwing(6.0 ,100.0 ,0.0 ,RATE);
Ticker interruptSwingSpeed;
int resetSwingSpeed = 0;
inline void countSwingSpeed() {
static double i = 0.0;
if (resetSwingSpeed == 1) {
i = 0.0;
resetSwingSpeed = 0;
}
if (i <= swingspeed) {
i+=swingspeed/10.0;
targSwingRadVelocity=i;
}
else {
interruptSwingSpeed.detach();
}
}
inline void initializeSwing() {
Motor_swing.period_us(SWING_PERIOD);
//controller set
contSwing.setInputLimits(0.0, 50.0);
contSwing.setOutputLimits(0.0, 1.0);
contSwing.setBias(0.0);
contSwing.setMode(AUTO_MODE);
}
double swingSita=0.0;
double Rad=0.0;
inline void mesureSwing() {
PulsesSwing = ( double )SwingSens.getPulses();
swingRadVelocity = (((PulsesSwing - PrefPulsesSwing) / 1445.0) * 2.0 * PI) / RATE;
Rad = (PulsesSwing / 1445.0) * 2.0 * PI;
if(Rad>2*PI) Rad-=2*Rad;
PrefPulsesSwing = PulsesSwing;
}
float cont=0.0;
inline void swingFollowing(){
contSwing.setSetPoint(( float )targSwingRadVelocity);
contSwing.setProcessValue(( float )swingRadVelocity);
cont = contSwing.compute();
Motor_swing = cont;
}
#endif /*Swing.h*/