Commit 13032120 authored by mattdr's avatar mattdr
Browse files

more updates at the tracki

parent 0a98c606
......@@ -31,7 +31,7 @@ int opposite_direction_offset = 341;
// hand calibration (done by buttons)
int button_offset = 60;
int button_offset = 70;
//how much of an effect the button press has
int button_offset_increment = 5;
......@@ -45,7 +45,7 @@ IntervalTimer speed_timer;
// buttons (for hand tuneing)
int ButtonA = 0;
int ButtonB = 1;
int ButtonB = 2;
//forward declarations
void isr_index(void);
......@@ -284,6 +284,13 @@ bool is_calibration_complete()
return calibration_complete;
}
void set_calibration_complete()
{
cli();
calibration_complete = true;
sei();
}
//This will provide debug prints with info that could be usefull
void debug_encoder(void)
{
......
......@@ -13,6 +13,8 @@ int get_elec_rev_position_ticks(int mechanical_position);
int get_phase_number(int elec_position);
int get_Zoffset(void);
bool is_calibration_complete();
void set_calibration_complete();
......
......@@ -3,7 +3,7 @@
#include "motor_ctrl.h"
#include "encoder.h"
float CALIBRATION_MAX_PWM = 53.0;
float CALIBRATION_MAX_PWM = 100.0;
const float UPWARD_ROC_LIMITER = 20.0;
float UPWARD_ROC_PREV_VALUE = 0;
......@@ -71,6 +71,13 @@ int get_pot_0_scaled(int scaleFactor, float period_over_255)
potval = UPWARD_ROC_PREV_VALUE - UPWARD_ROC_LIMITER;
}
//This code creates a limit on the amount of power durring calibration
if (!is_calibration_complete()){
if (potval > CALIBRATION_MAX_PWM){
potval = CALIBRATION_MAX_PWM;
}
}
UPWARD_ROC_PREV_VALUE = potval;
potval = potval/1024;
......@@ -84,19 +91,19 @@ int get_pot_0_scaled(int scaleFactor, float period_over_255)
return (int)0;
}
//This code creates a limit on the amount of power durring calibration
if (!is_calibration_complete()){
if (potval > CALIBRATION_MAX_PWM){
return CALIBRATION_MAX_PWM;
}
if (potval > 255) //limit the top
{
potval = 255;
}
return (int)potval;
}
//this just prints the output of get_pot_0_scaled
int debug_pot_0_scaled()
{
set_calibration_complete();//spoof complete calibration to get proper values
while(1){
Serial.println("value from get_pot_0_scaled");
Serial.println(get_pot_0_scaled(240,0.0000000817));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment