Commit b6b28c47 authored by mattdr's avatar mattdr
Browse files

made some code changes and moved to 3.5

parent 00015f86
......@@ -20,7 +20,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 = 321;
int hard_coded_offset = 5101;
// how long in microsec (us) to delay between phases while calibrating
// the wheel
......
......@@ -38,30 +38,37 @@ S TO START BUTT CONTROL (OPTIMIZED)\n");
}
else if(incomingByte == 'z') //'z'
{
charge_bootstrap_capacitors();
do_hard_coded_offset();// run the set zero
}
else if(incomingByte == 'o') //'o'
{
charge_bootstrap_capacitors();
open_loop_control();
}
else if(incomingByte == 'l') //'l'
{
charge_bootstrap_capacitors();
locate_state_positions();
}
else if (incomingByte == 'd') //'d'
{
charge_bootstrap_capacitors();
direct_position_control();
}
else if (incomingByte == 'b') //'b'
{
charge_bootstrap_capacitors();
motor_butt_control_inefficient();
}
else if (incomingByte == 's') //'s'
{
charge_bootstrap_capacitors();
motor_butt_control_precalculated();
}
}
charge_bootstrap_capacitors();
int calibration_return = calibrate_encoder();
if(calibration_return == -1)
{
......
......@@ -39,6 +39,7 @@ void set_block_phase(int phase);
void motor_butt_control_inefficient(void);
void set_phase_float(float f1, float f2, float f3);
void motor_butt_control_precalculated(void);
void charge_bootstrap_capacitors(void);
......@@ -127,19 +128,30 @@ void set_block_phase(int phase)
return;
}
// This function takes in a seris of
// This function takes in a seris of 1 and 0s
void set_phase(int high1, int high2, int high3, int low1, int low2, int low3)
{
high1 = one_to_scaleFactor(high1);
high2 = one_to_scaleFactor(high2);
high3 = one_to_scaleFactor(high3);
digitalWrite(L1, low1);
digitalWrite(L2, low2);
digitalWrite(L3, low3);
analogWrite(H1, high1);
analogWrite(H2, high2);
analogWrite(H3, high3);
//turn the stuff that should be off, off first
if (! low1) digitalWrite(L1, low1);
if (! low2) digitalWrite(L2, low2);
if (! low3) digitalWrite(L3, low3);
if (! high1) analogWrite(H1, high1);
if (! high2) analogWrite(H2, high2);
if (! high3) analogWrite(H3, high3);
//turn the stuff that should be on, on
if (low1) digitalWrite(L1, low1);
if (low2) digitalWrite(L2, low2);
if (low3) digitalWrite(L3, low3);
if (high1) analogWrite(H1, high1);
if (high2) analogWrite(H2, high2);
if (high3) analogWrite(H3, high3);
}
void set_phase_float(float f1, float f2, float f3)
......@@ -246,6 +258,17 @@ void open_loop_control(void)
}
}
// This just charges up the small boostrap capacitors
// this should allways be called right before powering the motor
void charge_bootstrap_capacitors(void)
{
turn_all_off();
delayMicroseconds(50);
set_phase(0,0,0,1,1,1);
delayMicroseconds(50);
turn_all_off();
}
//using hardcoded located state positions
void direct_position_control(void)
{
......
......@@ -10,6 +10,7 @@ void set_phase(int high1, int high2, int high3, int low1, int low2, int low3);
void motor_butt_control_inefficient(void);
void set_phase_float(float f1, float f2, float f3);
void motor_butt_control_precalculated(void);
void charge_bootstrap_capacitors(void);
......
......@@ -47,7 +47,7 @@ int get_pot_0_scaled(int scaleFactor, float period_over_255)
// This code is used to make sure that the pwm nver has a period
// lower than 250 ns (as this may be problematic for gate drivrs)
if ((period_over_255 * potval) < 250.0E-9){
potval = 0.0;
return (int)0;
}
return (int)potval;
......
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