Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mattdr
supermileage_2018
Commits
4b828896
Commit
4b828896
authored
Mar 26, 2019
by
mattdr
Browse files
reversed direction of motor and hand tuned
parent
c3eadfee
Changes
2
Hide whitespace changes
Inline
Side-by-side
source_code/Teensy35/src/encoder.cpp
View file @
4b828896
...
@@ -21,14 +21,15 @@ int Zoffset = 0;
...
@@ -21,14 +21,15 @@ int Zoffset = 0;
// This is the difference in encoder tics from the Z index to
// This is the difference in encoder tics from the Z index to
// the electrical encoder zero (which is found by powering the
// the electrical encoder zero (which is found by powering the
// AB block and waiting for the motor to settle)
// AB block and waiting for the motor to settle)
int
hard_coded_offset
=
-
30
7
;
int
hard_coded_offset
=
38
7
;
//Invert position to invert position add 341 to any offset
//Invert position to invert position add 341 to any offset
int
opposite_direction_offset
=
341
;
// hand calibration (done by buttons)
// hand calibration (done by buttons)
int
button_offset
=
0
;
int
button_offset
=
6
0
;
//how much of an effect the button press has
//how much of an effect the button press has
int
button_offset_increment
=
5
;
int
button_offset_increment
=
5
;
...
@@ -41,8 +42,8 @@ int CALIBRATION_DELAY = 28500;
...
@@ -41,8 +42,8 @@ int CALIBRATION_DELAY = 28500;
IntervalTimer
speed_timer
;
IntervalTimer
speed_timer
;
// buttons (for hand tuneing)
// buttons (for hand tuneing)
int
ButtonA
=
11
;
int
ButtonA
=
0
;
int
ButtonB
=
1
2
;
int
ButtonB
=
1
;
//forward declarations
//forward declarations
void
isr_index
(
void
);
void
isr_index
(
void
);
...
@@ -169,7 +170,7 @@ int get_wheel_position_ticks(void)
...
@@ -169,7 +170,7 @@ int get_wheel_position_ticks(void)
{
{
int
raw_position
=
encoder
.
calcPosn
();
int
raw_position
=
encoder
.
calcPosn
();
cli
();
cli
();
int
my_position
=
raw_position
-
Zoffset
-
hard_coded_offset
-
button_offset
;
int
my_position
=
raw_position
-
Zoffset
-
hard_coded_offset
-
button_offset
-
opposite_direction_offset
;
sei
();
sei
();
int
wrapped_position
=
wrap_wheel_tics
(
my_position
);
int
wrapped_position
=
wrap_wheel_tics
(
my_position
);
return
wrapped_position
;
return
wrapped_position
;
...
@@ -248,7 +249,8 @@ int calibrate_encoder()
...
@@ -248,7 +249,8 @@ int calibrate_encoder()
}
}
while
(
1
){
while
(
1
){
for
(
int
p
=
1
;
p
<=
6
;
p
++
)
// WARNING THIS IS SPINNING IN THE OTHER DIRECTION
for
(
int
p
=
6
;
p
>=
1
;
p
--
)
{
{
set_block_phase
(
p
);
set_block_phase
(
p
);
delayMicroseconds
(
CALIBRATION_DELAY
);
delayMicroseconds
(
CALIBRATION_DELAY
);
...
...
source_code/Teensy35/src/motor_ctrl.cpp
View file @
4b828896
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
#define L2 20 //YellowL
#define L2 20 //YellowL
#define L3 22 //BlueL
#define L3 22 //BlueL
#define HB1EN 0 //halfbridge 1 enable
//
#define HB1EN 0 //halfbridge 1 enable
#define HB2EN 1 //halfbridge 2 enable
//
#define HB2EN 1 //halfbridge 2 enable
#define HB3EN 2 //halfbridge 3 enable
//
#define HB3EN 2 //halfbridge 3 enable
const
int
led
=
13
;
const
int
led
=
13
;
...
@@ -74,13 +74,13 @@ void motor_setup(void) {
...
@@ -74,13 +74,13 @@ void motor_setup(void) {
turn_all_off
();
turn_all_off
();
//setup the halfbridges enables
//setup the halfbridges enables
pinMode
(
HB1EN
,
OUTPUT
);
//
pinMode(HB1EN, OUTPUT);
pinMode
(
HB2EN
,
OUTPUT
);
//
pinMode(HB2EN, OUTPUT);
pinMode
(
HB3EN
,
OUTPUT
);
//
pinMode(HB3EN, OUTPUT);
//enable the halfbridges
//enable the halfbridges
digitalWrite
(
HB1EN
,
HIGH
);
//
digitalWrite(HB1EN, HIGH);
digitalWrite
(
HB2EN
,
HIGH
);
//
digitalWrite(HB2EN, HIGH);
digitalWrite
(
HB3EN
,
HIGH
);
//
digitalWrite(HB3EN, HIGH);
//setup led
//setup led
pinMode
(
led
,
OUTPUT
);
pinMode
(
led
,
OUTPUT
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment