Skip to content

Commit b4a10d5

Browse files
committed
FEAT Moved motor.monitor to the BLDCMotor class
1 parent 301e5e9 commit b4a10d5

File tree

13 files changed

+40
-309
lines changed

13 files changed

+40
-309
lines changed

examples/encoder_examples/HMBGC_example/HMBGC_example.ino

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,38 +106,9 @@ void loop() {
106106

107107
// function intended to be used with serial plotter to monitor motor variables
108108
// significantly slowing the execution down!!!!
109-
// motor_monitor();
109+
// motor.monitor();
110110
}
111111

112-
// utility function intended to be used with serial plotter to monitor motor variables
113-
// significantly slowing the execution down!!!!
114-
void motor_monitor() {
115-
switch (motor.controller) {
116-
case ControlType::velocity:
117-
Serial.print(motor.voltage_q);
118-
Serial.print("\t");
119-
Serial.print(motor.shaft_velocity_sp);
120-
Serial.print("\t");
121-
Serial.println(motor.shaft_velocity);
122-
break;
123-
case ControlType::angle:
124-
Serial.print(motor.voltage_q);
125-
Serial.print("\t");
126-
Serial.print(motor.shaft_angle_sp);
127-
Serial.print("\t");
128-
Serial.println(motor.shaft_angle);
129-
break;
130-
case ControlType::voltage:
131-
Serial.print(motor.voltage_q);
132-
Serial.print("\t");
133-
Serial.print(motor.shaft_velocity);
134-
Serial.print("\t");
135-
Serial.println(motor.shaft_angle);
136-
break;
137-
}
138-
}
139-
140-
141112
// Serial communication callback function
142113
// gets the target value from the user
143114
void serialEvent() {

examples/encoder_examples/angle_control/angle_control.ino

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,7 @@ void loop() {
131131

132132
// function intended to be used with serial plotter to monitor motor variables
133133
// significantly slowing the execution down!!!!
134-
// motor_monitor();
135-
}
136-
137-
// utility function intended to be used with serial plotter to monitor motor variables
138-
// significantly slowing the execution down!!!!
139-
void motor_monitor() {
140-
switch (motor.controller) {
141-
case ControlType::velocity:
142-
Serial.print(motor.voltage_q);
143-
Serial.print("\t");
144-
Serial.print(motor.shaft_velocity_sp);
145-
Serial.print("\t");
146-
Serial.println(motor.shaft_velocity);
147-
break;
148-
case ControlType::angle:
149-
Serial.print(motor.voltage_q);
150-
Serial.print("\t");
151-
Serial.print(motor.shaft_angle_sp);
152-
Serial.print("\t");
153-
Serial.println(motor.shaft_angle);
154-
break;
155-
case ControlType::voltage:
156-
Serial.print(motor.voltage_q);
157-
Serial.print("\t");
158-
Serial.print(motor.shaft_angle);
159-
Serial.print("\t");
160-
Serial.println(motor.shaft_velocity);
161-
break;
162-
}
134+
// motor.monitor();
163135
}
164136

165137
// Serial communication callback function

examples/encoder_examples/change_direction/change_direction.ino

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -120,34 +120,7 @@ void loop() {
120120

121121
// function intended to be used with serial plotter to monitor motor variables
122122
// significantly slowing the execution down!!!!
123-
//motor_monitor();
123+
//motor.monitor();
124124
}
125125

126-
// utility function intended to be used with serial plotter to monitor motor variables
127-
// significantly slowing the execution down!!!!
128-
void motor_monitor() {
129-
switch (motor.controller) {
130-
case ControlType::velocity:
131-
Serial.print(motor.voltage_q);
132-
Serial.print("\t");
133-
Serial.print(motor.shaft_velocity_sp);
134-
Serial.print("\t");
135-
Serial.println(motor.shaft_velocity);
136-
break;
137-
case ControlType::angle:
138-
Serial.print(motor.voltage_q);
139-
Serial.print("\t");
140-
Serial.print(motor.shaft_angle_sp);
141-
Serial.print("\t");
142-
Serial.println(motor.shaft_angle);
143-
break;
144-
case ControlType::voltage:
145-
Serial.print(motor.voltage_q);
146-
Serial.print("\t");
147-
Serial.print(motor.shaft_angle);
148-
Serial.print("\t");
149-
Serial.println(motor.shaft_velocity);
150-
break;
151-
}
152-
}
153126

examples/encoder_examples/velocity_PI_tuning/velocity_PI_tuning.ino

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,38 +121,12 @@ void loop() {
121121

122122
// function intended to be used with serial plotter to monitor motor variables
123123
// significantly slowing the execution down!!!!
124-
// motor_monitor();
124+
// motor.monitor();
125125

126126
// keep track of loop number
127127
t++;
128128
}
129129

130-
// utility function intended to be used with serial plotter to monitor motor variables
131-
// significantly slowing the execution down!!!!
132-
void motor_monitor() {
133-
switch (motor.controller) {
134-
case ControlType::velocity:
135-
Serial.print(motor.voltage_q);
136-
Serial.print("\t");
137-
Serial.print(motor.shaft_velocity_sp);
138-
Serial.print("\t");
139-
Serial.println(motor.shaft_velocity);
140-
break;
141-
case ControlType::angle:
142-
Serial.print(motor.voltage_q);
143-
Serial.print("\t");
144-
Serial.print(motor.shaft_angle_sp);
145-
Serial.print("\t");
146-
Serial.println(motor.shaft_angle);
147-
break;
148-
case ControlType::voltage:
149-
Serial.print(motor.voltage_q);
150-
Serial.print("\t");
151-
Serial.println(motor.shaft_velocity);
152-
break;
153-
}
154-
}
155-
156130
// Serial communication callback function
157131
// gets the target value from the user
158132
void serialEvent() {

examples/encoder_examples/velocity_control/velocity_control.ino

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -122,33 +122,7 @@ void loop() {
122122

123123
// function intended to be used with serial plotter to monitor motor variables
124124
// significantly slowing the execution down!!!!
125-
// motor_monitor();
126-
}
127-
128-
// utility function intended to be used with serial plotter to monitor motor variables
129-
// significantly slowing the execution down!!!!
130-
void motor_monitor() {
131-
switch (motor.controller) {
132-
case ControlType::velocity:
133-
Serial.print(motor.voltage_q);
134-
Serial.print("\t");
135-
Serial.print(motor.shaft_velocity_sp);
136-
Serial.print("\t");
137-
Serial.println(motor.shaft_velocity);
138-
break;
139-
case ControlType::angle:
140-
Serial.print(motor.voltage_q);
141-
Serial.print("\t");
142-
Serial.print(motor.shaft_angle_sp);
143-
Serial.print("\t");
144-
Serial.println(motor.shaft_angle);
145-
break;
146-
case ControlType::voltage:
147-
Serial.print(motor.voltage_q);
148-
Serial.print("\t");
149-
Serial.println(motor.shaft_velocity);
150-
break;
151-
}
125+
// motor.monitor();
152126
}
153127

154128
// Serial communication callback function

examples/encoder_examples/voltage_control/voltage_control.ino

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -87,35 +87,7 @@ void loop() {
8787

8888
// function intended to be used with serial plotter to monitor motor variables
8989
// significantly slowing the execution down!!!!
90-
motor_monitor();
91-
}
92-
93-
// utility function intended to be used with serial plotter to monitor motor variables
94-
// significantly slowing the execution down!!!!
95-
void motor_monitor() {
96-
switch (motor.controller) {
97-
case ControlType::velocity:
98-
Serial.print(motor.voltage_q);
99-
Serial.print("\t");
100-
Serial.print(motor.shaft_velocity_sp);
101-
Serial.print("\t");
102-
Serial.println(motor.shaft_velocity);
103-
break;
104-
case ControlType::angle:
105-
Serial.print(motor.voltage_q);
106-
Serial.print("\t");
107-
Serial.print(motor.shaft_angle_sp);
108-
Serial.print("\t");
109-
Serial.println(motor.shaft_angle);
110-
break;
111-
case ControlType::voltage:
112-
Serial.print(motor.voltage_q);
113-
Serial.print("\t");
114-
Serial.print(motor.shaft_angle);
115-
Serial.print("\t");
116-
Serial.println(motor.shaft_velocity);
117-
break;
118-
}
90+
motor.monitor();
11991
}
12092

12193

examples/magnetic_sensor_examples/angle_control/angle_control.ino

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,36 +94,9 @@ void loop() {
9494

9595
// function intended to be used with serial plotter to monitor motor variables
9696
// significantly slowing the execution down!!!!
97-
// motor_monitor();
97+
// motor.monitor();
9898
}
9999

100-
// utility function intended to be used with serial plotter to monitor motor variables
101-
// significantly slowing the execution down!!!!
102-
void motor_monitor() {
103-
switch (motor.controller) {
104-
case ControlType::velocity:
105-
Serial.print(motor.voltage_q);
106-
Serial.print("\t");
107-
Serial.print(motor.shaft_velocity_sp);
108-
Serial.print("\t");
109-
Serial.println(motor.shaft_velocity);
110-
break;
111-
case ControlType::angle:
112-
Serial.print(motor.voltage_q);
113-
Serial.print("\t");
114-
Serial.print(motor.shaft_angle_sp);
115-
Serial.print("\t");
116-
Serial.println(motor.shaft_angle);
117-
break;
118-
case ControlType::voltage:
119-
Serial.print(motor.voltage_q);
120-
Serial.print("\t");
121-
Serial.print(motor.shaft_angle);
122-
Serial.print("\t");
123-
Serial.println(motor.shaft_velocity);
124-
break;
125-
}
126-
}
127100

128101
// Serial communication callback function
129102
// gets the target value from the user

examples/magnetic_sensor_examples/change_direction/change_direction.ino

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -93,34 +93,7 @@ void loop() {
9393

9494
// function intended to be used with serial plotter to monitor motor variables
9595
// significantly slowing the execution down!!!!
96-
//motor_monitor();
96+
//motormonitor();
9797
}
9898

99-
// utility function intended to be used with serial plotter to monitor motor variables
100-
// significantly slowing the execution down!!!!
101-
void motor_monitor() {
102-
switch (motor.controller) {
103-
case ControlType::velocity:
104-
Serial.print(motor.voltage_q);
105-
Serial.print("\t");
106-
Serial.print(motor.shaft_velocity_sp);
107-
Serial.print("\t");
108-
Serial.println(motor.shaft_velocity);
109-
break;
110-
case ControlType::angle:
111-
Serial.print(motor.voltage_q);
112-
Serial.print("\t");
113-
Serial.print(motor.shaft_angle_sp);
114-
Serial.print("\t");
115-
Serial.println(motor.shaft_angle);
116-
break;
117-
case ControlType::voltage:
118-
Serial.print(motor.voltage_q);
119-
Serial.print("\t");
120-
Serial.print(motor.shaft_angle);
121-
Serial.print("\t");
122-
Serial.println(motor.shaft_velocity);
123-
break;
124-
}
125-
}
12699

examples/magnetic_sensor_examples/velocity_PI_tuning/velocity_PI_tuning.ino

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,38 +104,12 @@ void loop() {
104104

105105
// function intended to be used with serial plotter to monitor motor variables
106106
// significantly slowing the execution down!!!!
107-
// motor_monitor();
107+
// motor.monitor();
108108

109109
// keep track of loop number
110110
t++;
111111
}
112112

113-
// utility function intended to be used with serial plotter to monitor motor variables
114-
// significantly slowing the execution down!!!!
115-
void motor_monitor() {
116-
switch (motor.controller) {
117-
case ControlType::velocity:
118-
Serial.print(motor.voltage_q);
119-
Serial.print("\t");
120-
Serial.print(motor.shaft_velocity_sp);
121-
Serial.print("\t");
122-
Serial.println(motor.shaft_velocity);
123-
break;
124-
case ControlType::angle:
125-
Serial.print(motor.voltage_q);
126-
Serial.print("\t");
127-
Serial.print(motor.shaft_angle_sp);
128-
Serial.print("\t");
129-
Serial.println(motor.shaft_angle);
130-
break;
131-
case ControlType::voltage:
132-
Serial.print(motor.voltage_q);
133-
Serial.print("\t");
134-
Serial.println(motor.shaft_velocity);
135-
break;
136-
}
137-
}
138-
139113
// Serial communication callback function
140114
// gets the target value from the user
141115
void serialEvent() {

examples/magnetic_sensor_examples/velocity_control/velocity_control.ino

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,7 @@ void loop() {
8686

8787
// function intended to be used with serial plotter to monitor motor variables
8888
// significantly slowing the execution down!!!!
89-
// motor_monitor();
90-
}
91-
92-
// utility function intended to be used with serial plotter to monitor motor variables
93-
// significantly slowing the execution down!!!!
94-
void motor_monitor() {
95-
switch (motor.controller) {
96-
case ControlType::velocity:
97-
Serial.print(motor.voltage_q);
98-
Serial.print("\t");
99-
Serial.print(motor.shaft_velocity_sp);
100-
Serial.print("\t");
101-
Serial.println(motor.shaft_velocity);
102-
break;
103-
case ControlType::angle:
104-
Serial.print(motor.voltage_q);
105-
Serial.print("\t");
106-
Serial.print(motor.shaft_angle_sp);
107-
Serial.print("\t");
108-
Serial.println(motor.shaft_angle);
109-
break;
110-
case ControlType::voltage:
111-
Serial.print(motor.voltage_q);
112-
Serial.print("\t");
113-
Serial.println(motor.shaft_velocity);
114-
break;
115-
}
89+
// motor.monitor();
11690
}
11791

11892
// Serial communication callback function

0 commit comments

Comments
 (0)