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.
Dependencies: mbed
Revision 5:30cf394eca48, committed 2019-04-23
- Comitter:
- heathcor
- Date:
- Tue Apr 23 18:16:53 2019 +0000
- Parent:
- 4:11559b04c4ff
- Commit message:
- digitalout for states
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 04 20:54:00 2019 +0000
+++ b/main.cpp Tue Apr 23 18:16:53 2019 +0000
@@ -18,7 +18,7 @@
#define dKP 5.1491f //Proportional Gain
#define dKI 119.3089f //Integral Gain
#define MOTORPWM 0.00004f //PWM Frequency
-#define MOTORMAX 0.6f //Max Value of Buck Converter
+#define MOTORMAX 0.9f //Max Value of Buck Converter
#define MOTORMIN 0.0f //Minimum Value of Buck Converter
//Steering
@@ -67,8 +67,8 @@
//Hardware Interupts
Ticker Update;
-InterruptIn IN_pRunButton(PTA5);
-InterruptIn IN_pStopButton(PTA4);
+DigitalIn IN_pRunButton(PTA5);
+DigitalIn IN_pStopButton(PTA4);
InterruptIn IN_pBumperStop(PTD3);
InterruptIn IN_pArrowheadLeft(PTD5);
@@ -127,8 +127,15 @@
int main() {
cout << "\rCarStart" << endl;
Init();
- while(1) {wait(LOOPTIME); Loop();}
- //int r = counter; for(int b = 3; b <= 0; b--){ if(r > pow(2,b+1)){ LED[b] = LEDON; r = r - pow(2,b+1);}
+ while(1) {wait(LOOPTIME); Loop();
+ if(IN_pStopButton.read()>=.9)
+ StopMethod();
+ if(IN_pRunButton.read()>=.9)
+ TriggerSwitch();
+
+ }
+ //int r = counter; for(int b = 3; b <= 0; b--){ if(r > pow(2,b+1)){ LED[b] = LEDON; r = r - pow(2,b+1);}
+
}
void Init() //Initializer
@@ -156,8 +163,8 @@
PWM_pServo.period(SERVOPWM);
//Interupt Init
- IN_pRunButton.rise(&TriggerSwitch);
- IN_pStopButton.rise(&StopMethod);
+ //IN_pRunButton.rise(&TriggerSwitch);
+ //IN_pStopButton.rise(&StopMethod);
IN_pBumperStop.rise(&BumperStopMethod);
IN_pArrowheadLeft.rise(&UpdateLeft);
IN_pArrowheadRight.rise(&UpdateRight);
@@ -181,7 +188,7 @@
{
if(_oCurrentState == RUN)
{
- _fMotorReference = AI_pSpeedReference.read();
+ _fMotorReference = 0.85;//AI_pSpeedReference.read();
_fError = _fMotorReference - AI_pTacho.read();
_fErrorArea += TI*_fError;
_fControllerOutput = dKP*_fError+ dKI*_fErrorArea;