ManualControl
Dependencies: TPixy-Interface
Fork of MbedOS_Robot_Team by
Revision 8:a0890fa79084, committed 2018-02-19
- Comitter:
- asobhy
- Date:
- Mon Feb 19 17:42:33 2018 +0000
- Parent:
- 7:73fd05fe556a
- Child:
- 9:fe56b888985c
- Commit message:
- added more comments
Changed in this revision
--- a/Drivers/DE0_driver.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/Drivers/DE0_driver.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,4 +1,16 @@ -// DE0 FPGA driver +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: DE0_driver.cpp +// file content description: +// * function to initialize the hardware interface for communication +// between the FPGA and LPC1768 +// * function to read required data from the DE0 (FPGA). +/******************************************************************************/ #include "mbed.h"
--- a/Drivers/DE0_driver.h Thu Feb 15 01:15:26 2018 +0000 +++ b/Drivers/DE0_driver.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,11 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ + #ifndef DE0_DRIVER_H #define DE0_DRIVER_H
--- a/Drivers/PiController.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/Drivers/PiController.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,17 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: PiController.cpp +// file content description: +// * PiController initialization function +// * Picontroller function +// * Value Saturation functions +/******************************************************************************/ + #include "mbed.h" #include "PiController.h"
--- a/Drivers/PiController.h Thu Feb 15 01:15:26 2018 +0000 +++ b/Drivers/PiController.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,11 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ + #ifndef PICONTROLLER_H #define PICONTROLLER_H
--- a/Drivers/motor_driver.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/Drivers/motor_driver.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,16 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: motor_driver.cpp +// file content description: +// * function to initialize the hardware used to control a DC Motor +// * functions to drive to motor in forward, reverse and stop. +/******************************************************************************/ + #include "mbed.h" #include "motor_driver.h"
--- a/Drivers/motor_driver.h Thu Feb 15 01:15:26 2018 +0000 +++ b/Drivers/motor_driver.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,10 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ #ifndef MOTOR_DRIVER_H #define MOTOR_DRIVER_H
--- a/ExternalInterruptThread.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/ExternalInterruptThread.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,16 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: ExternalInterruptThread.cpp +// file content description: +// * Function to create the External Interrupt Thread +// * ExternalInterruptThread +// * ExternalInterrupt ISR +/******************************************************************************/ #include "mbed.h" void ExtInterruptISR(void);
--- a/ExternalInterruptThread.h Thu Feb 15 01:15:26 2018 +0000 +++ b/ExternalInterruptThread.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,11 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ + #ifndef EXTERNAL_INT_H #define EXTERNAL_INT_H
--- a/PiControlThread.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/PiControlThread.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,18 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: PiControlThread.cpp +// file content description: +// * Function to Create the PiControl Thread +// * PiControl Thread +// * PiControl ISR +// * Variables related to the functionality of the thread +/******************************************************************************/ + #include "mbed.h" #include "ui.h" #include "Drivers/motor_driver.h" @@ -12,6 +27,8 @@ int vel; int32_t U; +int time_passed = 0; + void PiControlThread(void const *); void PeriodicInterruptISR(void); @@ -70,6 +87,8 @@ { osSignalWait(0x01, osWaitForever); // Go to sleep until signal, SignalPi, is received. + time_passed++; + // get incremental position and time from QEI DE0_read(&ID, &dPosition, &dTime); SaturateValue(dPosition, 560);
--- a/PiControlThread.h Thu Feb 15 01:15:26 2018 +0000 +++ b/PiControlThread.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,10 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ #ifndef PERIODIC_INT_H #define PERIODIC_INT_H
--- a/WatchdogThread.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/WatchdogThread.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,18 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: WatchdogThread.cpp +// file content description: +// * Function to create the Watchdog Thead +// * Watchdog thread +// * Watchdog ISR +// * Variables related to the functionality of the thread +/******************************************************************************/ + #include "mbed.h" osThreadId WatchdogId;
--- a/WatchdogThread.h Thu Feb 15 01:15:26 2018 +0000 +++ b/WatchdogThread.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,10 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ #ifndef WDTHREAD_H_ #define WDTHREAD_H_
--- a/main.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/main.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,6 +1,10 @@ +/******************************************************************************/ // ECE4333 -// Authors: Ahmed Sobhy & Brandon Kingman -// Project: Robot +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ #include "mbed.h" #include "WatchdogThread.h"
--- a/ui.cpp Thu Feb 15 01:15:26 2018 +0000 +++ b/ui.cpp Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,15 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ +// filename: ui.cpp +// file content description: +// * Functions to display and manage the user interface on the PC terminal. +/******************************************************************************/ + #include "mbed.h" #include "WatchdogThread.h" #include "ui.h" @@ -9,7 +21,7 @@ // speed int setpoint = 0; - +float total_time_passed = 0; // variable to store character recieved from terminal char x; @@ -20,6 +32,7 @@ extern int32_t e; extern int32_t xState; extern int32_t u; +extern int time_passed; int16_t position; @@ -58,7 +71,7 @@ /****************************************************************************** - User interface + User interface 1 ******************************************************************************/ /* void consoleUI(void) @@ -137,15 +150,15 @@ // by incrementing u else if(x == 'w') { setpoint_mutex.lock(); - if ( setpoint < 506 ) + if ( setpoint < 560 ) { //setpoint = setpoint + SPEED_STEP; - setpoint = 400; + setpoint = 280; } setpoint_mutex.unlock(); // display speed - bluetooth.printf("\r\n %5d", setpoint); + //bluetooth.printf("\r\n %5d", setpoint); } // if s is pressed decrease the speed @@ -155,7 +168,7 @@ setpoint_mutex.lock(); if (setpoint > -560) { - setpoint = -400; + setpoint = -280; //setpoint = setpoint - SPEED_STEP; } @@ -189,9 +202,18 @@ position += dPosition; + + //bluetooth.printf("\r\nPos: %d, dP: %d, dT: %d, Kp: %f, Ki: %f, vel: %d, e: %d", position, dPosition, dTime, Kp, Ki, vel, e); - bluetooth.printf("\r\ndP: %d, vel: %d, (Kp*e) Kp: %f, (Ki*xState) Ki: %f, e: %d, xState: %d, u: %d", dPosition, vel, Kp, Ki, e, xState , u); + //bluetooth.printf("\r\ndP: %d, vel: %d, (Kp*e) Kp: %f, (Ki*xState) Ki: %f, e: %d, xState: %d, u: %d", dPosition, vel, Kp, Ki, e, xState , u); + + + bluetooth.printf("\r\n %d, ", e); + bluetooth.printf("%d, ", dPosition); + bluetooth.printf("%d, ", xState); + bluetooth.printf("%d, ", u); + //bluetooth.printf("\r\ne: %d, Pos: %d, dP: %d, xState: %d, u: %d, dT: %d", e, position, dPosition, xState, u, dTime);
--- a/ui.h Thu Feb 15 01:15:26 2018 +0000 +++ b/ui.h Mon Feb 19 17:42:33 2018 +0000 @@ -1,3 +1,11 @@ +/******************************************************************************/ +// ECE4333 +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch +/******************************************************************************/ + #ifndef UI_H #define UI_H