Commit 4aee833f authored by thcl's avatar thcl
Browse files

added a set_calibration method so we can set calibration to true before we...

added a set_calibration method so we can set calibration to true before we enter open loop, so that get_pot_0_scaled will work.
parent efa14e13
......@@ -23,7 +23,7 @@ int Zoffset = 0;
// This is the difference in encoder tics from the Z index to
// the electrical encoder zero (which is found by powering the
// AB block and waiting for the motor to settle)
int hard_coded_offset = 2416;
int hard_coded_offset = 2425 - 50;
//Invert position to invert position add 341 to any offset
......@@ -59,6 +59,7 @@ int get_phase_number(int elec_position);
void print_speed_ISR(void);
void buttonA_ISR(void);
void buttonB_ISR(void);
void set_calibration_complete(void);
......@@ -313,7 +314,12 @@ void debug_encoder(void)
delayMicroseconds(1000);
}
}
}
void set_calibration_comlete() {
cli();
calibration_complete = true;
sei();
}
......@@ -13,6 +13,7 @@ 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_comlete(void);
......
......@@ -26,7 +26,7 @@ const int led = 13;
int const SCALE_FACTOR = 240;
// This is the PWM frequency and it is very important
int FREQ = 22000; //8000 was our original value;
int FREQ = 8000;//22000; //8000 was our original value;
// This is the lower limit of PWM frequency
// its important for not breaking gate drivers
......@@ -122,7 +122,9 @@ int one_to_scaleFactor(int x)
{
// NOTE: The scale factor is the max value we want out of
// the potentiometer
cli();
return POT_0_VALUE;
sei();
}
else{
return 0;
......@@ -175,9 +177,6 @@ void set_phase(int high1, int high2, int high3, int low1, int low2, int low3)
high2 = one_to_scaleFactor(high2);
high3 = one_to_scaleFactor(high3);
Serial.printf("High 1: %d\n", high1);
Serial.printf("High 2: %d\n", high2);
Serial.printf("High 3: %d\n", high3);
//turn the stuff that should be off, off first
......@@ -290,6 +289,12 @@ void motor_butt_control_precalculated(void)
//and torque (potentiometer on pin A0)
void open_loop_control(void)
{
// This is just a stupid work around for now
// Open Loop doesn't really need to calibrate, but
// get_pot_0_scaled requires calibration
set_calibration_comlete();
while(1)
{
for(int p = 6; p >= 1; p--)
......@@ -301,7 +306,7 @@ void open_loop_control(void)
// we want the maximum speed to be 2800 us per phase
// the max speed corresponds to 5 rev/sec
// we know we need to go faster but this is just testing
volatile int myDelay = 5000 + (get_pot_1_inv() * 300);
volatile int myDelay = 6000;
// Serial.println("my delay:");
// Serial.println(myDelay);
// Serial.println("my speed:");
......
......@@ -97,6 +97,7 @@ int get_pot_0_scaled(int scaleFactor, float period_over_255)
//this just prints the output of get_pot_0_scaled
int debug_pot_0_scaled()
{
set_calibration_comlete();
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