Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip A Levis
EE185
Commits
b8606fa9
Commit
b8606fa9
authored
Dec 11, 2021
by
ChristineC8
Browse files
fixed naming convention in testing script
parent
93566e82
Changes
1
Hide whitespace changes
Inline
Side-by-side
software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/extracting_graphing_printed_data.py
View file @
b8606fa9
...
...
@@ -20,14 +20,15 @@ def extract_data(text_file, string_label) :
if
not
line
:
break
# Find d
uty
cycle data
d
uty
_index
=
line
.
find
(
string_label
)
# Find d
ata
cycle data
d
ata
_index
=
line
.
find
(
string_label
)
# If found, extract duty data
# If found, extract data
# Our floats are printed with 5 decimal places
if
d
uty
_index
!=
-
1
:
if
d
ata
_index
!=
-
1
:
# Go to actual index of the data rather than the label
float_start_index
=
d
uty
_index
+
label_size
float_start_index
=
d
ata
_index
+
label_size
# Find decimal point index and add 5 decimal points to find size of floating point number
float_size
=
line
[
float_start_index
:].
find
(
"."
)
+
5
...
...
@@ -37,7 +38,7 @@ def extract_data(text_file, string_label) :
if
data_point
>
0.8
:
print
(
line
)
print
(
data_point
)
print
(
d
uty
_index
)
print
(
d
ata
_index
)
data_list
.
append
(
float
(
line
[
float_start_index
:
float_start_index
+
float_size
+
1
]))
...
...
@@ -54,9 +55,8 @@ def plot_data(y_data, x_label, y_label, title) :
plt
.
show
()
# Main :
# find and print left duty data
text_file
=
"/Users/cc/Documents/School/ee185/software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/pid_KI_0.0125_KP_0.0325.txt"
text_file
=
"/Users/cc/Documents/School/ee185/software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/pid_KI=0.04375_KP_0.00625.txt"
# find and print data
text_file
=
"/Users/cc/Documents/School/ee185/software/firmware/circuitpython-main/ports/atmel-samd/common-hal/motor_control/PID_testing/pid_scripts/pid_KI_0.005_KP_0.005.txt"
data_label
=
"duty_left: "
data_list
=
extract_data
(
text_file
,
data_label
)
title
=
"Calculated PID Left Wing Duty Cycles: KI = 0.04375 & KP = 0.00625"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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