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: MAX14871_Shield mbed
Revision 6:428538df7b63, committed 2016-02-16
- Comitter:
- j3
- Date:
- Tue Feb 16 22:43:52 2016 +0000
- Parent:
- 5:c673430c8a32
- Commit message:
- init publish
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Jan 10 19:12:08 2016 +0000
+++ b/main.cpp Tue Feb 16 22:43:52 2016 +0000
@@ -17,7 +17,7 @@
//comment out following line for normal operation
//#define TUNE_PID 1
-
+
//state variables for ISR
volatile bool run = false;
BusOut start_stop_led(D6, D7);
@@ -44,9 +44,10 @@
//Connect IR sensor to port 4
BusIn ir_bus(P4_0, P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7);
+
DigitalOut ir_bus_enable(D3, 1); //active high enable
- //raw sensor data
+ //binary sensor data
uint8_t ir_val = 0;
//used to measure dt
@@ -89,9 +90,9 @@
//Set PID terms to 0 if not used/needed
//For values below Kc = 10 and Pc was measured at 0.33 calculated starting points given in comments below
//Ended up decreasing integral term, increasing derivative term and small decrease in proportional term.
- int32_t kp = 4; //6
- int32_t ki = 3; //.0576, divide by 1000 later, 7
- int32_t kd = 250; //156.25, 500
+ int32_t kp = 4; //
+ int32_t ki = 2; //.0576, divide by 1000 later
+ int32_t kd = 250; //156.25
//initialize vars
int32_t current_error = 0;
@@ -158,7 +159,7 @@
loop_pulse = !loop_pulse;
//get raw ir sensor data
- ir_val = ~(ir_bus.read());
+ ir_val = ~(ir_bus.read()); // use with Parallax Sensor
//scale feedback
switch(ir_val)