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-07
- Revision:
- 22:4127fcf8c7d7
- Parent:
- 7:4aa57a35ec0b
File content as of revision 22:4127fcf8c7d7:
#ifndef SWING_H
#define SWING_H
/***Swing.***/
PID contSwing(20.917 ,2.0 ,0.0 ,RATE);
Ticker interruptSwingSpeed;
int resetSwingSpeed = 0;
inline void countSwingSpeed() {
static int i = 0;
if (resetSwingSpeed == 1) {
i = 0;
resetSwingSpeed = 0;
}
if (i <= swingspeed) {
i+=swingspeed/10.0;
targSwingRadVelocity=i;
}
else {
interruptSwingSpeed.detach();
}
}
inline void initializeSwing() {
interrupter.rise(&countSwing);
Motor_swing.period_us(SWING_PERIOD);
//controller set
contSwing.setInputLimits(0.0, 100.0);
contSwing.setOutputLimits(0.0, 1.0);
contSwing.setBias(0.0);
contSwing.setMode(AUTO_MODE);
}
void countSwing() {
Indicator1 = !Indicator1;
if(enableShoot){
enableShoot=0;
sendData(2,15);
}
}
double swingSita=0.0;
inline void mesureSwing() {
PulsesSwing = ( double )SwingSens.getPulses();
swingRadVelocity = ((PulsesSwing - PrefPulsesSwing / 360.0) * 2.0 * PI ) / RATE;
PrefPulsesSwing = PulsesSwing;
}
double cont=0.0;
inline void swingFollowing(){
contSwing.setSetPoint(( float )targSwingRadVelocity);
contSwing.setProcessValue(( float )swingRadVelocity);
cont = contSwing.compute();
Motor_swing = cont;
}
#endif /*Swing.h*/