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: Encoder HIDScope MODSERIAL mbed-dsp mbed
Fork of BMT-M9_motorcontrol by
Revision 5:06381e54b94a, committed 2014-09-29
- Comitter:
- vsluiter
- Date:
- Mon Sep 29 21:20:29 2014 +0000
- Parent:
- 4:1a53b06eeb7f
- Child:
- 6:0832c6c6bcba
- Commit message:
- Removed superfluous stuff (sort test), and added scope library
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HIDScope.lib Mon Sep 29 21:20:29 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/tomlankhorst/code/HIDScope/#e44574634162
--- a/MODSERIAL.lib Mon Sep 29 21:07:58 2014 +0000 +++ b/MODSERIAL.lib Mon Sep 29 21:20:29 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/Sissors/code/MODSERIAL/#b04ce87dc424 +http://mbed.org/users/Sissors/code/MODSERIAL/#180e968a751e
--- a/main.cpp Mon Sep 29 21:07:58 2014 +0000
+++ b/main.cpp Mon Sep 29 21:20:29 2014 +0000
@@ -2,12 +2,12 @@
#include "encoder.h"
#include "MODSERIAL.h"
-#define K_P .01
-//0.007//0.0184997836671646 //0.015
-#define K_I 0.00
-//.000824387821287097 //0
-#define K_D .05
-//0.01//.0972091946803081 //0.077
+#define TSAMP 0.01
+#define K_P (10 *TSAMP)
+
+#define K_I (0.00 *TSAMP)
+
+#define K_D (5 *TSAMP)
#define POT_AVG 50
void coerce(float * in, float min, float max);
@@ -23,7 +23,6 @@
void potAverager(void)
{
-
static uint16_t sample_index = 0;
float voltage = potmeter.read()-.5;
@@ -34,63 +33,8 @@
sample_index = 0;
}
-void bubblesort(float arr[], int size)
-{
- int i,j;
- float temp;
- for ( i = 0 ; i <= (size/2)+1 ; i++ )
- {
- for ( j = 0 ; j <= (size/2)+1 - i ; j++ )
- {
- if ( arr[j] > arr[j + 1] )
- {
- temp = arr[j] ;
- arr[j] = arr[j + 1] ;
- arr[j + 1] = temp ;
- }
- }
- }
-}
-
-void quicksort(float own_array[], int low, int high)
-{
- int i = low;
- int j = high;
- int y = 0;
- /* compare value */
- int z = own_array[(low + high) / 2];
- /* partition */
- do {
- /* find member above ... */
- while(own_array[i] < z) i++;
-
- /* find element below ... */
- while(own_array[j] > z) j--;
-
- if(i <= j) {
- /* swap two elements */
- y = own_array[i];
- own_array[i] = own_array[j];
- own_array[j] = y;
- i++;
- j--;
- }
- } while(i <= j);
-
- /* recurse */
- if(low <= j)
- quicksort(own_array, low, j);
-
- if(i <= high)
- quicksort(own_array, i, high);
-}
-
float getpotAverage(void)
{
- //float own_array[POT_AVG];
- //memcpy(own_array, potsamples, sizeof(own_array));
- //bubblesort(own_array, POT_AVG-1);
- //return own_array[POT_AVG/2];
uint16_t valuecounter;
float sum = 0;
for(valuecounter = 0 ; valuecounter < POT_AVG ; valuecounter++)
@@ -110,7 +54,7 @@
potaverage.attach(potAverager,0.002);
pc.baud(921600);
Ticker looptimer;
- looptimer.attach(setlooptimerflag,0.01);
+ looptimer.attach(setlooptimerflag,TSAMP);
pc.printf("bla");
while(1) {
float setpoint;
--- a/mbed.bld Mon Sep 29 21:07:58 2014 +0000 +++ b/mbed.bld Mon Sep 29 21:20:29 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file
