summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbel Tim <abel@abeltim.com>2025-04-01 19:54:58 +0200
committerAbel Tim <abel@abeltim.com>2025-04-01 19:54:58 +0200
commit611845d81d3eaf5517c206a305419ab3b3afd68a (patch)
tree7be1bc0b66afafabb605999448dfa30680685328
parentcee52440dbaa7d71ec14ab36829e150f661291e2 (diff)
downloadrobotica-611845d81d3eaf5517c206a305419ab3b3afd68a.tar.gz
robotica-611845d81d3eaf5517c206a305419ab3b3afd68a.zip
did a lot of thing lately
-rw-r--r--.gitignore16
-rw-r--r--OLD_CODE_REMOVE_LATER/code/teensy_code/teensy_code.ino373
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/IR/IR_sens/IR_sens.ino149
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/IR/communication/direct_rx/direct_rx.ino15
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/IR/communication/rx_teensy/rx_teensy.ino35
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/IR/communication/tx_seeed/tx_seeed.ino29
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/IR/teensydeco/teensydeco.ino104
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/color/color.ino58
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/driving/3mtest/3mtest.ino92
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/driving/base_drive/base_drive.ino140
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/driving/base_drive_with_speed_control/base_drive_with_speed_control.ino214
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/driving/onemotor_softPWM/onemotor_softPWM.ino126
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/Calibrate/Calibrate.ino42
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino120
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/IMU_comp.ino116
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/calcoffset/calcoffset.ino27
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore1
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING674
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER165
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py148
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino56
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino164
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino159
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino241
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino91
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino70
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino49
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/README.textile108
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/IR_seeker/IR_seeker.ino205
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/MCP23017.ino177
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/mcp20317_schemss.jpgbin21944 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/Scanner/Scanner.ino194
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/color_sensor.ino183
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/short/short.ino94
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino28
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_comm/arduino_comm.ino37
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/readme.txt.txt3
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/seeed_uart/seeed_uart.ino9
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino17
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_master/arduino_spi_master.ino34
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_slave_1.py102
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart/arduino_uart.ino17
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart_1.py42
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/InternalTemperature-master.zipbin246290 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/data_logging_teensy_temp.ino63
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/CODE.ino992
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/Calibrate/Calibrate.ino42
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino120
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/IMU_comp.ino116
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/calcoffset/calcoffset.ino27
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore1
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING674
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER165
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py148
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino56
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino164
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino159
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino241
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino91
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino70
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino49
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/README.textile108
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IR_seeker/IR_seeker.ino205
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/MCP23017.ino177
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/mcp20317_schemss.jpgbin21944 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/Scanner/Scanner.ino194
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/color_sensor.ino183
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/short/short.ino94
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino28
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_comm/arduino_comm.ino37
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/readme.txt.txt3
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino9
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino17
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_master/arduino_spi_master.ino34
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_slave_1.py102
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart/arduino_uart.ino17
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart_1.py42
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/InternalTemperature-master.zipbin246290 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/data_logging_teensy_temp.ino63
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/i2c_scanner/i2c_scanner.ino93
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID/PID.ino112
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID.py131
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID_autotune.ino82
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/man_test.py16
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master.zipbin9271 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/.gitignore1
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/README.md75
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino141
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/keywords.txt30
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/library.properties9
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/src/SoftPWM.h255
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/calibrated_motor/calibrated_motor.ino155
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/kiwidrive_calc.svg323
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swpbin61 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/avrage_motor_values.dat1
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/motor_calibration.ino231
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motordriver.ino386
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/nomultiplexer/nomultiplexer.ino254
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor/onemotor.ino86
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM/onemotor_softPWM.ino126
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino128
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/softPWM/softPWM.ino46
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/tree_motor_calibration/tree_motor_calibration.ino427
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/tcs34725/tcs34725.ino45
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/i2c_scanner/i2c_scanner.ino93
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID/PID.ino112
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID.py131
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID_autotune.ino82
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/man_test.py16
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master.zipbin9271 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/.gitignore1
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/README.md75
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino141
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/keywords.txt30
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/library.properties9
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/src/SoftPWM.h255
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/calibrated_motor/calibrated_motor.ino155
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/kiwidrive_calc.svg323
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swpbin61 -> 0 bytes
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/avrage_motor_values.dat1
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/motor_calibration.ino231
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motordriver.ino386
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/nomultiplexer/nomultiplexer.ino254
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor/onemotor.ino81
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM/onemotor_softPWM.ino126
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino128
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/softPWM/softPWM.ino46
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/tree_motor_calibration/tree_motor_calibration.ino427
-rw-r--r--OLD_CODE_REMOVE_LATER/debug/prewk/tcs34725/tcs34725.ino45
-rw-r--r--code/debug/communication/rx/rx_decode_teensy/.gitignore5
-rw-r--r--code/debug/communication/rx/rx_teensy/.gitignore5
-rw-r--r--code/debug/communication/rx/rx_teensy/src/main.cpp3
-rw-r--r--code/debug/communication/tx/tx-IR/include/README37
-rw-r--r--code/debug/communication/tx/tx-IR/lib/README46
-rw-r--r--code/debug/communication/tx/tx-IR/platformio.ini14
-rw-r--r--code/debug/communication/tx/tx-IR/src/main.cpp86
-rw-r--r--code/debug/communication/tx/tx-IR/test/README11
-rw-r--r--code/debug/communication/tx/tx_rand_XIAO/.gitignore5
-rw-r--r--code/debug/communication/tx/tx_rand_XIAO/src/main.cpp20
-rw-r--r--code/debug/motors/3m_test/.gitignore5
-rw-r--r--code/debug/motors/PWM/.gitignore5
-rw-r--r--code/debug/motors/PWM/src/main.cpp43
-rw-r--r--code/debug/motors/base_drive/.gitignore5
-rw-r--r--code/main/XIAO_ir/.gitignore5
-rw-r--r--code/main/teensy_goalie/.gitignore5
-rw-r--r--code/main/teensy_player/.gitignore5
146 files changed, 267 insertions, 15554 deletions
diff --git a/.gitignore b/.gitignore
index fafcf1e..77819c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,8 +48,8 @@ $RECYCLE.BIN/
.DS_Store
.AppleDouble
.LSOverride
-._*
.DocumentRevisions-V100
+._*
.fseventsd
.Spotlight-V100
.TemporaryItems
@@ -97,7 +97,6 @@ Project\ Outputs*/
*.sln.docstates
*.userprefs
mono_crash.*
-[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
@@ -111,15 +110,16 @@ bld/
[Oo]bj/
[Ll]og/
[Ll]ogs/
+[Tt]est[Rr]esult*/
.vs/
Generated\ Files/
-[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
project.lock.json
project.fragment.lock.json
artifacts/
*.binlog
.history/
+.vscode/
#freecad
*.pyc
@@ -130,3 +130,13 @@ artifacts/
# LibreOffice locks
.~lock.*#
+
+.pio
+.vscode/.browse.c_cpp.db*
+.vscode/c_cpp_properties.json
+.vscode/launch.json
+.vscode/ipch
+
+
+# more
+
diff --git a/OLD_CODE_REMOVE_LATER/code/teensy_code/teensy_code.ino b/OLD_CODE_REMOVE_LATER/code/teensy_code/teensy_code.ino
deleted file mode 100644
index f6918a7..0000000
--- a/OLD_CODE_REMOVE_LATER/code/teensy_code/teensy_code.ino
+++ /dev/null
@@ -1,373 +0,0 @@
-#include <TimerThree.h>
-#include <Arduino.h>
-
-int speed = 1000; // speed 0-1
-
-volatile int PWMval1 = 0; // PWM value 0-100
-volatile int PWMval2 = 0; // PWM value 0-100
-volatile int PWMval3 = 0; // PWM value 0-100
-
-int incomingbyte1 = 0; //the byte that it is reciefing
-bool iswriting1 = false; //true if writing else fals
-String tlocdat1 = ""; //temporary location data
-String locdat1 = ""; //location data
-int nir1 = "-99"; // which ir sensor it is
-int pir1 = "-99"; // amount of pulses it had
-
-int incomingbyte2 = 0; //same but for seeed xiao N 2
-bool iswriting2 = false;
-String tlocdat2 = "";
-String locdat2 = "";
-int nir2 = "-99";
-int pir2 = "-99";
-
-float degwhere = -99.0; // where the ball is in degrees
-
-int led = 13;
-
-int m1enA = 6;
-int m1enB = 5;
-int m1pwm1 = 4;
-int m1pwm2 = 3;
-int m1encoA = 32;
-int m1encoB = 31;
-
-int m2enA = 12;
-int m2enB = 11;
-int m2pwm1 = 9;
-int m2pwm2 = 10;
-int m2encoA = 30;
-int m2encoB = 29;
-
-int m3enA = 27;
-int m3enB = 26;
-int m3pwm1 = 24;
-int m3pwm2 = 25;
-int m3encoA = 28;
-int m3encoB = 23;
-
-int softpwr = 2;
-
-int pr1 = 13;
-int pr2 = 41;
-int pr3 = 40;
-int pr4 = 39;
-int pr5 = 38;
-int pr6 = 37;
-int pr7 = 36;
-int pr8 = 35;
-
-int dpr1 = "LOW";
-int dpr2 = "LOW";
-int dpr3 = "LOW";
-int dpr4 = "LOW";
-int dpr5 = "LOW";
-int dpr6 = "LOW";
-int dpr7 = "LOW";
-int dpr8 = "LOW";
-
-double sp1 = 0.00;
-double sp2 = 0.00;
-double sp3 = 0.00;
-
-void setup() {
- pinMode(m1enA, OUTPUT);
- pinMode(m1enB, OUTPUT);
- pinMode(m1pwm1, OUTPUT);
- pinMode(m1pwm2, OUTPUT);
-
- pinMode(m2enA, OUTPUT);
- pinMode(m2enB, OUTPUT);
- pinMode(m2pwm1, OUTPUT);
- pinMode(m2pwm2, OUTPUT);
-
- pinMode(m3enA, OUTPUT);
- pinMode(m3enB, OUTPUT);
- pinMode(m3pwm1, OUTPUT);
- pinMode(m3pwm2, OUTPUT);
-
- pinMode(softpwr, INPUT_PULLUP);
-
- pinMode(pr1, INPUT);
- pinMode(pr2, INPUT);
- pinMode(pr3, INPUT);
- pinMode(pr4, INPUT);
- pinMode(pr5, INPUT);
- pinMode(pr6, INPUT);
- pinMode(pr7, INPUT);
- pinMode(pr8, INPUT);
-
- Serial.begin(9600);
- Serial3.begin(9600);
- Serial2.begin(9600);
-
- Timer3.initialize(800); // 800 microseconds / 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval1) {
- digitalWrite(m1enA, HIGH);
- } else {
- digitalWrite(m1enA, LOW);
- }
-
- if (counter < PWMval2) {
- digitalWrite(m2enA, HIGH);
- } else {
- digitalWrite(m2enA, LOW);
- }
-
- if (counter < PWMval3) {
- digitalWrite(m3enA, HIGH);
- } else {
- digitalWrite(m3enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm1(int value1) {
- if (value1 < 0) value1 = 0;
- if (value1 > 100) value1 = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value1);
- PWMval1 = value1;
-}
-void mcpsoftpwm2(int value2) {
- if (value2 < 0) value2 = 0;
- if (value2 > 100) value2 = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value2);
- PWMval2 = value2;
-}void mcpsoftpwm3(int value3) {
- if (value3 < 0) value3 = 0;
- if (value3 > 100) value3 = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value3);
- PWMval3 = value3;
-}
-
-void move1(int sped1) {
- sp1 = abs(sped1)*0.1;
- mcpsoftpwm1(sp1);
- digitalWrite(m1enB, LOW);
- if (sped1 < 0) {
- Serial.print("back ");
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
- }
- Serial.println(sp1);
-}
-
-void move2(int sped2) {
- sp2 = abs(sped2)*0.1;
- mcpsoftpwm2(sp2);
- digitalWrite(m2enB, LOW);
- if (sped2 < 0) {
- Serial.print("back ");
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
- }
- Serial.println(sp2);
-}
-
-void move3(int sped3) {
- sp3 = abs(sped3)*0.1;
- mcpsoftpwm3(sp3);
- digitalWrite(m3enB, LOW);
- if (sped3 < 0) {
- Serial.print("back ");
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
- }
- Serial.println(sp3);
-}
-
-
-void drive(int speeeed, int direction){
- //
- // Direction............|.Motor 1.|.Motor 2.|.Motor 3.
- // 0deg(forward)........|....0....|....-....|....+....
- // 60deg................|....+....|....-....|....0....
- // 120deg...............|....+....|....0....|....-....
- // 180 deg (backward)...|....0....|....+....|....-....
- // 240 deg..............|....-....|....+....|....0....
- // 300 deg..............|....-....|....0....|....+....
- //
- if(direction>330 || direction<=30){
- //0 deg
- //Serial.println("drive 0 deg");
- move1(0);
- move2(-speeeed);
- move3(speeeed);
- }else if (direction>30 && direction <= 90){
- //60 deg
- //Serial.println("drive 60deg");
- move1(speeeed);
- move2(-speeeed);
- move3(0);
- }else if (direction>90 && direction <= 150){
- //120 deg
- //Serial.println("drive 120 deg");
- move1(speeeed);
- move2(0);
- move3(-speeeed);
- }else if (direction > 150 && direction <= 210) {
- //180 degrees
- //Serial.println("drive 180 deg");
- move1(0);
- move2(speeeed);
- move3(-speeeed);
- }else if (direction > 210 && direction <= 270) {
- //240 degrees
- //Serial.println("drive 240 deg");
- move1(-speeeed);
- move2(speeeed);
- move3(0);
- }else if (direction > 270 && direction <= 330) {
- //300 degrees
- //Serial.println("drive 300 deg");
- move1(-speeeed);
- move2(0);
- move3(speeeed);
- }else{
- Serial.println("how?");
- }
-}
-
-void loop() {
- int sprst = digitalRead(softpwr); //softpower status
- if(sprst == LOW){
- dpr1 = digitalRead(pr1);
- dpr2 = digitalRead(pr2);
- dpr3 = digitalRead(pr3);
- dpr4 = digitalRead(pr4);
- dpr5 = digitalRead(pr5);
- dpr6 = digitalRead(pr6);
- dpr7 = digitalRead(pr7);
- dpr8 = digitalRead(pr8);
-
- if(dpr1 == HIGH){
- //go back to ?deg
- }else if (dpr2 == HIGH){
- //go back to ?deg
- }else if (dpr3 == HIGH){
- //go back to ?deg
- }else if (dpr4 == HIGH){
- //go back to ?deg
- }else if (dpr5 == HIGH){
- //go back to ?deg
- }else if (dpr6 == HIGH){
- //go back to ?deg
- }else if (dpr7 == HIGH){
- //go back to ?deg
- }else if (dpr8 == HIGH){
- //go back to ?deg
- }else{
- if (Serial3.available() > 0) {
- incomingbyte1 = Serial3.read();
- //Serial.print(char(incomingbyte1));
- if (incomingbyte1 == 's'){
- iswriting1 = true;
- tlocdat1 = "";
- }else if(incomingbyte1 == 'e'){
- iswriting1 = false;
- locdat1 = tlocdat1;
- }else if(iswriting1 == true){
- //Serial.print(char(incomingbyte1));
- tlocdat1 += (char)incomingbyte1;
- }
- }
- if (Serial2.available() > 0) {
- incomingbyte2 = Serial2.read();
- //Serial.print(char(incomingbyte2));
- if (incomingbyte2 == 's'){
- iswriting2 = true;
- tlocdat2 = "";
- }else if(incomingbyte1 == 'e'){
- iswriting2 = false;
- locdat2 = tlocdat1;
- }else if(iswriting2 == true){
- //Serial.print(char(incomingbyte1));
- tlocdat2 += (char)incomingbyte1;
- }
- }
- //Serial.println(locdat);
- sscanf(locdat1.c_str(), "%d, %d", &nir1, &pir1);
- sscanf(locdat2.c_str(), "%d, %d", &nir2, &pir2);
-
- Serial.print("locdat: ");
- Serial.print(String(locdat1));
- Serial.println(String(locdat2));
-
-
- if(pir1 > pir2){
- if(nir1 = 1){ //not good looking code because posbile wrong wireing
- degwhere = 0;
- }else if(nir1 = 2){
- degwhere = 22.5;
- }else if(nir1 = 3){
- degwhere = 45;
- }else if(nir1 = 4){
- degwhere = 67.5;
- }else if(nir1 = 5){
- degwhere = 90;
- }else if(nir1 = 6){
- degwhere = 112.5;
- }else if(nir1 = 7){
- degwhere = 135;
- }else if(nir1 = 8){
- degwhere = 157.5;
- }
- }else{
- if(nir2 = 1){
- degwhere = 180;
- }else if(nir2 = 2){
- degwhere = 202.5;
- }else if(nir2 = 3){
- degwhere = 225;
- }else if(nir2 = 4){
- degwhere = 247.5;
- }else if(nir2 = 5){
- degwhere = 270;
- }else if(nir2 = 6){
- degwhere = 292.5;
- }else if(nir2 = 7){
- degwhere = 315;
- }else if(nir2 = 8){
- degwhere = 337.5;
- }
- }
-
- Serial.print("Ball is at ");
- Serial.print(degwhere);
- Serial.println(" degrees.");
- drive(75, degwhere);
- delay(1);
- }
- }else{
- Serial.println("softPWR is off, waiting");
- delay(100);
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/IR/IR_sens/IR_sens.ino b/OLD_CODE_REMOVE_LATER/debug/IR/IR_sens/IR_sens.ino
deleted file mode 100644
index 85089d4..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/IR/IR_sens/IR_sens.ino
+++ /dev/null
@@ -1,149 +0,0 @@
-int ir1 = 0;
-int ir2 = 1;
-int ir3 = 9;
-int ir4 = 2;
-int ir5 = 3;
-int ir6 = 4;
-int ir7 = 5;
-int ir8 = 8;
-
-int dir1 = 1; // data IR1
-int dir2 = 1; // data IR2
-int dir3 = 1; // etc
-int dir4 = 1;
-int dir5 = 1;
-int dir6 = 1;
-int dir7 = 1;
-int dir8 = 1;
-
-volatile long IRcount1 = 0;
-volatile long IRcount2 = 0;
-volatile long IRcount3 = 0;
-volatile long IRcount4 = 0;
-volatile long IRcount5 = 0;
-volatile long IRcount6 = 0;
-volatile long IRcount7 = 0;
-volatile long IRcount8 = 0;
-
-void setup() {
- pinMode(ir1, INPUT);
- pinMode(ir2, INPUT);
- pinMode(ir3, INPUT);
- pinMode(ir4, INPUT);
- pinMode(ir5, INPUT);
- pinMode(ir6, INPUT);
- pinMode(ir7, INPUT);
- pinMode(ir8, INPUT);
-
- Serial.begin(9600);
- Serial1.begin(9600);
- Serial.println("start");
- Serial1.println("start");
-
- attachInterrupt(digitalPinToInterrupt(ir1), IRtrigger1, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir2), IRtrigger2, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir3), IRtrigger3, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir4), IRtrigger4, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir5), IRtrigger5, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir6), IRtrigger6, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir7), IRtrigger7, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir8), IRtrigger8, CHANGE);
-
- Serial.println("Starting loop");
- Serial1.println("Starting loop");
-}
-
-void IRtrigger1() {
- IRcount1++;
-}
-void IRtrigger2() {
- IRcount2++;
-}
-void IRtrigger3() {
- IRcount3++;
-}
-void IRtrigger4() {
- IRcount4++;
-}
-void IRtrigger5() {
- IRcount5++;
-}
-void IRtrigger6() {
- IRcount6++;
-}
-void IRtrigger7() {
- IRcount7++;
-}
-void IRtrigger8() {
- IRcount8++;
-}
-
-void loop() {
- Serial.print("ir 1 changes: ");
- Serial.print(IRcount1);
- Serial.print(", ir 2 changes: ");
- Serial.print(IRcount2);
- Serial.print(", ir 3 changes: ");
- Serial.print(IRcount3);
- Serial.print(", ir 4 changes: ");
- Serial.print(IRcount4);
- Serial.print(", ir 5 changes: ");
- Serial.print(IRcount5);
- Serial.print(", ir 6 changes: ");
- Serial.print(IRcount6);
- Serial.print(", ir 7 changes: ");
- Serial.print(IRcount7);
- Serial.print(", ir 8 changes: ");
- Serial.println(IRcount8);
-
- Serial1.print("ir 1 changes: ");
- Serial1.print(IRcount1);
- Serial1.print(", ir 2 changes: ");
- Serial1.print(IRcount2);
- Serial1.print(", ir 3 changes: ");
- Serial1.print(IRcount3);
- Serial1.print(", ir 4 changes: ");
- Serial1.print(IRcount4);
- Serial1.print(", ir 5 changes: ");
- Serial1.print(IRcount5);
- Serial1.print(", ir 6 changes: ");
- Serial1.print(IRcount6);
- Serial1.print(", ir 7 changes: ");
- Serial1.print(IRcount7);
- Serial1.print(", ir 8 changes: ");
- Serial1.print(IRcount8);
-
- volatile long IRcounts[] = {IRcount1, IRcount2, IRcount3, IRcount4, IRcount5, IRcount6, IRcount7, IRcount8};
- long maxCount = IRcounts[0];
- int highessensor = 1;
- for (int i = 0; i < 7; ++i) {
- if (IRcounts[i] > maxCount) {
- maxCount = IRcounts[i];
- highessensor = i + 1;
- }
- }
- Serial.print("Ball is at sensor: ");
- Serial.print(highessensor);
- Serial.print(", with value of ");
- Serial.println(maxCount);
-
- Serial1.print("s");
- Serial1.print(highessensor);
- Serial1.print(", ");
- Serial1.println(maxCount);
- Serial1.print("e");
-
- IRcount1 = 0;
- IRcount2 = 0;
- IRcount3 = 0;
- IRcount4 = 0;
- IRcount5 = 0;
- IRcount6 = 0;
- IRcount7 = 0;
- IRcount8 = 0;
-
-
-
- delay(250);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/IR/communication/direct_rx/direct_rx.ino b/OLD_CODE_REMOVE_LATER/debug/IR/communication/direct_rx/direct_rx.ino
deleted file mode 100644
index 336b27b..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/IR/communication/direct_rx/direct_rx.ino
+++ /dev/null
@@ -1,15 +0,0 @@
-int incomingbyte = 0;
-void setup() {
- Serial.begin(9600);
- Serial2.begin(9600); //19200
- Serial3.begin(9600); //19200
- Serial.print("Starting ....");
-}
-
-void loop() {
- if (Serial3.available() > 0) {
- incomingbyte = Serial3.read();
- Serial.print(char(incomingbyte));
- }
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/IR/communication/rx_teensy/rx_teensy.ino b/OLD_CODE_REMOVE_LATER/debug/IR/communication/rx_teensy/rx_teensy.ino
deleted file mode 100644
index 68a768b..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/IR/communication/rx_teensy/rx_teensy.ino
+++ /dev/null
@@ -1,35 +0,0 @@
-int incomingbyte = 0;
-bool iswriting = false;
-String tlocdat = ""; //temporary location data
-String locdat = ""; //location data
-int nir = "-99"; // which ir sensor it is
-int pir = "-99"; // amount of pulses it had
-void setup() {
- Serial.begin(9600);
- Serial3.begin(9600); //19200
-}
-
-void loop() {
- if (Serial3.available() > 0) {
- incomingbyte = Serial3.read();
- //Serial.print(char(incomingbyte));
- if (incomingbyte == 's'){
- iswriting = true;
- tlocdat = "";
- }else if(incomingbyte == 'e'){
- iswriting = false;
- locdat = tlocdat;
- }else if(iswriting == true){
- //Serial.print(char(incomingbyte));
- tlocdat += (char)incomingbyte;
- }
- }
- //Serial.println(locdat);
- sscanf(locdat.c_str(), "%d, %d", &nir, &pir);
- Serial.print("IR sensor N: ");
- Serial.print(nir);
- Serial.print(", with ");
- Serial.print(pir);
- Serial.println(" pulses.");
- delay(10);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/IR/communication/tx_seeed/tx_seeed.ino b/OLD_CODE_REMOVE_LATER/debug/IR/communication/tx_seeed/tx_seeed.ino
deleted file mode 100644
index dc2d2e9..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/IR/communication/tx_seeed/tx_seeed.ino
+++ /dev/null
@@ -1,29 +0,0 @@
-long randNumber1;
-long randNumber2;
-
-void setup() {
- Serial.begin(9600);
- Serial1.begin(9600);
- delay(2500);
- randomSeed(analogRead(0));
-
-}
-
-void loop() {
- randNumber1 = random(1000);
- randNumber2 = random(1, 8);
- Serial1.print("s");
- Serial1.print(randNumber2);
- Serial1.print(", ");
- Serial1.print(randNumber1);
- Serial1.print("e");
-
- Serial.print("s");
- Serial.print(randNumber2);
- Serial.print(", ");
- Serial.print(randNumber1);
- Serial.println("e");
- delay(1000);
-
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/IR/teensydeco/teensydeco.ino b/OLD_CODE_REMOVE_LATER/debug/IR/teensydeco/teensydeco.ino
deleted file mode 100644
index f8fe2a5..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/IR/teensydeco/teensydeco.ino
+++ /dev/null
@@ -1,104 +0,0 @@
-int incomingbyte1 = 0; //the byte that it is reciefing
-bool iswriting1 = false; //true if writing else fals
-String tlocdat1 = ""; //temporary location data
-String locdat1 = ""; //location data
-int nir1 = "-99"; // which ir sensor it is
-int pir1 = "-99"; // amount of pulses it had
-
-int incomingbyte2 = 0; //same but for seeed xiao N 2
-bool iswriting2 = false;
-String tlocdat2 = "";
-String locdat2 = "";
-int nir2 = "-99";
-int pir2 = "-99";
-
-float degwhere = -99.0; // where the ball is in degrees
-
-void setup() {
- Serial.begin(9600);
- Serial3.begin(9600);
- Serial2.begin(9600);
-}
-
-void loop() {
- if (Serial3.available() > 0) {
- incomingbyte1 = Serial3.read();
- //Serial.print(char(incomingbyte1));
- if (incomingbyte1 == 's'){
- iswriting1 = true;
- tlocdat1 = "";
- }else if(incomingbyte1 == 'e'){
- iswriting1 = false;
- locdat1 = tlocdat1;
- }else if(iswriting1 == true){
- //Serial.print(char(incomingbyte1));
- tlocdat1 += (char)incomingbyte1;
- }
- }
- if (Serial2.available() > 0) {
- incomingbyte2 = Serial2.read();
- //Serial.print(char(incomingbyte2));
- if (incomingbyte2 == 's'){
- iswriting2 = true;
- tlocdat2 = "";
- }else if(incomingbyte1 == 'e'){
- iswriting2 = false;
- locdat2 = tlocdat1;
- }else if(iswriting2 == true){
- //Serial.print(char(incomingbyte1));
- tlocdat2 += (char)incomingbyte1;
- }
- }
- //Serial.println(locdat);
- sscanf(locdat1.c_str(), "%d, %d", &nir1, &pir1);
- sscanf(locdat2.c_str(), "%d, %d", &nir2, &pir2);
-
-
- if(pir1 > pir2){
- if(nir1 = 1){ //not good looking code because posbile wrong wireing
- degwhere = 0;
- }else if(nir1 = 2){
- degwhere = 22.5;
- }else if(nir1 = 3){
- degwhere = 45;
- }else if(nir1 = 4){
- degwhere = 67.5;
- }else if(nir1 = 5){
- degwhere = 90;
- }else if(nir1 = 6){
- degwhere = 112.5;
- }else if(nir1 = 7){
- degwhere = 135;
- }else if(nir1 = 8){
- degwhere = 157.5;
- }
- }else{
- if(nir2 = 1){
- degwhere = 180;
- }else if(nir2 = 2){
- degwhere = 202.5;
- }else if(nir2 = 3){
- degwhere = 225;
- }else if(nir2 = 4){
- degwhere = 247.5;
- }else if(nir2 = 5){
- degwhere = 270;
- }else if(nir2 = 6){
- degwhere = 292.5;
- }else if(nir2 = 7){
- degwhere = 315;
- }else if(nir2 = 8){
- degwhere = 337.5;
- }
- }
-
- Serial.print("IR sensor N: ");
- Serial.print(nir1);
- Serial.print(", with ");
- Serial.print(pir1);
- Serial.println(" pulses.");
- Serial.print("That is ");
- Serial.print(degwhere);
- Serial.println(" degrees.");
- delay(10);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/color/color.ino b/OLD_CODE_REMOVE_LATER/debug/color/color.ino
deleted file mode 100644
index 3397f72..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/color/color.ino
+++ /dev/null
@@ -1,58 +0,0 @@
-int pr1 = 13;
-int pr2 = 41;
-int pr3 = 40;
-int pr4 = 39;
-int pr5 = 38;
-int pr6 = 37;
-int pr7 = 36;
-int pr8 = 35;
-
-int dpr1 = "LOW";
-int dpr2 = "LOW";
-int dpr3 = "LOW";
-int dpr4 = "LOW";
-int dpr5 = "LOW";
-int dpr6 = "LOW";
-int dpr7 = "LOW";
-int dpr8 = "LOW";
-
-
-void setup() {
- pinMode(pr1, INPUT);
- pinMode(pr2, INPUT);
- pinMode(pr3, INPUT);
- pinMode(pr4, INPUT);
- pinMode(pr5, INPUT);
- pinMode(pr6, INPUT);
- pinMode(pr7, INPUT);
- pinMode(pr8, INPUT);
-}
-
-void loop() {
- dpr1 = digitalRead(pr1);
- dpr2 = digitalRead(pr2);
- dpr3 = digitalRead(pr3);
- dpr4 = digitalRead(pr4);
- dpr5 = digitalRead(pr5);
- dpr6 = digitalRead(pr6);
- dpr7 = digitalRead(pr7);
- dpr8 = digitalRead(pr8);
-
- if(dpr1 == HIGH){
- //go back to ?deg
- }else if (dpr2 == HIGH){
- //go back to ?deg
- }else if (dpr3 == HIGH){
- //go back to ?deg
- }else if (dpr4 == HIGH){
- //go back to ?deg
- }else if (dpr5 == HIGH){
- //go back to ?deg
- }else if (dpr6 == HIGH){
- //go back to ?deg
- }else if (dpr7 == HIGH){
- //go back to ?deg
- }else if (dpr8 == HIGH){
- //go back to ?deg
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/driving/3mtest/3mtest.ino b/OLD_CODE_REMOVE_LATER/debug/driving/3mtest/3mtest.ino
deleted file mode 100644
index da87ab5..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/driving/3mtest/3mtest.ino
+++ /dev/null
@@ -1,92 +0,0 @@
-//a test to test all motors, no PWM
-
-
-int led = 13;
-
-int m1enA = 6;
-int m1enB = 5;
-int m1pwm1 = 4;
-int m1pwm2 = 3;
-int m1encoA = 32;
-int m1encoB = 31;
-
-int m2enA = 12;
-int m2enB = 11;
-int m2pwm1 = 9;
-int m2pwm2 = 10;
-int m2encoA = 30;
-int m2encoB = 29;
-
-int m3enA = 27;
-int m3enB = 26;
-int m3pwm1 = 24;
-int m3pwm2 = 25;
-int m3encoA = 28;
-int m3encoB = 23;
-
-
-void setup() {
- pinMode(m1enA, OUTPUT);
- pinMode(m1enB, OUTPUT);
- pinMode(m1pwm1, OUTPUT);
- pinMode(m1pwm2, OUTPUT);
-
- pinMode(m2enA, OUTPUT);
- pinMode(m2enB, OUTPUT);
- pinMode(m2pwm1, OUTPUT);
- pinMode(m2pwm2, OUTPUT);
-
- pinMode(m3enA, OUTPUT);
- pinMode(m3enB, OUTPUT);
- pinMode(m3pwm1, OUTPUT);
- pinMode(m3pwm2, OUTPUT);
- Serial.begin(9600);
- Serial.print("debug 001");
-
-}
-
-// the loop routine runs over and over again forever:
-void loop() {
- digitalWrite(led, HIGH);
-
- digitalWrite(m1enA, HIGH);
- digitalWrite(m1enB, LOW);
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
-
-
- digitalWrite(m2enA, HIGH);
- digitalWrite(m2enB, LOW);
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
-
- digitalWrite(m3enA, HIGH);
- digitalWrite(m3enB, LOW);
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
-
- delay(5000);
-
-
- digitalWrite(led, LOW);
-
- digitalWrite(m1enA, HIGH);
- digitalWrite(m1enB, LOW);
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, LOW);
-
- digitalWrite(m2enA, HIGH);
- digitalWrite(m2enB, LOW);
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, LOW);
-
- digitalWrite(m3enA, HIGH);
- digitalWrite(m3enB, LOW);
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, LOW);
-
-
- delay(5000);
-
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/driving/base_drive/base_drive.ino b/OLD_CODE_REMOVE_LATER/debug/driving/base_drive/base_drive.ino
deleted file mode 100644
index 0e82170..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/driving/base_drive/base_drive.ino
+++ /dev/null
@@ -1,140 +0,0 @@
-//base code for six direction driving
-int led = 13;
-
-int m1enA = 6;
-int m1enB = 5;
-int m1pwm1 = 4;
-int m1pwm2 = 3;
-int m1encoA = 32;
-int m1encoB = 31;
-
-int m2enA = 12;
-int m2enB = 11;
-int m2pwm1 = 9;
-int m2pwm2 = 10;
-int m2encoA = 30;
-int m2encoB = 29;
-
-int m3enA = 27;
-int m3enB = 26;
-int m3pwm1 = 24;
-int m3pwm2 = 25;
-int m3encoA = 28;
-int m3encoB = 23;
-
-void setup() {
- pinMode(m1enA, OUTPUT);
- pinMode(m1enB, OUTPUT);
- pinMode(m1pwm1, OUTPUT);
- pinMode(m1pwm2, OUTPUT);
-
- pinMode(m2enA, OUTPUT);
- pinMode(m2enB, OUTPUT);
- pinMode(m2pwm1, OUTPUT);
- pinMode(m2pwm2, OUTPUT);
-
- pinMode(m3enA, OUTPUT);
- pinMode(m3enB, OUTPUT);
- pinMode(m3pwm1, OUTPUT);
- pinMode(m3pwm2, OUTPUT);
- Serial.begin(9600);
- Serial.print("start");
-
-}
-
-
-void drive(int speed, int direction){
- //
- // Direction............|.Motor 1.|.Motor 2.|.Motor 3.
- // 0deg(forward)........|....0....|....-....|....+....
- // 60deg................|....+....|....-....|....0....
- // 120deg...............|....+....|....0....|....-....
- // 180 deg (backward)...|....0....|....+....|....-....
- // 240 deg..............|....-....|....+....|....0....
- // 300 deg..............|....-....|....0....|....+....
- //
-
- digitalWrite(m1enA, HIGH);
- digitalWrite(m2enA, HIGH);
- digitalWrite(m3enA, HIGH);
- digitalWrite(m1enB, LOW);
- digitalWrite(m2enB, LOW);
- digitalWrite(m3enB, LOW);
- Serial.println("debug2");
- Serial.println(direction);
- if(direction>330 || direction<=30){
- //0 deg
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, HIGH);
-
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, LOW);
-
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, HIGH);
- Serial.println("0 deg");
- }else if (direction>30 && direction <= 90){
- //60 deg
- Serial.println("60deg");
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, LOW);
-
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
-
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, HIGH);
- }else if (direction>90 && direction <= 150){
- //120 deg
- Serial.println("120 deg");
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, LOW);
- }else if (direction > 150 && direction <= 210) {
- //180 degrees
- Serial.println("on 180");
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
-
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, LOW);
-
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
- }else if (direction > 210 && direction <= 270) {
- //240 degrees
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, LOW);
-
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, HIGH);
-
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
- }else if (direction > 270 && direction <= 330) {
- //300 degrees
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, HIGH);
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, HIGH);
- Serial.println("300deg");
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, LOW);
- }else{
- Serial.println("how?");
- }
-}
-
-// the loop routine runs over and over again forever:
-void loop() {
- drive(255, 0);
- Serial.println("ffor");
- delay(1500);
- drive(255, 180);
- Serial.println("back");
- delay(1500);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/driving/base_drive_with_speed_control/base_drive_with_speed_control.ino b/OLD_CODE_REMOVE_LATER/debug/driving/base_drive_with_speed_control/base_drive_with_speed_control.ino
deleted file mode 100644
index e5a783e..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/driving/base_drive_with_speed_control/base_drive_with_speed_control.ino
+++ /dev/null
@@ -1,214 +0,0 @@
-#include <TimerThree.h>
-
-int m1enA = 6;
-int m1enB = 5;
-int m1pwm1 = 4;
-int m1pwm2 = 3;
-int m1encoA = 32;
-int m1encoB = 31;
-
-int m2enA = 12;
-int m2enB = 11;
-int m2pwm1 = 9;
-int m2pwm2 = 10;
-int m2encoA = 30;
-int m2encoB = 29;
-
-int m3enA = 27;
-int m3enB = 26;
-int m3pwm1 = 24;
-int m3pwm2 = 25;
-int m3encoA = 28;
-int m3encoB = 23;
-
-int speed = 1000; // speed 0-1
-
-double sp1 = 0.00;
-double sp2 = 0.00;
-double sp3 = 0.00;
-
-volatile int PWMval1 = 0; // PWM value 0-100
-volatile int PWMval2 = 0; // PWM value 0-100
-volatile int PWMval3 = 0; // PWM value 0-100
-
-
-void setup() {
- pinMode(m1enA, OUTPUT);
- pinMode(m1enB, OUTPUT);
- pinMode(m1pwm1, OUTPUT);
- pinMode(m1pwm2, OUTPUT);
-
- pinMode(m2enA, OUTPUT);
- pinMode(m2enB, OUTPUT);
- pinMode(m2pwm1, OUTPUT);
- pinMode(m2pwm2, OUTPUT);
-
- pinMode(m3enA, OUTPUT);
- pinMode(m3enB, OUTPUT);
- pinMode(m3pwm1, OUTPUT);
- pinMode(m3pwm2, OUTPUT);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval1) {
- digitalWrite(m1enA, HIGH);
- } else {
- digitalWrite(m1enA, LOW);
- }
-
- if (counter < PWMval2) {
- digitalWrite(m2enA, HIGH);
- } else {
- digitalWrite(m2enA, LOW);
- }
-
- if (counter < PWMval3) {
- digitalWrite(m3enA, HIGH);
- } else {
- digitalWrite(m3enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm1(int value1) {
- if (value1 < 0) value1 = 0;
- if (value1 > 100) value1 = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value1);
- PWMval1 = value1;
-}
-void mcpsoftpwm2(int value2) {
- if (value2 < 0) value2 = 0;
- if (value2 > 100) value2 = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value2);
- PWMval2 = value2;
-}void mcpsoftpwm3(int value3) {
- if (value3 < 0) value3 = 0;
- if (value3 > 100) value3 = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value3);
- PWMval3 = value3;
-}
-
-void move1(int sped1) {
- sp1 = abs(sped1)*0.1;
- mcpsoftpwm1(sp1);
- digitalWrite(m1enB, LOW);
- if (sped1 < 0) {
- Serial.print("back ");
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
- }
- Serial.println(sp1);
-}
-
-void move2(int sped2) {
- sp2 = abs(sped2)*0.1;
- mcpsoftpwm2(sp2);
- digitalWrite(m2enB, LOW);
- if (sped2 < 0) {
- Serial.print("back ");
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
- }
- Serial.println(sp2);
-}
-
-void move3(int sped3) {
- sp3 = abs(sped3)*0.1;
- mcpsoftpwm3(sp3);
- digitalWrite(m3enB, LOW);
- if (sped3 < 0) {
- Serial.print("back ");
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
- }
- Serial.println(sp3);
-}
-
-void drive(int speeeed, int direction){
- //
- // Direction............|.Motor 1.|.Motor 2.|.Motor 3.
- // 0deg(forward)........|....0....|....-....|....+....
- // 60deg................|....+....|....-....|....0....
- // 120deg...............|....+....|....0....|....-....
- // 180 deg (backward)...|....0....|....+....|....-....
- // 240 deg..............|....-....|....+....|....0....
- // 300 deg..............|....-....|....0....|....+....
- //
- if(direction>330 || direction<=30){
- //0 deg
- //Serial.println("drive 0 deg");
- move1(0);
- move2(-speeeed);
- move3(speeeed);
- }else if (direction>30 && direction <= 90){
- //60 deg
- //Serial.println("drive 60deg");
- move1(speeeed);
- move2(-speeeed);
- move3(0);
- }else if (direction>90 && direction <= 150){
- //120 deg
- //Serial.println("drive 120 deg");
- move1(speeeed);
- move2(0);
- move3(-speeeed);
- }else if (direction > 150 && direction <= 210) {
- //180 degrees
- //Serial.println("drive 180 deg");
- move1(0);
- move2(speeeed);
- move3(-speeeed);
- }else if (direction > 210 && direction <= 270) {
- //240 degrees
- //Serial.println("drive 240 deg");
- move1(-speeeed);
- move2(speeeed);
- move3(0);
- }else if (direction > 270 && direction <= 330) {
- //300 degrees
- //Serial.println("drive 300 deg");
- move1(-speeeed);
- move2(0);
- move3(speeeed);
- }else{
- Serial.println("how?");
- }
-}
-
-void loop() {
- drive(1000, 0);
- Serial.println("ffor");
- delay(1500);
- drive(500, 180);
- Serial.println("back");
- delay(3000);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/driving/onemotor_softPWM/onemotor_softPWM.ino b/OLD_CODE_REMOVE_LATER/debug/driving/onemotor_softPWM/onemotor_softPWM.ino
deleted file mode 100644
index 68d95dd..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/driving/onemotor_softPWM/onemotor_softPWM.ino
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <TimerThree.h>
-
-int enA = 6; //PWM pin
-int enB = 5; //GND
-int pwm1 = 4; //
-int pwm2 = 3;
-int encoA = 32;
-int encoB = 31;
-
-int speed = 1000; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-
- move(0);
- delay(1000);
- resetenc();
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-
- move(500);
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/Calibrate/Calibrate.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/Calibrate/Calibrate.ino
deleted file mode 100644
index c5db31c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/Calibrate/Calibrate.ino
+++ /dev/null
@@ -1,42 +0,0 @@
-//example from https://github.com/pololu/lis3mdl-arduino
-#include <Wire.h>
-#include <LIS3MDL.h>
-
-LIS3MDL mag;
-LIS3MDL::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768};
-
-char report[80];
-
-void setup()
-{
- Serial.begin(9600);
- Wire.begin();
-
- if (!mag.init())
- {
- Serial.println("Failed to detect and initialize magnetometer!");
- while (1);
- }
-
- mag.enableDefault();
-}
-
-void loop()
-{
- mag.read();
-
- running_min.x = min(running_min.x, mag.m.x);
- running_min.y = min(running_min.y, mag.m.y);
- running_min.z = min(running_min.z, mag.m.z);
-
- running_max.x = max(running_max.x, mag.m.x);
- running_max.y = max(running_max.y, mag.m.y);
- running_max.z = max(running_max.z, mag.m.z);
-
- snprintf(report, sizeof(report), "min: {%+6d, %+6d, %+6d} max: {%+6d, %+6d, %+6d}",
- running_min.x, running_min.y, running_min.z,
- running_max.x, running_max.y, running_max.z);
- Serial.println(report);
-
- delay(100);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino
deleted file mode 100644
index ac60515..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-This sketch combines magnetometer readings from an LIS3MDL and accelerometer
-readings from an LSM6 to calculate a tilt-compensated magnetic heading. It
-requires Pololu's LSM6 Arduino library to be installed:
-
-https://github.com/pololu/lsm6-arduino
-
-This program can be used with a board that includes both sensors, like the
-Pololu MinIMU-9 v5 and AltIMU-10 v5, or with separate carrier boards for the two
-sensors, both connected to the same I2C bus. If you are using separate boards,
-make sure the axes are oriented the same way on both (i.e. the X, Y, and Z axes
-of both boards should point in the same direction, and the surfaces of the
-boards should be as close to parallel as possible).
-*/
-
-#include <Wire.h>
-#include <LIS3MDL.h>
-#include <LSM6.h>
-
-LIS3MDL mag;
-LSM6 imu;
-
-/*
-Calibration values; the default values of +/-32767 for each axis
-lead to an assumed magnetometer bias of 0. Use the Calibrate example
-program to determine appropriate values for your particular unit.
-*/
-LIS3MDL::vector<int16_t> m_min = {+5862, +2474, -6186};
-LIS3MDL::vector<int16_t> m_max = {+6610, +2849, -5547};
-
-void setup()
-{
- Serial.begin(9600);
- Wire.begin();
-
- if (!mag.init())
- {
- Serial.println("Failed to detect and initialize LIS3MDL magnetometer!");
- while (1);
- }
- mag.enableDefault();
-
- if (!imu.init())
- {
- Serial.println("Failed to detect and initialize LSM6 IMU!");
- while (1);
- }
- imu.enableDefault();
-}
-
-void loop()
-{
- mag.read();
- imu.read();
-
- /*
- When given no arguments, the heading() function returns the angular
- difference in the horizontal plane between a default vector (the
- +X axis) and north, in degrees.
- */
- float heading = computeHeading();
-
- /*
- To use a different vector as a reference, use the version of
- computeHeading() that takes a vector argument; for example, call it like this
- to use the -Z axis as a reference:
- */
- //float heading = computeHeading((LIS3MDL::vector<int>){0, 0, -1});
-
- Serial.println(heading);
- delay(100);
-}
-
-/*
-Returns the angular difference in the horizontal plane between the
-"from" vector and north, in degrees.
-
-Description of heading algorithm:
-Shift and scale the magnetic reading based on calibration data to find
-the North vector. Use the acceleration readings to determine the Up
-vector (gravity is measured as an upward acceleration). The cross
-product of North and Up vectors is East. The vectors East and North
-form a basis for the horizontal plane. The From vector is projected
-into the horizontal plane and the angle between the projected vector
-and horizontal north is returned.
-*/
-template <typename T> float computeHeading(LIS3MDL::vector<T> from)
-{
- LIS3MDL::vector<int32_t> temp_m = {mag.m.x, mag.m.y, mag.m.z};
-
- // copy acceleration readings from LSM6::vector into an LIS3MDL::vector
- LIS3MDL::vector<int16_t> a = {imu.a.x, imu.a.y, imu.a.z};
-
- // subtract offset (average of min and max) from magnetometer readings
- temp_m.x -= ((int32_t)m_min.x + m_max.x) / 2;
- temp_m.y -= ((int32_t)m_min.y + m_max.y) / 2;
- temp_m.z -= ((int32_t)m_min.z + m_max.z) / 2;
-
- // compute E and N
- LIS3MDL::vector<float> E;
- LIS3MDL::vector<float> N;
- LIS3MDL::vector_cross(&temp_m, &a, &E);
- LIS3MDL::vector_normalize(&E);
- LIS3MDL::vector_cross(&a, &E, &N);
- LIS3MDL::vector_normalize(&N);
-
- // compute heading
- float heading = atan2(LIS3MDL::vector_dot(&E, &from), LIS3MDL::vector_dot(&N, &from)) * 180 / PI;
- if (heading < 0) heading += 360;
- return heading;
-}
-
-/*
-Returns the angular difference in the horizontal plane between a
-default vector (the +X axis) and north, in degrees.
-*/
-float computeHeading()
-{
- return computeHeading((LIS3MDL::vector<int>){1, 0, 0});
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/IMU_comp.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/IMU_comp.ino
deleted file mode 100644
index c4578cb..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/IMU_comp.ino
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-This sketch combines magnetometer readings from an LIS3MDL and accelerometer
-readings from an LSM6 to calculate a tilt-compensated magnetic heading. It
-requires Pololu's LSM6 Arduino library to be installed:
-
-https://github.com/pololu/lsm6-arduino
-
-This program can be used with a board that includes both sensors, like the
-Pololu MinIMU-9 v5 and AltIMU-10 v5, or with separate carrier boards for the two
-sensors, both connected to the same I2C bus. If you are using separate boards,
-make sure the axes are oriented the same way on both (i.e. the X, Y, and Z axes
-of both boards should point in the same direction, and the surfaces of the
-boards should be as close to parallel as possible).
-*/
-
-#include <Wire.h>
-#include <LIS3MDL.h>
-#include <LSM6.h>
-
-LIS3MDL mag;
-LSM6 imu;
-int front = 0;
-
-/*
-Calibration values; the default values of +/-32767 for each axis
-lead to an assumed magnetometer bias of 0. Use the Calibrate example
-program to determine appropriate values for your particular unit.
-*/
-LIS3MDL::vector<int16_t> m_min = {+942, +3436, -3323};
-LIS3MDL::vector<int16_t> m_max = {+1053, +3559, -3142};
-
-void setup()
-{
- Serial.begin(9600);
- Wire.begin();
-
- if (!mag.init())
- {
- Serial.println("Failed to detect and initialize LIS3MDL magnetometer!");
- while (1);
- }
- mag.enableDefault();
-
- if (!imu.init())
- {
- Serial.println("Failed to detect and initialize LSM6 IMU!");
- while (1);
- }
- imu.enableDefault();
-
- //get start heading
- mag.read();
- imu.read();
- float heading = computeHeading();
- front = heading;
- Serial.println(heading);
-
-}
-
-void loop()
-{
- mag.read();
- imu.read();
-
-
- float heading = computeHeading();
- int offset = front - heading;
- if(offset<0){
- offset=360+offset;
- }
-
- Serial.print("heading: ");
- Serial.print(heading);
- Serial.print(", goal location: ");
- Serial.print(front);
- Serial.print(", offset: ");
-
- Serial.println(offset);
-
- delay(100);
-}
-
-template <typename T> float computeHeading(LIS3MDL::vector<T> from)
-{
- LIS3MDL::vector<int32_t> temp_m = {mag.m.x, mag.m.y, mag.m.z};
-
- // copy acceleration readings from LSM6::vector into an LIS3MDL::vector
- LIS3MDL::vector<int16_t> a = {imu.a.x, imu.a.y, imu.a.z};
-
- // subtract offset (average of min and max) from magnetometer readings
- temp_m.x -= ((int32_t)m_min.x + m_max.x) / 2;
- temp_m.y -= ((int32_t)m_min.y + m_max.y) / 2;
- temp_m.z -= ((int32_t)m_min.z + m_max.z) / 2;
-
- // compute E and N
- LIS3MDL::vector<float> E;
- LIS3MDL::vector<float> N;
- LIS3MDL::vector_cross(&temp_m, &a, &E);
- LIS3MDL::vector_normalize(&E);
- LIS3MDL::vector_cross(&a, &E, &N);
- LIS3MDL::vector_normalize(&N);
-
- // compute heading
- float heading = atan2(LIS3MDL::vector_dot(&E, &from), LIS3MDL::vector_dot(&N, &from)) * 180 / PI;
- if (heading < 0) heading += 360;
- return heading;
-}
-
-/*
-Returns the angular difference in the horizontal plane between a
-default vector (the +X axis) and north, in degrees.
-*/
-float computeHeading()
-{
- return computeHeading((LIS3MDL::vector<int>){1, 0, 0});
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/calcoffset/calcoffset.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/calcoffset/calcoffset.ino
deleted file mode 100644
index fc5f752..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/calcoffset/calcoffset.ino
+++ /dev/null
@@ -1,27 +0,0 @@
-void setup() {
- randomSeed(analogRead(0));
- Serial.begin(9600);
-
-}
-
-void loop() {
- int front = random(0, 360);
- int heading = random(0, 360);
- Serial.print("Front: ");
- Serial.println(front);
- Serial.print("heading: ");
- Serial.println(heading);
-
- int offset = heading - front;
- if(offset<0){
- offset=(offset+360);
- }
- Serial.print("offset: ");
- Serial.println(offset);
-
- Serial.println();
- Serial.println();
-
- delay(5000);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore
deleted file mode 100644
index 1089bae..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-Serial*.txt \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING
deleted file mode 100644
index 94a9ed0..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER
deleted file mode 100644
index 65c5ca8..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py
deleted file mode 100644
index 993c8e8..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# MinIMU9ArduinoAHRS
-# Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-# Copyright (c) 2011 Pololu Corporation.
-# http://www.pololu.com/
-
-# MinIMU9ArduinoAHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-# http://code.google.com/p/sf9domahrs/
-
-# sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-# Julio and Doug Weibel:
-# http://code.google.com/p/ardu-imu/
-
-# MinIMU9ArduinoAHRS is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-
-# MinIMU9ArduinoAHRS is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-# more details.
-
-# You should have received a copy of the GNU Lesser General Public License along
-# with MinIMU9ArduinoAHRS. If not, see <http://www.gnu.org/licenses/>.
-
-################################################################################
-
-# This is a test/3D visualization program for the Pololu MinIMU-9 + Arduino
-# AHRS, based on "Test for Razor 9DOF IMU" by Jose Julio, copyright 2009.
-
-# This script needs VPython, pyserial and pywin modules
-
-# First Install Python 2.6.4 (Python 2.7 also works)
-# Install pywin from http://sourceforge.net/projects/pywin32/
-# Install pyserial from http://sourceforge.net/projects/pyserial/files/
-# Install VPython from http://vpython.org/contents/download_windows.html
-
-from visual import *
-import serial
-import string
-import math
-
-from time import time
-
-grad2rad = 3.141592/180.0
-
-# Check your COM port and baud rate
-ser = serial.Serial(port='COM9',baudrate=115200, timeout=1)
-
-# Main scene
-scene=display(title="Pololu MinIMU-9 + Arduino AHRS")
-scene.range=(1.2,1.2,1.2)
-#scene.forward = (0,-1,-0.25)
-scene.forward = (1,0,-0.25)
-scene.up=(0,0,1)
-
-# Second scene (Roll, Pitch, Yaw)
-scene2 = display(title='Pololu MinIMU-9 + Arduino AHRS',x=0, y=0, width=500, height=200,center=(0,0,0), background=(0,0,0))
-scene2.range=(1,1,1)
-scene.width=500
-scene.y=200
-
-scene2.select()
-#Roll, Pitch, Yaw
-cil_roll = cylinder(pos=(-0.4,0,0),axis=(0.2,0,0),radius=0.01,color=color.red)
-cil_roll2 = cylinder(pos=(-0.4,0,0),axis=(-0.2,0,0),radius=0.01,color=color.red)
-cil_pitch = cylinder(pos=(0.1,0,0),axis=(0.2,0,0),radius=0.01,color=color.green)
-cil_pitch2 = cylinder(pos=(0.1,0,0),axis=(-0.2,0,0),radius=0.01,color=color.green)
-#cil_course = cylinder(pos=(0.6,0,0),axis=(0.2,0,0),radius=0.01,color=color.blue)
-#cil_course2 = cylinder(pos=(0.6,0,0),axis=(-0.2,0,0),radius=0.01,color=color.blue)
-arrow_course = arrow(pos=(0.6,0,0),color=color.cyan,axis=(-0.2,0,0), shaftwidth=0.02, fixedwidth=1)
-
-#Roll,Pitch,Yaw labels
-label(pos=(-0.4,0.3,0),text="Roll",box=0,opacity=0)
-label(pos=(0.1,0.3,0),text="Pitch",box=0,opacity=0)
-label(pos=(0.55,0.3,0),text="Yaw",box=0,opacity=0)
-label(pos=(0.6,0.22,0),text="N",box=0,opacity=0,color=color.yellow)
-label(pos=(0.6,-0.22,0),text="S",box=0,opacity=0,color=color.yellow)
-label(pos=(0.38,0,0),text="W",box=0,opacity=0,color=color.yellow)
-label(pos=(0.82,0,0),text="E",box=0,opacity=0,color=color.yellow)
-label(pos=(0.75,0.15,0),height=7,text="NE",box=0,color=color.yellow)
-label(pos=(0.45,0.15,0),height=7,text="NW",box=0,color=color.yellow)
-label(pos=(0.75,-0.15,0),height=7,text="SE",box=0,color=color.yellow)
-label(pos=(0.45,-0.15,0),height=7,text="SW",box=0,color=color.yellow)
-
-L1 = label(pos=(-0.4,0.22,0),text="-",box=0,opacity=0)
-L2 = label(pos=(0.1,0.22,0),text="-",box=0,opacity=0)
-L3 = label(pos=(0.7,0.3,0),text="-",box=0,opacity=0)
-
-# Main scene objects
-scene.select()
-# Reference axis (x,y,z)
-arrow(color=color.green,axis=(1,0,0), shaftwidth=0.02, fixedwidth=1)
-arrow(color=color.green,axis=(0,-1,0), shaftwidth=0.02 , fixedwidth=1)
-arrow(color=color.green,axis=(0,0,-1), shaftwidth=0.02, fixedwidth=1)
-# labels
-label(pos=(0,0,0.8),text="Pololu MinIMU-9 + Arduino AHRS",box=0,opacity=0)
-label(pos=(1,0,0),text="X",box=0,opacity=0)
-label(pos=(0,-1,0),text="Y",box=0,opacity=0)
-label(pos=(0,0,-1),text="Z",box=0,opacity=0)
-# IMU object
-platform = box(length=1, height=0.05, width=1, color=color.blue)
-p_line = box(length=1,height=0.08,width=0.1,color=color.yellow)
-plat_arrow = arrow(color=color.green,axis=(1,0,0), shaftwidth=0.06, fixedwidth=1)
-
-
-f = open("Serial"+str(time())+".txt", 'w')
-
-roll=0
-pitch=0
-yaw=0
-while 1:
- line = ser.readline()
- if line.find("!ANG:") != -1: # filter out incomplete (invalid) lines
- line = line.replace("!ANG:","") # Delete "!ANG:"
- print line
- f.write(line) # Write to the output log file
- words = string.split(line,",") # Fields split
- if len(words) > 2:
- try:
- roll = float(words[0])*grad2rad
- pitch = float(words[1])*grad2rad
- yaw = float(words[2])*grad2rad
- except:
- print "Invalid line"
-
- axis=(cos(pitch)*cos(yaw),-cos(pitch)*sin(yaw),sin(pitch))
- up=(sin(roll)*sin(yaw)+cos(roll)*sin(pitch)*cos(yaw),sin(roll)*cos(yaw)-cos(roll)*sin(pitch)*sin(yaw),-cos(roll)*cos(pitch))
- platform.axis=axis
- platform.up=up
- platform.length=1.0
- platform.width=0.65
- plat_arrow.axis=axis
- plat_arrow.up=up
- plat_arrow.length=0.8
- p_line.axis=axis
- p_line.up=up
- cil_roll.axis=(0.2*cos(roll),0.2*sin(roll),0)
- cil_roll2.axis=(-0.2*cos(roll),-0.2*sin(roll),0)
- cil_pitch.axis=(0.2*cos(pitch),0.2*sin(pitch),0)
- cil_pitch2.axis=(-0.2*cos(pitch),-0.2*sin(pitch),0)
- arrow_course.axis=(0.2*sin(yaw),0.2*cos(yaw),0)
- L1.text = str(float(words[0]))
- L2.text = str(float(words[1]))
- L3.text = str(float(words[2]))
-ser.close
-f.close
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino
deleted file mode 100644
index 767227b..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-void Compass_Heading()
-{
- float MAG_X;
- float MAG_Y;
- float cos_roll;
- float sin_roll;
- float cos_pitch;
- float sin_pitch;
-
- cos_roll = cos(roll);
- sin_roll = sin(roll);
- cos_pitch = cos(pitch);
- sin_pitch = sin(pitch);
-
- // adjust for LSM303 compass axis offsets/sensitivity differences by scaling to +/-0.5 range
- c_magnetom_x = (float)(magnetom_x - SENSOR_SIGN[6]*M_X_MIN) / (M_X_MAX - M_X_MIN) - SENSOR_SIGN[6]*0.5;
- c_magnetom_y = (float)(magnetom_y - SENSOR_SIGN[7]*M_Y_MIN) / (M_Y_MAX - M_Y_MIN) - SENSOR_SIGN[7]*0.5;
- c_magnetom_z = (float)(magnetom_z - SENSOR_SIGN[8]*M_Z_MIN) / (M_Z_MAX - M_Z_MIN) - SENSOR_SIGN[8]*0.5;
-
- // Tilt compensated Magnetic filed X:
- MAG_X = c_magnetom_x*cos_pitch+c_magnetom_y*sin_roll*sin_pitch+c_magnetom_z*cos_roll*sin_pitch;
- // Tilt compensated Magnetic filed Y:
- MAG_Y = c_magnetom_y*cos_roll-c_magnetom_z*sin_roll;
- // Magnetic Heading
- MAG_Heading = atan2(-MAG_Y,MAG_X);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino
deleted file mode 100644
index 7f9f276..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/**************************************************/
-void Normalize(void)
-{
- float error=0;
- float temporary[3][3];
- float renorm=0;
-
- error= -Vector_Dot_Product(&DCM_Matrix[0][0],&DCM_Matrix[1][0])*.5; //eq.19
-
- Vector_Scale(&temporary[0][0], &DCM_Matrix[1][0], error); //eq.19
- Vector_Scale(&temporary[1][0], &DCM_Matrix[0][0], error); //eq.19
-
- Vector_Add(&temporary[0][0], &temporary[0][0], &DCM_Matrix[0][0]);//eq.19
- Vector_Add(&temporary[1][0], &temporary[1][0], &DCM_Matrix[1][0]);//eq.19
-
- Vector_Cross_Product(&temporary[2][0],&temporary[0][0],&temporary[1][0]); // c= a x b //eq.20
-
- renorm= .5 *(3 - Vector_Dot_Product(&temporary[0][0],&temporary[0][0])); //eq.21
- Vector_Scale(&DCM_Matrix[0][0], &temporary[0][0], renorm);
-
- renorm= .5 *(3 - Vector_Dot_Product(&temporary[1][0],&temporary[1][0])); //eq.21
- Vector_Scale(&DCM_Matrix[1][0], &temporary[1][0], renorm);
-
- renorm= .5 *(3 - Vector_Dot_Product(&temporary[2][0],&temporary[2][0])); //eq.21
- Vector_Scale(&DCM_Matrix[2][0], &temporary[2][0], renorm);
-}
-
-/**************************************************/
-void Drift_correction(void)
-{
- float mag_heading_x;
- float mag_heading_y;
- float errorCourse;
- //Compensation the Roll, Pitch and Yaw drift.
- static float Scaled_Omega_P[3];
- static float Scaled_Omega_I[3];
- float Accel_magnitude;
- float Accel_weight;
-
-
- //*****Roll and Pitch***************
-
- // Calculate the magnitude of the accelerometer vector
- Accel_magnitude = sqrt(Accel_Vector[0]*Accel_Vector[0] + Accel_Vector[1]*Accel_Vector[1] + Accel_Vector[2]*Accel_Vector[2]);
- Accel_magnitude = Accel_magnitude / GRAVITY; // Scale to gravity.
- // Dynamic weighting of accelerometer info (reliability filter)
- // Weight for accelerometer info (<0.5G = 0.0, 1G = 1.0 , >1.5G = 0.0)
- Accel_weight = constrain(1 - 2*abs(1 - Accel_magnitude),0,1); //
-
- Vector_Cross_Product(&errorRollPitch[0],&Accel_Vector[0],&DCM_Matrix[2][0]); //adjust the ground of reference
- Vector_Scale(&Omega_P[0],&errorRollPitch[0],Kp_ROLLPITCH*Accel_weight);
-
- Vector_Scale(&Scaled_Omega_I[0],&errorRollPitch[0],Ki_ROLLPITCH*Accel_weight);
- Vector_Add(Omega_I,Omega_I,Scaled_Omega_I);
-
- //*****YAW***************
- // We make the gyro YAW drift correction based on compass magnetic heading
-
- mag_heading_x = cos(MAG_Heading);
- mag_heading_y = sin(MAG_Heading);
- errorCourse=(DCM_Matrix[0][0]*mag_heading_y) - (DCM_Matrix[1][0]*mag_heading_x); //Calculating YAW error
- Vector_Scale(errorYaw,&DCM_Matrix[2][0],errorCourse); //Applys the yaw correction to the XYZ rotation of the aircraft, depeding the position.
-
- Vector_Scale(&Scaled_Omega_P[0],&errorYaw[0],Kp_YAW);//.01proportional of YAW.
- Vector_Add(Omega_P,Omega_P,Scaled_Omega_P);//Adding Proportional.
-
- Vector_Scale(&Scaled_Omega_I[0],&errorYaw[0],Ki_YAW);//.00001Integrator
- Vector_Add(Omega_I,Omega_I,Scaled_Omega_I);//adding integrator to the Omega_I
-}
-/**************************************************/
-/*
-void Accel_adjust(void)
-{
- Accel_Vector[1] += Accel_Scale(speed_3d*Omega[2]); // Centrifugal force on Acc_y = GPS_speed*GyroZ
- Accel_Vector[2] -= Accel_Scale(speed_3d*Omega[1]); // Centrifugal force on Acc_z = GPS_speed*GyroY
-}
-*/
-/**************************************************/
-
-void Matrix_update(void)
-{
- Gyro_Vector[0]=Gyro_Scaled_X(gyro_x); //gyro x roll
- Gyro_Vector[1]=Gyro_Scaled_Y(gyro_y); //gyro y pitch
- Gyro_Vector[2]=Gyro_Scaled_Z(gyro_z); //gyro Z yaw
-
- Accel_Vector[0]=accel_x;
- Accel_Vector[1]=accel_y;
- Accel_Vector[2]=accel_z;
-
- Vector_Add(&Omega[0], &Gyro_Vector[0], &Omega_I[0]); //adding proportional term
- Vector_Add(&Omega_Vector[0], &Omega[0], &Omega_P[0]); //adding Integrator term
-
- //Accel_adjust(); //Remove centrifugal acceleration. We are not using this function in this version - we have no speed measurement
-
- #if OUTPUTMODE==1
- Update_Matrix[0][0]=0;
- Update_Matrix[0][1]=-G_Dt*Omega_Vector[2];//-z
- Update_Matrix[0][2]=G_Dt*Omega_Vector[1];//y
- Update_Matrix[1][0]=G_Dt*Omega_Vector[2];//z
- Update_Matrix[1][1]=0;
- Update_Matrix[1][2]=-G_Dt*Omega_Vector[0];//-x
- Update_Matrix[2][0]=-G_Dt*Omega_Vector[1];//-y
- Update_Matrix[2][1]=G_Dt*Omega_Vector[0];//x
- Update_Matrix[2][2]=0;
- #else // Uncorrected data (no drift correction)
- Update_Matrix[0][0]=0;
- Update_Matrix[0][1]=-G_Dt*Gyro_Vector[2];//-z
- Update_Matrix[0][2]=G_Dt*Gyro_Vector[1];//y
- Update_Matrix[1][0]=G_Dt*Gyro_Vector[2];//z
- Update_Matrix[1][1]=0;
- Update_Matrix[1][2]=-G_Dt*Gyro_Vector[0];
- Update_Matrix[2][0]=-G_Dt*Gyro_Vector[1];
- Update_Matrix[2][1]=G_Dt*Gyro_Vector[0];
- Update_Matrix[2][2]=0;
- #endif
-
- Matrix_Multiply(DCM_Matrix,Update_Matrix,Temporary_Matrix); //a*b=c
-
- for(int x=0; x<3; x++) //Matrix Addition (update)
- {
- for(int y=0; y<3; y++)
- {
- DCM_Matrix[x][y]+=Temporary_Matrix[x][y];
- }
- }
-}
-
-void Euler_angles(void)
-{
- pitch = -asin(DCM_Matrix[2][0]);
- roll = atan2(DCM_Matrix[2][1],DCM_Matrix[2][2]);
- yaw = atan2(DCM_Matrix[1][0],DCM_Matrix[0][0]);
-}
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino
deleted file mode 100644
index 5ca58e2..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef IMU_V5
-
-#include <LSM6.h>
-#include <LIS3MDL.h>
-
-LSM6 gyro_acc;
-LIS3MDL mag;
-
-#else // older IMUs through v4
-
-#include <L3G.h>
-#include <LSM303.h>
-
-L3G gyro;
-LSM303 compass;
-
-#endif
-
-
-void I2C_Init()
-{
- Wire.begin();
-}
-
-void Gyro_Init()
-{
-#ifdef IMU_V5
- // Accel_Init() should have already called gyro_acc.init() and enableDefault()
- gyro_acc.writeReg(LSM6::CTRL2_G, 0x4C); // 104 Hz, 2000 dps full scale
-#else
- gyro.init();
- gyro.enableDefault();
- gyro.writeReg(L3G::CTRL_REG4, 0x20); // 2000 dps full scale
- gyro.writeReg(L3G::CTRL_REG1, 0x0F); // normal power mode, all axes enabled, 100 Hz
-#endif
-}
-
-void Read_Gyro()
-{
-#ifdef IMU_V5
- gyro_acc.readGyro();
-
- AN[0] = gyro_acc.g.x;
- AN[1] = gyro_acc.g.y;
- AN[2] = gyro_acc.g.z;
-#else
- gyro.read();
-
- AN[0] = gyro.g.x;
- AN[1] = gyro.g.y;
- AN[2] = gyro.g.z;
-#endif
-
- gyro_x = SENSOR_SIGN[0] * (AN[0] - AN_OFFSET[0]);
- gyro_y = SENSOR_SIGN[1] * (AN[1] - AN_OFFSET[1]);
- gyro_z = SENSOR_SIGN[2] * (AN[2] - AN_OFFSET[2]);
-}
-
-void Accel_Init()
-{
-#ifdef IMU_V5
- gyro_acc.init();
- gyro_acc.enableDefault();
- gyro_acc.writeReg(LSM6::CTRL1_XL, 0x3C); // 52 Hz, 8 g full scale
-#else
- compass.init();
- compass.enableDefault();
- switch (compass.getDeviceType())
- {
- case LSM303::device_D:
- compass.writeReg(LSM303::CTRL2, 0x18); // 8 g full scale: AFS = 011
- break;
- case LSM303::device_DLHC:
- compass.writeReg(LSM303::CTRL_REG4_A, 0x28); // 8 g full scale: FS = 10; high resolution output mode
- break;
- default: // DLM, DLH
- compass.writeReg(LSM303::CTRL_REG4_A, 0x30); // 8 g full scale: FS = 11
- }
-#endif
-}
-
-// Reads x,y and z accelerometer registers
-void Read_Accel()
-{
-#ifdef IMU_V5
- gyro_acc.readAcc();
-
- AN[3] = gyro_acc.a.x >> 4; // shift right 4 bits to use 12-bit representation (1 g = 256)
- AN[4] = gyro_acc.a.y >> 4;
- AN[5] = gyro_acc.a.z >> 4;
-#else
- compass.readAcc();
-
- AN[3] = compass.a.x >> 4; // shift right 4 bits to use 12-bit representation (1 g = 256)
- AN[4] = compass.a.y >> 4;
- AN[5] = compass.a.z >> 4;
-#endif
- accel_x = SENSOR_SIGN[3] * (AN[3] - AN_OFFSET[3]);
- accel_y = SENSOR_SIGN[4] * (AN[4] - AN_OFFSET[4]);
- accel_z = SENSOR_SIGN[5] * (AN[5] - AN_OFFSET[5]);
-}
-
-void Compass_Init()
-{
-#ifdef IMU_V5
- mag.init();
- mag.enableDefault();
-#else
- // LSM303: doesn't need to do anything because Accel_Init() should have already called compass.enableDefault()
-#endif
-}
-
-void Read_Compass()
-{
-#ifdef IMU_V5
- mag.read();
-
- magnetom_x = SENSOR_SIGN[6] * mag.m.x;
- magnetom_y = SENSOR_SIGN[7] * mag.m.y;
- magnetom_z = SENSOR_SIGN[8] * mag.m.z;
-#else
- compass.readMag();
-
- magnetom_x = SENSOR_SIGN[6] * compass.m.x;
- magnetom_y = SENSOR_SIGN[7] * compass.m.y;
- magnetom_z = SENSOR_SIGN[8] * compass.m.z;
-#endif
-}
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino
deleted file mode 100644
index 5307f5e..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-// Uncomment the following line to use a MinIMU-9 v5 or AltIMU-10 v5. Leave commented for older IMUs (up through v4).
-#define IMU_V5
-
-// Uncomment the below line to use this axis definition:
- // X axis pointing forward
- // Y axis pointing to the right
- // and Z axis pointing down.
-// Positive pitch : nose up
-// Positive roll : right wing down
-// Positive yaw : clockwise
-int SENSOR_SIGN[9] = {1,1,1,-1,-1,-1,1,1,1}; //Correct directions x,y,z - gyro, accelerometer, magnetometer
-// Uncomment the below line to use this axis definition:
- // X axis pointing forward
- // Y axis pointing to the left
- // and Z axis pointing up.
-// Positive pitch : nose down
-// Positive roll : right wing down
-// Positive yaw : counterclockwise
-//int SENSOR_SIGN[9] = {1,-1,-1,-1,1,1,1,-1,-1}; //Correct directions x,y,z - gyro, accelerometer, magnetometer
-
-// tested with Arduino Uno with ATmega328 and Arduino Duemilanove with ATMega168
-
-#include <Wire.h>
-
-// accelerometer: 8 g sensitivity
-// 3.9 mg/digit; 1 g = 256
-#define GRAVITY 256 //this equivalent to 1G in the raw data coming from the accelerometer
-
-#define ToRad(x) ((x)*0.01745329252) // *pi/180
-#define ToDeg(x) ((x)*57.2957795131) // *180/pi
-
-// gyro: 2000 dps full scale
-// 70 mdps/digit; 1 dps = 0.07
-#define Gyro_Gain_X 0.07 //X axis Gyro gain
-#define Gyro_Gain_Y 0.07 //Y axis Gyro gain
-#define Gyro_Gain_Z 0.07 //Z axis Gyro gain
-#define Gyro_Scaled_X(x) ((x)*ToRad(Gyro_Gain_X)) //Return the scaled ADC raw data of the gyro in radians for second
-#define Gyro_Scaled_Y(x) ((x)*ToRad(Gyro_Gain_Y)) //Return the scaled ADC raw data of the gyro in radians for second
-#define Gyro_Scaled_Z(x) ((x)*ToRad(Gyro_Gain_Z)) //Return the scaled ADC raw data of the gyro in radians for second
-
-// LSM303/LIS3MDL magnetometer calibration constants; use the Calibrate example from
-// the Pololu LSM303 or LIS3MDL library to find the right values for your board
-
-#define M_X_MIN -1000
-#define M_Y_MIN -1000
-#define M_Z_MIN -1000
-#define M_X_MAX +1000
-#define M_Y_MAX +1000
-#define M_Z_MAX +1000
-
-#define Kp_ROLLPITCH 0.02
-#define Ki_ROLLPITCH 0.00002
-#define Kp_YAW 1.2
-#define Ki_YAW 0.00002
-
-/*For debugging purposes*/
-//OUTPUTMODE=1 will print the corrected data,
-//OUTPUTMODE=0 will print uncorrected data of the gyros (with drift)
-#define OUTPUTMODE 1
-
-#define PRINT_DCM 0 //Will print the whole direction cosine matrix
-#define PRINT_ANALOGS 0 //Will print the analog raw data
-#define PRINT_EULER 1 //Will print the Euler angles Roll, Pitch and Yaw
-
-#define STATUS_LED 13
-
-float G_Dt=0.02; // Integration time (DCM algorithm) We will run the integration loop at 50Hz if possible
-
-long timer=0; //general purpuse timer
-long timer_old;
-long timer24=0; //Second timer used to print values
-int AN[6]; //array that stores the gyro and accelerometer data
-int AN_OFFSET[6]={0,0,0,0,0,0}; //Array that stores the Offset of the sensors
-
-int gyro_x;
-int gyro_y;
-int gyro_z;
-int accel_x;
-int accel_y;
-int accel_z;
-int magnetom_x;
-int magnetom_y;
-int magnetom_z;
-float c_magnetom_x;
-float c_magnetom_y;
-float c_magnetom_z;
-float MAG_Heading;
-
-float Accel_Vector[3]= {0,0,0}; //Store the acceleration in a vector
-float Gyro_Vector[3]= {0,0,0};//Store the gyros turn rate in a vector
-float Omega_Vector[3]= {0,0,0}; //Corrected Gyro_Vector data
-float Omega_P[3]= {0,0,0};//Omega Proportional correction
-float Omega_I[3]= {0,0,0};//Omega Integrator
-float Omega[3]= {0,0,0};
-
-// Euler angles
-float roll;
-float pitch;
-float yaw;
-
-float errorRollPitch[3]= {0,0,0};
-float errorYaw[3]= {0,0,0};
-
-unsigned int counter=0;
-byte gyro_sat=0;
-
-float DCM_Matrix[3][3]= {
- {
- 1,0,0 }
- ,{
- 0,1,0 }
- ,{
- 0,0,1 }
-};
-float Update_Matrix[3][3]={{0,1,2},{3,4,5},{6,7,8}}; //Gyros here
-
-
-float Temporary_Matrix[3][3]={
- {
- 0,0,0 }
- ,{
- 0,0,0 }
- ,{
- 0,0,0 }
-};
-
-void setup()
-{
- Serial.begin(115200);
- pinMode (STATUS_LED,OUTPUT); // Status LED
-
- I2C_Init();
-
- Serial.println("Pololu MinIMU-9 + Arduino AHRS");
-
- digitalWrite(STATUS_LED,LOW);
- delay(1500);
-
- Accel_Init();
- Compass_Init();
- Gyro_Init();
-
- delay(20);
-
- for(int i=0;i<32;i++) // We take some readings...
- {
- Read_Gyro();
- Read_Accel();
- for(int y=0; y<6; y++) // Cumulate values
- AN_OFFSET[y] += AN[y];
- delay(20);
- }
-
- for(int y=0; y<6; y++)
- AN_OFFSET[y] = AN_OFFSET[y]/32;
-
- AN_OFFSET[5]-=GRAVITY*SENSOR_SIGN[5];
-
- //Serial.println("Offset:");
- for(int y=0; y<6; y++)
- Serial.println(AN_OFFSET[y]);
-
- delay(2000);
- digitalWrite(STATUS_LED,HIGH);
-
- timer=millis();
- delay(20);
- counter=0;
-}
-
-void loop() //Main Loop
-{
- if((millis()-timer)>=20) // Main loop runs at 50Hz
- {
- counter++;
- timer_old = timer;
- timer=millis();
- if (timer>timer_old)
- {
- G_Dt = (timer-timer_old)/1000.0; // Real time of loop run. We use this on the DCM algorithm (gyro integration time)
- if (G_Dt > 0.2)
- G_Dt = 0; // ignore integration times over 200 ms
- }
- else
- G_Dt = 0;
-
-
-
- // *** DCM algorithm
- // Data adquisition
- Read_Gyro(); // This read gyro data
- Read_Accel(); // Read I2C accelerometer
-
- if (counter > 5) // Read compass data at 10Hz... (5 loop runs)
- {
- counter=0;
- Read_Compass(); // Read I2C magnetometer
- Compass_Heading(); // Calculate magnetic heading
- }
-
- // Calculations...
- Matrix_update();
- Normalize();
- Drift_correction();
- Euler_angles();
- // ***
-
- printdata();
- }
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino
deleted file mode 100644
index f1f31e5..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-void printdata(void)
-{
- Serial.print("!");
-
- #if PRINT_EULER == 1
- Serial.print("ANG:");
- Serial.print(ToDeg(roll));
- Serial.print(",");
- Serial.print(ToDeg(pitch));
- Serial.print(",");
- Serial.print(ToDeg(yaw));
- #endif
- #if PRINT_ANALOGS==1
- Serial.print(",AN:");
- Serial.print(AN[0]); //(int)read_adc(0)
- Serial.print(",");
- Serial.print(AN[1]);
- Serial.print(",");
- Serial.print(AN[2]);
- Serial.print(",");
- Serial.print(AN[3]);
- Serial.print (",");
- Serial.print(AN[4]);
- Serial.print (",");
- Serial.print(AN[5]);
- Serial.print(",");
- Serial.print(c_magnetom_x);
- Serial.print (",");
- Serial.print(c_magnetom_y);
- Serial.print (",");
- Serial.print(c_magnetom_z);
- #endif
- #if PRINT_DCM == 1
- Serial.print (",DCM:");
- Serial.print(DCM_Matrix[0][0]);
- Serial.print (",");
- Serial.print(DCM_Matrix[0][1]);
- Serial.print (",");
- Serial.print(DCM_Matrix[0][2]);
- Serial.print (",");
- Serial.print(DCM_Matrix[1][0]);
- Serial.print (",");
- Serial.print(DCM_Matrix[1][1]);
- Serial.print (",");
- Serial.print(DCM_Matrix[1][2]);
- Serial.print (",");
- Serial.print(DCM_Matrix[2][0]);
- Serial.print (",");
- Serial.print(DCM_Matrix[2][1]);
- Serial.print (",");
- Serial.print(DCM_Matrix[2][2]);
- #endif
- Serial.println();
-
-}
-
-/*long convert_to_dec(float x)
-{
- return x*10000000;
-}*/
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino
deleted file mode 100644
index d69b49c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-//Computes the dot product of two vectors
-float Vector_Dot_Product(float vector1[3],float vector2[3])
-{
- float op=0;
-
- for(int c=0; c<3; c++)
- {
- op+=vector1[c]*vector2[c];
- }
-
- return op;
-}
-
-//Computes the cross product of two vectors
-void Vector_Cross_Product(float vectorOut[3], float v1[3],float v2[3])
-{
- vectorOut[0]= (v1[1]*v2[2]) - (v1[2]*v2[1]);
- vectorOut[1]= (v1[2]*v2[0]) - (v1[0]*v2[2]);
- vectorOut[2]= (v1[0]*v2[1]) - (v1[1]*v2[0]);
-}
-
-//Multiply the vector by a scalar.
-void Vector_Scale(float vectorOut[3],float vectorIn[3], float scale2)
-{
- for(int c=0; c<3; c++)
- {
- vectorOut[c]=vectorIn[c]*scale2;
- }
-}
-
-void Vector_Add(float vectorOut[3],float vectorIn1[3], float vectorIn2[3])
-{
- for(int c=0; c<3; c++)
- {
- vectorOut[c]=vectorIn1[c]+vectorIn2[c];
- }
-}
-
-
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino
deleted file mode 100644
index c8a7a15..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/**************************************************/
-//Multiply two 3x3 matrixs. This function developed by Jordi can be easily adapted to multiple n*n matrix's. (Pero me da flojera!).
-void Matrix_Multiply(float a[3][3], float b[3][3], float mat[3][3])
-{
- for(int x = 0; x < 3; x++)
- {
- for(int y = 0; y < 3; y++)
- {
- mat[x][y] = 0;
-
- for(int w = 0; w < 3; w++)
- {
- mat[x][y] += a[x][w] * b[w][y];
- }
- }
- }
-}
-
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/README.textile b/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/README.textile
deleted file mode 100644
index ac1cb3f..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IMU_comp/minimu-9-ahrs-arduino-master/README.textile
+++ /dev/null
@@ -1,108 +0,0 @@
-h1. Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Version: 1.3.0
-Release Date: 2016-04-27
-"www.pololu.com":http://www.pololu.com/
-
-h2. Summary
-
-This is a program (sketch) for the "Arduino":http://pololu.com/catalog/product/2191 that interfaces with the Pololu MinIMU-9 inertial measurement units:
-
-* "MinIMU-9 v5 <notextile>(LSM6DS33 and LIS3MDL carrier)</notextile>":http://www.pololu.com/product/2738
-* "MinIMU-9 v3 <notextile>(L3GD20H and LSM303D carrier)</notextile>":http://www.pololu.com/product/2468
-* "MinIMU-9 v2 <notextile>(L3GD20 and LSM303DLHC carrier)</notextile>":http://www.pololu.com/catalog/product/1268 (discontinued)
-* "MinIMU-9 <notextile>(L3G4200D and LSM303DLM carrier)</notextile>":http://www.pololu.com/catalog/product/1265 (discontinued)
-* "MinIMU-9 <notextile>(L3G4200D and LSM303DLH carrier)</notextile>":http://www.pololu.com/catalog/product/1264 (discontinued)
-
-It also works with the Pololu AltIMU-10 boards, although the output from the barometer is not used:
-
-* "AltIMU-10 v5 <notextile>(LSM6DS33, LIS3MDL, and LPS25H carrier)</notextile>":http://www.pololu.com/product/2739
-* "AltIMU-10 v4 <notextile>(L3GD20H, LSM303D, and LPS25H carrier)</notextile>":http://www.pololu.com/catalog/product/2470
-* "AltIMU-10 v3 <notextile>(L3GD20H, LSM303D, and LPS331AP carrier)</notextile>":http://www.pololu.com/catalog/product/2469
-* "AltIMU-10 <notextile>(L3GD20, LSM303DLHC, and LPS331AP carrier)</notextile>":http://www.pololu.com/catalog/product/1269 (discontinued)
-
-This Arduino program processes the raw rotation, acceleration, and magnetic data from the MinIMU-9 to derive an estimate of the board's absolute orientation, which it outputs through the Arduino's serial interface, turning the MinIMU-9 and Arduino into an attitude and heading reference system (AHRS).
-
-A Python test program is also included. It communicates with the Arduino serially and displays a 3D representation of the MinIMU-9 board, allowing you to visualize the output of the AHRS in real time.
-
-Both the Arduino software and Python test program are based on "sf9domahrs":http://code.google.com/p/sf9domahrs/ by Doug Weibel and Jose Julio, which is in turn based on "ArduIMU":http://code.google.com/p/ardu-imu/ v1.5 by Jordi Munoz, William Premerlani, Jose Julio, and Doug Weibel.
-
-h2. Getting Started
-
-h3. Software
-
-The Arduino program uses Pololu's Arduino libraries for the sensors on the IMU board, which can also be downloaded from GitHub. Follow the instructions on their respective pages to install the libraries.
-
-* *v5* IMUs: "LSM6":https://github.com/pololu/LSM6-arduino and "LIS3MDL":https://github.com/pololu/LIS3MDL-arduino libraries
-* *v4 and earlier* IMUs: "L3G":https://github.com/pololu/L3G and "LSM303":https://github.com/pololu/LSM303 libraries
-
-The Python test program also has several dependencies you must install before you can run it:
-
-* "Python 2.7":http://www.python.org/download/ (download the 32-bit version)
-* "pywin32":http://sourceforge.net/projects/pywin32/files/pywin32/ (direct link: "pywin32-218.win32-py2.7.exe":http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download)
-* "pyserial":http://sourceforge.net/projects/pyserial/files/pyserial/ (direct link: "pyserial-2.5.win32.exe":http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.win32.exe/download)
-* "VPython 5":http://vpython.org/contents/download_windows.html (direct link: "VPython-Win-Py2.7-5.74.exe":http://vpython.org/contents/download/VPython-Win-Py2.7-5.74.exe)
-
-After you have set up the prerequisites, download the archive from "GitHub":https://github.com/pololu/MinIMU-9-Arduino-AHRS and decompress it.
-
-h3. Hardware
-
-Make the following connections with wires between the Arduino and the MinIMU-9:
-
-h4. 5V Arduino boards
-
-(including Arduino Uno, Leonardo, Mega; Pololu A-Star 32U4)
-
-pre. Arduino IMU
-------- ---
- 5V - VIN
- GND - GND
- SDA - SDA
- SCL - SCL
-
-h4. 3.3V Arduino boards
-
-(including Arduino Due)
-
-pre. Arduino IMU
-------- ---
- 3V3 - VIN
- GND - GND
- SDA - SDA
- SCL - SCL
-
-h3. Using the AHRS
-
-From the Arduino environment, open MinIMU9AHRS.ino, which can be found in the MinIMU9AHRS folder.
-
-The Arduino program is set up for a *v4 or earlier* IMU by default. If you are using a MinIMU or AltIMU *v5*, uncomment the line that says @//#define IMU_V5@ at the beginning of MinIMU9AHRS.ino.
-
-By default, the Arduino code treats the positive X axis of the MinIMU-9 as forward and the negative Z axis as up (so that the components are on the bottom of the board and the silkscreen is on top). If you want the positive Z axis to be up instead (so that the components are on top), find the definition of @SENSOR_SIGN[9]@ at the beginning of MinIMU9AHRS.ino and uncomment the appropriate line (after commenting the original).
-
-To ensure that the heading derived from the compass is accurate, you should change the @M_X_MIN@ through @M_Z_MAX@ calibration constants to appropriate values. You can use the Calibrate example from the "LIS3MDL library":https://github.com/pololu/LIS3MDL-arduino (v5) or "LSM303 library":https://github.com/pololu/LSM303 (v4 or earlier) to find the right values for your board.
-
-In the Tools menu, select the appropriate board and serial port. Click the "Upload" button to compile the sketch and load it onto your Arduino.
-
-When the AHRS program first starts running, it takes some readings to establish a baseline orientation, during which it expects both the roll and the pitch of the sensors to be zero. Therefore, it is important to keep the MinIMU-9 level for a few seconds after powering on or resetting the Arduino or connecting to it from a computer.
-
-After performing the startup routine, the program constantly takes readings from the gyro, accelerometer, and magnetometer on the MinIMU-9 and calculates an estimate of the board's orientation. It outputs estimated roll, pitch, and yaw angles (in degrees) through the Arduino's serial interface, and you can view the output with the Arduino Serial Monitor.
-
-Example output:
-
-pre. !ANG:0.08,0.09,137.01
-!ANG:0.14,0.11,137.04
-!ANG:0.15,0.12,137.06
-
-To visualize the output of the AHRS, you can run the Python test program (MinIMU-9-test.py) while the Arduino is connected to your computer. (You will probably have to edit the file first and change the definition of @ser@ to match the COM port your Arduino is using.) You should be able to see three indicators showing the roll, pitch, and yaw angles being calculated by the AHRS, as well as a 3D representation of the MinIMU-9 board (the arrow indicates the positive X direction). You can watch these change in real time as you move the board around.
-
-!http://b.pololu-files.com/picture/0J3722.600.jpg!
-
-h2. Version History
-
-* 1.3.0 (2016-04-27): Added support for MinIMU-9 v5 and AltIMU-10 v5. Added a check to help work around nan (not a number) problems caused by USB serial stalling the main loop.
-* 1.2.3 (2015-02-05): Updated to work with L3G library version 2.0.0.
-* 1.2.2 (2013-11-27): Updated to work with LSM303 library version 2.0.0.
-* 1.2.1 (2013-03-15): Fixed issue with properly enabling high-resolution mode on accelerometer.
-* 1.2.0 (2012-07-06): Added support for MinIMU-9 v2 (L3GD20 and LSM303DLHC); L3G4200D library dependency changed to L3G.
-* 1.1.0 (2011-11-15): Added support for LSM303DLM; LSM303DLH library dependency changed to LSM303.
-* 1.0.0 (2011-09-26): Original release.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/IR_seeker/IR_seeker.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/IR_seeker/IR_seeker.ino
deleted file mode 100644
index 90c9965..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/IR_seeker/IR_seeker.ino
+++ /dev/null
@@ -1,205 +0,0 @@
-#include <Adafruit_MCP23X17.h>
-
-#define ir1 0 // GPA0
-#define ir2 1 // GPA1
-#define ir3 2 // GPA2
-#define ir4 3 // GPA3
-#define ir5 4 // GPA4
-#define ir6 5 // GPA5
-#define ir7 6 // GPA6
-#define ir8 7 // GPA7
-#define ir9 8 // GPB0
-#define ir10 9 // GPB1
-#define ir11 10 // GPB2
-#define ir12 11 // GPB3
-#define ir13 12 // GPB4
-#define ir14 13 // GPB5
-#define ir15 14 // GPB6
-#define ir16 15 // GPB7
-
-int dir1 = 1; // data IR1
-int dir2 = 1; // data IR2
-int dir3 = 1; // etc
-int dir4 = 1;
-int dir5 = 1;
-int dir6 = 1;
-int dir7 = 1;
-int dir8 = 1;
-int dir9 = 1;
-int dir10 = 1;
-int dir11 = 1;
-int dir12 = 1;
-int dir13 = 1;
-int dir14 = 1;
-int dir15 = 1;
-int dir16 = 1;
-
-volatile long IRcount1 = 0;
-volatile long IRcount2 = 0;
-volatile long IRcount3 = 0;
-volatile long IRcount4 = 0;
-volatile long IRcount5 = 0;
-volatile long IRcount6 = 0;
-volatile long IRcount7 = 0;
-volatile long IRcount8 = 0;
-volatile long IRcount9 = 0;
-volatile long IRcount10 = 0;
-volatile long IRcount11 = 0;
-volatile long IRcount12 = 0;
-volatile long IRcount13 = 0;
-volatile long IRcount14 = 0;
-volatile long IRcount15 = 0;
-volatile long IRcount16 = 0;
-
-// Instance for the first MCP23017 at address 0x20
-Adafruit_MCP23X17 mcp1;
-
-void setup() {
- Serial.begin(9600);
- while (!Serial);
- Serial.println("MCP23xxx Button Test!");
-
- // Initialize first MCP23017 with I2C address 0x20
- if (!mcp1.begin_I2C(0x20)) {
- Serial.println("Error initializing MCP23017 at 0x20.");
- while (1);
- }
-
- // Configure pins for the first MCP23017 (0x20)
- mcp1.pinMode(ir1, INPUT);
- mcp1.pinMode(ir2, INPUT);
- mcp1.pinMode(ir3, INPUT);
- mcp1.pinMode(ir4, INPUT);
- mcp1.pinMode(ir5, INPUT);
- mcp1.pinMode(ir6, INPUT);
- mcp1.pinMode(ir7, INPUT);
- mcp1.pinMode(ir8, INPUT);
- mcp1.pinMode(ir9, INPUT);
- mcp1.pinMode(ir10, INPUT);
- mcp1.pinMode(ir11, INPUT);
- mcp1.pinMode(ir12, INPUT);
- mcp1.pinMode(ir13, INPUT);
- mcp1.pinMode(ir14, INPUT);
- mcp1.pinMode(ir15, INPUT);
- mcp1.pinMode(ir16, INPUT);
-
- attachInterrupt(digitalPinToInterrupt(ir1), IRtrigger1, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir2), IRtrigger2, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir3), IRtrigger3, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir4), IRtrigger4, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir5), IRtrigger5, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir6), IRtrigger6, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir7), IRtrigger7, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir8), IRtrigger8, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir9), IRtrigger9, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir10), IRtrigger10, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir11), IRtrigger11, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir12), IRtrigger12, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir13), IRtrigger13, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir14), IRtrigger14, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir15), IRtrigger15, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir16), IRtrigger16, CHANGE);
-
- Serial.println("Looping...");
-}
-
-void IRtrigger1() {
- IRcount1++;
-}
-void IRtrigger2() {
- IRcount2++;
-}
-void IRtrigger3() {
- IRcount3++;
-}
-void IRtrigger4() {
- IRcount4++;
-}
-void IRtrigger5() {
- IRcount5++;
-}
-void IRtrigger6() {
- IRcount6++;
-}
-void IRtrigger7() {
- IRcount7++;
-}
-void IRtrigger8() {
- IRcount8++;
-}
-void IRtrigger9() {
- IRcount9++;
-}
-void IRtrigger10() {
- IRcount10++;
-}
-void IRtrigger11() {
- IRcount11++;
-}
-void IRtrigger12() {
- IRcount12++;
-}
-void IRtrigger13() {
- IRcount13++;
-}
-void IRtrigger14() {
- IRcount14++;
-}
-void IRtrigger15() {
- IRcount15++;
-}
-void IRtrigger16() {
- IRcount16++;
-}
-
-
-void loop() {
- Serial.print("ir 1 changes: ");
- Serial.print(IRcount1);
- Serial.print(", ir 2 changes: ");
- Serial.print(IRcount2);
- Serial.print(", ir 3 changes: ");
- Serial.print(IRcount3);
- Serial.print(", ir 4 changes: ");
- Serial.print(IRcount4);
- Serial.print(", ir 5 changes: ");
- Serial.print(IRcount5);
- Serial.print(", ir 6 changes: ");
- Serial.print(IRcount6);
- Serial.print(", ir 7 changes: ");
- Serial.print(IRcount7);
- Serial.print(", ir 8 changes: ");
- Serial.print(IRcount8);
- Serial.print(", ir 9 changes: ");
- Serial.print(IRcount9);
- Serial.print(", ir 10 changes: ");
- Serial.print(IRcount10);
- Serial.print(", ir 11 changes: ");
- Serial.print(IRcount11);
- Serial.print(", ir 12 changes: ");
- Serial.print(IRcount12);
- Serial.print(", ir 13 changes: ");
- Serial.print(IRcount13);
- Serial.print(", ir 14 changes: ");
- Serial.print(IRcount14);
- Serial.print(", ir 15 changes: ");
- Serial.print(IRcount15);
- Serial.print(", ir 16 changes: ");
- Serial.println(IRcount16);
-
- volatile long IRcounts[] = {IRcount1, IRcount2, IRcount3, IRcount4, IRcount5, IRcount6, IRcount7, IRcount8, IRcount9, IRcount10, IRcount11, IRcount12, IRcount13, IRcount14, IRcount15, IRcount16};
- long maxCount = IRcounts[0];
- int highessensor = 1;
- for (int i = 0; i < 15; ++i) {
- if (IRcounts[i] > maxCount) {
- maxCount = IRcounts[i];
- highessensor = i + 1;
- }
- }
- Serial.print("Ball is at sensor: ");
- Serial.print(highessensor);
- Serial.print(", with value of ");
- Serial.println(maxCount);
-
- delay(250);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/MCP23017.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/MCP23017.ino
deleted file mode 100644
index d295e7c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/MCP23017.ino
+++ /dev/null
@@ -1,177 +0,0 @@
-#include <Adafruit_MCP23X17.h>
-
-#define ir1 0 // GPA0
-#define ir2 1 // GPA1
-#define ir3 2 // GPA2
-#define ir4 3 // GPA3
-#define ir5 4 // GPA4
-#define ir6 5 // GPA5
-#define ir7 6 // GPA6
-#define ir8 7 // GPA7
-#define ir9 8 // GPB0
-#define ir10 9 // GPB1
-#define ir11 10 // GPB2
-#define ir12 11 // GPB3
-#define ir13 12 // GPB4
-#define ir14 13 // GPB5
-#define ir15 14 // GPB6
-#define ir16 15 // GPB7
-
-int dir1 = 1; // data IR1
-int dir2 = 1; // data IR2
-int dir3 = 1; // etc
-int dir4 = 1;
-int dir5 = 1;
-int dir6 = 1;
-int dir7 = 1;
-int dir8 = 1;
-int dir9 = 1;
-int dir10 = 1;
-int dir11 = 1;
-int dir12 = 1;
-int dir13 = 1;
-int dir14 = 1;
-int dir15 = 1;
-int dir16 = 1;
-
-int dir17 = 1; // data IR17
-int dir18 = 1; // data IR18
-int dir19 = 1; // etc
-int dir20 = 1;
-int dir21 = 1;
-int dir22 = 1;
-int dir23 = 1;
-int dir24 = 1;
-int dir25 = 1;
-int dir26 = 1;
-int dir27 = 1;
-int dir28 = 1;
-int dir29 = 1;
-int dir30 = 1;
-int dir31 = 1;
-int dir32 = 1;
-
-// Instance for the first MCP23017 at address 0x20
-Adafruit_MCP23X17 mcp1;
-
-// Instance for the second MCP23017 at address 0x22
-Adafruit_MCP23X17 mcp2;
-
-void setup() {
- Serial.begin(9600);
- while (!Serial);
- Serial.println("MCP23xxx Button Test!");
-
- // Initialize first MCP23017 with I2C address 0x20
- if (!mcp1.begin_I2C(0x20)) {
- Serial.println("Error initializing MCP23017 at 0x20.");
- while (1);
- }
-
- // Initialize second MCP23017 with I2C address 0x22
- if (!mcp2.begin_I2C(0x22)) {
- Serial.println("Error initializing MCP23017 at 0x22.");
- while (1);
- }
-
- // Configure pins for the first MCP23017 (0x20)
- mcp1.pinMode(ir1, INPUT);
- mcp1.pinMode(ir2, INPUT);
- mcp1.pinMode(ir3, INPUT);
- mcp1.pinMode(ir4, INPUT);
- mcp1.pinMode(ir5, INPUT);
- mcp1.pinMode(ir6, INPUT);
- mcp1.pinMode(ir7, INPUT);
- mcp1.pinMode(ir8, INPUT);
- mcp1.pinMode(ir9, INPUT);
- mcp1.pinMode(ir10, INPUT);
- mcp1.pinMode(ir11, INPUT);
- mcp1.pinMode(ir12, INPUT);
- mcp1.pinMode(ir13, INPUT);
- mcp1.pinMode(ir14, INPUT);
- mcp1.pinMode(ir15, INPUT);
- mcp1.pinMode(ir16, INPUT);
-
- // Configure pins for the second MCP23017 (0x22)
- mcp2.pinMode(ir1, INPUT);
- mcp2.pinMode(ir2, INPUT);
- mcp2.pinMode(ir3, INPUT);
- mcp2.pinMode(ir4, INPUT);
- mcp2.pinMode(ir5, INPUT);
- mcp2.pinMode(ir6, INPUT);
- mcp2.pinMode(ir7, INPUT);
- mcp2.pinMode(ir8, INPUT);
- mcp2.pinMode(ir9, INPUT);
- mcp2.pinMode(ir10, INPUT);
- mcp2.pinMode(ir11, INPUT);
- mcp2.pinMode(ir12, INPUT);
- mcp2.pinMode(ir13, INPUT);
- mcp2.pinMode(ir14, INPUT);
- mcp2.pinMode(ir15, INPUT);
- mcp2.pinMode(ir16, INPUT);
-
- Serial.println("Looping...");
-}
-
-void loop() {
- // Read pins from the first MCP23017 (0x20)
- dir1 = mcp1.digitalRead(ir1);
- dir2 = mcp1.digitalRead(ir2);
- dir3 = mcp1.digitalRead(ir3);
- dir4 = mcp1.digitalRead(ir4);
- dir5 = mcp1.digitalRead(ir5);
- dir6 = mcp1.digitalRead(ir6);
- dir7 = mcp1.digitalRead(ir7);
- dir8 = mcp1.digitalRead(ir8);
- dir9 = mcp1.digitalRead(ir9);
- dir10 = mcp1.digitalRead(ir10);
- dir11 = mcp1.digitalRead(ir11);
- dir12 = mcp1.digitalRead(ir12);
- dir13 = mcp1.digitalRead(ir13);
- dir14 = mcp1.digitalRead(ir14);
- dir15 = mcp1.digitalRead(ir15);
- dir16 = mcp1.digitalRead(ir16);
-
- // Read pins from the second MCP23017 (0x22)
- dir17 = mcp2.digitalRead(ir1);
- dir18 = mcp2.digitalRead(ir2);
- dir19 = mcp2.digitalRead(ir3);
- dir20 = mcp2.digitalRead(ir4);
- dir21 = mcp2.digitalRead(ir5);
- dir22 = mcp2.digitalRead(ir6);
- dir23 = mcp2.digitalRead(ir7);
- dir24 = mcp2.digitalRead(ir8);
- dir25 = mcp2.digitalRead(ir9);
- dir26 = mcp2.digitalRead(ir10);
- dir27 = mcp2.digitalRead(ir11);
- dir28 = mcp2.digitalRead(ir12);
- dir29 = mcp2.digitalRead(ir13);
- dir30 = mcp2.digitalRead(ir14);
- dir31 = mcp2.digitalRead(ir15);
- dir32 = mcp2.digitalRead(ir16);
-
- // Print the results from the first MCP23017 (0x20)
- Serial.print("MCP23017 @ 0x20: ");
- Serial.print(dir1); Serial.print(", "); Serial.print(dir2);
- Serial.print(", "); Serial.print(dir3); Serial.print(", "); Serial.print(dir4);
- Serial.print(", "); Serial.print(dir5); Serial.print(", "); Serial.print(dir6);
- Serial.print(", "); Serial.print(dir7); Serial.print(", "); Serial.print(dir8);
- Serial.print(", "); Serial.print(dir9); Serial.print(", "); Serial.print(dir10);
- Serial.print(", "); Serial.print(dir11); Serial.print(", "); Serial.print(dir12);
- Serial.print(", "); Serial.print(dir13); Serial.print(", "); Serial.print(dir14);
- Serial.print(", "); Serial.print(dir15); Serial.print(", "); Serial.print(dir16);
-
- // Print the results from the second MCP23017 (0x22)
- Serial.print(" MCP23017 @ 0x22: ");
- Serial.print(dir17); Serial.print(", "); Serial.print(dir18);
- Serial.print(", "); Serial.print(dir19); Serial.print(", "); Serial.print(dir20);
- Serial.print(", "); Serial.print(dir21); Serial.print(", "); Serial.print(dir22);
- Serial.print(", "); Serial.print(dir23); Serial.print(", "); Serial.print(dir24);
- Serial.print(", "); Serial.print(dir25); Serial.print(", "); Serial.print(dir26);
- Serial.print(", "); Serial.print(dir27); Serial.print(", "); Serial.print(dir28);
- Serial.print(", "); Serial.print(dir29); Serial.print(", "); Serial.print(dir30);
- Serial.print(", "); Serial.print(dir31); Serial.print(", "); Serial.println(dir32);
-
- Serial.println();
- delay(250);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/mcp20317_schemss.jpg b/OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/mcp20317_schemss.jpg
deleted file mode 100644
index 5231394..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/MCP23017/mcp20317_schemss.jpg
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/Scanner/Scanner.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/Scanner/Scanner.ino
deleted file mode 100644
index 879dbd6..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/Scanner/Scanner.ino
+++ /dev/null
@@ -1,194 +0,0 @@
-// Wire Scanner - scans for I2C devices on all Wire ports
-//
-// This Wire library adapted is for Teensy boards
-//
-// https://github.com/PaulStoffregen/Wire/
-//
-// Adapted from I2C Scanner originally published on Arduino Playground
-// see comments below for link and credits for original authors.
-
-#include <Wire.h>
-
-void setup() {
-#if WIRE_INTERFACES_COUNT >= 1
- //Wire.setSCL(16); // uncomment these to use alternate Wire pins
- //Wire.setSDA(17);
- Wire.begin();
-#endif
- Serial.begin(9600);
- while (!Serial); // Wait for Arduino Serial Monitor
- Serial.println(F("\nI2C Scanner"));
-}
-
-
-void loop() {
- Serial.println();
-#if WIRE_INTERFACES_COUNT >= 1
- Serial.println(F("Scanning Wire..."));
- scan(Wire);
- delay(500);
-#endif
- delay(2000); // wait 5 seconds for next scan
-}
-
-
-void scan(TwoWire &myport) {
- int nDevices = 0;
- for (int address = 1; address < 127; address++) {
- // The i2c_scanner uses the return value of
- // the Write.endTransmisstion to see if
- // a device did acknowledge to the address.
- myport.beginTransmission(address);
- int error = myport.endTransmission();
-
- if (error == 0) {
- Serial.print(F("Device found at address 0x"));
- if (address < 16) {
- Serial.print("0");
- }
- Serial.print(address,HEX);
- Serial.print(" (");
- printKnownChips(address);
- Serial.println(")");
- nDevices++;
- } else if (error==4) {
- Serial.print(F("Unknown error at address 0x"));
- if (address < 16) {
- Serial.print("0");
- }
- Serial.println(address,HEX);
- }
- }
- if (nDevices == 0) {
- Serial.println(F("No I2C devices found"));
- } else {
- Serial.println(F("done"));
- }
- Serial.println();
-}
-
-
-void printKnownChips(byte address)
-{
- // Is this list missing part numbers for chips you use?
- // Please suggest additions here:
- // https://github.com/PaulStoffregen/Wire/issues/new
- switch (address) {
- case 0x00: Serial.print(F("AS3935")); break;
- case 0x01: Serial.print(F("AS3935")); break;
- case 0x02: Serial.print(F("AS3935")); break;
- case 0x03: Serial.print(F("AS3935")); break;
- case 0x04: Serial.print(F("ADAU1966")); break;
- case 0x0A: Serial.print(F("SGTL5000")); break; // MCLK required
- case 0x0B: Serial.print(F("SMBusBattery?")); break;
- case 0x0C: Serial.print(F("AK8963")); break;
- case 0x10: Serial.print(F("CS4272")); break;
- case 0x11: Serial.print(F("Si4713")); break;
- case 0x13: Serial.print(F("VCNL4000,AK4558")); break;
- case 0x18: Serial.print(F("LIS331DLH")); break;
- case 0x19: Serial.print(F("LSM303,LIS331DLH")); break;
- case 0x1A: Serial.print(F("WM8731")); break;
- case 0x1C: Serial.print(F("LIS3MDL")); break;
- case 0x1D: Serial.print(F("LSM303D,LSM9DS0,ADXL345,MMA7455L,LSM9DS1,LIS3DSH")); break;
- case 0x1E: Serial.print(F("LSM303D,HMC5883L,FXOS8700,LIS3DSH")); break;
- case 0x20: Serial.print(F("MCP23017,MCP23008,PCF8574,FXAS21002,SoilMoisture")); break;
- case 0x21: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x22: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x23: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x24: Serial.print(F("MCP23017,MCP23008,PCF8574,ADAU1966,HM01B0")); break;
- case 0x25: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x26: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x27: Serial.print(F("MCP23017,MCP23008,PCF8574,LCD16x2,DigoleDisplay")); break;
- case 0x28: Serial.print(F("BNO055,EM7180,CAP1188")); break;
- case 0x29: Serial.print(F("TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188")); break;
- case 0x2A: Serial.print(F("SGTL5000,CAP1188")); break;
- case 0x2B: Serial.print(F("CAP1188")); break;
- case 0x2C: Serial.print(F("MCP44XX ePot")); break;
- case 0x2D: Serial.print(F("MCP44XX ePot")); break;
- case 0x2E: Serial.print(F("MCP44XX ePot")); break;
- case 0x2F: Serial.print(F("MCP44XX ePot")); break;
- case 0x30: Serial.print(F("Si7210")); break;
- case 0x31: Serial.print(F("Si7210")); break;
- case 0x32: Serial.print(F("Si7210")); break;
- case 0x33: Serial.print(F("MAX11614,MAX11615,Si7210,MLX90640,MLX90641")); break;
- case 0x34: Serial.print(F("MAX11612,MAX11613")); break;
- case 0x35: Serial.print(F("MAX11616,MAX11617")); break;
- case 0x38: Serial.print(F("RA8875,FT6206,MAX98390")); break;
- case 0x39: Serial.print(F("TSL2561, APDS9960")); break;
- case 0x3A: Serial.print(F("MLX90632")); break;
- case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
- case 0x3D: Serial.print(F("SSD1306")); break;
- case 0x40: Serial.print(F("PCA9685,Si7021,MS8607")); break;
- case 0x41: Serial.print(F("STMPE610,PCA9685")); break;
- case 0x42: Serial.print(F("PCA9685")); break;
- case 0x43: Serial.print(F("PCA9685")); break;
- case 0x44: Serial.print(F("PCA9685, SHT3X, ADAU1966")); break;
- case 0x45: Serial.print(F("PCA9685, SHT3X")); break;
- case 0x46: Serial.print(F("PCA9685")); break;
- case 0x47: Serial.print(F("PCA9685")); break;
- case 0x48: Serial.print(F("ADS1115,PN532,TMP102,LM75,PCF8591,CS42448")); break;
- case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591,CS42448,TC74A1")); break;
- case 0x4A: Serial.print(F("ADS1115,Qwiic Keypad,CS42448")); break;
- case 0x4B: Serial.print(F("ADS1115,TMP102,BNO080,Qwiic Keypad,CS42448")); break;
- case 0x50: Serial.print(F("EEPROM,FRAM")); break;
- case 0x51: Serial.print(F("EEPROM")); break;
- case 0x52: Serial.print(F("Nunchuk,EEPROM")); break;
- case 0x53: Serial.print(F("ADXL345,EEPROM")); break;
- case 0x54: Serial.print(F("EEPROM")); break;
- case 0x55: Serial.print(F("EEPROM")); break;
- case 0x56: Serial.print(F("EEPROM")); break;
- case 0x57: Serial.print(F("EEPROM")); break;
- case 0x58: Serial.print(F("TPA2016,MAX21100")); break;
- case 0x5A: Serial.print(F("MPR121,MLX90614")); break;
- case 0x60: Serial.print(F("MPL3115,MCP4725,MCP4728,TEA5767,Si5351")); break;
- case 0x61: Serial.print(F("MCP4725,AtlasEzoDO")); break;
- case 0x62: Serial.print(F("LidarLite,MCP4725,AtlasEzoORP")); break;
- case 0x63: Serial.print(F("MCP4725,AtlasEzoPH")); break;
- case 0x64: Serial.print(F("AtlasEzoEC, ADAU1966")); break;
- case 0x66: Serial.print(F("AtlasEzoRTD")); break;
- case 0x68: Serial.print(F("DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D")); break;
- case 0x69: Serial.print(F("MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D")); break;
- case 0x6A: Serial.print(F("LSM9DS1")); break;
- case 0x6B: Serial.print(F("LSM9DS0")); break;
- case 0x6F: Serial.print(F("Qwiic Button")); break;
- case 0x70: Serial.print(F("HT16K33,TCA9548A")); break;
- case 0x71: Serial.print(F("SFE7SEG,HT16K33")); break;
- case 0x72: Serial.print(F("HT16K33")); break;
- case 0x73: Serial.print(F("HT16K33")); break;
- case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
- case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
- case 0x7C: Serial.print(F("FRAM_ID")); break;
- default: Serial.print(F("unknown chip"));
- }
-}
-
-
-// --------------------------------------
-// i2c_scanner
-// https://playground.arduino.cc/Main/I2cScanner/
-//
-// Version 1
-// This program (or code that looks like it)
-// can be found in many places.
-// For example on the Arduino.cc forum.
-// The original author is not know.
-// Version 2, Juni 2012, Using Arduino 1.0.1
-// Adapted to be as simple as possible by Arduino.cc user Krodal
-// Version 3, Feb 26 2013
-// V3 by louarnold
-// Version 4, March 3, 2013, Using Arduino 1.0.3
-// by Arduino.cc user Krodal.
-// Changes by louarnold removed.
-// Scanning addresses changed from 0...127 to 1...119,
-// according to the i2c scanner by Nick Gammon
-// http://www.gammon.com.au/forum/?id=10896
-// Version 5, March 28, 2013
-// As version 4, but address scans now to 127.
-// A sensor seems to use address 120.
-// Version 6, November 27, 2015.
-// Added waiting for the Leonardo serial communication.
-//
-//
-// This sketch tests the standard 7-bit addresses
-// Devices with higher bit address might not be seen properly.
-//
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/color_sensor.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/color_sensor.ino
deleted file mode 100644
index c800f16..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/color_sensor.ino
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
-i2c port scanner based on:
- in wire library examples i2c_scanner
- https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino
-
-color sensor based on±
- adafruit TCS34725 librarys
-
- type var:
- https://arduino.stackexchange.com/questions/3079/how-to-retrieve-the-data-type-of-a-variable
-
- *
- */
-
-#include <Wire.h> //https://www.arduino.cc/reference/en/language/functions/communication/wire/
-#include "Adafruit_TCS34725.h" //https://github.com/adafruit/Adafruit_TCS34725
-
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-
-/* Initialise with default values (int time = 2.4ms, gain = 1x) */
-Adafruit_TCS34725 tcs = Adafruit_TCS34725();
-//Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);
-
-const int buzzer = 6; //buzzer to arduino pin 9
-
-
-int colsensdata[6] = {99, 99, 99, 99, 99, 99};
-
-
-
-void setup() {
- Serial.begin(115200);
- //while (!Serial); // Leonardo: wait for Serial Monitor
- Serial.println("\nI2C Scanner");
- pinMode(buzzer, OUTPUT);
-
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-void scandirectports(){
- Wire.begin();
- int nDevices = 0;
- Serial.println("Scanning for i2c ports on board...");
-
- for (byte address = 1; address < 127; ++address) {
- // The i2c_scanner uses the return value of
- // the Wire.endTransmission to see if
- // a device did acknowledge to the address.
- Wire.beginTransmission(address);
- byte error = Wire.endTransmission();
-
- if (error == 0) {
- Serial.print("I2C device found at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.print(address, HEX);
- Serial.println(" !");
-
- ++nDevices;
- } else if (error == 4) {
- Serial.print("Unknown error at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.println(address, HEX);
- }
- }
- if (nDevices == 0) {
- Serial.println("No I2C devices found\n");
- } else {
- Serial.println("done\n");
- }
-}
-
-
-// Generic catch-all implementation.
-template <typename T_ty> struct TypeInfo { static const char * name; };
-template <typename T_ty> const char * TypeInfo<T_ty>::name = "unknown";
-
-// Handy macro to make querying stuff easier.
-#define TYPE_NAME(var) TypeInfo< typeof(var) >::name
-
-// Handy macro to make defining stuff easier.
-#define MAKE_TYPE_INFO(type) template <> const char * TypeInfo<type>::name = #type;
-
-// Type-specific implementations.
-MAKE_TYPE_INFO( int )
-MAKE_TYPE_INFO( float )
-MAKE_TYPE_INFO( short )
-
-void loop() {
- Wire.begin();
-
- for (uint8_t t=0; t<50; t++) {
- Serial.println();
- }
-
- scandirectports();
-
- Serial.println();
- Serial.println();
-
- for (uint8_t t=0; t<6; t++) {
- pcaselect(t);
- Serial.print("PCA Port #"); Serial.println(t);
- for (uint8_t addr = 0; addr<=127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
- Serial.println("scanning for tcs sensor");
- if (tcs.begin()) {
- Serial.println("Found sensor");
- Serial.println("collecting data");
- uint16_t r, g, b, c, colorTemp, lux;
- tcs.getRawData(&r, &g, &b, &c);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
- Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
- Serial.print("RGB: "); Serial.print(r, DEC); Serial.print(", "); Serial.print(g, DEC); Serial.print(", "); Serial.print(b, DEC); Serial.println(" ");
- if ((colorTemp) == 5201){
- Serial.println("sensor in air");
- tone(buzzer, 100);
- colsensdata[t] = 0;
- }
- else if ((g)>=(2*(r)) && (g)>=12){
- Serial.println("green");
- tone(buzzer, 200);
- colsensdata[t] = 1;
- }
- else if ((colorTemp)>= 6750){
- Serial.println("black");
- tone(buzzer, 300);
- colsensdata[t] = 2;
- }
- else if ((colorTemp) < 6750){
- Serial.println("white");
- tone(buzzer, 400);
- colsensdata[t] = 3;
- }
- else{
- Serial.println(colorTemp);
- Serial.println(TYPE_NAME((colorTemp, DEC)));
- colsensdata[t] = 98;
- }
- Serial.println();
-
-
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- colsensdata[t] = 97;
- }
- delay(500);
- }
- }
- }
- Serial.println();
- Serial.print("sensor data = ");
- for(int i = 0; i < 6; i++){
- Serial.print(colsensdata[i]);
- Serial.print(", ");
- }
- /**
-0 = air
-1 = green
-2 = black
-3 = white
-90 = error
-
- *
- */
- Serial.println("");
- Serial.println("DONE");
- tone(buzzer, 1000);
- delay(2500);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/short/short.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/short/short.ino
deleted file mode 100644
index 2f80412..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/color_sensor/short/short.ino
+++ /dev/null
@@ -1,94 +0,0 @@
-
-#include <Wire.h> //https://www.arduino.cc/reference/en/language/functions/communication/wire/
-#include "Adafruit_TCS34725.h" //https://github.com/adafruit/Adafruit_TCS34725
-
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-
-
-Adafruit_TCS34725 tcs = Adafruit_TCS34725();/* Initialise with default values (int time = 2.4ms, gain = 1x) */
-
-int colsensdata[6] = {99, 99, 99, 99, 99, 99};
-
-void setup() {
- Serial.begin(115200);
- Serial.println("\nI2C Scanner");
-
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-
-template <typename T_ty> struct TypeInfo { static const char * name; };
-template <typename T_ty> const char * TypeInfo<T_ty>::name = "unknown";
-#define TYPE_NAME(var) TypeInfo< typeof(var) >::name
-#define MAKE_TYPE_INFO(type) template <> const char * TypeInfo<type>::name = #type;
-MAKE_TYPE_INFO( int )
-MAKE_TYPE_INFO( float )
-MAKE_TYPE_INFO( short )
-
-void loop() {
- Wire.begin();
- for (uint8_t t=0; t<6; t++) {
- pcaselect(t);
- Serial.print("PCA Port #"); Serial.println(t);
- for (uint8_t addr = 0; addr<=127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
- if (tcs.begin()) {
- Serial.println("Found sensor");
- Serial.println("collecting data");
- uint16_t r, g, b, c, colorTemp, lux;
- tcs.getRawData(&r, &g, &b, &c);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
- Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
- Serial.print("RGB: "); Serial.print(r, DEC); Serial.print(", "); Serial.print(g, DEC); Serial.print(", "); Serial.print(b, DEC); Serial.println(" ");
- if ((colorTemp) == 5201){
- colsensdata[t] = 0;
- }
- else if ((g)>=(2*(r)) && (g)>=12){
- colsensdata[t] = 1;
- }
- else if ((colorTemp)>= 6750){
- colsensdata[t] = 2;
- }
- else if ((colorTemp) < 6750){
- colsensdata[t] = 3;
- }
- else{
- Serial.println(colorTemp);
- Serial.println(TYPE_NAME((colorTemp, DEC)));
- colsensdata[t] = 98;
- }
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- colsensdata[t] = 97;
- }
- }
- }
- }
- Serial.print("sensor data = ");
- for(int i = 0; i < 6; i++){
- Serial.print(colsensdata[i]);
- Serial.print(", ");
- }
- /**
-0 = air
-1 = green
-2 = black
-3 = white
-90 = error
-
- *
- */
- Serial.println("");
- Serial.println("DONE");
- delay(2500);
-} \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino
deleted file mode 100644
index eb257e5..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino
+++ /dev/null
@@ -1,28 +0,0 @@
-String inp = "01101000";
-int decimalValue = 0;
-
-void setup() {
- Serial.begin(115200);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for native USB
- }
- Serial.println("");
-
- Serial.println(inp);
- String binary = inp.substring(2);
- Serial.println(binary);
- for (int i = 0; i < binary.length(); i++) {
- // Calculate the value of the current bit
- int bitValue = binary.charAt(i) - '0';
- // Update the decimal value by shifting the bit to its correct position
- decimalValue = (decimalValue << 1) | bitValue;
- }
- Serial.println(decimalValue);
- Serial.println("");
-}
-
-void loop() {
- // put your main code here, to run repeatedly:
- delay(1000);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_comm/arduino_comm.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_comm/arduino_comm.ino
deleted file mode 100644
index 4a2b205..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/arduino_comm/arduino_comm.ino
+++ /dev/null
@@ -1,37 +0,0 @@
-String tlocd = "";
-String locd = "";
-bool readloc = false;
-unsigned long datatime = 0;
-
-void setup() {
- Serial1.begin(19200);
- Serial.begin(19200);
-}
-
-void loop() {
- if(Serial1.available()){
- datatime = millis();
-
- byte byteRead = Serial1.read();
-
- if(byteRead == 's'){
- tlocd = "";
- readloc = true;
- }
- else if(byteRead == 'e'){
- readloc = false;
- locd = tlocd;
- }
- else if(readloc == true){
- tlocd += (char)byteRead;
- }
- }
- else{
- if(millis() - datatime > 5000){
- Serial.println("Err no data recieved for 5 sec");
- locd = "999";
- }
- }
- Serial.println(locd);
- delay(134);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/readme.txt.txt b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/readme.txt.txt
deleted file mode 100644
index ef9f996..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/readme.txt.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-serial communication between two Seeed Studio XIAO SAMD21 and one teensy.
-Teensy Serial 2 and 3 on read
-Seeed XIAO SAMD21 write a 8 values on Serial1 between 0-10000 (pulses from IR sensor) every 0,25 seconds. For example 100 pulses in 1 second = 00025
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/seeed_uart/seeed_uart.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/seeed_uart/seeed_uart.ino
deleted file mode 100644
index 32750de..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/seeed_uart/seeed_uart.ino
+++ /dev/null
@@ -1,9 +0,0 @@
-void setup() {
- Serial1.begin(9600)
-
-}
-
-void loop() {
- Serial1.println("/D:00025:/E");
- delay(250);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino
deleted file mode 100644
index 684c199..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino
+++ /dev/null
@@ -1,17 +0,0 @@
-void setup() {
- // Initialize Serial1 with a baud rate of 19200
- Serial1.begin(9600);
- Serial.begin(9600); // Initialize Serial for debugging
-}
-
-void loop() {
- // Check if there is any data available to read from Serial1
- if (Serial1.available()) {
- // Read the most recent byte
- byte byteRead = Serial1.read();
- // Echo the value that was read
- Serial1.write(byteRead);
- // Print the received byte for debugging
- Serial.print((char)byteRead);
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_master/arduino_spi_master.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_master/arduino_spi_master.ino
deleted file mode 100644
index 248ef0f..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_master/arduino_spi_master.ino
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <SPI.h>
-#define SS_PIN 10
-#define BAUD_RATE 19200
-#define CHAR_BUF 128
-
-void setup() {
- pinMode(SS_PIN, OUTPUT);
- Serial.begin(BAUD_RATE);
- SPI.begin();
- SPI.setBitOrder(MSBFIRST);
- SPI.setClockDivider(SPI_CLOCK_DIV16);
- SPI.setDataMode(SPI_MODE0);
- delay(1000); // Give the OpenMV Cam time to bootup.
-}
-
-void loop() {
- int32_t len = 0;
- char buff[CHAR_BUF] = {0};
- digitalWrite(SS_PIN, LOW);
- delay(1); // Give the OpenMV Cam some time to setup to send data.
-
- if(SPI.transfer(1) == 85) { // saw sync char?
- SPI.transfer(&len, 4); // get length
- if (len) {
- SPI.transfer(&buff, min(len, CHAR_BUF));
- len -= min(len, CHAR_BUF);
- }
- while (len--) SPI.transfer(0); // eat any remaining bytes
- }
-
- digitalWrite(SS_PIN, HIGH);
- Serial.print(buff);
- delay(1); // Don't loop to quickly.
-} \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_slave_1.py b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_slave_1.py
deleted file mode 100644
index e05c2f0..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/spi/arduino_spi_slave_1.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# This work is licensed under the MIT license.
-# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
-# https://github.com/openmv/openmv/blob/master/LICENSE
-#
-# SPI with the Arduino as the master device and the OpenMV Cam as the slave.
-#
-# Please wire up your OpenMV Cam to your Arduino like this:
-#
-# OpenMV Cam Master Out Slave In (P0) - Arduino Uno MOSI (11)
-# OpenMV Cam Master In Slave Out (P1) - Arduino Uno MISO (12)
-# OpenMV Cam Serial Clock (P2) - Arduino Uno SCK (13)
-# OpenMV Cam Slave Select (P3) - Arduino Uno SS (10)
-# OpenMV Cam Ground - Arduino Ground
-
-import pyb
-import ustruct
-import time
-
-text = "Hello World!\n"
-data = ustruct.pack("<bi%ds" % len(text), 85, len(text), text) # 85 is a sync char.
-# Use "ustruct" to build data packets to send.
-# "<" puts the data in the struct in little endian order.
-# "b" puts a signed char in the data stream.
-# "i" puts a signed integer in the data stream.
-# "%ds" puts a string in the data stream. E.g. "13s" for "Hello World!\n" (13 chars).
-# See https://docs.python.org/3/library/struct.html
-
-# READ ME!!!
-#
-# Please understand that when your OpenMV Cam is not the SPI master it may miss responding to
-# sending data as a SPI slave no matter if you call "spi.send()" in an interrupt callback or in the
-# main loop below. Because of this you must absolutely design your communications protocol such
-# that if the slave device (the OpenMV Cam) doesn't call "spi.send()" in time that garbage data
-# read from the SPI peripheral by the master (the Arduino) is tossed. To accomplish this we use a
-# sync character of 85 (binary 01010101) which the Arduino will look for as the first byte read.
-# If it doesn't see this then it aborts the SPI transaction and will try again. Second, in order to
-# clear out the SPI peripheral state we always send a multiple of four bytes and an extra four zero
-# bytes to make sure that the SPI peripheral doesn't hold any stale data which could be 85. Note
-# that the OpenMV Cam will miss the "spi.send()" window randomly because it has to service
-# interrupts. Interrupts will happen a lot more while connected to your PC.
-
-# The hardware SPI bus for your OpenMV Cam is always SPI bus 2.
-# polarity = 0 -> clock is idle low.
-# phase = 0 -> sample data on rising clock edge, output data on falling clock edge.
-spi = pyb.SPI(2, pyb.SPI.SLAVE, polarity=0, phase=0)
-
-
-# NSS callback.
-def nss_callback(line):
- global spi, data
- try:
- spi.send(data, timeout=1000)
- except OSError as err:
- pass # Don't care about errors - so pass.
- # Note that there are 3 possible errors. A timeout error, a general purpose error, or
- # a busy error. The error codes are 116, 5, 16 respectively for "err.arg[0]".
-
-
-# Configure NSS/CS in IRQ mode to send data when requested by the master.
-pyb.ExtInt(pyb.Pin("P3"), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, nss_callback)
-
-while True:
- time.sleep_ms(1000)
-
-###################################################################################################
-# Arduino Code
-###################################################################################################
-#
-# #include <SPI.h>
-# #define SS_PIN 10
-# #define BAUD_RATE 19200
-# #define CHAR_BUF 128
-#
-# void setup() {
-# pinMode(SS_PIN, OUTPUT);
-# Serial.begin(BAUD_RATE);
-# SPI.begin();
-# SPI.setBitOrder(MSBFIRST);
-# SPI.setClockDivider(SPI_CLOCK_DIV16);
-# SPI.setDataMode(SPI_MODE0);
-# delay(1000); // Give the OpenMV Cam time to bootup.
-# }
-#
-# void loop() {
-# int32_t len = 0;
-# char buff[CHAR_BUF] = {0};
-# digitalWrite(SS_PIN, LOW);
-# delay(1); // Give the OpenMV Cam some time to setup to send data.
-#
-# if(SPI.transfer(1) == 85) { // saw sync char?
-# SPI.transfer(&len, 4); // get length
-# if (len) {
-# SPI.transfer(&buff, min(len, CHAR_BUF));
-# len -= min(len, CHAR_BUF);
-# }
-# while (len--) SPI.transfer(0); // eat any remaining bytes
-# }
-#
-# digitalWrite(SS_PIN, HIGH);
-# Serial.print(buff);
-# delay(1); // Don't loop to quickly.
-# }
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart/arduino_uart.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart/arduino_uart.ino
deleted file mode 100644
index 6385695..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart/arduino_uart.ino
+++ /dev/null
@@ -1,17 +0,0 @@
-void setup() {
- // Initialize Serial1 with a baud rate of 19200
- Serial1.begin(19200);
- Serial.begin(19200); // Initialize Serial for debugging
-}
-
-void loop() {
- // Check if there is any data available to read from Serial1
- if (Serial1.available()) {
- // Read the most recent byte
- byte byteRead = Serial1.read();
- // Echo the value that was read
- Serial1.write(byteRead);
- // Print the received byte for debugging
- Serial.print((char)byteRead);
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart_1.py b/OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart_1.py
deleted file mode 100644
index 3996cf7..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/comm/uart/arduino_uart_1.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# This work is licensed under the MIT license.
-# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
-# https://github.com/openmv/openmv/blob/master/LICENSE
-#
-# Basic UART communications between OpenMV and Arduino Uno.
-
-# 1) Wire up your OpenMV Cam to your Arduino Uno like this:
-#
-# OpenMV Cam Ground Pin ----> Arduino Ground
-# OpenMV Cam UART3_TX(P4) ----> Arduino Uno UART_RX(0)
-# OpenMV Cam UART3_RX(P5) ----> Arduino Uno UART_TX(1)
-
-# 2) Uncomment and upload the following sketch to Arduino:
-#
-# void setup() {
-# // put your setup code here, to run once:
-# Serial.begin(19200);
-# }
-#
-# void loop() {
-# // put your main code here, to run repeatedly:
-# if (Serial.available()) {
-# // Read the most recent byte
-# byte byteRead = Serial.read();
-# // ECHO the value that was read
-# Serial.write(byteRead);
-# }
-# }
-
-# 3) Run the following script in OpenMV IDE:
-
-import time
-from pyb import UART
-
-# UART 3, and baudrate.
-uart = UART(3, 19200, timeout_char=200)
-
-while True:
- uart.write("Hello World!\n")
- if uart.any():
- print(uart.read())
- time.sleep_ms(1000)
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/InternalTemperature-master.zip b/OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/InternalTemperature-master.zip
deleted file mode 100644
index 64b7dc4..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/InternalTemperature-master.zip
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/data_logging_teensy_temp.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/data_logging_teensy_temp.ino
deleted file mode 100644
index fcd6c64..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/data_logging_teensy_temp/data_logging_teensy_temp.ino
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <InternalTemperature.h>
-#include <SD.h>
-#include <SPI.h>
-
-File ;
-File avrage;
-const int chipSelect = BUILTIN_SDCARD;
-
-/
-
-void setup()
-{
- Serial.begin(9600);
-
- //open current loop motor values file
- current = SD.open("motor_values.csv", FILE_WRITE);
-
- while(true){
- if (current) {
- if (SD.exists((String("motor_values") + x + ".csv").c_str())){
- Serial.println(((String)"motor_values"+x+".csv already exists"));
- x++;
- } else {
- Serial.println((String)"motor_values"+x+".csv"" doesn't exist.");
- Serial.println((String)"creating motor_values"+x+".csv");
- current = SD.open(((String("motor_values") + x + ".csv").c_str()), FILE_WRITE);
- break;
- }
- }
- delay(1);
- }
- Serial.println("!!!setup complete!!!");
-}
-
-
-void loop()
-{
- String currentvals = "";
- String avrvals = "";
-
- currentvals += InternalTemperature.readTemperatureC();
- d_println("°C");
- debugdataString += "°C";
-
- //log sensor data to sensor log
- sensordataString += InternalTemperature.readTemperatureC();
- sensordataString += ", ";
-
- //open sensor log file
- File csvfile = SD.open((String("motor_values") + x + ".csv").c_str()), FILE_WRITE);
- if (csvfile) {
- csvfile.println(sensordataString);
- csvfile.close();
- }
-
- //open debug file
- File dataFile = SD.open("avrage_motor_values.txt", FILE_WRITE);
- if (dataFile) {
- dataFile.println((String)"debug data:"+debugdataString+"sensor data"+sensordataString);
- dataFile.close();
- }
- delay(1000);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/CODE.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/CODE.ino
deleted file mode 100644
index 5b993c3..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/CODE.ino
+++ /dev/null
@@ -1,992 +0,0 @@
-#include <Wire.h> //https://www.arduino.cc/reference/en/language/functions/communication/wire/
-#include "Adafruit_TCS34725.h" //https://github.com/adafruit/Adafruit_TCS34725
-#include <Adafruit_MCP23X17.h> //https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/tree/master
-#include <LIS3MDL.h> //https://github.com/pololu/lis3mdl-arduino
-#include <LSM6.h> //https://github.com/pololu/lsm6-arduino
-#include <TimerThree.h> //https://www.arduino.cc/reference/en/libraries/timerthree/
-
-
-const int minpulsbal = 1100; //minimum pulses needed to be able to say it has the ball in posesion
-double sp = 1200.000; //estemate needed speed in RPM ~0-1800
-
-//i2c addr
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-#define mcp1ADDR 0x20 //first portmultiplexer for ir sensors
-#define mcp2ADDR 0x22 //first portmultiplexer for motors
-
-//IR sensors on multiplex1 0x20
-#define ir1 0 // GPA0
-#define ir2 1 // GPA1
-#define ir3 2 // GPA2
-#define ir4 3 // GPA3
-#define ir5 4 // GPA4
-#define ir6 5 // GPA5
-#define ir7 6 // GPA6
-#define ir8 7 // GPA7
-#define ir9 8 // GPB0
-#define ir10 9 // GPB1
-#define ir11 10 // GPB2
-#define ir12 11 // GPB3
-#define ir13 12 // GPB4
-#define ir14 13 // GPB5
-#define ir15 14 // GPB6
-#define ir16 15 // GPB7
-#define irBALL 25 // IR sensor to see if we have the ball, teensy pin NO 25
-
-//motors on multiplex2 0x22
-#define ArrayElementCount(needRPM) (sizeof(needRPM) / sizeof(needRPM[0])) //used to calculate array size
-const int maxspeed = 1000; //max speed in PWM value
-//calibration data
-int Amotordata[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641,
- 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192,
- 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400,
- 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562,
- 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702,
- 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751,
- 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833,
- 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809,
- 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951,
- 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924,
- 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893,
- 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923,
- 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982,
- 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979,
- 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948,
- 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924,
- 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910 };
-int Bmotordata[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667,
- 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194,
- 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435,
- 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602,
- 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673,
- 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846,
- 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914,
- 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944,
- 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927,
- 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036,
- 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978,
- 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036,
- 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949,
- 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992,
- 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948,
- 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905,
- 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910 };
-int Cmotordata[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667,
- 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194,
- 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415,
- 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592,
- 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676,
- 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765,
- 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920,
- 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859,
- 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946,
- 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893,
- 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935,
- 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965,
- 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907,
- 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034,
- 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880,
- 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883,
- 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910 };
-//how much rpm the robot aims for
-int AneedRPM = 0;
-int BneedRPM = 0;
-int CneedRPM = 0;
-//kiwidrive values
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-#define m1enA 3 // GPA3 PWM1
-#define m1enB 2 // GPA2
-#define m1pwm1 0 // GPA0
-#define m1pwm2 1 // GPA1
-#define m1encA 12 // GPB4
-#define m1encB 13 // GPB5
-// motor two/B left
-#define m2enA 7 // GPA7 PWM2
-#define m2enB 6 // GPA6
-#define m2pwm1 4 // GPA4
-#define m2pwm2 5 // GPA5
-#define m2encA 14 // GPB6
-#define m2encB 15 // GPB7
-// motor three/C right
-#define m3enA 11 // GPB3 PWM3
-#define m3enB 10 // GPB2
-#define m3pwm1 8 // GPB0
-#define m3pwm2 9 // GPB1
-#define m3encA 24 // teensy port 24
-#define m3encB 9 // teensy port 9
-//encoder values
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-//softPWM values
-volatile int PWMval1 = 0; // PWM m1enA value 0-100
-volatile int PWMval2 = 0; // PWM m2enA value 0-100
-volatile int PWMval3 = 0; // PWM m3enA value 0-100
-
-//settings
-#define dip1 2 //settings dip switch port 1
-#define dip2 3 //settings dip switch port 2
-#define dip3 4 //settings dip switch port 3
-#define dip4 5 //settings dip switch port 4
-#define buz 8 //buzzer
-
-//NOT USED CONNECT TO PULLUP
-#define P1 6 //pin 6 on Teensy
-#define P2 7 //pin 7 on Teensy
-#define P3 10 //pin 10 on Teensy
-#define P4 11 //pin 11 on Teensy
-#define P5 12 //pin 12 on Teensy
-#define P6 13 //pin 13 on Teensy
-#define P7 14 //pin 14 on Teensy
-#define P8 15 //pin 15 on Teensy
-#define P9 16 //pin 16 on Teensy
-#define P10 17 //pin 17 on Teensy
-#define P11 20 //pin 20 on Teensy
-#define P12 21 //pin 21 on Teensy
-#define P13 22 //pin 22 on Teensy
-#define P14 23 //pin 23 on Teensy
-#define P15 29 //pin 29 on Teensy
-#define P16 30 //pin 30 on Teensy
-#define P17 31 //pin 31 on Teensy
-#define P18 32 //pin 32 on Teensy
-#define P19 33 //pin 33 on Teensy
-#define P20 34 //pin 34 on Teensy
-#define P21 35 //pin 35 on Teensy
-#define P22 36 //pin 36 on Teensy
-#define P23 37 //pin 37 on Teensy
-#define P24 38 //pin 38 on Teensy
-#define P25 39 //pin 39 on Teensy
-#define P26 40 //pin 40 on Teensy
-#define P27 41 //pin 41 on Teensy
-//extra pins
-// #define EP1 25 //pin 41 on Teensy used for IR seeker
-#define EP2 26 //pin 41 on Teensy
-#define EP3 27 //pin 41 on Teensy
-#define EP4 28 //pin 41 on Teensy
-
-volatile long IRcount1 = 0;
-volatile long IRcount2 = 0;
-volatile long IRcount3 = 0;
-volatile long IRcount4 = 0;
-volatile long IRcount5 = 0;
-volatile long IRcount6 = 0;
-volatile long IRcount7 = 0;
-volatile long IRcount8 = 0;
-volatile long IRcount9 = 0;
-volatile long IRcount10 = 0;
-volatile long IRcount11 = 0;
-volatile long IRcount12 = 0;
-volatile long IRcount13 = 0;
-volatile long IRcount14 = 0;
-volatile long IRcount15 = 0;
-volatile long IRcount16 = 0;
-volatile long IRcountBALL = 0;
-int ballpos = 0; //location of ball in degrees
-
-int errorbuz = 0; //if there is an error someware it goes to 1 and the buzzer starts
-
-int ballinpos = 0; //is ball in our posesion. 0=no 1=yes
-int colsensdata[6] = { 99, 99, 99, 99, 99, 99 }; //data colorsensors
-
-int dip1val = 0; //value of dip, 0=LOW, 1=HIGH
-int dip2val = 0;
-int dip3val = 0;
-int dip4val = 0;
-int settingval = 1;
-
-Adafruit_MCP23X17 mcp1; // Instance for the first MCP23017 at address 0x20
-Adafruit_MCP23X17 mcp2; // Instance for the second MCP23017 at address 0x22
-
-Adafruit_TCS34725 tcs = Adafruit_TCS34725(); // Initialise color sensorwith default values (int time = 2.4ms, gain = 1x)
-
-String tlocd = ""; //temp data for goal location
-String locd = ""; //goal location in deg
-int gloc = 0; //goal location in deg int
-bool readloc = false;
-unsigned long datatime = 0;
-
-LIS3MDL mag;
-LSM6 imu;
-int front = 0;
-//enter calibration values
-LIS3MDL::vector<int16_t> m_min = { +942, +3436, -3323 };
-LIS3MDL::vector<int16_t> m_max = { +1053, +3559, -3142 };
-
-void setup() {
- Serial.begin(9600); //serial debug
- Serial1.begin(19200); //connection to openMV
-
- //connect unconected pins to GND
- pinMode(P1, INPUT_PULLUP);
- pinMode(P2, INPUT_PULLUP);
- pinMode(P3, INPUT_PULLUP);
- pinMode(P4, INPUT_PULLUP);
- pinMode(P5, INPUT_PULLUP);
- pinMode(P6, INPUT_PULLUP);
- pinMode(P7, INPUT_PULLUP);
- pinMode(P8, INPUT_PULLUP);
- pinMode(P9, INPUT_PULLUP);
- pinMode(P10, INPUT_PULLUP);
- pinMode(P11, INPUT_PULLUP);
- pinMode(P12, INPUT_PULLUP);
- pinMode(P13, INPUT_PULLUP);
- pinMode(P14, INPUT_PULLUP);
- pinMode(P15, INPUT_PULLUP);
- pinMode(P16, INPUT_PULLUP);
- pinMode(P17, INPUT_PULLUP);
- pinMode(P18, INPUT_PULLUP);
- pinMode(P19, INPUT_PULLUP);
- pinMode(P20, INPUT_PULLUP);
- pinMode(P21, INPUT_PULLUP);
- pinMode(P22, INPUT_PULLUP);
- pinMode(P23, INPUT_PULLUP);
- pinMode(P24, INPUT_PULLUP);
- pinMode(P25, INPUT_PULLUP);
- pinMode(P26, INPUT_PULLUP);
- pinMode(P27, INPUT_PULLUP);
- //connect unconected extrapins to GND
- pinMode(EP2, INPUT_PULLUP);
- pinMode(EP3, INPUT_PULLUP);
- pinMode(EP4, INPUT_PULLUP);
-
- // Initialize first MCP23017 with I2C address 0x20
- if (!mcp1.begin_I2C(mcp1ADDR)) {
- Serial.println("(IR_sensors)Error initializing MCP23017 at 0x20.");
- }
-
- // Initialize second MCP23017 with I2C address 0x22
- if (!mcp2.begin_I2C(mcp2ADDR)) {
- Serial.println("(Motors)Error initializing MCP23017 at 0x22.");
- }
- //magnetometer
- if (!mag.init()) {
- Serial.println("Error initializing LIS3MDL magnetometer.");
- }
- //IMU
- if (!imu.init()) {
- Serial.println("Error initializing LSM6 IMU.");
- }
- imu.enableDefault();
- //get start heading to use as refreance point
- mag.read();
- imu.read();
- float heading = computeHeading();
- front = heading;
- Serial.println(heading);
-
- // Configure pins for the IR seekers
- mcp1.pinMode(ir1, INPUT);
- mcp1.pinMode(ir2, INPUT);
- mcp1.pinMode(ir3, INPUT);
- mcp1.pinMode(ir4, INPUT);
- mcp1.pinMode(ir5, INPUT);
- mcp1.pinMode(ir6, INPUT);
- mcp1.pinMode(ir7, INPUT);
- mcp1.pinMode(ir8, INPUT);
- mcp1.pinMode(ir9, INPUT);
- mcp1.pinMode(ir10, INPUT);
- mcp1.pinMode(ir11, INPUT);
- mcp1.pinMode(ir12, INPUT);
- mcp1.pinMode(ir13, INPUT);
- mcp1.pinMode(ir14, INPUT);
- mcp1.pinMode(ir15, INPUT);
- mcp1.pinMode(ir16, INPUT);
- pinMode(irBALL, INPUT);
-
- // Configure pins for the motor
- mcp2.pinMode(m1enA, OUTPUT);
- mcp2.pinMode(m1enB, OUTPUT);
- mcp2.pinMode(m2enA, OUTPUT);
- mcp2.pinMode(m2enB, OUTPUT);
- mcp2.pinMode(m3enA, OUTPUT);
- mcp2.pinMode(m3enB, OUTPUT);
- mcp2.pinMode(m1pwm1, OUTPUT);
- mcp2.pinMode(m1pwm2, OUTPUT);
- mcp2.pinMode(m2pwm1, OUTPUT);
- mcp2.pinMode(m2pwm2, OUTPUT);
- mcp2.pinMode(m3pwm1, OUTPUT);
- mcp2.pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins
- mcp2.pinMode(m1encA, INPUT);
- mcp2.pinMode(m1encB, INPUT);
- mcp2.pinMode(m2encA, INPUT);
- mcp2.pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
-
- //IR seeker interupts
- attachInterrupt(digitalPinToInterrupt(ir1), IRtrigger1, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir2), IRtrigger2, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir3), IRtrigger3, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir4), IRtrigger4, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir5), IRtrigger5, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir6), IRtrigger6, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir7), IRtrigger7, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir8), IRtrigger8, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir9), IRtrigger9, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir10), IRtrigger10, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir11), IRtrigger11, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir12), IRtrigger12, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir13), IRtrigger13, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir14), IRtrigger14, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir15), IRtrigger15, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir16), IRtrigger16, CHANGE);
- attachInterrupt(digitalPinToInterrupt(irBALL), IRtrigger16, CHANGE);
-
- //encoder interupst
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-
- //PWM interupst
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM1);
- Timer3.attachInterrupt(updatePWM2);
- Timer3.attachInterrupt(updatePWM3);
-
- pinMode(buz, OUTPUT);
- Serial.println("SETUP COMPLETE GOING TO LOOP");
- tone(buz, 1000);
-}
-void updatePWM1() {
- static int counter1 = 0;
- if (counter1 < PWMval1) {
- mcp2.digitalWrite(m1enA, HIGH);
- } else {
- mcp2.digitalWrite(m1enA, LOW);
- }
- counter1++;
- if (counter1 >= 100) {
- counter1 = 0;
- }
-}
-void updatePWM2() {
- static int counter2 = 0;
- if (counter2 < PWMval2) {
- mcp2.digitalWrite(m2enA, HIGH);
- } else {
- mcp2.digitalWrite(m2enA, LOW);
- }
- counter2++;
- if (counter2 >= 100) {
- counter2 = 0;
- }
-}
-void updatePWM3() {
- static int counter3 = 0;
- if (counter3 < PWMval3) {
- mcp2.digitalWrite(m3enA, HIGH);
- } else {
- mcp2.digitalWrite(m3enA, LOW);
- }
- counter3++;
- if (counter3 >= 100) {
- counter3 = 0;
- }
-}
-void mcpsoftpwm(int pin, int vall) {
- //M1enA = 3 = GPA3
- //M2enA = 7 = GPA7
- //M3enA = 11 = GPB3
- Serial.print("softPWM pin: ");
- Serial.print(pin);
- Serial.print(", value: ");
- Serial.println(vall);
- if (pin = 3) {
- PWMval1 = vall;
- Serial.print("Motor 1 enA PWM set");
- }
- if (pin = 7) {
- PWMval2 = vall;
- Serial.print("Motor 2 enA PWM set");
- }
- if (pin = 11) {
- PWMval3 = vall;
- Serial.print("Motor 3 enA PWM set");
- }
-}
-
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-
-void IRtrigger1() {
- IRcount1++;
-}
-void IRtrigger2() {
- IRcount2++;
-}
-void IRtrigger3() {
- IRcount3++;
-}
-void IRtrigger4() {
- IRcount4++;
-}
-void IRtrigger5() {
- IRcount5++;
-}
-void IRtrigger6() {
- IRcount6++;
-}
-void IRtrigger7() {
- IRcount7++;
-}
-void IRtrigger8() {
- IRcount8++;
-}
-void IRtrigger9() {
- IRcount9++;
-}
-void IRtrigger10() {
- IRcount10++;
-}
-void IRtrigger11() {
- IRcount11++;
-}
-void IRtrigger12() {
- IRcount12++;
-}
-void IRtrigger13() {
- IRcount13++;
-}
-void IRtrigger14() {
- IRcount14++;
-}
-void IRtrigger15() {
- IRcount15++;
-}
-void IRtrigger16() {
- IRcount16++;
-}
-void IRtriggerBALL() {
- IRcountBALL++;
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-void Aresetenc() {
- ACtime = micros();
- ALtime = ACtime;
- Aencount = 0;
-}
-void Bresetenc() {
- BCtime = micros();
- BLtime = BCtime;
- Bencount = 0;
-}
-void Cresetenc() {
- CCtime = micros();
- CLtime = CCtime;
- Cencount = 0;
-}
-
-void Amove(double Rsped) {
- double sped = nearest(Rsped, Amotordata, ArrayElementCount(Amotordata));
- spdA = abs(sped) * 0.1;
- mcpsoftpwm(m1enA, spdA);
- mcp2.digitalWrite(m1enB, LOW);
- if (sped < 0) {
- Serial.print("Motor A back ");
- mcp2.digitalWrite(m1pwm1, LOW);
- mcp2.digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("Motor A forward ");
- mcp2.digitalWrite(m1pwm1, HIGH);
- mcp2.digitalWrite(m1pwm2, LOW);
- }
- Serial.println(spdA);
-}
-void Bmove(double Rsped) {
- double sped = nearest(Rsped, Bmotordata, ArrayElementCount(Bmotordata));
- spdB = abs(sped) * 0.1;
- mcpsoftpwm(m2enA, spdB);
- mcp2.digitalWrite(m2enB, LOW);
- if (sped < 0) {
- Serial.print("Motor B back ");
- mcp2.digitalWrite(m2pwm1, LOW);
- mcp2.digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("Motor B forward ");
- mcp2.digitalWrite(m2pwm1, HIGH);
- mcp2.digitalWrite(m2pwm2, LOW);
- }
- Serial.println(spdB);
-}
-void Cmove(double Rsped) {
- double sped = nearest(Rsped, Cmotordata, ArrayElementCount(Cmotordata));
- spdC = abs(sped) * 0.1;
- mcpsoftpwm(m3enA, spdC);
- mcp2.digitalWrite(m3enB, LOW);
- if (sped < 0) {
- Serial.print("Motor C back ");
- mcp2.digitalWrite(m3pwm1, LOW);
- mcp2.digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("Motor C forward ");
- mcp2.digitalWrite(m3pwm1, HIGH);
- mcp2.digitalWrite(m3pwm2, LOW);
- }
- Serial.println(spdC);
-}
-
-void moveohmi(int speed, int direction) {
- Amove(0);
- Bmove(0);
- Cmove(0);
-
- double dirrad = (direction * 71.0000) / 4068.0000;
- Serial.println(dirrad);
- //vector ontbinden in x en y
- double y = sin(dirrad);
- double x = cos(dirrad);
- Serial.println((String) "x:" + x + " y:" + y);
- double spdeA = y * speed; //speed motor A = Y vector
- double spdeB = (-0.500 * x - 0.8660054 * y) * speed; //speed motor B = -1/2 X - sqrt(3)/2 Y
- double spdeC = (-0.500 * x + 0.8660054 * y) * speed; //speed motor C = -1/2 X + sqrt(3)/2 Y
- Amove(spdeA);
- Bmove(spdeB);
- Cmove(spdeC);
- Serial.println();
- Serial.println();
-}
-void rotate(int speed) {
- Amove(speed);
- Bmove(speed);
- Cmove(speed);
-}
-void compasrotate(int speed, int direction, int accuracy, int curheading) {
- //inacurate compas data
- //0deg is start heading offset(deg)
- int headmin = direction - accuracy;
- if (headmin < 0) {
- headmin = 360 - headmin;
- }
- int headmax = direction + accuracy;
- if (headmax > 360) {
- headmax = headmax - 360;
- }
- if (!(curheading >= headmin) && !(curheading <= headmax)) {
- if ((direction - curheading) > 180) {
- Amove(-speed);
- Bmove(-speed);
- Cmove(-speed);
- } else {
- Amove(speed);
- Bmove(speed);
- Cmove(speed);
- }
- }
-}
-
-void loop() {
- /*
- 1. it proceses/collects the sensor data
- 2. It prints the data for debugging
- 3. It do stuff with the data
- */
- /*
- 1. collect data
- 2. do stuff with data --> 3
- 3. check if we are on any white lines:
- Yes: go oppiside direction for 250ms --> 1
- No: --> 4
- 4. do we have the ball
- Yes: go towards goal --> 1
- No: --> 5
- 5. Go towards the ball --> 1
- */
- Wire.begin();
- //IR sensors data collection done in background, finding highest value and see if we have ball in posesion
- volatile long IRcounts[] = { IRcount1, IRcount2, IRcount3, IRcount4, IRcount5, IRcount6, IRcount7, IRcount8, IRcount9, IRcount10, IRcount11, IRcount12, IRcount13, IRcount14, IRcount15, IRcount16 };
- long maxCount = IRcounts[0];
- int highessensor = 1;
- for (int i = 0; i < 15; ++i) {
- if (IRcounts[i] > maxCount) {
- maxCount = IRcounts[i];
- highessensor = i + 1;
- ballpos = (360 - (22.5 * i));
- }
- }
- if (IRcountBALL > minpulsbal) {
- ballinpos = 1;
- } else {
- ballinpos = 0;
- }
- //Read color sensors
- for (uint8_t t = 0; t < 6; t++) {
- pcaselect(t);
- for (uint8_t addr = 0; addr <= 127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- if (tcs.begin()) {
- uint16_t r, g, b, c, colorTemp, lux;
- tcs.getRawData(&r, &g, &b, &c);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
- if ((colorTemp) == 5201) {
- colsensdata[t] = 0;
- } else if ((g) >= (2 * (r)) && (g) >= 12) {
- colsensdata[t] = 1;
- } else if ((colorTemp) >= 6750) {
- colsensdata[t] = 2;
- } else if ((colorTemp) < 6750) {
- colsensdata[t] = 3;
- } else {
- Serial.println(colorTemp);
- colsensdata[t] = 98;
- }
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- colsensdata[t] = 97;
- }
- }
- }
- }
- //read camera
- if (Serial1.available()) {
- datatime = millis();
-
- byte byteRead = Serial1.read();
-
- if (byteRead == 's') {
- tlocd = "";
- readloc = true;
- } else if (byteRead == 'e') {
- readloc = false;
- locd = tlocd;
- } else if (readloc == true) {
- tlocd += (char)byteRead;
- }
- } else {
- if (millis() - datatime > 5000) {
- locd = "999";
- }
- }
- int gloc = locd.toInt();
- //read and calculate compas
- mag.read();
- imu.read();
- float heading = computeHeading();
- int offset = heading - front;
- if (offset < 0) {
- offset = (offset + 360);
- }
- //read dip settings
- dip1val = digitalRead(dip1);
- dip2val = digitalRead(dip2);
- dip3val = digitalRead(dip3);
- dip4val = digitalRead(dip4);
- //printing sensor data
- //IR
- Serial.println("IR data: ");
- Serial.print("ir 1 changes: ");
- Serial.print(IRcount1);
- Serial.print(", ir 2 changes: ");
- Serial.print(IRcount2);
- Serial.print(", ir 3 changes: ");
- Serial.print(IRcount3);
- Serial.print(", ir 4 changes: ");
- Serial.print(IRcount4);
- Serial.print(", ir 5 changes: ");
- Serial.print(IRcount5);
- Serial.print(", ir 6 changes: ");
- Serial.print(IRcount6);
- Serial.print(", ir 7 changes: ");
- Serial.print(IRcount7);
- Serial.print(", ir 8 changes: ");
- Serial.print(IRcount8);
- Serial.print(", ir 9 changes: ");
- Serial.print(IRcount9);
- Serial.print(", ir 10 changes: ");
- Serial.print(IRcount10);
- Serial.print(", ir 11 changes: ");
- Serial.print(IRcount11);
- Serial.print(", ir 12 changes: ");
- Serial.print(IRcount12);
- Serial.print(", ir 13 changes: ");
- Serial.print(IRcount13);
- Serial.print(", ir 14 changes: ");
- Serial.print(IRcount14);
- Serial.print(", ir 15 changes: ");
- Serial.print(IRcount15);
- Serial.print(", ir 16 changes: ");
- Serial.println(IRcount16);
- Serial.print(", ball in posesion ir changes: ");
- Serial.println(IRcountBALL);
- Serial.print("Ball is at sensor: ");
- Serial.print(highessensor);
- Serial.print(", with value of ");
- Serial.print(maxCount);
- Serial.print(", withs it also at");
- Serial.print(ballpos);
- Serial.print(" degrees");
- if (ballinpos == 1) {
- Serial.print("Ball is in our posesion with: ");
- Serial.print(IRcountBALL);
- Serial.println(" pulses.");
- } else {
- Serial.println("ball is not in our posesion");
- }
- //color
- Serial.print("sensor data = "); // 0=air, 1=green, 2=black, 3=white, 90=error
- for (int i = 0; i < 6; i++) {
- Serial.print(colsensdata[i]);
- Serial.print(", ");
- }
- Serial.println();
- //camera
- Serial.print("location of the goal is: ");
- if (gloc == 999) {
- Serial.println("unknown, there is no working connection with the camera");
- } else {
- Serial.println(gloc);
- }
- //compas
- Serial.print("heading: ");
- Serial.print(heading);
- Serial.print(", goal location: ");
- Serial.print(front);
- Serial.print(", offset: ");
- //dip
- if ((dip1val = 0) && (dip1val = 1)) {
- settingval = 1;
- } else if ((dip1val = 1) && (dip1val = 1)) {
- settingval = 2;
- } else if ((dip1val = 0) && (dip1val = 0)) {
- settingval = 3;
- } else if ((dip1val = 1) && (dip1val = 0)) {
- settingval = 4;
- }
-
-
- /*
- dip 1-4 settings:
- dip 1 = rotation 1=enables 0 = disables
- dip 2 = buzzer err/debug (buzz only if err = 1 -debug buzz = 0)
- dip 3 = on/off 1=on 0 = off
- dip 4 = camera 1=enables 0 = disables
- settings:
- 1. rotation OFF
- camera ON
- 2. rotation ON
- camera ON
- 3. rotation OFF
- camera OFF
- 4. rotation ON
- camera OFF
- /*dip3val
-
-
-
-
- /*
- data we have:
- rotation since start: offset(deg)
- if we have an ball in posesion ballinpos = 1, else ballinpos = 0
- location of the ball on the field: ballpos(deg)
- colorsensordata list: colsensdata[6]. 0=air, 1=green, 2=black, 3=white, 90=error
- goal location: gloc(deg)
- */
- //select with version of the code using dip switches
-
- //do stuf with data version 1: rotation disables and camera enabled
- if (dip3val = 1) {
- if (settingval = 1) {
- //check if we arent on any white lines
- for (int i = 0; i < 6; i++) {
- if (colsensdata[i] = 3) {
- Serial.println((String) "detected white collor on sensor:" + i + "going back " + (360 - (i * 60)) + "degrees");
- moveohmi(sp, (i * 60));
- delay(250);
- return; //restart loop
- }
- }
- //if we have the bal go towards the goal
- if (ballinpos = 1) {
- moveohmi(sp, 0);
- } else { //go towards ball
- moveohmi(sp, ballpos);
- }
- }
-
- //do stuf with data version 2: rotation enabled and camera enabled N
- if (settingval = 2) {
- //check if we arent on any white lines
- for (int i = 0; i < 6; i++) {
- if (colsensdata[i] = 3) {
- Serial.println((String) "detected white collor on sensor:" + i + "going back " + (360 - (i * 60)) + "degrees");
- moveohmi(sp, (i * 60));
- delay(250);
- return; //restart loop
- }
- if (ballinpos = 1) {
- moveohmi(sp, gloc);
- } else { //go towards ball
- moveohmi(sp, ballpos);
- }
- }
- }
-
- //do stuf with data version 3: rotation disabled and camera disabled (use compas to detect goal)
- if (settingval = 3) {
- //check if we arent on any white lines
- for (int i = 0; i < 6; i++) {
- if (colsensdata[i] = 3) {
- Serial.println((String) "detected white collor on sensor:" + i + "going back " + (360 - (i * 60)) + "degrees");
- moveohmi(sp, (i * 60));
- delay(250);
- return; //restart loop
- }
- }
- }
-
- //do stuf with data version 4: rotation enabled and camera disabled (use compas to detect goal)
- if (settingval = 4) {
- //check if we arent on any white lines
- for (int i = 0; i < 6; i++) {
- if (colsensdata[i] = 3) {
- Serial.println((String) "detected white collor on sensor:" + i + "going back " + (360 - (i * 60)) + "degrees");
- moveohmi(sp, (i * 60));
- delay(250);
- return; //restart loop
- }
- }
- }
- } else {
- Serial.println("skipping loop robot is off");
- }
-
- if (errorbuz = 1) {
- tone(buz, 2000);
- }
-
-
- Serial.println();
- Serial.println();
- Serial.println();
-}
-
-
-template<typename T> float computeHeading(LIS3MDL::vector<T> from) {
- //from https://github.com/pololu/lis3mdl-arduino/tree/master/examples/HeadingWithLSM6
- LIS3MDL::vector<int32_t> temp_m = { mag.m.x, mag.m.y, mag.m.z };
-
- // copy acceleration readings from LSM6::vector into an LIS3MDL::vector
- LIS3MDL::vector<int16_t> a = { imu.a.x, imu.a.y, imu.a.z };
-
- // subtract offset (average of min and max) from magnetometer readings
- temp_m.x -= ((int32_t)m_min.x + m_max.x) / 2;
- temp_m.y -= ((int32_t)m_min.y + m_max.y) / 2;
- temp_m.z -= ((int32_t)m_min.z + m_max.z) / 2;
-
- // compute E and N
- LIS3MDL::vector<float> E;
- LIS3MDL::vector<float> N;
- LIS3MDL::vector_cross(&temp_m, &a, &E);
- LIS3MDL::vector_normalize(&E);
- LIS3MDL::vector_cross(&a, &E, &N);
- LIS3MDL::vector_normalize(&N);
-
- // compute heading
- float heading = atan2(LIS3MDL::vector_dot(&E, &from), LIS3MDL::vector_dot(&N, &from)) * 180 / PI;
- if (heading < 0) heading += 360;
- return heading;
-}
-
-/*
-Returns the angular difference in the horizontal plane between a
-default vector (the +X axis) and north, in degrees.
-*/
-float computeHeading() {
- //from https://github.com/pololu/lis3mdl-arduino/tree/master/examples/HeadingWithLSM6
- return computeHeading((LIS3MDL::vector<int>){ 1, 0, 0 });
-}
-int nearest(int x, int myArray[], int elements) {
- //https://forum.arduino.cc/t/search-for-nearest-number-in-an-array-help/245843/5
- int idx = 0; // by default near first element
-
- int distance = abs(myArray[idx] - x);
- for (int i = 1; i < elements; i++) {
- int d = abs(myArray[i] - x);
- if (d < distance) {
- idx = i;
- distance = d;
- }
- }
- return idx;
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/Calibrate/Calibrate.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/Calibrate/Calibrate.ino
deleted file mode 100644
index c5db31c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/Calibrate/Calibrate.ino
+++ /dev/null
@@ -1,42 +0,0 @@
-//example from https://github.com/pololu/lis3mdl-arduino
-#include <Wire.h>
-#include <LIS3MDL.h>
-
-LIS3MDL mag;
-LIS3MDL::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768};
-
-char report[80];
-
-void setup()
-{
- Serial.begin(9600);
- Wire.begin();
-
- if (!mag.init())
- {
- Serial.println("Failed to detect and initialize magnetometer!");
- while (1);
- }
-
- mag.enableDefault();
-}
-
-void loop()
-{
- mag.read();
-
- running_min.x = min(running_min.x, mag.m.x);
- running_min.y = min(running_min.y, mag.m.y);
- running_min.z = min(running_min.z, mag.m.z);
-
- running_max.x = max(running_max.x, mag.m.x);
- running_max.y = max(running_max.y, mag.m.y);
- running_max.z = max(running_max.z, mag.m.z);
-
- snprintf(report, sizeof(report), "min: {%+6d, %+6d, %+6d} max: {%+6d, %+6d, %+6d}",
- running_min.x, running_min.y, running_min.z,
- running_max.x, running_max.y, running_max.z);
- Serial.println(report);
-
- delay(100);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino
deleted file mode 100644
index ac60515..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/HeadingWithLSM6/HeadingWithLSM6.ino
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-This sketch combines magnetometer readings from an LIS3MDL and accelerometer
-readings from an LSM6 to calculate a tilt-compensated magnetic heading. It
-requires Pololu's LSM6 Arduino library to be installed:
-
-https://github.com/pololu/lsm6-arduino
-
-This program can be used with a board that includes both sensors, like the
-Pololu MinIMU-9 v5 and AltIMU-10 v5, or with separate carrier boards for the two
-sensors, both connected to the same I2C bus. If you are using separate boards,
-make sure the axes are oriented the same way on both (i.e. the X, Y, and Z axes
-of both boards should point in the same direction, and the surfaces of the
-boards should be as close to parallel as possible).
-*/
-
-#include <Wire.h>
-#include <LIS3MDL.h>
-#include <LSM6.h>
-
-LIS3MDL mag;
-LSM6 imu;
-
-/*
-Calibration values; the default values of +/-32767 for each axis
-lead to an assumed magnetometer bias of 0. Use the Calibrate example
-program to determine appropriate values for your particular unit.
-*/
-LIS3MDL::vector<int16_t> m_min = {+5862, +2474, -6186};
-LIS3MDL::vector<int16_t> m_max = {+6610, +2849, -5547};
-
-void setup()
-{
- Serial.begin(9600);
- Wire.begin();
-
- if (!mag.init())
- {
- Serial.println("Failed to detect and initialize LIS3MDL magnetometer!");
- while (1);
- }
- mag.enableDefault();
-
- if (!imu.init())
- {
- Serial.println("Failed to detect and initialize LSM6 IMU!");
- while (1);
- }
- imu.enableDefault();
-}
-
-void loop()
-{
- mag.read();
- imu.read();
-
- /*
- When given no arguments, the heading() function returns the angular
- difference in the horizontal plane between a default vector (the
- +X axis) and north, in degrees.
- */
- float heading = computeHeading();
-
- /*
- To use a different vector as a reference, use the version of
- computeHeading() that takes a vector argument; for example, call it like this
- to use the -Z axis as a reference:
- */
- //float heading = computeHeading((LIS3MDL::vector<int>){0, 0, -1});
-
- Serial.println(heading);
- delay(100);
-}
-
-/*
-Returns the angular difference in the horizontal plane between the
-"from" vector and north, in degrees.
-
-Description of heading algorithm:
-Shift and scale the magnetic reading based on calibration data to find
-the North vector. Use the acceleration readings to determine the Up
-vector (gravity is measured as an upward acceleration). The cross
-product of North and Up vectors is East. The vectors East and North
-form a basis for the horizontal plane. The From vector is projected
-into the horizontal plane and the angle between the projected vector
-and horizontal north is returned.
-*/
-template <typename T> float computeHeading(LIS3MDL::vector<T> from)
-{
- LIS3MDL::vector<int32_t> temp_m = {mag.m.x, mag.m.y, mag.m.z};
-
- // copy acceleration readings from LSM6::vector into an LIS3MDL::vector
- LIS3MDL::vector<int16_t> a = {imu.a.x, imu.a.y, imu.a.z};
-
- // subtract offset (average of min and max) from magnetometer readings
- temp_m.x -= ((int32_t)m_min.x + m_max.x) / 2;
- temp_m.y -= ((int32_t)m_min.y + m_max.y) / 2;
- temp_m.z -= ((int32_t)m_min.z + m_max.z) / 2;
-
- // compute E and N
- LIS3MDL::vector<float> E;
- LIS3MDL::vector<float> N;
- LIS3MDL::vector_cross(&temp_m, &a, &E);
- LIS3MDL::vector_normalize(&E);
- LIS3MDL::vector_cross(&a, &E, &N);
- LIS3MDL::vector_normalize(&N);
-
- // compute heading
- float heading = atan2(LIS3MDL::vector_dot(&E, &from), LIS3MDL::vector_dot(&N, &from)) * 180 / PI;
- if (heading < 0) heading += 360;
- return heading;
-}
-
-/*
-Returns the angular difference in the horizontal plane between a
-default vector (the +X axis) and north, in degrees.
-*/
-float computeHeading()
-{
- return computeHeading((LIS3MDL::vector<int>){1, 0, 0});
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/IMU_comp.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/IMU_comp.ino
deleted file mode 100644
index c4578cb..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/IMU_comp.ino
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-This sketch combines magnetometer readings from an LIS3MDL and accelerometer
-readings from an LSM6 to calculate a tilt-compensated magnetic heading. It
-requires Pololu's LSM6 Arduino library to be installed:
-
-https://github.com/pololu/lsm6-arduino
-
-This program can be used with a board that includes both sensors, like the
-Pololu MinIMU-9 v5 and AltIMU-10 v5, or with separate carrier boards for the two
-sensors, both connected to the same I2C bus. If you are using separate boards,
-make sure the axes are oriented the same way on both (i.e. the X, Y, and Z axes
-of both boards should point in the same direction, and the surfaces of the
-boards should be as close to parallel as possible).
-*/
-
-#include <Wire.h>
-#include <LIS3MDL.h>
-#include <LSM6.h>
-
-LIS3MDL mag;
-LSM6 imu;
-int front = 0;
-
-/*
-Calibration values; the default values of +/-32767 for each axis
-lead to an assumed magnetometer bias of 0. Use the Calibrate example
-program to determine appropriate values for your particular unit.
-*/
-LIS3MDL::vector<int16_t> m_min = {+942, +3436, -3323};
-LIS3MDL::vector<int16_t> m_max = {+1053, +3559, -3142};
-
-void setup()
-{
- Serial.begin(9600);
- Wire.begin();
-
- if (!mag.init())
- {
- Serial.println("Failed to detect and initialize LIS3MDL magnetometer!");
- while (1);
- }
- mag.enableDefault();
-
- if (!imu.init())
- {
- Serial.println("Failed to detect and initialize LSM6 IMU!");
- while (1);
- }
- imu.enableDefault();
-
- //get start heading
- mag.read();
- imu.read();
- float heading = computeHeading();
- front = heading;
- Serial.println(heading);
-
-}
-
-void loop()
-{
- mag.read();
- imu.read();
-
-
- float heading = computeHeading();
- int offset = front - heading;
- if(offset<0){
- offset=360+offset;
- }
-
- Serial.print("heading: ");
- Serial.print(heading);
- Serial.print(", goal location: ");
- Serial.print(front);
- Serial.print(", offset: ");
-
- Serial.println(offset);
-
- delay(100);
-}
-
-template <typename T> float computeHeading(LIS3MDL::vector<T> from)
-{
- LIS3MDL::vector<int32_t> temp_m = {mag.m.x, mag.m.y, mag.m.z};
-
- // copy acceleration readings from LSM6::vector into an LIS3MDL::vector
- LIS3MDL::vector<int16_t> a = {imu.a.x, imu.a.y, imu.a.z};
-
- // subtract offset (average of min and max) from magnetometer readings
- temp_m.x -= ((int32_t)m_min.x + m_max.x) / 2;
- temp_m.y -= ((int32_t)m_min.y + m_max.y) / 2;
- temp_m.z -= ((int32_t)m_min.z + m_max.z) / 2;
-
- // compute E and N
- LIS3MDL::vector<float> E;
- LIS3MDL::vector<float> N;
- LIS3MDL::vector_cross(&temp_m, &a, &E);
- LIS3MDL::vector_normalize(&E);
- LIS3MDL::vector_cross(&a, &E, &N);
- LIS3MDL::vector_normalize(&N);
-
- // compute heading
- float heading = atan2(LIS3MDL::vector_dot(&E, &from), LIS3MDL::vector_dot(&N, &from)) * 180 / PI;
- if (heading < 0) heading += 360;
- return heading;
-}
-
-/*
-Returns the angular difference in the horizontal plane between a
-default vector (the +X axis) and north, in degrees.
-*/
-float computeHeading()
-{
- return computeHeading((LIS3MDL::vector<int>){1, 0, 0});
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/calcoffset/calcoffset.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/calcoffset/calcoffset.ino
deleted file mode 100644
index fc5f752..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/calcoffset/calcoffset.ino
+++ /dev/null
@@ -1,27 +0,0 @@
-void setup() {
- randomSeed(analogRead(0));
- Serial.begin(9600);
-
-}
-
-void loop() {
- int front = random(0, 360);
- int heading = random(0, 360);
- Serial.print("Front: ");
- Serial.println(front);
- Serial.print("heading: ");
- Serial.println(heading);
-
- int offset = heading - front;
- if(offset<0){
- offset=(offset+360);
- }
- Serial.print("offset: ");
- Serial.println(offset);
-
- Serial.println();
- Serial.println();
-
- delay(5000);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore
deleted file mode 100644
index 1089bae..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-Serial*.txt \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING
deleted file mode 100644
index 94a9ed0..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER
deleted file mode 100644
index 65c5ca8..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py
deleted file mode 100644
index 993c8e8..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU-9-test.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# MinIMU9ArduinoAHRS
-# Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-# Copyright (c) 2011 Pololu Corporation.
-# http://www.pololu.com/
-
-# MinIMU9ArduinoAHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-# http://code.google.com/p/sf9domahrs/
-
-# sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-# Julio and Doug Weibel:
-# http://code.google.com/p/ardu-imu/
-
-# MinIMU9ArduinoAHRS is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-
-# MinIMU9ArduinoAHRS is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-# more details.
-
-# You should have received a copy of the GNU Lesser General Public License along
-# with MinIMU9ArduinoAHRS. If not, see <http://www.gnu.org/licenses/>.
-
-################################################################################
-
-# This is a test/3D visualization program for the Pololu MinIMU-9 + Arduino
-# AHRS, based on "Test for Razor 9DOF IMU" by Jose Julio, copyright 2009.
-
-# This script needs VPython, pyserial and pywin modules
-
-# First Install Python 2.6.4 (Python 2.7 also works)
-# Install pywin from http://sourceforge.net/projects/pywin32/
-# Install pyserial from http://sourceforge.net/projects/pyserial/files/
-# Install VPython from http://vpython.org/contents/download_windows.html
-
-from visual import *
-import serial
-import string
-import math
-
-from time import time
-
-grad2rad = 3.141592/180.0
-
-# Check your COM port and baud rate
-ser = serial.Serial(port='COM9',baudrate=115200, timeout=1)
-
-# Main scene
-scene=display(title="Pololu MinIMU-9 + Arduino AHRS")
-scene.range=(1.2,1.2,1.2)
-#scene.forward = (0,-1,-0.25)
-scene.forward = (1,0,-0.25)
-scene.up=(0,0,1)
-
-# Second scene (Roll, Pitch, Yaw)
-scene2 = display(title='Pololu MinIMU-9 + Arduino AHRS',x=0, y=0, width=500, height=200,center=(0,0,0), background=(0,0,0))
-scene2.range=(1,1,1)
-scene.width=500
-scene.y=200
-
-scene2.select()
-#Roll, Pitch, Yaw
-cil_roll = cylinder(pos=(-0.4,0,0),axis=(0.2,0,0),radius=0.01,color=color.red)
-cil_roll2 = cylinder(pos=(-0.4,0,0),axis=(-0.2,0,0),radius=0.01,color=color.red)
-cil_pitch = cylinder(pos=(0.1,0,0),axis=(0.2,0,0),radius=0.01,color=color.green)
-cil_pitch2 = cylinder(pos=(0.1,0,0),axis=(-0.2,0,0),radius=0.01,color=color.green)
-#cil_course = cylinder(pos=(0.6,0,0),axis=(0.2,0,0),radius=0.01,color=color.blue)
-#cil_course2 = cylinder(pos=(0.6,0,0),axis=(-0.2,0,0),radius=0.01,color=color.blue)
-arrow_course = arrow(pos=(0.6,0,0),color=color.cyan,axis=(-0.2,0,0), shaftwidth=0.02, fixedwidth=1)
-
-#Roll,Pitch,Yaw labels
-label(pos=(-0.4,0.3,0),text="Roll",box=0,opacity=0)
-label(pos=(0.1,0.3,0),text="Pitch",box=0,opacity=0)
-label(pos=(0.55,0.3,0),text="Yaw",box=0,opacity=0)
-label(pos=(0.6,0.22,0),text="N",box=0,opacity=0,color=color.yellow)
-label(pos=(0.6,-0.22,0),text="S",box=0,opacity=0,color=color.yellow)
-label(pos=(0.38,0,0),text="W",box=0,opacity=0,color=color.yellow)
-label(pos=(0.82,0,0),text="E",box=0,opacity=0,color=color.yellow)
-label(pos=(0.75,0.15,0),height=7,text="NE",box=0,color=color.yellow)
-label(pos=(0.45,0.15,0),height=7,text="NW",box=0,color=color.yellow)
-label(pos=(0.75,-0.15,0),height=7,text="SE",box=0,color=color.yellow)
-label(pos=(0.45,-0.15,0),height=7,text="SW",box=0,color=color.yellow)
-
-L1 = label(pos=(-0.4,0.22,0),text="-",box=0,opacity=0)
-L2 = label(pos=(0.1,0.22,0),text="-",box=0,opacity=0)
-L3 = label(pos=(0.7,0.3,0),text="-",box=0,opacity=0)
-
-# Main scene objects
-scene.select()
-# Reference axis (x,y,z)
-arrow(color=color.green,axis=(1,0,0), shaftwidth=0.02, fixedwidth=1)
-arrow(color=color.green,axis=(0,-1,0), shaftwidth=0.02 , fixedwidth=1)
-arrow(color=color.green,axis=(0,0,-1), shaftwidth=0.02, fixedwidth=1)
-# labels
-label(pos=(0,0,0.8),text="Pololu MinIMU-9 + Arduino AHRS",box=0,opacity=0)
-label(pos=(1,0,0),text="X",box=0,opacity=0)
-label(pos=(0,-1,0),text="Y",box=0,opacity=0)
-label(pos=(0,0,-1),text="Z",box=0,opacity=0)
-# IMU object
-platform = box(length=1, height=0.05, width=1, color=color.blue)
-p_line = box(length=1,height=0.08,width=0.1,color=color.yellow)
-plat_arrow = arrow(color=color.green,axis=(1,0,0), shaftwidth=0.06, fixedwidth=1)
-
-
-f = open("Serial"+str(time())+".txt", 'w')
-
-roll=0
-pitch=0
-yaw=0
-while 1:
- line = ser.readline()
- if line.find("!ANG:") != -1: # filter out incomplete (invalid) lines
- line = line.replace("!ANG:","") # Delete "!ANG:"
- print line
- f.write(line) # Write to the output log file
- words = string.split(line,",") # Fields split
- if len(words) > 2:
- try:
- roll = float(words[0])*grad2rad
- pitch = float(words[1])*grad2rad
- yaw = float(words[2])*grad2rad
- except:
- print "Invalid line"
-
- axis=(cos(pitch)*cos(yaw),-cos(pitch)*sin(yaw),sin(pitch))
- up=(sin(roll)*sin(yaw)+cos(roll)*sin(pitch)*cos(yaw),sin(roll)*cos(yaw)-cos(roll)*sin(pitch)*sin(yaw),-cos(roll)*cos(pitch))
- platform.axis=axis
- platform.up=up
- platform.length=1.0
- platform.width=0.65
- plat_arrow.axis=axis
- plat_arrow.up=up
- plat_arrow.length=0.8
- p_line.axis=axis
- p_line.up=up
- cil_roll.axis=(0.2*cos(roll),0.2*sin(roll),0)
- cil_roll2.axis=(-0.2*cos(roll),-0.2*sin(roll),0)
- cil_pitch.axis=(0.2*cos(pitch),0.2*sin(pitch),0)
- cil_pitch2.axis=(-0.2*cos(pitch),-0.2*sin(pitch),0)
- arrow_course.axis=(0.2*sin(yaw),0.2*cos(yaw),0)
- L1.text = str(float(words[0]))
- L2.text = str(float(words[1]))
- L3.text = str(float(words[2]))
-ser.close
-f.close
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino
deleted file mode 100644
index 767227b..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Compass.ino
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-void Compass_Heading()
-{
- float MAG_X;
- float MAG_Y;
- float cos_roll;
- float sin_roll;
- float cos_pitch;
- float sin_pitch;
-
- cos_roll = cos(roll);
- sin_roll = sin(roll);
- cos_pitch = cos(pitch);
- sin_pitch = sin(pitch);
-
- // adjust for LSM303 compass axis offsets/sensitivity differences by scaling to +/-0.5 range
- c_magnetom_x = (float)(magnetom_x - SENSOR_SIGN[6]*M_X_MIN) / (M_X_MAX - M_X_MIN) - SENSOR_SIGN[6]*0.5;
- c_magnetom_y = (float)(magnetom_y - SENSOR_SIGN[7]*M_Y_MIN) / (M_Y_MAX - M_Y_MIN) - SENSOR_SIGN[7]*0.5;
- c_magnetom_z = (float)(magnetom_z - SENSOR_SIGN[8]*M_Z_MIN) / (M_Z_MAX - M_Z_MIN) - SENSOR_SIGN[8]*0.5;
-
- // Tilt compensated Magnetic filed X:
- MAG_X = c_magnetom_x*cos_pitch+c_magnetom_y*sin_roll*sin_pitch+c_magnetom_z*cos_roll*sin_pitch;
- // Tilt compensated Magnetic filed Y:
- MAG_Y = c_magnetom_y*cos_roll-c_magnetom_z*sin_roll;
- // Magnetic Heading
- MAG_Heading = atan2(-MAG_Y,MAG_X);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino
deleted file mode 100644
index 7f9f276..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/DCM.ino
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/**************************************************/
-void Normalize(void)
-{
- float error=0;
- float temporary[3][3];
- float renorm=0;
-
- error= -Vector_Dot_Product(&DCM_Matrix[0][0],&DCM_Matrix[1][0])*.5; //eq.19
-
- Vector_Scale(&temporary[0][0], &DCM_Matrix[1][0], error); //eq.19
- Vector_Scale(&temporary[1][0], &DCM_Matrix[0][0], error); //eq.19
-
- Vector_Add(&temporary[0][0], &temporary[0][0], &DCM_Matrix[0][0]);//eq.19
- Vector_Add(&temporary[1][0], &temporary[1][0], &DCM_Matrix[1][0]);//eq.19
-
- Vector_Cross_Product(&temporary[2][0],&temporary[0][0],&temporary[1][0]); // c= a x b //eq.20
-
- renorm= .5 *(3 - Vector_Dot_Product(&temporary[0][0],&temporary[0][0])); //eq.21
- Vector_Scale(&DCM_Matrix[0][0], &temporary[0][0], renorm);
-
- renorm= .5 *(3 - Vector_Dot_Product(&temporary[1][0],&temporary[1][0])); //eq.21
- Vector_Scale(&DCM_Matrix[1][0], &temporary[1][0], renorm);
-
- renorm= .5 *(3 - Vector_Dot_Product(&temporary[2][0],&temporary[2][0])); //eq.21
- Vector_Scale(&DCM_Matrix[2][0], &temporary[2][0], renorm);
-}
-
-/**************************************************/
-void Drift_correction(void)
-{
- float mag_heading_x;
- float mag_heading_y;
- float errorCourse;
- //Compensation the Roll, Pitch and Yaw drift.
- static float Scaled_Omega_P[3];
- static float Scaled_Omega_I[3];
- float Accel_magnitude;
- float Accel_weight;
-
-
- //*****Roll and Pitch***************
-
- // Calculate the magnitude of the accelerometer vector
- Accel_magnitude = sqrt(Accel_Vector[0]*Accel_Vector[0] + Accel_Vector[1]*Accel_Vector[1] + Accel_Vector[2]*Accel_Vector[2]);
- Accel_magnitude = Accel_magnitude / GRAVITY; // Scale to gravity.
- // Dynamic weighting of accelerometer info (reliability filter)
- // Weight for accelerometer info (<0.5G = 0.0, 1G = 1.0 , >1.5G = 0.0)
- Accel_weight = constrain(1 - 2*abs(1 - Accel_magnitude),0,1); //
-
- Vector_Cross_Product(&errorRollPitch[0],&Accel_Vector[0],&DCM_Matrix[2][0]); //adjust the ground of reference
- Vector_Scale(&Omega_P[0],&errorRollPitch[0],Kp_ROLLPITCH*Accel_weight);
-
- Vector_Scale(&Scaled_Omega_I[0],&errorRollPitch[0],Ki_ROLLPITCH*Accel_weight);
- Vector_Add(Omega_I,Omega_I,Scaled_Omega_I);
-
- //*****YAW***************
- // We make the gyro YAW drift correction based on compass magnetic heading
-
- mag_heading_x = cos(MAG_Heading);
- mag_heading_y = sin(MAG_Heading);
- errorCourse=(DCM_Matrix[0][0]*mag_heading_y) - (DCM_Matrix[1][0]*mag_heading_x); //Calculating YAW error
- Vector_Scale(errorYaw,&DCM_Matrix[2][0],errorCourse); //Applys the yaw correction to the XYZ rotation of the aircraft, depeding the position.
-
- Vector_Scale(&Scaled_Omega_P[0],&errorYaw[0],Kp_YAW);//.01proportional of YAW.
- Vector_Add(Omega_P,Omega_P,Scaled_Omega_P);//Adding Proportional.
-
- Vector_Scale(&Scaled_Omega_I[0],&errorYaw[0],Ki_YAW);//.00001Integrator
- Vector_Add(Omega_I,Omega_I,Scaled_Omega_I);//adding integrator to the Omega_I
-}
-/**************************************************/
-/*
-void Accel_adjust(void)
-{
- Accel_Vector[1] += Accel_Scale(speed_3d*Omega[2]); // Centrifugal force on Acc_y = GPS_speed*GyroZ
- Accel_Vector[2] -= Accel_Scale(speed_3d*Omega[1]); // Centrifugal force on Acc_z = GPS_speed*GyroY
-}
-*/
-/**************************************************/
-
-void Matrix_update(void)
-{
- Gyro_Vector[0]=Gyro_Scaled_X(gyro_x); //gyro x roll
- Gyro_Vector[1]=Gyro_Scaled_Y(gyro_y); //gyro y pitch
- Gyro_Vector[2]=Gyro_Scaled_Z(gyro_z); //gyro Z yaw
-
- Accel_Vector[0]=accel_x;
- Accel_Vector[1]=accel_y;
- Accel_Vector[2]=accel_z;
-
- Vector_Add(&Omega[0], &Gyro_Vector[0], &Omega_I[0]); //adding proportional term
- Vector_Add(&Omega_Vector[0], &Omega[0], &Omega_P[0]); //adding Integrator term
-
- //Accel_adjust(); //Remove centrifugal acceleration. We are not using this function in this version - we have no speed measurement
-
- #if OUTPUTMODE==1
- Update_Matrix[0][0]=0;
- Update_Matrix[0][1]=-G_Dt*Omega_Vector[2];//-z
- Update_Matrix[0][2]=G_Dt*Omega_Vector[1];//y
- Update_Matrix[1][0]=G_Dt*Omega_Vector[2];//z
- Update_Matrix[1][1]=0;
- Update_Matrix[1][2]=-G_Dt*Omega_Vector[0];//-x
- Update_Matrix[2][0]=-G_Dt*Omega_Vector[1];//-y
- Update_Matrix[2][1]=G_Dt*Omega_Vector[0];//x
- Update_Matrix[2][2]=0;
- #else // Uncorrected data (no drift correction)
- Update_Matrix[0][0]=0;
- Update_Matrix[0][1]=-G_Dt*Gyro_Vector[2];//-z
- Update_Matrix[0][2]=G_Dt*Gyro_Vector[1];//y
- Update_Matrix[1][0]=G_Dt*Gyro_Vector[2];//z
- Update_Matrix[1][1]=0;
- Update_Matrix[1][2]=-G_Dt*Gyro_Vector[0];
- Update_Matrix[2][0]=-G_Dt*Gyro_Vector[1];
- Update_Matrix[2][1]=G_Dt*Gyro_Vector[0];
- Update_Matrix[2][2]=0;
- #endif
-
- Matrix_Multiply(DCM_Matrix,Update_Matrix,Temporary_Matrix); //a*b=c
-
- for(int x=0; x<3; x++) //Matrix Addition (update)
- {
- for(int y=0; y<3; y++)
- {
- DCM_Matrix[x][y]+=Temporary_Matrix[x][y];
- }
- }
-}
-
-void Euler_angles(void)
-{
- pitch = -asin(DCM_Matrix[2][0]);
- roll = atan2(DCM_Matrix[2][1],DCM_Matrix[2][2]);
- yaw = atan2(DCM_Matrix[1][0],DCM_Matrix[0][0]);
-}
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino
deleted file mode 100644
index 5ca58e2..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/I2C.ino
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef IMU_V5
-
-#include <LSM6.h>
-#include <LIS3MDL.h>
-
-LSM6 gyro_acc;
-LIS3MDL mag;
-
-#else // older IMUs through v4
-
-#include <L3G.h>
-#include <LSM303.h>
-
-L3G gyro;
-LSM303 compass;
-
-#endif
-
-
-void I2C_Init()
-{
- Wire.begin();
-}
-
-void Gyro_Init()
-{
-#ifdef IMU_V5
- // Accel_Init() should have already called gyro_acc.init() and enableDefault()
- gyro_acc.writeReg(LSM6::CTRL2_G, 0x4C); // 104 Hz, 2000 dps full scale
-#else
- gyro.init();
- gyro.enableDefault();
- gyro.writeReg(L3G::CTRL_REG4, 0x20); // 2000 dps full scale
- gyro.writeReg(L3G::CTRL_REG1, 0x0F); // normal power mode, all axes enabled, 100 Hz
-#endif
-}
-
-void Read_Gyro()
-{
-#ifdef IMU_V5
- gyro_acc.readGyro();
-
- AN[0] = gyro_acc.g.x;
- AN[1] = gyro_acc.g.y;
- AN[2] = gyro_acc.g.z;
-#else
- gyro.read();
-
- AN[0] = gyro.g.x;
- AN[1] = gyro.g.y;
- AN[2] = gyro.g.z;
-#endif
-
- gyro_x = SENSOR_SIGN[0] * (AN[0] - AN_OFFSET[0]);
- gyro_y = SENSOR_SIGN[1] * (AN[1] - AN_OFFSET[1]);
- gyro_z = SENSOR_SIGN[2] * (AN[2] - AN_OFFSET[2]);
-}
-
-void Accel_Init()
-{
-#ifdef IMU_V5
- gyro_acc.init();
- gyro_acc.enableDefault();
- gyro_acc.writeReg(LSM6::CTRL1_XL, 0x3C); // 52 Hz, 8 g full scale
-#else
- compass.init();
- compass.enableDefault();
- switch (compass.getDeviceType())
- {
- case LSM303::device_D:
- compass.writeReg(LSM303::CTRL2, 0x18); // 8 g full scale: AFS = 011
- break;
- case LSM303::device_DLHC:
- compass.writeReg(LSM303::CTRL_REG4_A, 0x28); // 8 g full scale: FS = 10; high resolution output mode
- break;
- default: // DLM, DLH
- compass.writeReg(LSM303::CTRL_REG4_A, 0x30); // 8 g full scale: FS = 11
- }
-#endif
-}
-
-// Reads x,y and z accelerometer registers
-void Read_Accel()
-{
-#ifdef IMU_V5
- gyro_acc.readAcc();
-
- AN[3] = gyro_acc.a.x >> 4; // shift right 4 bits to use 12-bit representation (1 g = 256)
- AN[4] = gyro_acc.a.y >> 4;
- AN[5] = gyro_acc.a.z >> 4;
-#else
- compass.readAcc();
-
- AN[3] = compass.a.x >> 4; // shift right 4 bits to use 12-bit representation (1 g = 256)
- AN[4] = compass.a.y >> 4;
- AN[5] = compass.a.z >> 4;
-#endif
- accel_x = SENSOR_SIGN[3] * (AN[3] - AN_OFFSET[3]);
- accel_y = SENSOR_SIGN[4] * (AN[4] - AN_OFFSET[4]);
- accel_z = SENSOR_SIGN[5] * (AN[5] - AN_OFFSET[5]);
-}
-
-void Compass_Init()
-{
-#ifdef IMU_V5
- mag.init();
- mag.enableDefault();
-#else
- // LSM303: doesn't need to do anything because Accel_Init() should have already called compass.enableDefault()
-#endif
-}
-
-void Read_Compass()
-{
-#ifdef IMU_V5
- mag.read();
-
- magnetom_x = SENSOR_SIGN[6] * mag.m.x;
- magnetom_y = SENSOR_SIGN[7] * mag.m.y;
- magnetom_z = SENSOR_SIGN[8] * mag.m.z;
-#else
- compass.readMag();
-
- magnetom_x = SENSOR_SIGN[6] * compass.m.x;
- magnetom_y = SENSOR_SIGN[7] * compass.m.y;
- magnetom_z = SENSOR_SIGN[8] * compass.m.z;
-#endif
-}
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino
deleted file mode 100644
index 5307f5e..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/MinIMU9AHRS.ino
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-// Uncomment the following line to use a MinIMU-9 v5 or AltIMU-10 v5. Leave commented for older IMUs (up through v4).
-#define IMU_V5
-
-// Uncomment the below line to use this axis definition:
- // X axis pointing forward
- // Y axis pointing to the right
- // and Z axis pointing down.
-// Positive pitch : nose up
-// Positive roll : right wing down
-// Positive yaw : clockwise
-int SENSOR_SIGN[9] = {1,1,1,-1,-1,-1,1,1,1}; //Correct directions x,y,z - gyro, accelerometer, magnetometer
-// Uncomment the below line to use this axis definition:
- // X axis pointing forward
- // Y axis pointing to the left
- // and Z axis pointing up.
-// Positive pitch : nose down
-// Positive roll : right wing down
-// Positive yaw : counterclockwise
-//int SENSOR_SIGN[9] = {1,-1,-1,-1,1,1,1,-1,-1}; //Correct directions x,y,z - gyro, accelerometer, magnetometer
-
-// tested with Arduino Uno with ATmega328 and Arduino Duemilanove with ATMega168
-
-#include <Wire.h>
-
-// accelerometer: 8 g sensitivity
-// 3.9 mg/digit; 1 g = 256
-#define GRAVITY 256 //this equivalent to 1G in the raw data coming from the accelerometer
-
-#define ToRad(x) ((x)*0.01745329252) // *pi/180
-#define ToDeg(x) ((x)*57.2957795131) // *180/pi
-
-// gyro: 2000 dps full scale
-// 70 mdps/digit; 1 dps = 0.07
-#define Gyro_Gain_X 0.07 //X axis Gyro gain
-#define Gyro_Gain_Y 0.07 //Y axis Gyro gain
-#define Gyro_Gain_Z 0.07 //Z axis Gyro gain
-#define Gyro_Scaled_X(x) ((x)*ToRad(Gyro_Gain_X)) //Return the scaled ADC raw data of the gyro in radians for second
-#define Gyro_Scaled_Y(x) ((x)*ToRad(Gyro_Gain_Y)) //Return the scaled ADC raw data of the gyro in radians for second
-#define Gyro_Scaled_Z(x) ((x)*ToRad(Gyro_Gain_Z)) //Return the scaled ADC raw data of the gyro in radians for second
-
-// LSM303/LIS3MDL magnetometer calibration constants; use the Calibrate example from
-// the Pololu LSM303 or LIS3MDL library to find the right values for your board
-
-#define M_X_MIN -1000
-#define M_Y_MIN -1000
-#define M_Z_MIN -1000
-#define M_X_MAX +1000
-#define M_Y_MAX +1000
-#define M_Z_MAX +1000
-
-#define Kp_ROLLPITCH 0.02
-#define Ki_ROLLPITCH 0.00002
-#define Kp_YAW 1.2
-#define Ki_YAW 0.00002
-
-/*For debugging purposes*/
-//OUTPUTMODE=1 will print the corrected data,
-//OUTPUTMODE=0 will print uncorrected data of the gyros (with drift)
-#define OUTPUTMODE 1
-
-#define PRINT_DCM 0 //Will print the whole direction cosine matrix
-#define PRINT_ANALOGS 0 //Will print the analog raw data
-#define PRINT_EULER 1 //Will print the Euler angles Roll, Pitch and Yaw
-
-#define STATUS_LED 13
-
-float G_Dt=0.02; // Integration time (DCM algorithm) We will run the integration loop at 50Hz if possible
-
-long timer=0; //general purpuse timer
-long timer_old;
-long timer24=0; //Second timer used to print values
-int AN[6]; //array that stores the gyro and accelerometer data
-int AN_OFFSET[6]={0,0,0,0,0,0}; //Array that stores the Offset of the sensors
-
-int gyro_x;
-int gyro_y;
-int gyro_z;
-int accel_x;
-int accel_y;
-int accel_z;
-int magnetom_x;
-int magnetom_y;
-int magnetom_z;
-float c_magnetom_x;
-float c_magnetom_y;
-float c_magnetom_z;
-float MAG_Heading;
-
-float Accel_Vector[3]= {0,0,0}; //Store the acceleration in a vector
-float Gyro_Vector[3]= {0,0,0};//Store the gyros turn rate in a vector
-float Omega_Vector[3]= {0,0,0}; //Corrected Gyro_Vector data
-float Omega_P[3]= {0,0,0};//Omega Proportional correction
-float Omega_I[3]= {0,0,0};//Omega Integrator
-float Omega[3]= {0,0,0};
-
-// Euler angles
-float roll;
-float pitch;
-float yaw;
-
-float errorRollPitch[3]= {0,0,0};
-float errorYaw[3]= {0,0,0};
-
-unsigned int counter=0;
-byte gyro_sat=0;
-
-float DCM_Matrix[3][3]= {
- {
- 1,0,0 }
- ,{
- 0,1,0 }
- ,{
- 0,0,1 }
-};
-float Update_Matrix[3][3]={{0,1,2},{3,4,5},{6,7,8}}; //Gyros here
-
-
-float Temporary_Matrix[3][3]={
- {
- 0,0,0 }
- ,{
- 0,0,0 }
- ,{
- 0,0,0 }
-};
-
-void setup()
-{
- Serial.begin(115200);
- pinMode (STATUS_LED,OUTPUT); // Status LED
-
- I2C_Init();
-
- Serial.println("Pololu MinIMU-9 + Arduino AHRS");
-
- digitalWrite(STATUS_LED,LOW);
- delay(1500);
-
- Accel_Init();
- Compass_Init();
- Gyro_Init();
-
- delay(20);
-
- for(int i=0;i<32;i++) // We take some readings...
- {
- Read_Gyro();
- Read_Accel();
- for(int y=0; y<6; y++) // Cumulate values
- AN_OFFSET[y] += AN[y];
- delay(20);
- }
-
- for(int y=0; y<6; y++)
- AN_OFFSET[y] = AN_OFFSET[y]/32;
-
- AN_OFFSET[5]-=GRAVITY*SENSOR_SIGN[5];
-
- //Serial.println("Offset:");
- for(int y=0; y<6; y++)
- Serial.println(AN_OFFSET[y]);
-
- delay(2000);
- digitalWrite(STATUS_LED,HIGH);
-
- timer=millis();
- delay(20);
- counter=0;
-}
-
-void loop() //Main Loop
-{
- if((millis()-timer)>=20) // Main loop runs at 50Hz
- {
- counter++;
- timer_old = timer;
- timer=millis();
- if (timer>timer_old)
- {
- G_Dt = (timer-timer_old)/1000.0; // Real time of loop run. We use this on the DCM algorithm (gyro integration time)
- if (G_Dt > 0.2)
- G_Dt = 0; // ignore integration times over 200 ms
- }
- else
- G_Dt = 0;
-
-
-
- // *** DCM algorithm
- // Data adquisition
- Read_Gyro(); // This read gyro data
- Read_Accel(); // Read I2C accelerometer
-
- if (counter > 5) // Read compass data at 10Hz... (5 loop runs)
- {
- counter=0;
- Read_Compass(); // Read I2C magnetometer
- Compass_Heading(); // Calculate magnetic heading
- }
-
- // Calculations...
- Matrix_update();
- Normalize();
- Drift_correction();
- Euler_angles();
- // ***
-
- printdata();
- }
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino
deleted file mode 100644
index f1f31e5..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Output.ino
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-void printdata(void)
-{
- Serial.print("!");
-
- #if PRINT_EULER == 1
- Serial.print("ANG:");
- Serial.print(ToDeg(roll));
- Serial.print(",");
- Serial.print(ToDeg(pitch));
- Serial.print(",");
- Serial.print(ToDeg(yaw));
- #endif
- #if PRINT_ANALOGS==1
- Serial.print(",AN:");
- Serial.print(AN[0]); //(int)read_adc(0)
- Serial.print(",");
- Serial.print(AN[1]);
- Serial.print(",");
- Serial.print(AN[2]);
- Serial.print(",");
- Serial.print(AN[3]);
- Serial.print (",");
- Serial.print(AN[4]);
- Serial.print (",");
- Serial.print(AN[5]);
- Serial.print(",");
- Serial.print(c_magnetom_x);
- Serial.print (",");
- Serial.print(c_magnetom_y);
- Serial.print (",");
- Serial.print(c_magnetom_z);
- #endif
- #if PRINT_DCM == 1
- Serial.print (",DCM:");
- Serial.print(DCM_Matrix[0][0]);
- Serial.print (",");
- Serial.print(DCM_Matrix[0][1]);
- Serial.print (",");
- Serial.print(DCM_Matrix[0][2]);
- Serial.print (",");
- Serial.print(DCM_Matrix[1][0]);
- Serial.print (",");
- Serial.print(DCM_Matrix[1][1]);
- Serial.print (",");
- Serial.print(DCM_Matrix[1][2]);
- Serial.print (",");
- Serial.print(DCM_Matrix[2][0]);
- Serial.print (",");
- Serial.print(DCM_Matrix[2][1]);
- Serial.print (",");
- Serial.print(DCM_Matrix[2][2]);
- #endif
- Serial.println();
-
-}
-
-/*long convert_to_dec(float x)
-{
- return x*10000000;
-}*/
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino
deleted file mode 100644
index d69b49c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/Vector.ino
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-//Computes the dot product of two vectors
-float Vector_Dot_Product(float vector1[3],float vector2[3])
-{
- float op=0;
-
- for(int c=0; c<3; c++)
- {
- op+=vector1[c]*vector2[c];
- }
-
- return op;
-}
-
-//Computes the cross product of two vectors
-void Vector_Cross_Product(float vectorOut[3], float v1[3],float v2[3])
-{
- vectorOut[0]= (v1[1]*v2[2]) - (v1[2]*v2[1]);
- vectorOut[1]= (v1[2]*v2[0]) - (v1[0]*v2[2]);
- vectorOut[2]= (v1[0]*v2[1]) - (v1[1]*v2[0]);
-}
-
-//Multiply the vector by a scalar.
-void Vector_Scale(float vectorOut[3],float vectorIn[3], float scale2)
-{
- for(int c=0; c<3; c++)
- {
- vectorOut[c]=vectorIn[c]*scale2;
- }
-}
-
-void Vector_Add(float vectorOut[3],float vectorIn1[3], float vectorIn2[3])
-{
- for(int c=0; c<3; c++)
- {
- vectorOut[c]=vectorIn1[c]+vectorIn2[c];
- }
-}
-
-
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino
deleted file mode 100644
index c8a7a15..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/MinIMU9AHRS/matrix.ino
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-
-MinIMU-9-Arduino-AHRS
-Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Copyright (c) 2011-2016 Pololu Corporation.
-http://www.pololu.com/
-
-MinIMU-9-Arduino-AHRS is based on sf9domahrs by Doug Weibel and Jose Julio:
-http://code.google.com/p/sf9domahrs/
-
-sf9domahrs is based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose
-Julio and Doug Weibel:
-http://code.google.com/p/ardu-imu/
-
-MinIMU-9-Arduino-AHRS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-MinIMU-9-Arduino-AHRS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with MinIMU-9-Arduino-AHRS. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/**************************************************/
-//Multiply two 3x3 matrixs. This function developed by Jordi can be easily adapted to multiple n*n matrix's. (Pero me da flojera!).
-void Matrix_Multiply(float a[3][3], float b[3][3], float mat[3][3])
-{
- for(int x = 0; x < 3; x++)
- {
- for(int y = 0; y < 3; y++)
- {
- mat[x][y] = 0;
-
- for(int w = 0; w < 3; w++)
- {
- mat[x][y] += a[x][w] * b[w][y];
- }
- }
- }
-}
-
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/README.textile b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/README.textile
deleted file mode 100644
index ac1cb3f..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IMU_comp/minimu-9-ahrs-arduino-master/README.textile
+++ /dev/null
@@ -1,108 +0,0 @@
-h1. Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System)
-
-Version: 1.3.0
-Release Date: 2016-04-27
-"www.pololu.com":http://www.pololu.com/
-
-h2. Summary
-
-This is a program (sketch) for the "Arduino":http://pololu.com/catalog/product/2191 that interfaces with the Pololu MinIMU-9 inertial measurement units:
-
-* "MinIMU-9 v5 <notextile>(LSM6DS33 and LIS3MDL carrier)</notextile>":http://www.pololu.com/product/2738
-* "MinIMU-9 v3 <notextile>(L3GD20H and LSM303D carrier)</notextile>":http://www.pololu.com/product/2468
-* "MinIMU-9 v2 <notextile>(L3GD20 and LSM303DLHC carrier)</notextile>":http://www.pololu.com/catalog/product/1268 (discontinued)
-* "MinIMU-9 <notextile>(L3G4200D and LSM303DLM carrier)</notextile>":http://www.pololu.com/catalog/product/1265 (discontinued)
-* "MinIMU-9 <notextile>(L3G4200D and LSM303DLH carrier)</notextile>":http://www.pololu.com/catalog/product/1264 (discontinued)
-
-It also works with the Pololu AltIMU-10 boards, although the output from the barometer is not used:
-
-* "AltIMU-10 v5 <notextile>(LSM6DS33, LIS3MDL, and LPS25H carrier)</notextile>":http://www.pololu.com/product/2739
-* "AltIMU-10 v4 <notextile>(L3GD20H, LSM303D, and LPS25H carrier)</notextile>":http://www.pololu.com/catalog/product/2470
-* "AltIMU-10 v3 <notextile>(L3GD20H, LSM303D, and LPS331AP carrier)</notextile>":http://www.pololu.com/catalog/product/2469
-* "AltIMU-10 <notextile>(L3GD20, LSM303DLHC, and LPS331AP carrier)</notextile>":http://www.pololu.com/catalog/product/1269 (discontinued)
-
-This Arduino program processes the raw rotation, acceleration, and magnetic data from the MinIMU-9 to derive an estimate of the board's absolute orientation, which it outputs through the Arduino's serial interface, turning the MinIMU-9 and Arduino into an attitude and heading reference system (AHRS).
-
-A Python test program is also included. It communicates with the Arduino serially and displays a 3D representation of the MinIMU-9 board, allowing you to visualize the output of the AHRS in real time.
-
-Both the Arduino software and Python test program are based on "sf9domahrs":http://code.google.com/p/sf9domahrs/ by Doug Weibel and Jose Julio, which is in turn based on "ArduIMU":http://code.google.com/p/ardu-imu/ v1.5 by Jordi Munoz, William Premerlani, Jose Julio, and Doug Weibel.
-
-h2. Getting Started
-
-h3. Software
-
-The Arduino program uses Pololu's Arduino libraries for the sensors on the IMU board, which can also be downloaded from GitHub. Follow the instructions on their respective pages to install the libraries.
-
-* *v5* IMUs: "LSM6":https://github.com/pololu/LSM6-arduino and "LIS3MDL":https://github.com/pololu/LIS3MDL-arduino libraries
-* *v4 and earlier* IMUs: "L3G":https://github.com/pololu/L3G and "LSM303":https://github.com/pololu/LSM303 libraries
-
-The Python test program also has several dependencies you must install before you can run it:
-
-* "Python 2.7":http://www.python.org/download/ (download the 32-bit version)
-* "pywin32":http://sourceforge.net/projects/pywin32/files/pywin32/ (direct link: "pywin32-218.win32-py2.7.exe":http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download)
-* "pyserial":http://sourceforge.net/projects/pyserial/files/pyserial/ (direct link: "pyserial-2.5.win32.exe":http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.win32.exe/download)
-* "VPython 5":http://vpython.org/contents/download_windows.html (direct link: "VPython-Win-Py2.7-5.74.exe":http://vpython.org/contents/download/VPython-Win-Py2.7-5.74.exe)
-
-After you have set up the prerequisites, download the archive from "GitHub":https://github.com/pololu/MinIMU-9-Arduino-AHRS and decompress it.
-
-h3. Hardware
-
-Make the following connections with wires between the Arduino and the MinIMU-9:
-
-h4. 5V Arduino boards
-
-(including Arduino Uno, Leonardo, Mega; Pololu A-Star 32U4)
-
-pre. Arduino IMU
-------- ---
- 5V - VIN
- GND - GND
- SDA - SDA
- SCL - SCL
-
-h4. 3.3V Arduino boards
-
-(including Arduino Due)
-
-pre. Arduino IMU
-------- ---
- 3V3 - VIN
- GND - GND
- SDA - SDA
- SCL - SCL
-
-h3. Using the AHRS
-
-From the Arduino environment, open MinIMU9AHRS.ino, which can be found in the MinIMU9AHRS folder.
-
-The Arduino program is set up for a *v4 or earlier* IMU by default. If you are using a MinIMU or AltIMU *v5*, uncomment the line that says @//#define IMU_V5@ at the beginning of MinIMU9AHRS.ino.
-
-By default, the Arduino code treats the positive X axis of the MinIMU-9 as forward and the negative Z axis as up (so that the components are on the bottom of the board and the silkscreen is on top). If you want the positive Z axis to be up instead (so that the components are on top), find the definition of @SENSOR_SIGN[9]@ at the beginning of MinIMU9AHRS.ino and uncomment the appropriate line (after commenting the original).
-
-To ensure that the heading derived from the compass is accurate, you should change the @M_X_MIN@ through @M_Z_MAX@ calibration constants to appropriate values. You can use the Calibrate example from the "LIS3MDL library":https://github.com/pololu/LIS3MDL-arduino (v5) or "LSM303 library":https://github.com/pololu/LSM303 (v4 or earlier) to find the right values for your board.
-
-In the Tools menu, select the appropriate board and serial port. Click the "Upload" button to compile the sketch and load it onto your Arduino.
-
-When the AHRS program first starts running, it takes some readings to establish a baseline orientation, during which it expects both the roll and the pitch of the sensors to be zero. Therefore, it is important to keep the MinIMU-9 level for a few seconds after powering on or resetting the Arduino or connecting to it from a computer.
-
-After performing the startup routine, the program constantly takes readings from the gyro, accelerometer, and magnetometer on the MinIMU-9 and calculates an estimate of the board's orientation. It outputs estimated roll, pitch, and yaw angles (in degrees) through the Arduino's serial interface, and you can view the output with the Arduino Serial Monitor.
-
-Example output:
-
-pre. !ANG:0.08,0.09,137.01
-!ANG:0.14,0.11,137.04
-!ANG:0.15,0.12,137.06
-
-To visualize the output of the AHRS, you can run the Python test program (MinIMU-9-test.py) while the Arduino is connected to your computer. (You will probably have to edit the file first and change the definition of @ser@ to match the COM port your Arduino is using.) You should be able to see three indicators showing the roll, pitch, and yaw angles being calculated by the AHRS, as well as a 3D representation of the MinIMU-9 board (the arrow indicates the positive X direction). You can watch these change in real time as you move the board around.
-
-!http://b.pololu-files.com/picture/0J3722.600.jpg!
-
-h2. Version History
-
-* 1.3.0 (2016-04-27): Added support for MinIMU-9 v5 and AltIMU-10 v5. Added a check to help work around nan (not a number) problems caused by USB serial stalling the main loop.
-* 1.2.3 (2015-02-05): Updated to work with L3G library version 2.0.0.
-* 1.2.2 (2013-11-27): Updated to work with LSM303 library version 2.0.0.
-* 1.2.1 (2013-03-15): Fixed issue with properly enabling high-resolution mode on accelerometer.
-* 1.2.0 (2012-07-06): Added support for MinIMU-9 v2 (L3GD20 and LSM303DLHC); L3G4200D library dependency changed to L3G.
-* 1.1.0 (2011-11-15): Added support for LSM303DLM; LSM303DLH library dependency changed to LSM303.
-* 1.0.0 (2011-09-26): Original release.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IR_seeker/IR_seeker.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IR_seeker/IR_seeker.ino
deleted file mode 100644
index 90c9965..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/IR_seeker/IR_seeker.ino
+++ /dev/null
@@ -1,205 +0,0 @@
-#include <Adafruit_MCP23X17.h>
-
-#define ir1 0 // GPA0
-#define ir2 1 // GPA1
-#define ir3 2 // GPA2
-#define ir4 3 // GPA3
-#define ir5 4 // GPA4
-#define ir6 5 // GPA5
-#define ir7 6 // GPA6
-#define ir8 7 // GPA7
-#define ir9 8 // GPB0
-#define ir10 9 // GPB1
-#define ir11 10 // GPB2
-#define ir12 11 // GPB3
-#define ir13 12 // GPB4
-#define ir14 13 // GPB5
-#define ir15 14 // GPB6
-#define ir16 15 // GPB7
-
-int dir1 = 1; // data IR1
-int dir2 = 1; // data IR2
-int dir3 = 1; // etc
-int dir4 = 1;
-int dir5 = 1;
-int dir6 = 1;
-int dir7 = 1;
-int dir8 = 1;
-int dir9 = 1;
-int dir10 = 1;
-int dir11 = 1;
-int dir12 = 1;
-int dir13 = 1;
-int dir14 = 1;
-int dir15 = 1;
-int dir16 = 1;
-
-volatile long IRcount1 = 0;
-volatile long IRcount2 = 0;
-volatile long IRcount3 = 0;
-volatile long IRcount4 = 0;
-volatile long IRcount5 = 0;
-volatile long IRcount6 = 0;
-volatile long IRcount7 = 0;
-volatile long IRcount8 = 0;
-volatile long IRcount9 = 0;
-volatile long IRcount10 = 0;
-volatile long IRcount11 = 0;
-volatile long IRcount12 = 0;
-volatile long IRcount13 = 0;
-volatile long IRcount14 = 0;
-volatile long IRcount15 = 0;
-volatile long IRcount16 = 0;
-
-// Instance for the first MCP23017 at address 0x20
-Adafruit_MCP23X17 mcp1;
-
-void setup() {
- Serial.begin(9600);
- while (!Serial);
- Serial.println("MCP23xxx Button Test!");
-
- // Initialize first MCP23017 with I2C address 0x20
- if (!mcp1.begin_I2C(0x20)) {
- Serial.println("Error initializing MCP23017 at 0x20.");
- while (1);
- }
-
- // Configure pins for the first MCP23017 (0x20)
- mcp1.pinMode(ir1, INPUT);
- mcp1.pinMode(ir2, INPUT);
- mcp1.pinMode(ir3, INPUT);
- mcp1.pinMode(ir4, INPUT);
- mcp1.pinMode(ir5, INPUT);
- mcp1.pinMode(ir6, INPUT);
- mcp1.pinMode(ir7, INPUT);
- mcp1.pinMode(ir8, INPUT);
- mcp1.pinMode(ir9, INPUT);
- mcp1.pinMode(ir10, INPUT);
- mcp1.pinMode(ir11, INPUT);
- mcp1.pinMode(ir12, INPUT);
- mcp1.pinMode(ir13, INPUT);
- mcp1.pinMode(ir14, INPUT);
- mcp1.pinMode(ir15, INPUT);
- mcp1.pinMode(ir16, INPUT);
-
- attachInterrupt(digitalPinToInterrupt(ir1), IRtrigger1, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir2), IRtrigger2, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir3), IRtrigger3, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir4), IRtrigger4, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir5), IRtrigger5, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir6), IRtrigger6, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir7), IRtrigger7, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir8), IRtrigger8, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir9), IRtrigger9, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir10), IRtrigger10, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir11), IRtrigger11, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir12), IRtrigger12, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir13), IRtrigger13, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir14), IRtrigger14, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir15), IRtrigger15, CHANGE);
- attachInterrupt(digitalPinToInterrupt(ir16), IRtrigger16, CHANGE);
-
- Serial.println("Looping...");
-}
-
-void IRtrigger1() {
- IRcount1++;
-}
-void IRtrigger2() {
- IRcount2++;
-}
-void IRtrigger3() {
- IRcount3++;
-}
-void IRtrigger4() {
- IRcount4++;
-}
-void IRtrigger5() {
- IRcount5++;
-}
-void IRtrigger6() {
- IRcount6++;
-}
-void IRtrigger7() {
- IRcount7++;
-}
-void IRtrigger8() {
- IRcount8++;
-}
-void IRtrigger9() {
- IRcount9++;
-}
-void IRtrigger10() {
- IRcount10++;
-}
-void IRtrigger11() {
- IRcount11++;
-}
-void IRtrigger12() {
- IRcount12++;
-}
-void IRtrigger13() {
- IRcount13++;
-}
-void IRtrigger14() {
- IRcount14++;
-}
-void IRtrigger15() {
- IRcount15++;
-}
-void IRtrigger16() {
- IRcount16++;
-}
-
-
-void loop() {
- Serial.print("ir 1 changes: ");
- Serial.print(IRcount1);
- Serial.print(", ir 2 changes: ");
- Serial.print(IRcount2);
- Serial.print(", ir 3 changes: ");
- Serial.print(IRcount3);
- Serial.print(", ir 4 changes: ");
- Serial.print(IRcount4);
- Serial.print(", ir 5 changes: ");
- Serial.print(IRcount5);
- Serial.print(", ir 6 changes: ");
- Serial.print(IRcount6);
- Serial.print(", ir 7 changes: ");
- Serial.print(IRcount7);
- Serial.print(", ir 8 changes: ");
- Serial.print(IRcount8);
- Serial.print(", ir 9 changes: ");
- Serial.print(IRcount9);
- Serial.print(", ir 10 changes: ");
- Serial.print(IRcount10);
- Serial.print(", ir 11 changes: ");
- Serial.print(IRcount11);
- Serial.print(", ir 12 changes: ");
- Serial.print(IRcount12);
- Serial.print(", ir 13 changes: ");
- Serial.print(IRcount13);
- Serial.print(", ir 14 changes: ");
- Serial.print(IRcount14);
- Serial.print(", ir 15 changes: ");
- Serial.print(IRcount15);
- Serial.print(", ir 16 changes: ");
- Serial.println(IRcount16);
-
- volatile long IRcounts[] = {IRcount1, IRcount2, IRcount3, IRcount4, IRcount5, IRcount6, IRcount7, IRcount8, IRcount9, IRcount10, IRcount11, IRcount12, IRcount13, IRcount14, IRcount15, IRcount16};
- long maxCount = IRcounts[0];
- int highessensor = 1;
- for (int i = 0; i < 15; ++i) {
- if (IRcounts[i] > maxCount) {
- maxCount = IRcounts[i];
- highessensor = i + 1;
- }
- }
- Serial.print("Ball is at sensor: ");
- Serial.print(highessensor);
- Serial.print(", with value of ");
- Serial.println(maxCount);
-
- delay(250);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/MCP23017.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/MCP23017.ino
deleted file mode 100644
index d295e7c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/MCP23017.ino
+++ /dev/null
@@ -1,177 +0,0 @@
-#include <Adafruit_MCP23X17.h>
-
-#define ir1 0 // GPA0
-#define ir2 1 // GPA1
-#define ir3 2 // GPA2
-#define ir4 3 // GPA3
-#define ir5 4 // GPA4
-#define ir6 5 // GPA5
-#define ir7 6 // GPA6
-#define ir8 7 // GPA7
-#define ir9 8 // GPB0
-#define ir10 9 // GPB1
-#define ir11 10 // GPB2
-#define ir12 11 // GPB3
-#define ir13 12 // GPB4
-#define ir14 13 // GPB5
-#define ir15 14 // GPB6
-#define ir16 15 // GPB7
-
-int dir1 = 1; // data IR1
-int dir2 = 1; // data IR2
-int dir3 = 1; // etc
-int dir4 = 1;
-int dir5 = 1;
-int dir6 = 1;
-int dir7 = 1;
-int dir8 = 1;
-int dir9 = 1;
-int dir10 = 1;
-int dir11 = 1;
-int dir12 = 1;
-int dir13 = 1;
-int dir14 = 1;
-int dir15 = 1;
-int dir16 = 1;
-
-int dir17 = 1; // data IR17
-int dir18 = 1; // data IR18
-int dir19 = 1; // etc
-int dir20 = 1;
-int dir21 = 1;
-int dir22 = 1;
-int dir23 = 1;
-int dir24 = 1;
-int dir25 = 1;
-int dir26 = 1;
-int dir27 = 1;
-int dir28 = 1;
-int dir29 = 1;
-int dir30 = 1;
-int dir31 = 1;
-int dir32 = 1;
-
-// Instance for the first MCP23017 at address 0x20
-Adafruit_MCP23X17 mcp1;
-
-// Instance for the second MCP23017 at address 0x22
-Adafruit_MCP23X17 mcp2;
-
-void setup() {
- Serial.begin(9600);
- while (!Serial);
- Serial.println("MCP23xxx Button Test!");
-
- // Initialize first MCP23017 with I2C address 0x20
- if (!mcp1.begin_I2C(0x20)) {
- Serial.println("Error initializing MCP23017 at 0x20.");
- while (1);
- }
-
- // Initialize second MCP23017 with I2C address 0x22
- if (!mcp2.begin_I2C(0x22)) {
- Serial.println("Error initializing MCP23017 at 0x22.");
- while (1);
- }
-
- // Configure pins for the first MCP23017 (0x20)
- mcp1.pinMode(ir1, INPUT);
- mcp1.pinMode(ir2, INPUT);
- mcp1.pinMode(ir3, INPUT);
- mcp1.pinMode(ir4, INPUT);
- mcp1.pinMode(ir5, INPUT);
- mcp1.pinMode(ir6, INPUT);
- mcp1.pinMode(ir7, INPUT);
- mcp1.pinMode(ir8, INPUT);
- mcp1.pinMode(ir9, INPUT);
- mcp1.pinMode(ir10, INPUT);
- mcp1.pinMode(ir11, INPUT);
- mcp1.pinMode(ir12, INPUT);
- mcp1.pinMode(ir13, INPUT);
- mcp1.pinMode(ir14, INPUT);
- mcp1.pinMode(ir15, INPUT);
- mcp1.pinMode(ir16, INPUT);
-
- // Configure pins for the second MCP23017 (0x22)
- mcp2.pinMode(ir1, INPUT);
- mcp2.pinMode(ir2, INPUT);
- mcp2.pinMode(ir3, INPUT);
- mcp2.pinMode(ir4, INPUT);
- mcp2.pinMode(ir5, INPUT);
- mcp2.pinMode(ir6, INPUT);
- mcp2.pinMode(ir7, INPUT);
- mcp2.pinMode(ir8, INPUT);
- mcp2.pinMode(ir9, INPUT);
- mcp2.pinMode(ir10, INPUT);
- mcp2.pinMode(ir11, INPUT);
- mcp2.pinMode(ir12, INPUT);
- mcp2.pinMode(ir13, INPUT);
- mcp2.pinMode(ir14, INPUT);
- mcp2.pinMode(ir15, INPUT);
- mcp2.pinMode(ir16, INPUT);
-
- Serial.println("Looping...");
-}
-
-void loop() {
- // Read pins from the first MCP23017 (0x20)
- dir1 = mcp1.digitalRead(ir1);
- dir2 = mcp1.digitalRead(ir2);
- dir3 = mcp1.digitalRead(ir3);
- dir4 = mcp1.digitalRead(ir4);
- dir5 = mcp1.digitalRead(ir5);
- dir6 = mcp1.digitalRead(ir6);
- dir7 = mcp1.digitalRead(ir7);
- dir8 = mcp1.digitalRead(ir8);
- dir9 = mcp1.digitalRead(ir9);
- dir10 = mcp1.digitalRead(ir10);
- dir11 = mcp1.digitalRead(ir11);
- dir12 = mcp1.digitalRead(ir12);
- dir13 = mcp1.digitalRead(ir13);
- dir14 = mcp1.digitalRead(ir14);
- dir15 = mcp1.digitalRead(ir15);
- dir16 = mcp1.digitalRead(ir16);
-
- // Read pins from the second MCP23017 (0x22)
- dir17 = mcp2.digitalRead(ir1);
- dir18 = mcp2.digitalRead(ir2);
- dir19 = mcp2.digitalRead(ir3);
- dir20 = mcp2.digitalRead(ir4);
- dir21 = mcp2.digitalRead(ir5);
- dir22 = mcp2.digitalRead(ir6);
- dir23 = mcp2.digitalRead(ir7);
- dir24 = mcp2.digitalRead(ir8);
- dir25 = mcp2.digitalRead(ir9);
- dir26 = mcp2.digitalRead(ir10);
- dir27 = mcp2.digitalRead(ir11);
- dir28 = mcp2.digitalRead(ir12);
- dir29 = mcp2.digitalRead(ir13);
- dir30 = mcp2.digitalRead(ir14);
- dir31 = mcp2.digitalRead(ir15);
- dir32 = mcp2.digitalRead(ir16);
-
- // Print the results from the first MCP23017 (0x20)
- Serial.print("MCP23017 @ 0x20: ");
- Serial.print(dir1); Serial.print(", "); Serial.print(dir2);
- Serial.print(", "); Serial.print(dir3); Serial.print(", "); Serial.print(dir4);
- Serial.print(", "); Serial.print(dir5); Serial.print(", "); Serial.print(dir6);
- Serial.print(", "); Serial.print(dir7); Serial.print(", "); Serial.print(dir8);
- Serial.print(", "); Serial.print(dir9); Serial.print(", "); Serial.print(dir10);
- Serial.print(", "); Serial.print(dir11); Serial.print(", "); Serial.print(dir12);
- Serial.print(", "); Serial.print(dir13); Serial.print(", "); Serial.print(dir14);
- Serial.print(", "); Serial.print(dir15); Serial.print(", "); Serial.print(dir16);
-
- // Print the results from the second MCP23017 (0x22)
- Serial.print(" MCP23017 @ 0x22: ");
- Serial.print(dir17); Serial.print(", "); Serial.print(dir18);
- Serial.print(", "); Serial.print(dir19); Serial.print(", "); Serial.print(dir20);
- Serial.print(", "); Serial.print(dir21); Serial.print(", "); Serial.print(dir22);
- Serial.print(", "); Serial.print(dir23); Serial.print(", "); Serial.print(dir24);
- Serial.print(", "); Serial.print(dir25); Serial.print(", "); Serial.print(dir26);
- Serial.print(", "); Serial.print(dir27); Serial.print(", "); Serial.print(dir28);
- Serial.print(", "); Serial.print(dir29); Serial.print(", "); Serial.print(dir30);
- Serial.print(", "); Serial.print(dir31); Serial.print(", "); Serial.println(dir32);
-
- Serial.println();
- delay(250);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/mcp20317_schemss.jpg b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/mcp20317_schemss.jpg
deleted file mode 100644
index 5231394..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/MCP23017/mcp20317_schemss.jpg
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/Scanner/Scanner.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/Scanner/Scanner.ino
deleted file mode 100644
index 879dbd6..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/Scanner/Scanner.ino
+++ /dev/null
@@ -1,194 +0,0 @@
-// Wire Scanner - scans for I2C devices on all Wire ports
-//
-// This Wire library adapted is for Teensy boards
-//
-// https://github.com/PaulStoffregen/Wire/
-//
-// Adapted from I2C Scanner originally published on Arduino Playground
-// see comments below for link and credits for original authors.
-
-#include <Wire.h>
-
-void setup() {
-#if WIRE_INTERFACES_COUNT >= 1
- //Wire.setSCL(16); // uncomment these to use alternate Wire pins
- //Wire.setSDA(17);
- Wire.begin();
-#endif
- Serial.begin(9600);
- while (!Serial); // Wait for Arduino Serial Monitor
- Serial.println(F("\nI2C Scanner"));
-}
-
-
-void loop() {
- Serial.println();
-#if WIRE_INTERFACES_COUNT >= 1
- Serial.println(F("Scanning Wire..."));
- scan(Wire);
- delay(500);
-#endif
- delay(2000); // wait 5 seconds for next scan
-}
-
-
-void scan(TwoWire &myport) {
- int nDevices = 0;
- for (int address = 1; address < 127; address++) {
- // The i2c_scanner uses the return value of
- // the Write.endTransmisstion to see if
- // a device did acknowledge to the address.
- myport.beginTransmission(address);
- int error = myport.endTransmission();
-
- if (error == 0) {
- Serial.print(F("Device found at address 0x"));
- if (address < 16) {
- Serial.print("0");
- }
- Serial.print(address,HEX);
- Serial.print(" (");
- printKnownChips(address);
- Serial.println(")");
- nDevices++;
- } else if (error==4) {
- Serial.print(F("Unknown error at address 0x"));
- if (address < 16) {
- Serial.print("0");
- }
- Serial.println(address,HEX);
- }
- }
- if (nDevices == 0) {
- Serial.println(F("No I2C devices found"));
- } else {
- Serial.println(F("done"));
- }
- Serial.println();
-}
-
-
-void printKnownChips(byte address)
-{
- // Is this list missing part numbers for chips you use?
- // Please suggest additions here:
- // https://github.com/PaulStoffregen/Wire/issues/new
- switch (address) {
- case 0x00: Serial.print(F("AS3935")); break;
- case 0x01: Serial.print(F("AS3935")); break;
- case 0x02: Serial.print(F("AS3935")); break;
- case 0x03: Serial.print(F("AS3935")); break;
- case 0x04: Serial.print(F("ADAU1966")); break;
- case 0x0A: Serial.print(F("SGTL5000")); break; // MCLK required
- case 0x0B: Serial.print(F("SMBusBattery?")); break;
- case 0x0C: Serial.print(F("AK8963")); break;
- case 0x10: Serial.print(F("CS4272")); break;
- case 0x11: Serial.print(F("Si4713")); break;
- case 0x13: Serial.print(F("VCNL4000,AK4558")); break;
- case 0x18: Serial.print(F("LIS331DLH")); break;
- case 0x19: Serial.print(F("LSM303,LIS331DLH")); break;
- case 0x1A: Serial.print(F("WM8731")); break;
- case 0x1C: Serial.print(F("LIS3MDL")); break;
- case 0x1D: Serial.print(F("LSM303D,LSM9DS0,ADXL345,MMA7455L,LSM9DS1,LIS3DSH")); break;
- case 0x1E: Serial.print(F("LSM303D,HMC5883L,FXOS8700,LIS3DSH")); break;
- case 0x20: Serial.print(F("MCP23017,MCP23008,PCF8574,FXAS21002,SoilMoisture")); break;
- case 0x21: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x22: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x23: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x24: Serial.print(F("MCP23017,MCP23008,PCF8574,ADAU1966,HM01B0")); break;
- case 0x25: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x26: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
- case 0x27: Serial.print(F("MCP23017,MCP23008,PCF8574,LCD16x2,DigoleDisplay")); break;
- case 0x28: Serial.print(F("BNO055,EM7180,CAP1188")); break;
- case 0x29: Serial.print(F("TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188")); break;
- case 0x2A: Serial.print(F("SGTL5000,CAP1188")); break;
- case 0x2B: Serial.print(F("CAP1188")); break;
- case 0x2C: Serial.print(F("MCP44XX ePot")); break;
- case 0x2D: Serial.print(F("MCP44XX ePot")); break;
- case 0x2E: Serial.print(F("MCP44XX ePot")); break;
- case 0x2F: Serial.print(F("MCP44XX ePot")); break;
- case 0x30: Serial.print(F("Si7210")); break;
- case 0x31: Serial.print(F("Si7210")); break;
- case 0x32: Serial.print(F("Si7210")); break;
- case 0x33: Serial.print(F("MAX11614,MAX11615,Si7210,MLX90640,MLX90641")); break;
- case 0x34: Serial.print(F("MAX11612,MAX11613")); break;
- case 0x35: Serial.print(F("MAX11616,MAX11617")); break;
- case 0x38: Serial.print(F("RA8875,FT6206,MAX98390")); break;
- case 0x39: Serial.print(F("TSL2561, APDS9960")); break;
- case 0x3A: Serial.print(F("MLX90632")); break;
- case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
- case 0x3D: Serial.print(F("SSD1306")); break;
- case 0x40: Serial.print(F("PCA9685,Si7021,MS8607")); break;
- case 0x41: Serial.print(F("STMPE610,PCA9685")); break;
- case 0x42: Serial.print(F("PCA9685")); break;
- case 0x43: Serial.print(F("PCA9685")); break;
- case 0x44: Serial.print(F("PCA9685, SHT3X, ADAU1966")); break;
- case 0x45: Serial.print(F("PCA9685, SHT3X")); break;
- case 0x46: Serial.print(F("PCA9685")); break;
- case 0x47: Serial.print(F("PCA9685")); break;
- case 0x48: Serial.print(F("ADS1115,PN532,TMP102,LM75,PCF8591,CS42448")); break;
- case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591,CS42448,TC74A1")); break;
- case 0x4A: Serial.print(F("ADS1115,Qwiic Keypad,CS42448")); break;
- case 0x4B: Serial.print(F("ADS1115,TMP102,BNO080,Qwiic Keypad,CS42448")); break;
- case 0x50: Serial.print(F("EEPROM,FRAM")); break;
- case 0x51: Serial.print(F("EEPROM")); break;
- case 0x52: Serial.print(F("Nunchuk,EEPROM")); break;
- case 0x53: Serial.print(F("ADXL345,EEPROM")); break;
- case 0x54: Serial.print(F("EEPROM")); break;
- case 0x55: Serial.print(F("EEPROM")); break;
- case 0x56: Serial.print(F("EEPROM")); break;
- case 0x57: Serial.print(F("EEPROM")); break;
- case 0x58: Serial.print(F("TPA2016,MAX21100")); break;
- case 0x5A: Serial.print(F("MPR121,MLX90614")); break;
- case 0x60: Serial.print(F("MPL3115,MCP4725,MCP4728,TEA5767,Si5351")); break;
- case 0x61: Serial.print(F("MCP4725,AtlasEzoDO")); break;
- case 0x62: Serial.print(F("LidarLite,MCP4725,AtlasEzoORP")); break;
- case 0x63: Serial.print(F("MCP4725,AtlasEzoPH")); break;
- case 0x64: Serial.print(F("AtlasEzoEC, ADAU1966")); break;
- case 0x66: Serial.print(F("AtlasEzoRTD")); break;
- case 0x68: Serial.print(F("DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D")); break;
- case 0x69: Serial.print(F("MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D")); break;
- case 0x6A: Serial.print(F("LSM9DS1")); break;
- case 0x6B: Serial.print(F("LSM9DS0")); break;
- case 0x6F: Serial.print(F("Qwiic Button")); break;
- case 0x70: Serial.print(F("HT16K33,TCA9548A")); break;
- case 0x71: Serial.print(F("SFE7SEG,HT16K33")); break;
- case 0x72: Serial.print(F("HT16K33")); break;
- case 0x73: Serial.print(F("HT16K33")); break;
- case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
- case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
- case 0x7C: Serial.print(F("FRAM_ID")); break;
- default: Serial.print(F("unknown chip"));
- }
-}
-
-
-// --------------------------------------
-// i2c_scanner
-// https://playground.arduino.cc/Main/I2cScanner/
-//
-// Version 1
-// This program (or code that looks like it)
-// can be found in many places.
-// For example on the Arduino.cc forum.
-// The original author is not know.
-// Version 2, Juni 2012, Using Arduino 1.0.1
-// Adapted to be as simple as possible by Arduino.cc user Krodal
-// Version 3, Feb 26 2013
-// V3 by louarnold
-// Version 4, March 3, 2013, Using Arduino 1.0.3
-// by Arduino.cc user Krodal.
-// Changes by louarnold removed.
-// Scanning addresses changed from 0...127 to 1...119,
-// according to the i2c scanner by Nick Gammon
-// http://www.gammon.com.au/forum/?id=10896
-// Version 5, March 28, 2013
-// As version 4, but address scans now to 127.
-// A sensor seems to use address 120.
-// Version 6, November 27, 2015.
-// Added waiting for the Leonardo serial communication.
-//
-//
-// This sketch tests the standard 7-bit addresses
-// Devices with higher bit address might not be seen properly.
-//
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/color_sensor.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/color_sensor.ino
deleted file mode 100644
index c800f16..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/color_sensor.ino
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
-i2c port scanner based on:
- in wire library examples i2c_scanner
- https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino
-
-color sensor based on±
- adafruit TCS34725 librarys
-
- type var:
- https://arduino.stackexchange.com/questions/3079/how-to-retrieve-the-data-type-of-a-variable
-
- *
- */
-
-#include <Wire.h> //https://www.arduino.cc/reference/en/language/functions/communication/wire/
-#include "Adafruit_TCS34725.h" //https://github.com/adafruit/Adafruit_TCS34725
-
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-
-/* Initialise with default values (int time = 2.4ms, gain = 1x) */
-Adafruit_TCS34725 tcs = Adafruit_TCS34725();
-//Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);
-
-const int buzzer = 6; //buzzer to arduino pin 9
-
-
-int colsensdata[6] = {99, 99, 99, 99, 99, 99};
-
-
-
-void setup() {
- Serial.begin(115200);
- //while (!Serial); // Leonardo: wait for Serial Monitor
- Serial.println("\nI2C Scanner");
- pinMode(buzzer, OUTPUT);
-
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-void scandirectports(){
- Wire.begin();
- int nDevices = 0;
- Serial.println("Scanning for i2c ports on board...");
-
- for (byte address = 1; address < 127; ++address) {
- // The i2c_scanner uses the return value of
- // the Wire.endTransmission to see if
- // a device did acknowledge to the address.
- Wire.beginTransmission(address);
- byte error = Wire.endTransmission();
-
- if (error == 0) {
- Serial.print("I2C device found at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.print(address, HEX);
- Serial.println(" !");
-
- ++nDevices;
- } else if (error == 4) {
- Serial.print("Unknown error at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.println(address, HEX);
- }
- }
- if (nDevices == 0) {
- Serial.println("No I2C devices found\n");
- } else {
- Serial.println("done\n");
- }
-}
-
-
-// Generic catch-all implementation.
-template <typename T_ty> struct TypeInfo { static const char * name; };
-template <typename T_ty> const char * TypeInfo<T_ty>::name = "unknown";
-
-// Handy macro to make querying stuff easier.
-#define TYPE_NAME(var) TypeInfo< typeof(var) >::name
-
-// Handy macro to make defining stuff easier.
-#define MAKE_TYPE_INFO(type) template <> const char * TypeInfo<type>::name = #type;
-
-// Type-specific implementations.
-MAKE_TYPE_INFO( int )
-MAKE_TYPE_INFO( float )
-MAKE_TYPE_INFO( short )
-
-void loop() {
- Wire.begin();
-
- for (uint8_t t=0; t<50; t++) {
- Serial.println();
- }
-
- scandirectports();
-
- Serial.println();
- Serial.println();
-
- for (uint8_t t=0; t<6; t++) {
- pcaselect(t);
- Serial.print("PCA Port #"); Serial.println(t);
- for (uint8_t addr = 0; addr<=127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
- Serial.println("scanning for tcs sensor");
- if (tcs.begin()) {
- Serial.println("Found sensor");
- Serial.println("collecting data");
- uint16_t r, g, b, c, colorTemp, lux;
- tcs.getRawData(&r, &g, &b, &c);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
- Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
- Serial.print("RGB: "); Serial.print(r, DEC); Serial.print(", "); Serial.print(g, DEC); Serial.print(", "); Serial.print(b, DEC); Serial.println(" ");
- if ((colorTemp) == 5201){
- Serial.println("sensor in air");
- tone(buzzer, 100);
- colsensdata[t] = 0;
- }
- else if ((g)>=(2*(r)) && (g)>=12){
- Serial.println("green");
- tone(buzzer, 200);
- colsensdata[t] = 1;
- }
- else if ((colorTemp)>= 6750){
- Serial.println("black");
- tone(buzzer, 300);
- colsensdata[t] = 2;
- }
- else if ((colorTemp) < 6750){
- Serial.println("white");
- tone(buzzer, 400);
- colsensdata[t] = 3;
- }
- else{
- Serial.println(colorTemp);
- Serial.println(TYPE_NAME((colorTemp, DEC)));
- colsensdata[t] = 98;
- }
- Serial.println();
-
-
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- colsensdata[t] = 97;
- }
- delay(500);
- }
- }
- }
- Serial.println();
- Serial.print("sensor data = ");
- for(int i = 0; i < 6; i++){
- Serial.print(colsensdata[i]);
- Serial.print(", ");
- }
- /**
-0 = air
-1 = green
-2 = black
-3 = white
-90 = error
-
- *
- */
- Serial.println("");
- Serial.println("DONE");
- tone(buzzer, 1000);
- delay(2500);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/short/short.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/short/short.ino
deleted file mode 100644
index 2f80412..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/color_sensor/short/short.ino
+++ /dev/null
@@ -1,94 +0,0 @@
-
-#include <Wire.h> //https://www.arduino.cc/reference/en/language/functions/communication/wire/
-#include "Adafruit_TCS34725.h" //https://github.com/adafruit/Adafruit_TCS34725
-
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-
-
-Adafruit_TCS34725 tcs = Adafruit_TCS34725();/* Initialise with default values (int time = 2.4ms, gain = 1x) */
-
-int colsensdata[6] = {99, 99, 99, 99, 99, 99};
-
-void setup() {
- Serial.begin(115200);
- Serial.println("\nI2C Scanner");
-
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-
-template <typename T_ty> struct TypeInfo { static const char * name; };
-template <typename T_ty> const char * TypeInfo<T_ty>::name = "unknown";
-#define TYPE_NAME(var) TypeInfo< typeof(var) >::name
-#define MAKE_TYPE_INFO(type) template <> const char * TypeInfo<type>::name = #type;
-MAKE_TYPE_INFO( int )
-MAKE_TYPE_INFO( float )
-MAKE_TYPE_INFO( short )
-
-void loop() {
- Wire.begin();
- for (uint8_t t=0; t<6; t++) {
- pcaselect(t);
- Serial.print("PCA Port #"); Serial.println(t);
- for (uint8_t addr = 0; addr<=127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
- if (tcs.begin()) {
- Serial.println("Found sensor");
- Serial.println("collecting data");
- uint16_t r, g, b, c, colorTemp, lux;
- tcs.getRawData(&r, &g, &b, &c);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
- Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
- Serial.print("RGB: "); Serial.print(r, DEC); Serial.print(", "); Serial.print(g, DEC); Serial.print(", "); Serial.print(b, DEC); Serial.println(" ");
- if ((colorTemp) == 5201){
- colsensdata[t] = 0;
- }
- else if ((g)>=(2*(r)) && (g)>=12){
- colsensdata[t] = 1;
- }
- else if ((colorTemp)>= 6750){
- colsensdata[t] = 2;
- }
- else if ((colorTemp) < 6750){
- colsensdata[t] = 3;
- }
- else{
- Serial.println(colorTemp);
- Serial.println(TYPE_NAME((colorTemp, DEC)));
- colsensdata[t] = 98;
- }
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- colsensdata[t] = 97;
- }
- }
- }
- }
- Serial.print("sensor data = ");
- for(int i = 0; i < 6; i++){
- Serial.print(colsensdata[i]);
- Serial.print(", ");
- }
- /**
-0 = air
-1 = green
-2 = black
-3 = white
-90 = error
-
- *
- */
- Serial.println("");
- Serial.println("DONE");
- delay(2500);
-} \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino
deleted file mode 100644
index eb257e5..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_binairy_decoder/arduino_binairy_decoder.ino
+++ /dev/null
@@ -1,28 +0,0 @@
-String inp = "01101000";
-int decimalValue = 0;
-
-void setup() {
- Serial.begin(115200);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for native USB
- }
- Serial.println("");
-
- Serial.println(inp);
- String binary = inp.substring(2);
- Serial.println(binary);
- for (int i = 0; i < binary.length(); i++) {
- // Calculate the value of the current bit
- int bitValue = binary.charAt(i) - '0';
- // Update the decimal value by shifting the bit to its correct position
- decimalValue = (decimalValue << 1) | bitValue;
- }
- Serial.println(decimalValue);
- Serial.println("");
-}
-
-void loop() {
- // put your main code here, to run repeatedly:
- delay(1000);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_comm/arduino_comm.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_comm/arduino_comm.ino
deleted file mode 100644
index 4a2b205..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/arduino_comm/arduino_comm.ino
+++ /dev/null
@@ -1,37 +0,0 @@
-String tlocd = "";
-String locd = "";
-bool readloc = false;
-unsigned long datatime = 0;
-
-void setup() {
- Serial1.begin(19200);
- Serial.begin(19200);
-}
-
-void loop() {
- if(Serial1.available()){
- datatime = millis();
-
- byte byteRead = Serial1.read();
-
- if(byteRead == 's'){
- tlocd = "";
- readloc = true;
- }
- else if(byteRead == 'e'){
- readloc = false;
- locd = tlocd;
- }
- else if(readloc == true){
- tlocd += (char)byteRead;
- }
- }
- else{
- if(millis() - datatime > 5000){
- Serial.println("Err no data recieved for 5 sec");
- locd = "999";
- }
- }
- Serial.println(locd);
- delay(134);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/readme.txt.txt b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/readme.txt.txt
deleted file mode 100644
index ef9f996..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/readme.txt.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-serial communication between two Seeed Studio XIAO SAMD21 and one teensy.
-Teensy Serial 2 and 3 on read
-Seeed XIAO SAMD21 write a 8 values on Serial1 between 0-10000 (pulses from IR sensor) every 0,25 seconds. For example 100 pulses in 1 second = 00025
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino
deleted file mode 100644
index 32750de..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino
+++ /dev/null
@@ -1,9 +0,0 @@
-void setup() {
- Serial1.begin(9600)
-
-}
-
-void loop() {
- Serial1.println("/D:00025:/E");
- delay(250);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino
deleted file mode 100644
index 684c199..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino
+++ /dev/null
@@ -1,17 +0,0 @@
-void setup() {
- // Initialize Serial1 with a baud rate of 19200
- Serial1.begin(9600);
- Serial.begin(9600); // Initialize Serial for debugging
-}
-
-void loop() {
- // Check if there is any data available to read from Serial1
- if (Serial1.available()) {
- // Read the most recent byte
- byte byteRead = Serial1.read();
- // Echo the value that was read
- Serial1.write(byteRead);
- // Print the received byte for debugging
- Serial.print((char)byteRead);
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_master/arduino_spi_master.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_master/arduino_spi_master.ino
deleted file mode 100644
index 248ef0f..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_master/arduino_spi_master.ino
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <SPI.h>
-#define SS_PIN 10
-#define BAUD_RATE 19200
-#define CHAR_BUF 128
-
-void setup() {
- pinMode(SS_PIN, OUTPUT);
- Serial.begin(BAUD_RATE);
- SPI.begin();
- SPI.setBitOrder(MSBFIRST);
- SPI.setClockDivider(SPI_CLOCK_DIV16);
- SPI.setDataMode(SPI_MODE0);
- delay(1000); // Give the OpenMV Cam time to bootup.
-}
-
-void loop() {
- int32_t len = 0;
- char buff[CHAR_BUF] = {0};
- digitalWrite(SS_PIN, LOW);
- delay(1); // Give the OpenMV Cam some time to setup to send data.
-
- if(SPI.transfer(1) == 85) { // saw sync char?
- SPI.transfer(&len, 4); // get length
- if (len) {
- SPI.transfer(&buff, min(len, CHAR_BUF));
- len -= min(len, CHAR_BUF);
- }
- while (len--) SPI.transfer(0); // eat any remaining bytes
- }
-
- digitalWrite(SS_PIN, HIGH);
- Serial.print(buff);
- delay(1); // Don't loop to quickly.
-} \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_slave_1.py b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_slave_1.py
deleted file mode 100644
index e05c2f0..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/spi/arduino_spi_slave_1.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# This work is licensed under the MIT license.
-# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
-# https://github.com/openmv/openmv/blob/master/LICENSE
-#
-# SPI with the Arduino as the master device and the OpenMV Cam as the slave.
-#
-# Please wire up your OpenMV Cam to your Arduino like this:
-#
-# OpenMV Cam Master Out Slave In (P0) - Arduino Uno MOSI (11)
-# OpenMV Cam Master In Slave Out (P1) - Arduino Uno MISO (12)
-# OpenMV Cam Serial Clock (P2) - Arduino Uno SCK (13)
-# OpenMV Cam Slave Select (P3) - Arduino Uno SS (10)
-# OpenMV Cam Ground - Arduino Ground
-
-import pyb
-import ustruct
-import time
-
-text = "Hello World!\n"
-data = ustruct.pack("<bi%ds" % len(text), 85, len(text), text) # 85 is a sync char.
-# Use "ustruct" to build data packets to send.
-# "<" puts the data in the struct in little endian order.
-# "b" puts a signed char in the data stream.
-# "i" puts a signed integer in the data stream.
-# "%ds" puts a string in the data stream. E.g. "13s" for "Hello World!\n" (13 chars).
-# See https://docs.python.org/3/library/struct.html
-
-# READ ME!!!
-#
-# Please understand that when your OpenMV Cam is not the SPI master it may miss responding to
-# sending data as a SPI slave no matter if you call "spi.send()" in an interrupt callback or in the
-# main loop below. Because of this you must absolutely design your communications protocol such
-# that if the slave device (the OpenMV Cam) doesn't call "spi.send()" in time that garbage data
-# read from the SPI peripheral by the master (the Arduino) is tossed. To accomplish this we use a
-# sync character of 85 (binary 01010101) which the Arduino will look for as the first byte read.
-# If it doesn't see this then it aborts the SPI transaction and will try again. Second, in order to
-# clear out the SPI peripheral state we always send a multiple of four bytes and an extra four zero
-# bytes to make sure that the SPI peripheral doesn't hold any stale data which could be 85. Note
-# that the OpenMV Cam will miss the "spi.send()" window randomly because it has to service
-# interrupts. Interrupts will happen a lot more while connected to your PC.
-
-# The hardware SPI bus for your OpenMV Cam is always SPI bus 2.
-# polarity = 0 -> clock is idle low.
-# phase = 0 -> sample data on rising clock edge, output data on falling clock edge.
-spi = pyb.SPI(2, pyb.SPI.SLAVE, polarity=0, phase=0)
-
-
-# NSS callback.
-def nss_callback(line):
- global spi, data
- try:
- spi.send(data, timeout=1000)
- except OSError as err:
- pass # Don't care about errors - so pass.
- # Note that there are 3 possible errors. A timeout error, a general purpose error, or
- # a busy error. The error codes are 116, 5, 16 respectively for "err.arg[0]".
-
-
-# Configure NSS/CS in IRQ mode to send data when requested by the master.
-pyb.ExtInt(pyb.Pin("P3"), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, nss_callback)
-
-while True:
- time.sleep_ms(1000)
-
-###################################################################################################
-# Arduino Code
-###################################################################################################
-#
-# #include <SPI.h>
-# #define SS_PIN 10
-# #define BAUD_RATE 19200
-# #define CHAR_BUF 128
-#
-# void setup() {
-# pinMode(SS_PIN, OUTPUT);
-# Serial.begin(BAUD_RATE);
-# SPI.begin();
-# SPI.setBitOrder(MSBFIRST);
-# SPI.setClockDivider(SPI_CLOCK_DIV16);
-# SPI.setDataMode(SPI_MODE0);
-# delay(1000); // Give the OpenMV Cam time to bootup.
-# }
-#
-# void loop() {
-# int32_t len = 0;
-# char buff[CHAR_BUF] = {0};
-# digitalWrite(SS_PIN, LOW);
-# delay(1); // Give the OpenMV Cam some time to setup to send data.
-#
-# if(SPI.transfer(1) == 85) { // saw sync char?
-# SPI.transfer(&len, 4); // get length
-# if (len) {
-# SPI.transfer(&buff, min(len, CHAR_BUF));
-# len -= min(len, CHAR_BUF);
-# }
-# while (len--) SPI.transfer(0); // eat any remaining bytes
-# }
-#
-# digitalWrite(SS_PIN, HIGH);
-# Serial.print(buff);
-# delay(1); // Don't loop to quickly.
-# }
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart/arduino_uart.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart/arduino_uart.ino
deleted file mode 100644
index 6385695..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart/arduino_uart.ino
+++ /dev/null
@@ -1,17 +0,0 @@
-void setup() {
- // Initialize Serial1 with a baud rate of 19200
- Serial1.begin(19200);
- Serial.begin(19200); // Initialize Serial for debugging
-}
-
-void loop() {
- // Check if there is any data available to read from Serial1
- if (Serial1.available()) {
- // Read the most recent byte
- byte byteRead = Serial1.read();
- // Echo the value that was read
- Serial1.write(byteRead);
- // Print the received byte for debugging
- Serial.print((char)byteRead);
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart_1.py b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart_1.py
deleted file mode 100644
index 3996cf7..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/comm/uart/arduino_uart_1.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# This work is licensed under the MIT license.
-# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
-# https://github.com/openmv/openmv/blob/master/LICENSE
-#
-# Basic UART communications between OpenMV and Arduino Uno.
-
-# 1) Wire up your OpenMV Cam to your Arduino Uno like this:
-#
-# OpenMV Cam Ground Pin ----> Arduino Ground
-# OpenMV Cam UART3_TX(P4) ----> Arduino Uno UART_RX(0)
-# OpenMV Cam UART3_RX(P5) ----> Arduino Uno UART_TX(1)
-
-# 2) Uncomment and upload the following sketch to Arduino:
-#
-# void setup() {
-# // put your setup code here, to run once:
-# Serial.begin(19200);
-# }
-#
-# void loop() {
-# // put your main code here, to run repeatedly:
-# if (Serial.available()) {
-# // Read the most recent byte
-# byte byteRead = Serial.read();
-# // ECHO the value that was read
-# Serial.write(byteRead);
-# }
-# }
-
-# 3) Run the following script in OpenMV IDE:
-
-import time
-from pyb import UART
-
-# UART 3, and baudrate.
-uart = UART(3, 19200, timeout_char=200)
-
-while True:
- uart.write("Hello World!\n")
- if uart.any():
- print(uart.read())
- time.sleep_ms(1000)
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/InternalTemperature-master.zip b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/InternalTemperature-master.zip
deleted file mode 100644
index 64b7dc4..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/InternalTemperature-master.zip
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/data_logging_teensy_temp.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/data_logging_teensy_temp.ino
deleted file mode 100644
index fcd6c64..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/data_logging_teensy_temp/data_logging_teensy_temp.ino
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <InternalTemperature.h>
-#include <SD.h>
-#include <SPI.h>
-
-File ;
-File avrage;
-const int chipSelect = BUILTIN_SDCARD;
-
-/
-
-void setup()
-{
- Serial.begin(9600);
-
- //open current loop motor values file
- current = SD.open("motor_values.csv", FILE_WRITE);
-
- while(true){
- if (current) {
- if (SD.exists((String("motor_values") + x + ".csv").c_str())){
- Serial.println(((String)"motor_values"+x+".csv already exists"));
- x++;
- } else {
- Serial.println((String)"motor_values"+x+".csv"" doesn't exist.");
- Serial.println((String)"creating motor_values"+x+".csv");
- current = SD.open(((String("motor_values") + x + ".csv").c_str()), FILE_WRITE);
- break;
- }
- }
- delay(1);
- }
- Serial.println("!!!setup complete!!!");
-}
-
-
-void loop()
-{
- String currentvals = "";
- String avrvals = "";
-
- currentvals += InternalTemperature.readTemperatureC();
- d_println("°C");
- debugdataString += "°C";
-
- //log sensor data to sensor log
- sensordataString += InternalTemperature.readTemperatureC();
- sensordataString += ", ";
-
- //open sensor log file
- File csvfile = SD.open((String("motor_values") + x + ".csv").c_str()), FILE_WRITE);
- if (csvfile) {
- csvfile.println(sensordataString);
- csvfile.close();
- }
-
- //open debug file
- File dataFile = SD.open("avrage_motor_values.txt", FILE_WRITE);
- if (dataFile) {
- dataFile.println((String)"debug data:"+debugdataString+"sensor data"+sensordataString);
- dataFile.close();
- }
- delay(1000);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/i2c_scanner/i2c_scanner.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/i2c_scanner/i2c_scanner.ino
deleted file mode 100644
index d3d4570..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/i2c_scanner/i2c_scanner.ino
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
-i2c port scanner based on:
- in wire library examples i2c_scanner
- https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino
-
-
- *
- */
-
-#include <Wire.h>
-
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-
-
-void setup() {
- Serial.begin(115200);
- while (!Serial); // Leonardo: wait for Serial Monitor
- Serial.println("\nI2C Scanner");
-
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-
-
-
-
-void scandirectports(){
- Wire.begin();
- int nDevices = 0;
- Serial.println("Scanning for i2c ports on board...");
-
- for (byte address = 1; address < 127; ++address) {
- // The i2c_scanner uses the return value of
- // the Wire.endTransmission to see if
- // a device did acknowledge to the address.
- Wire.beginTransmission(address);
- byte error = Wire.endTransmission();
-
- if (error == 0) {
- Serial.print("I2C device found at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.print(address, HEX);
- Serial.println(" !");
-
- ++nDevices;
- } else if (error == 4) {
- Serial.print("Unknown error at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.println(address, HEX);
- }
- }
- if (nDevices == 0) {
- Serial.println("No I2C devices found\n");
- } else {
- Serial.println("done\n");
- }
- Serial.println("done scanning for i2c ports on board");
-}
-void scani2cmultiplexer(){
- Serial.println("Scanning for i2c ports on i2c multiplexer...");
- for (uint8_t t=0; t<8; t++) {
- pcaselect(t);
- Serial.print("PCA Port #"); Serial.println(t);
-
- for (uint8_t addr = 0; addr<=127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
- }
- }
- }
- Serial.println("done scanning for i2c ports on i2c multiplexer");
-}
-
-
-
-void loop() {
- scandirectports();
- delay(1000);
- scani2cmultiplexer();
- delay(1000);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID/PID.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID/PID.ino
deleted file mode 100644
index c7f351a..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID/PID.ino
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <TimerThree.h>
-#include <QuickPID.h>
-
-
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-
-
-float Setpoint, Input, Output;
-float Kp = 2, Ki = 5, Kd = 1;
-QuickPID myPID(&Input, &Output, &Setpoint);
-
-
-int enA = 1; // PWM pin
-int enB = 2; // GND
-int pwm1 = 3; // Motor control pin 1
-int pwm2 = 4; // Motor control pin 2
-int encoA = 5; // Encoder pin A
-int encoB = 6; // Encoder pin B
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-1000
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-
- // PID settings
- Input = rpm;
- Setpoint = 500;
- myPID.SetTunings(Kp, Ki, Kd);
- myPID.SetMode(myPID.Control::automatic);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 1000) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 1000) value = 1000;
-
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime); // Adjust the encoder counts per revolution here if necessary
- encount = 0;
-}
-
-void resetenc() {
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped) * 0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
-}
-
-void loop() {
- Input = rpm;
- myPID.Compute();
- move(Output);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID.py b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID.py
deleted file mode 100644
index e24dbd6..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID.py
+++ /dev/null
@@ -1,131 +0,0 @@
-import serial
-import time
-from simple_pid import PID
-import matplotlib.pyplot as plt
-from matplotlib.widgets import Slider, Button
-
-# Initialize serial communication
-arduino = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=.1)
-
-# Function to write to and read from Arduino
-def write_read(x):
- arduino.write(bytes(x, 'utf-8'))
- time.sleep(0.05)
- data = arduino.readline().decode().strip()
- return data
-
-# Real-time plotting setup
-fig, (ax1, ax2) = plt.subplots(2, 1)
-feedback_list = []
-control_list = []
-setpoint_list = []
-
-def clamp(feedback, min_value, max_value):
- return max(min(feedback, max_value), min_value)
-
-def update_plot(feedback, control, setpoint):
- feedback_clamped = clamp(feedback, 0, 1000) # Clamp feedback value between 0 and 1000
- feedback_list.append(feedback_clamped)
- control_list.append(control)
- setpoint_list.append(setpoint)
-
- # Limit lists to 50 items for smoother plotting
- if len(feedback_list) > 50:
- feedback_list.pop(0)
- control_list.pop(0)
- setpoint_list.pop(0)
-
- ax1.clear()
- ax2.clear()
-
- ax1.plot(feedback_list, label="Feedback")
- ax1.plot(setpoint_list, label="Setpoint")
- ax1.legend()
-
- ax2.plot(control_list, label="Control")
- ax2.legend()
-
- ax1.set_ylabel('RPM')
- ax2.set_ylabel('Control Signal')
- ax2.set_xlabel('Time')
-
- plt.tight_layout()
- plt.pause(0.05) # Pause to allow plot to update
-
-# Initialize PID controller with output limits
-initial_setpoint = 500 # Initial setpoint
-pid = PID(0, 0, 0, output_limits=(0, 1000))
-pid.setpoint = initial_setpoint
-
-# Initialize PID parameters (preserved across resets)
-preserved_parameters = {
- 'Kp': 0,
- 'Ki': 0,
- 'Kd': 0,
- 'setpoint': initial_setpoint
-}
-
-# Function to update PID parameters
-def update_pid(val):
- pid.Kp = s_kp.val
- pid.Ki = s_ki.val
- pid.Kd = s_kd.val
- preserved_parameters['Kp'] = s_kp.val
- preserved_parameters['Ki'] = s_ki.val
- preserved_parameters['Kd'] = s_kd.val
- setpoint = s_setpoint.val
- pid.setpoint = setpoint
- preserved_parameters['setpoint'] = setpoint
- print(f"Setpoint: {setpoint}, Kp: {pid.Kp}, Ki: {pid.Ki}, Kd: {pid.Kd}")
-
-# Create sliders for PID parameters and setpoint
-axcolor = 'lightgoldenrodyellow'
-ax_setpoint = plt.axes([0.15, 0.1, 0.65, 0.03], facecolor=axcolor)
-ax_kp = plt.axes([0.15, 0.15, 0.65, 0.03], facecolor=axcolor)
-ax_ki = plt.axes([0.15, 0.2, 0.65, 0.03], facecolor=axcolor)
-ax_kd = plt.axes([0.15, 0.25, 0.65, 0.03], facecolor=axcolor)
-
-s_setpoint = Slider(ax_setpoint, 'Setpoint', 0, 1000, valinit=initial_setpoint)
-s_kp = Slider(ax_kp, 'Kp', 0, 10, valinit=preserved_parameters['Kp'])
-s_ki = Slider(ax_ki, 'Ki', 0, 10, valinit=preserved_parameters['Ki'])
-s_kd = Slider(ax_kd, 'Kd', 0, 10, valinit=preserved_parameters['Kd'])
-
-s_setpoint.on_changed(update_pid)
-s_kp.on_changed(update_pid)
-s_ki.on_changed(update_pid)
-s_kd.on_changed(update_pid)
-
-# Function to reset algorithm and set speed to zero
-def reset_algorithm(event):
- global feedback_list, control_list, setpoint_list
- feedback_list.clear()
- control_list.clear()
- setpoint_list.clear()
- pid.reset()
- s_setpoint.set_val(preserved_parameters['setpoint'])
- s_kp.set_val(preserved_parameters['Kp'])
- s_ki.set_val(preserved_parameters['Ki'])
- s_kd.set_val(preserved_parameters['Kd'])
- print("Algorithm reset")
- time.sleep(1) # Delay of 1 second after reset
-
-# Create reset button
-ax_reset = plt.axes([0.8, 0.02, 0.1, 0.05])
-btn_reset = Button(ax_reset, 'Reset')
-btn_reset.on_clicked(reset_algorithm)
-
-# Function to update Arduino with clamped control signal
-def update_arduino_control(control):
- control_clamped = clamp(control, 0, 1000)
- write_read(str(control_clamped))
-
-# Control loop
-while True:
- feedback = float(write_read(str(pid.setpoint)))
- feedback_clamped = clamp(feedback, 0, 1000) # Clamp feedback value between 0 and 1000
- control = pid(feedback_clamped)
- update_arduino_control(control)
- update_plot(feedback_clamped, control, pid.setpoint)
-
-# Keep plot open
-plt.show()
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID_autotune.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID_autotune.ino
deleted file mode 100644
index ab99c50..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/PID_autotune.ino
+++ /dev/null
@@ -1,82 +0,0 @@
-int enA = 1;
-int enB = 2;
-int pwm1 = 3;
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-int speed = 1; // speed 0-1000
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-int mess;
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Serial.begin(115200);
- Serial.setTimeout(1);
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- /*Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
- */
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*2.55;
- analogWrite(enA, sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- //Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- //Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- //Serial.println(sp);
-}
-
-void loop() {
- while (!Serial.available());
- mess = Serial.readString().toInt();
- move(mess);
- readenc();
- Serial.print(rpm);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/man_test.py b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/man_test.py
deleted file mode 100644
index 52c84e3..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/PID_autotune/man_test.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import serial
-import time
-
-arduino = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=.1)
-
-def write_read(x):
- arduino.write(bytes(x, 'utf-8'))
- time.sleep(0.05)
- data = arduino.readline()
- return data
-
-while True:
- num = input("Enter a number: ") # Taking input from user
- value = write_read(num)
- print(value) # printing the value
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master.zip b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master.zip
deleted file mode 100644
index dc713b7..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master.zip
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/.gitignore b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/.gitignore
deleted file mode 100644
index 1605aab..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-SoftPWM.h.gch \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/README.md b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/README.md
deleted file mode 100644
index 46e5456..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/README.md
+++ /dev/null
@@ -1,75 +0,0 @@
-arduino-softpwm
-===============
-
-Software PWM library for [Arduino](https://arduino.cc/), and other compatible AVR boards.
-
-AVR microcontrollers provide hardware PWM on some pins but if you need PWM on other pins then it must be implemented in software. This library provides easy and efficient software PWM on any pin. Each channel can be set to a different PWM duty cycle.
-
-This library is licensed under [BSD3](https://opensource.org/licenses/BSD-3-Clause)
-
-#### Installation
-- Download the most recent version here: https://github.com/Palatis/arduino-softpwm/archive/master.zip
-- Using Arduino IDE 1.0.x:
- - Sketch > Import Library... > Add Library... > select the downloaded file > Open
-- Using Arduino IDE 1.5+:
- - Sketch > Include Library > Add ZIP Library... > select the downloaded file > Open
-
-
-#### Usage
-See **File > Examples > arduino-softpwm > SoftPWM_example** for demonstration of library usage.
-
-Everything in this library except for preprocessor defines are wrapped in `namespace Palatis {}`, so if your compiler blames you about symbol not found, try add `Palatis::` before that thing. For example, `Palatis::SoftPWM.size()`.
-
-Alternatively, you can add `using namespace Palatis;` at the top of the source file to import everything under the `Palatis` namespace, this might be convenient if you're using my other libraries.
-
-`#define SOFTPWM_OUTPUT_DELAY` - Add this line above `#include <SoftPWM.h>` for a 1 PWM clock cycle delay between outputs to prevent large in-rush currents.
-
-`SOFTPWM_DEFINE_CHANNEL(CHANNEL, PMODE, PORT, BIT)` - Configure a pin for software PWM use. Consult the datasheet for your microcontroller for the appropriate `PORT` and `BIT` values for the physical pin. This information is shown in the pinout diagram, for example: [ATmega328P datasheet](http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Summary.pdf) **Figure 1-1** found on page 3. If you want to determine the Arduino pin assigned to the physical pin http://www.pighixxx.com/test/pinoutspg/boards/ provides this information for the most popular Arduino boards or you can look at the pins_arduino.h file in the **variant** folder used by your board.
-- Parameter: **CHANNEL** - The channel number is used as an ID for the pin.
-- Parameter: **PMODE** - DDRx register of the pin's port. Append the port letter to `DDR`. For example: The [Arduino UNO diagram](http://www.pighixxx.com/test/portfolio-items/uno/?portfolioID=314) shows that Arduino pin 13 is **PB5** which means that the port is **B** so you should use the value `DDRB` for that pin.
-- Parameter: **PORT** - The port of the pin. For example: Arduino pin 13 is **PB5** so you should use the value `PORTB` for that pin.
-- Parameter: **BIT** - The bit of the pin. For example: Arduino pin 13 is **PB5** so you should use the value `PORTB5` for that pin.
-
-`SOFTPWM_DEFINE_CHANNEL_INVERT( CHANNEL, PMODE, PORT, BIT )` - Depending on your application you may prefer to invert the output. See `SOFTPWM_DEFINE_CHANNEL()` for description of parameters.
-
-`SOFTPWM_DEFINE_OBJECT(CHANNEL_CNT)` - Define the softPWM object with the default 256 PWM levels.
-- Parameter: **CHANNEL_CNT** - The number of channels that are defined.
-
-`SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS)` - Define the softPWM object with the specified number of PWM levels.
-- Parameter: **CHANNEL_CNT** - The number of channels that are defined.
-- Parameter: **PWM_LEVELS** - The number of PWM levels. Using less PWM levels may allow a higher PWM frequency. The maximum value is 256.
-
-`SOFTPWM_DEFINE_EXTERN_OBJECT(CHANNEL_CNT)` - Add this if you want to use the SoftPWM object outside where it's defined. See `SOFTPWM_DEFINE_OBJECT()` for description of the parameter.
-
-`SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS)` - Add this if you want to use the SoftPWM object outside where it's defined. See `SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS()` for description of parameters.
-
-`SoftPWM.begin(hertz)` - Initialize SoftPWM.
-- Parameter: **hertz** - The PWM frequency. Setting the value too high will cause incorrect operation, too low will cause a visible flicker.
- - Type: long
-
-`SoftPWM.printInterruptLoad()` - Prints diagnostic information to the serial monitor. This can be used to find the optimal PWM frequency by setting different PWM frequency values in begin() and then checking the resulting interrupt load. Calling this function will momentarily turn off the PWM on all channels.
-
-`SoftPWM.set(channel_idx, value)` - Set the PWM level of the given channel.
-- Parameter: **channel_idx** - The channel to set.
- - Type: int
-- Parameter: **value** - The PWM level to set.
- - Type: byte
-
-`SoftPWM.size()`
-- Returns: Number of channels defined.
- - Type: size_t
-
-`SoftPWM.PWMlevels()`
-- Returns: The number of PWM levels.
- - Type: unsigned int
-
-`SoftPWM.allOff()` - Set the PWM value of all channels to 0.
-
-
-#### Troubleshooting
-- LEDs have a visible flicker, especially noticeable when the LED is moving relative to the viewer.
- - The PWM frequency set in `SoftPWM.begin()` is too low. Use `SoftPWM.printInterruptLoad()` to determine the optimum PWM frequency. You may be able to achieve a higher PWM frequency by setting less PWM levels with `SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS()` or `SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS()`.
-- Erratic PWM operation
- - The interrupt load is too high. Use `SoftPWM.printInterruptLoad()` to determine the interrupt load. You can decrease the interrupt load by setting less PWM levels with `SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS()` or `SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS()` or setting the PWM frequency lower in `SoftPWM.begin()`.
-- LED brightness changes between low brightness PWM values are larger than at brighter PWM values.
- - This is caused by the way LEDs work and is not caused by a problem with the library. If possible, use more PWM levels or never allow the LED to get dimmer than the level below which the difference between PWM levels is too distinct.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino
deleted file mode 100644
index 96fc0b2..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- Arduino-SoftPWM: a software PWM library for Arduino
- Copyright 2016, Victor Tseng <palatis@gmail.com>
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <SoftPWM.h>
-
-/* pins_arduino.h defines the pin-port/bit mapping as PROGMEM so
- you have to read them with pgm_read_xxx(). That's generally okay
- for ordinary use, but really bad when you're writing super fast
- codes because the compiler doesn't treat them as constants and
- cannot optimize them away with sbi/cbi instructions.
-
- Therefore we have to tell the compiler the PORT and BIT here.
- Hope someday we can find a way to workaround this.
-
- Check the manual of your MCU for port/bit mapping.
-
- The following example demonstrates setting channels for all pins
- on the ATmega328P or ATmega168 used on Arduino Uno, Pro Mini,
- Nano and other boards. */
-SOFTPWM_DEFINE_CHANNEL(0, DDRD, PORTD, PORTD0); //Arduino pin 0
-SOFTPWM_DEFINE_CHANNEL(1, DDRD, PORTD, PORTD1); //Arduino pin 1
-SOFTPWM_DEFINE_CHANNEL(2, DDRD, PORTD, PORTD2); //Arduino pin 2
-SOFTPWM_DEFINE_CHANNEL(3, DDRD, PORTD, PORTD3); //Arduino pin 3
-SOFTPWM_DEFINE_CHANNEL(4, DDRD, PORTD, PORTD4); //Arduino pin 4
-SOFTPWM_DEFINE_CHANNEL(5, DDRD, PORTD, PORTD5); //Arduino pin 5
-SOFTPWM_DEFINE_CHANNEL(6, DDRD, PORTD, PORTD6); //Arduino pin 6
-SOFTPWM_DEFINE_CHANNEL(7, DDRD, PORTD, PORTD7); //Arduino pin 7
-SOFTPWM_DEFINE_CHANNEL(8, DDRB, PORTB, PORTB0); //Arduino pin 8
-SOFTPWM_DEFINE_CHANNEL(9, DDRB, PORTB, PORTB1); //Arduino pin 9
-SOFTPWM_DEFINE_CHANNEL(10, DDRB, PORTB, PORTB2); //Arduino pin 10
-SOFTPWM_DEFINE_CHANNEL(11, DDRB, PORTB, PORTB3); //Arduino pin 11
-SOFTPWM_DEFINE_CHANNEL(12, DDRB, PORTB, PORTB4); //Arduino pin 12
-SOFTPWM_DEFINE_CHANNEL(13, DDRB, PORTB, PORTB5); //Arduino pin 13
-SOFTPWM_DEFINE_CHANNEL(14, DDRC, PORTC, PORTC0); //Arduino pin A0
-SOFTPWM_DEFINE_CHANNEL(15, DDRC, PORTC, PORTC1); //Arduino pin A1
-SOFTPWM_DEFINE_CHANNEL(16, DDRC, PORTC, PORTC2); //Arduino pin A2
-SOFTPWM_DEFINE_CHANNEL(17, DDRC, PORTC, PORTC3); //Arduino pin A3
-SOFTPWM_DEFINE_CHANNEL(18, DDRC, PORTC, PORTC4); //Arduino pin A4
-SOFTPWM_DEFINE_CHANNEL(19, DDRC, PORTC, PORTC5); //Arduino pin A5
-
-
-/* Or you may want inverted outputs: */
-/*
- SOFTPWM_DEFINE_CHANNEL_INVERT(0, DDRD, PORTD, PORTD0); //Arduino pin 0
- SOFTPWM_DEFINE_CHANNEL_INVERT(1, DDRD, PORTD, PORTD1); //Arduino pin 1
- SOFTPWM_DEFINE_CHANNEL_INVERT(2, DDRD, PORTD, PORTD2); //Arduino pin 2
- SOFTPWM_DEFINE_CHANNEL_INVERT(3, DDRD, PORTD, PORTD3); //Arduino pin 3
- SOFTPWM_DEFINE_CHANNEL_INVERT(4, DDRD, PORTD, PORTD4); //Arduino pin 4
- SOFTPWM_DEFINE_CHANNEL_INVERT(5, DDRD, PORTD, PORTD5); //Arduino pin 5
- SOFTPWM_DEFINE_CHANNEL_INVERT(6, DDRD, PORTD, PORTD6); //Arduino pin 6
- SOFTPWM_DEFINE_CHANNEL_INVERT(7, DDRD, PORTD, PORTD7); //Arduino pin 7
- SOFTPWM_DEFINE_CHANNEL_INVERT(8, DDRB, PORTB, PORTB0); //Arduino pin 8
- SOFTPWM_DEFINE_CHANNEL_INVERT(9, DDRB, PORTB, PORTB2); //Arduino pin 9
- SOFTPWM_DEFINE_CHANNEL_INVERT(10, DDRB, PORTB, PORTB2); //Arduino pin 10
- SOFTPWM_DEFINE_CHANNEL_INVERT(11, DDRB, PORTB, PORTB3); //Arduino pin 11
- SOFTPWM_DEFINE_CHANNEL_INVERT(12, DDRB, PORTB, PORTB4); //Arduino pin 12
- SOFTPWM_DEFINE_CHANNEL_INVERT(13, DDRB, PORTB, PORTB5); //Arduino pin 13
- SOFTPWM_DEFINE_CHANNEL_INVERT(14, DDRC, PORTC, PORTC0); //Arduino pin A0
- SOFTPWM_DEFINE_CHANNEL_INVERT(15, DDRC, PORTC, PORTC1); //Arduino pin A1
- SOFTPWM_DEFINE_CHANNEL_INVERT(16, DDRC, PORTC, PORTC2); //Arduino pin A2
- SOFTPWM_DEFINE_CHANNEL_INVERT(17, DDRC, PORTC, PORTC3); //Arduino pin A3
- SOFTPWM_DEFINE_CHANNEL_INVERT(18, DDRC, PORTC, PORTC4); //Arduino pin A4
- SOFTPWM_DEFINE_CHANNEL_INVERT(19, DDRC, PORTC, PORTC5); //Arduino pin A5
-*/
-
-/* Here you make an instance of desired channel counts you want
- with the default 256 PWM levels (0 ~ 255). */
-//SOFTPWM_DEFINE_OBJECT(20);
-
-/* Or you can make one with only 100 PWM levels (0 ~ 99).
- By using less PWM levels, you may be able to use higher
- pwm frequencies. */
-SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(20, 100);
-
-/* If you want to use the SoftPWM object outside where it's defined,
- add the following line to the file. */
-//SOFTPWM_DEFINE_EXTERN_OBJECT(16);
-SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(20, 100);
-
-void setup() {
- Serial.begin(19200);
-
- // begin with 60hz pwm frequency
- Palatis::SoftPWM.begin(60);
-
- // print interrupt load for diagnostic purposes
- Palatis::SoftPWM.printInterruptLoad();
-}
-
-static volatile uint8_t v = 0;
-void loop() {
- for (uint8_t i = 0; i < Palatis::SoftPWM.size(); ++i) {
- Serial.print(micros());
- Serial.print(" loop(): ");
- Serial.println(i);
-
- unsigned long const WAIT = 1000000 / Palatis::SoftPWM.PWMlevels() / 2;
- unsigned long nextMicros = 0;
- for (int v = 0; v < Palatis::SoftPWM.PWMlevels() - 1; ++v) {
- while (micros() < nextMicros);
- nextMicros = micros() + WAIT;
- Palatis::SoftPWM.set(i, v);
- }
- for (int v = Palatis::SoftPWM.PWMlevels() - 1; v >= 0; --v) {
- while (micros() < nextMicros);
- nextMicros = micros() + WAIT;
- Palatis::SoftPWM.set(i, v);
- }
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/keywords.txt b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/keywords.txt
deleted file mode 100644
index 61d42b7..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/keywords.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-#######################################
-# Syntax Coloring Map SoftPWM
-#######################################
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-Palatis KEYWORD1
-SoftPWM KEYWORD1
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-begin KEYWORD2
-set KEYWORD2
-size KEYWORD2
-PWMlevels KEYWORD2
-allOff KEYWORD2
-update KEYWORD2
-printInterruptLoad KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-SOFTPWM_DEFINE_PINMODE LITERAL1
-SOFTPWM_DEFINE_CHANNEL LITERAL1
-SOFTPWM_DEFINE_CHANNEL_INVERT LITERAL1
-SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS LITERAL1
-SOFTPWM_DEFINE_OBJECT LITERAL1
-SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS LITERAL1
-SOFTPWM_DEFINE_EXTERN_OBJECT LITERAL1
-SOFTPWM_OUTPUT_DELAY LITERAL1
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/library.properties b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/library.properties
deleted file mode 100644
index 174c19b..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/library.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-name=arduino-softpwm
-version=1.0.1
-author=Victor Tseng <palatis@gmail.com>
-maintainer=Victor Tseng <palatis@gmail.com>
-sentence=Software PWM library for Arduino.
-paragraph=Provides PWM on any pin.
-category=Signal Input/Output
-url=https://github.com/Palatis/arduino-softpwm
-architectures=avr
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/src/SoftPWM.h b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/src/SoftPWM.h
deleted file mode 100644
index c315a4e..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/arduino-softpwm-master/src/SoftPWM.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- Arduino-SoftPWM: a software PWM library for Arduino
- Copyright 2016, Victor Tseng <palatis@gmail.com>
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef _SOFTPWM_H_
-#define _SOFTPWM_H_
-
-#include <Arduino.h>
-
-// helper macros
-#define SOFTPWM_DEFINE_PINMODE(CHANNEL, PMODE, PORT, BIT) \
- namespace Palatis { \
- template <> \
- inline void pinModeStatic<CHANNEL>(uint8_t const mode) { \
- if (mode == INPUT) { \
- bitClear(PMODE, BIT); bitClear(PORT, BIT); \
- } \
- else if (mode == INPUT_PULLUP) { \
- bitClear(PMODE, BIT); bitSet(PORT, BIT); \
- } \
- else { \
- bitSet(PMODE, BIT); \
- } \
- } \
- }
-
-#define SOFTPWM_DEFINE_CHANNEL(CHANNEL, PMODE, PORT, BIT) \
- namespace Palatis { \
- template <> \
- inline void bitWriteStatic<CHANNEL>(bool const value) { \
- bitWrite( PORT, BIT, value ); \
- } \
- } \
- SOFTPWM_DEFINE_PINMODE(CHANNEL, PMODE, PORT, BIT)
-
-#define SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, PMODE, PORT, BIT) \
- namespace Palatis { \
- template <> \
- inline void bitWriteStatic<CHANNEL>(bool const value) { \
- bitWrite(PORT, BIT, !value); \
- } \
- } \
- SOFTPWM_DEFINE_PINMODE(CHANNEL, PMODE, PORT, BIT)
-
-#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
-#define SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS) \
- namespace Palatis { \
- CSoftPWM<CHANNEL_CNT, PWM_LEVELS> SoftPWM; \
- } \
- ISR(TIM1_COMPA_vect) { \
- interrupts(); \
- Palatis::SoftPWM.update(); \
- }
-#else
- #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__)
- #define TIMSK1 TIMSK
- #endif
-#define SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS) \
- namespace Palatis { \
- CSoftPWM<CHANNEL_CNT, PWM_LEVELS> SoftPWM; \
- } \
- ISR(TIMER1_COMPA_vect) { \
- interrupts(); \
- Palatis::SoftPWM.update(); \
- }
-#endif
-
-#define SOFTPWM_DEFINE_OBJECT(CHANNEL_CNT) \
- SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, 0)
-
-#define SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS) \
- namespace Palatis { \
- extern CSoftPWM<CHANNEL_CNT, PWM_LEVELS> SoftPWM; \
- }
-
-#define SOFTPWM_DEFINE_EXTERN_OBJECT(CHANNEL_CNT) \
- SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, 0)
-
-// here comes the magic @o@
-namespace Palatis {
-
-template <int channel> inline void bitWriteStatic(bool value) {}
-template <int channel> inline void pinModeStatic(uint8_t mode) {}
-
-template <int channel>
-struct bitWriteStaticExpander {
- void operator() (bool value) const {
- bitWriteStatic<channel>(value);
- bitWriteStaticExpander < channel - 1 > ()(value);
- }
-
- void operator() (uint8_t const &count, uint8_t const * const &channels) const {
-#ifdef SOFTPWM_OUTPUT_DELAY
- bitWriteStatic<channel>((count + channel) < channels[channel]);
-#else
- bitWriteStatic<channel>(count < channels[channel]);
-#endif
- bitWriteStaticExpander < channel - 1 > ()(count, channels);
- }
-};
-
-template <>
-struct bitWriteStaticExpander < -1 > {
- void operator() (bool) const {}
- void operator() (uint8_t const &, uint8_t const * const &) const {}
-};
-
-template <int channel>
-struct pinModeStaticExpander {
- void operator() (uint8_t const mode) const
- {
- pinModeStatic<channel>(mode);
- pinModeStaticExpander < channel - 1 > ()(mode);
- }
-};
-
-template <>
-struct pinModeStaticExpander < -1 > {
- void operator() (uint8_t const mode) const {}
-};
-
-template <unsigned int num_channels, unsigned int num_PWM_levels>
-class CSoftPWM {
- public:
- void begin(const unsigned long hertz) {
- allOff(); //this prevents inverted channels from momentarily going LOW
- asm volatile ("/************ pinModeStaticExpander begin ************/");
- const uint8_t oldSREG = SREG;
- noInterrupts();
- pinModeStaticExpander < num_channels - 1 > ()( OUTPUT );
- SREG = oldSREG;
- asm volatile ("/************ pinModeStaticExpander end ************/");
-
- /* the setup of timer1 is stolen from ShiftPWM :-P
- http://www.elcojacobs.com/shiftpwm/ */
- asm volatile ("/************ timer setup begin ************/");
- TCCR1A = 0b00000000;
- TCCR1B = 0b00001001;
- OCR1A = (F_CPU - hertz * PWMlevels() / 2) / (hertz * PWMlevels());
- bitSet(TIMSK1, OCIE1A);
- asm volatile ("/************ timer setup end ************/");
-
- _count = 0;
- }
-
- void set(const int channel_idx, const uint8_t value) {
- _channels[channel_idx] = value;
- }
-
- size_t size() const {
- return num_channels;
- }
-
- unsigned int PWMlevels() const {
- return num_PWM_levels ? num_PWM_levels : 256;
- }
-
- void allOff() {
- asm volatile ("/********** CSoftPWM::allOff() begin **********/");
- const uint8_t oldSREG = SREG;
- noInterrupts();
- for (int i = 0; i < num_channels; ++i)
- _channels[i] = 0;
- bitWriteStaticExpander < num_channels - 1 > ()(false);
- SREG = oldSREG;
- asm volatile ("/********** CSoftPWM::allOff() end **********/");
- }
-
- /* This function cannot be private because the ISR uses it, and I have
- no idea about how to make friends with ISR. :-( */
- void update() __attribute__((always_inline)) {
- asm volatile ("/********** CSoftPWM::update() begin **********/");
- const uint8_t count = _count;
- bitWriteStaticExpander < num_channels - 1 > ()(count, _channels);
- ++_count;
- if (_count == PWMlevels())
- _count = 0;
- asm volatile ("/********** CSoftPWM::update() end **********/");
- }
-
- #if defined(HAVE_HWSERIAL0)
- /* this function is stolen from ShiftPWM :-P
- http://www.elcojacobs.com/shiftpwm/ */
- void printInterruptLoad() {
- unsigned long time1, time2;
-
- bitSet(TIMSK1, OCIE1A); // enable interrupt
- time1 = micros();
- delayMicroseconds(5000);
- time1 = micros() - time1;
-
- bitClear(TIMSK1, OCIE1A); // disable interrupt
- time2 = micros();
- delayMicroseconds(5000);
- time2 = micros() - time2;
-
- const double load = static_cast<double>(time1 - time2) / time1;
- const double interrupt_frequency = static_cast<double>(F_CPU) / (OCR1A + 1);
- const double cycles_per_interrupt = load * F_CPU / interrupt_frequency;
-
- Serial.println(F("SoftPWM::printInterruptLoad():"));
- Serial.print(F(" Load of interrupt: "));
- Serial.println(load, 10);
- Serial.print(F(" Clock cycles per interrupt: "));
- Serial.println( cycles_per_interrupt );
- Serial.print(F(" Interrupt frequency: "));
- Serial.print(interrupt_frequency);
- Serial.println(F(" Hz"));
- Serial.print(F(" PWM frequency: "));
- Serial.print(interrupt_frequency / PWMlevels());
- Serial.println(F(" Hz"));
- Serial.print(F(" PWM levels: "));
- Serial.println(PWMlevels());
-
- bitSet(TIMSK1, OCIE1A); // enable interrupt again
- }
- #endif
-
- private:
- uint8_t _channels[num_channels];
- uint8_t _count;
-};
-
-} // namespace Palatis
-#endif // #ifndef _SOFTPWM_H_
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/calibrated_motor/calibrated_motor.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/calibrated_motor/calibrated_motor.ino
deleted file mode 100644
index 60e2c04..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/calibrated_motor/calibrated_motor.ino
+++ /dev/null
@@ -1,155 +0,0 @@
-#include <TimerThree.h>
-
-#define ArrayElementCount(needRPM) (sizeof(needRPM) / sizeof(needRPM[0]))
-
-int enA = 1; //PWM pin
-int enB = 2; //GND
-int pwm1 = 3; //
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-const int maxspeed = 1000;
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-int motordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-int needRPM = 41;
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- //Serial.print("softPWM pin: enA, value: ");
- //Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- //Serial.print("RPM: ");
- //Serial.print(rpm);
- //Serial.print(" Sample period:");
- //Serial.print(Ptime);
- //Serial.print("ms, encoder count:");
- //Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- //Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- //Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- //Serial.println(sp);
-}
-void RPMmove(int Rsped) {
- int idx = nearest(Rsped, motordata, ArrayElementCount(motordata));
- move(idx);
-}
-
-
-void loop() {
- for (int i = 0; i < maxspeed; i++) {
- Serial.print(motordata[i]);
- Serial.print(", ");
- }
- Serial.println("");
- int idx = nearest(needRPM, motordata, ArrayElementCount(motordata));
- Serial.print(needRPM);
- Serial.print(", ");
- Serial.print(idx);
- Serial.print(", ");
- Serial.println(motordata[idx]);
- delay(2500);
- move(idx);
- delay(1000);
- resetenc();
- delay(100);
- readenc();
- Serial.println(rpm);
- delay(10);
-
-
-
-}
-int nearest(int x, int myArray[], int elements)
-{
- //https://forum.arduino.cc/t/search-for-nearest-number-in-an-array-help/245843/5
- int idx = 0; // by default near first element
-
- int distance = abs(myArray[idx] - x);
- for (int i = 1; i < elements; i++)
- {
- int d = abs(myArray[i] - x);
- if (d < distance)
- {
- idx = i;
- distance = d;
- }
- }
- return idx;
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/kiwidrive_calc.svg b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/kiwidrive_calc.svg
deleted file mode 100644
index 3ca09e2..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/kiwidrive_calc.svg
+++ /dev/null
@@ -1,323 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="210mm"
- height="297mm"
- viewBox="0 0 210 297"
- version="1.1"
- id="svg8"
- inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
- sodipodi:docname="kiwidrive_calc.svg">
- <defs
- id="defs2" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1.4"
- inkscape:cx="350.96101"
- inkscape:cy="562.71867"
- inkscape:document-units="mm"
- inkscape:current-layer="layer1"
- inkscape:document-rotation="0"
- showgrid="false"
- inkscape:window-width="1920"
- inkscape:window-height="1125"
- inkscape:window-x="2560"
- inkscape:window-y="0"
- inkscape:window-maximized="1" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1">
- <ellipse
- style="fill:#ff0000;fill-rule:evenodd;stroke-width:0.264583"
- id="path10"
- cx="99.888367"
- cy="134.68913"
- rx="39.564999"
- ry="38.587662" />
- <path
- style="fill:#a0a0a0;stroke:none;stroke-width:0.0944941"
- d="m 139.72661,146.01799 c -1.63175,-1.14292 -2.20174,-11.72757 -0.90654,-16.83422 0.39799,-1.56917 0.89479,-2.32023 1.34986,-2.04073 0.45996,0.2825 0.99183,1.8708 1.27726,3.81422 0.51922,3.53519 0.43362,9.37384 -0.18105,12.34962 -0.43334,2.09796 -0.99722,3.09095 -1.53953,2.71111 z"
- id="path22" />
- <path
- style="fill:#a0a0a0;stroke:none;stroke-width:0.0944941"
- d="m 63.718331,112.73542 c -0.31847,-1.96659 6.871434,-9.75535 11.435089,-12.38756 1.402322,-0.808823 2.287091,-0.976383 2.404045,-0.455293 0.1182,0.526683 -0.64948,2.015393 -1.843555,3.575053 -2.17208,2.83712 -6.417053,6.84677 -8.978746,8.48104 -1.806017,1.15218 -2.910982,1.44035 -3.016833,0.78676 z"
- id="path22-3" />
- <path
- style="fill:#a0a0a0;stroke:none;stroke-width:0.0944941"
- d="m 74.709966,169.73071 c -1.970594,0.29267 -9.664519,-6.99861 -12.236726,-11.59635 -0.790382,-1.4128 -0.946345,-2.29969 -0.423758,-2.4098 0.528179,-0.11131 2.0067,0.67581 3.550588,1.89022 2.808431,2.20905 6.762138,6.50618 8.362712,9.08905 1.12843,1.82096 1.402097,2.9296 0.747184,3.02688 z"
- id="path22-3-6"
- inkscape:transform-center-x="37.420481"
- inkscape:transform-center-y="-21.837511" />
- <rect
- style="fill:#0000ff;fill-rule:evenodd;stroke-width:0.264583"
- id="rect64"
- width="186.92551"
- height="1.8174417"
- x="17.333752"
- y="135.38728" />
- <rect
- style="fill:#0000ff;fill-rule:evenodd;stroke-width:0.264583"
- id="rect64-7"
- width="186.92551"
- height="1.8174417"
- x="31.72876"
- y="-100.25121"
- transform="rotate(89.560511)" />
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="197.80376"
- y="132.93736"
- id="text88"><tspan
- sodipodi:role="line"
- id="tspan86"
- x="197.80376"
- y="132.93736"
- style="stroke-width:0.264583">x</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="101.31552"
- y="42.965397"
- id="text92"><tspan
- sodipodi:role="line"
- id="tspan90"
- x="101.31552"
- y="42.965397"
- style="stroke-width:0.264583">y</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="92.677986"
- y="145.29591"
- id="text96"><tspan
- sodipodi:role="line"
- id="tspan94"
- x="92.677986"
- y="145.29591"
- style="stroke-width:0.264583">0</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="142.35989"
- y="149.98514"
- id="text96-5"><tspan
- sodipodi:role="line"
- id="tspan94-3"
- x="142.35989"
- y="149.98514"
- style="stroke-width:0.264583">1</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="94.360558"
- y="101.32148"
- id="text96-5-5"><tspan
- sodipodi:role="line"
- id="tspan94-3-6"
- x="94.360558"
- y="101.32148"
- style="stroke-width:0.264583">1</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="46.688869"
- y="147.24464"
- id="text96-5-5-2"><tspan
- sodipodi:role="line"
- x="46.688869"
- y="147.24464"
- style="stroke-width:0.264583"
- id="tspan170">-1</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="88.356491"
- y="186.57739"
- id="text96-5-5-2-1"><tspan
- sodipodi:role="line"
- x="88.356491"
- y="186.57739"
- style="stroke-width:0.264583"
- id="tspan170-2">-1</tspan></text>
- <circle
- id="path198"
- style="fill:#000000;stroke:#000000;stroke-width:0.264583"
- cx="144.59926"
- cy="132.06937"
- r="0.012488274" />
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="140.65088"
- y="140.43587"
- id="text202"><tspan
- sodipodi:role="line"
- id="tspan200"
- x="140.65088"
- y="140.43587"
- style="font-size:4.23333px;stroke-width:0.264583">0rad</tspan><tspan
- sodipodi:role="line"
- x="140.65088"
- y="153.66498"
- style="stroke-width:0.264583"
- id="tspan204" /></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:4.23333px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="59.606441"
- y="102.25119"
- id="text208"><tspan
- sodipodi:role="line"
- id="tspan206"
- x="59.606441"
- y="102.25119"
- style="font-size:4.23333px;stroke-width:0.264583">2.09rad</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:4.23333px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="53.299278"
- y="167.29311"
- id="text212"><tspan
- sodipodi:role="line"
- id="tspan210"
- x="53.299278"
- y="167.29311"
- style="font-size:4.23333px;stroke-width:0.264583">4.18rad</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="142.78784"
- y="135.75781"
- id="text216"><tspan
- sodipodi:role="line"
- id="tspan214"
- x="142.78784"
- y="135.75781"
- style="stroke-width:0.264583">A</tspan><tspan
- sodipodi:role="line"
- x="142.78784"
- y="148.98694"
- style="stroke-width:0.264583"
- id="tspan218" /><tspan
- sodipodi:role="line"
- x="142.78784"
- y="162.21606"
- style="stroke-width:0.264583"
- id="tspan220" /></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="68.655945"
- y="112.41339"
- id="text216-7"><tspan
- sodipodi:role="line"
- id="tspan214-0"
- x="68.655945"
- y="112.41339"
- style="stroke-width:0.264583">B</tspan><tspan
- sodipodi:role="line"
- x="68.655945"
- y="125.64252"
- style="stroke-width:0.264583"
- id="tspan218-9" /><tspan
- sodipodi:role="line"
- x="68.655945"
- y="138.87164"
- style="stroke-width:0.264583"
- id="tspan220-3" /></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="67.528885"
- y="164.8815"
- id="text216-7-6"><tspan
- sodipodi:role="line"
- id="tspan214-0-0"
- x="67.528885"
- y="164.8815"
- style="stroke-width:0.264583">C</tspan><tspan
- sodipodi:role="line"
- x="67.528885"
- y="178.11063"
- style="stroke-width:0.264583"
- id="tspan298" /><tspan
- sodipodi:role="line"
- x="67.528885"
- y="191.33975"
- style="stroke-width:0.264583"
- id="tspan218-9-6" /><tspan
- sodipodi:role="line"
- x="67.528885"
- y="204.56888"
- style="stroke-width:0.264583"
- id="tspan220-3-2" /></text>
- <rect
- style="fill:#c900ff;fill-opacity:1;fill-rule:evenodd;stroke-width:0.264583"
- id="rect318"
- width="40.081783"
- height="3.5191765"
- x="-9.3766651"
- y="166.49748"
- transform="rotate(-39.971721)" />
- <rect
- style="fill:#c900ff;fill-opacity:1;fill-rule:evenodd;stroke-width:0.12328"
- id="rect318-6"
- width="27.441587"
- height="1.1159221"
- x="104.34172"
- y="135.77676"
- transform="matrix(0.99998555,0.0053753,-0.01704694,0.99985469,0,0)" />
- <rect
- style="fill:#c900ff;fill-opacity:1;fill-rule:evenodd;stroke-width:0.127056"
- id="rect318-6-1"
- width="29.147621"
- height="1.1159564"
- x="-135.70338"
- y="128.97763"
- transform="matrix(-0.00379001,-0.99999282,0.9999488,0.01011907,0,0)" />
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:4.58611px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="102.17614"
- y="135.32759"
- id="text208-8"><tspan
- sodipodi:role="line"
- id="tspan206-7"
- x="102.17614"
- y="135.32759"
- style="font-size:4.58611px;stroke-width:0.264583">0.52rad</tspan></text>
- <rect
- style="fill:#c98b00;fill-opacity:1;fill-rule:evenodd;stroke-width:0.121786"
- id="rect318-6-1-0"
- width="26.779816"
- height="1.1159475"
- x="-135.58972"
- y="138.72464"
- transform="matrix(-0.00412511,-0.99999149,0.99995678,0.00929711,0,0)" />
- </g>
-</svg>
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swp b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swp
deleted file mode 100644
index 3b62227..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swp
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/avrage_motor_values.dat b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/avrage_motor_values.dat
deleted file mode 100644
index dbbfee0..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/example_outp/avrage_motor_values.dat
+++ /dev/null
@@ -1 +0,0 @@
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910, \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/motor_calibration.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/motor_calibration.ino
deleted file mode 100644
index 362d130..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motor_calibration/motor_calibration.ino
+++ /dev/null
@@ -1,231 +0,0 @@
-#include <TimerThree.h>
-#include <SD.h>
-#include <SPI.h>
-
-int enA = 1; //PWM pin
-int enB = 2; //GND
-int pwm1 = 3; //
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-const int maxspeed = 1000;
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-File ;
-File avrage;
-Sd2Card card;
-SdVolume volume;
-SdFile root;
-const int chipSelect = BUILTIN_SDCARD;
-int x = 1;
-
-int Nloop = 0;
-int totloopdata[maxspeed] = {};
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- //Serial.print("softPWM pin: enA, value: ");
- //Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- //Serial.print("RPM: ");
- //Serial.print(rpm);
- //Serial.print(" Sample period:");
- //Serial.print(Ptime);
- //Serial.print("ms, encoder count:");
- //Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- //Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- //Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- //Serial.println(sp);
-}
-
-void loop() {
- move(0);
- //max
- /*
- Serial.println();
- Serial.println();
- Serial.println();
- move(maxspeed);
- Serial.print("max speed: ");
- delay(1000);
- resetenc();
- delay(1000);
- readenc();
- Serial.print(rpm);
- Serial.print("rpm, with input: ");
- Serial.println(maxspeed);
- delay(250);
- move(0);
-
- //min
- delay(5000);
- Serial.print("min speed: ");
- for (int i = 0; i < maxspeed; i++) {
- move(i);
- delay(1000);
- readenc();
- if ((rpm > 10) && (i>5)) {
- Serial.print(rpm);
- Serial.print("rpm, with input: ");
- Serial.println(i);
- break;
- }
- }
- */
- delay(2000);
- for (int i = 0; i < maxspeed; i++) {
- Serial.println("0,0");
- }
- int currentloopdata[maxspeed] = {};
- for (int i = 0; i < maxspeed; i++) {
- move(i);
- delay(100);
- readenc();
- Serial.print(i);
- Serial.print(",");
- Serial.print(rpm);
- currentloopdata[i] = rpm;
- Serial.print(",");
- Serial.println(totloopdata[i]);
- }
- /*
- for (int i = 0; i < maxspeed; i++) {
- move(0);
- delay(200);
- move(i);
- delay(1000);
- resetenc();
- delay(100);
- readenc();
- Serial.print(i);
- Serial.print(",");
- Serial.print(rpm);
- currentloopdata[i] = rpm;
- Serial.print(",");
- Serial.println(totloopdata[i]);
- }
- */
- currentloopdata[0] = 0;
- if (Nloop == 0){
- for (int i = 0; i < maxspeed; i++) {
- totloopdata[i] = currentloopdata[i];
- }
- }else{
- for (int i = 0; i < maxspeed; i++) {
- //Serial.print(currentloopdata[i]);
- //Serial.print(", ");
- //Serial.print(totloopdata[i]);
- totloopdata[i] = ((totloopdata[i]*Nloop)+currentloopdata[i])/(Nloop+1);
- }
- }
- for (int i = 0; i < maxspeed; i++) {
- //Serial.print(currentloopdata[i]);
- //Serial.print(", ");
- }
-
- resetenc();
- SD.remove("avrage_motor_values.dat");
- File dataFile = SD.open("avrage_motor_values.dat", FILE_WRITE);
- if (dataFile) {
- for (int i = 0; i < maxspeed; i++) {
- dataFile.print(totloopdata[i]);
- dataFile.print(", ");
- }
- dataFile.close();
- }
- SD.remove("avrage_motor_values.csv");
- File debugFile = SD.open("avrage_motor_values.csv", FILE_WRITE);
- if (debugFile) {
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(totloopdata[i]);
- }
- }
-
- if (!card.init(SPI_HALF_SPEED, chipSelect)) {
- Serial.println("FAILED TO FIND SD CARD");
- Serial.println("* is a card inserted?");
- Serial.println("* is your wiring correct?");
- Serial.println("* did you change the chipSelect pin to match your shield or module?");
- }
-
-
- Nloop++;
-
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motordriver.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motordriver.ino
deleted file mode 100644
index 2f1c225..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/motordriver.ino
+++ /dev/null
@@ -1,386 +0,0 @@
-#include <Adafruit_MCP23X17.h>
-#include <TimerThree.h>
-//moveohmi = https://stackoverflow.com/questions/3748037/how-to-control-a-kiwi-drive-robot
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
-
-
-#define ArrayElementCount(needRPM) (sizeof(needRPM) / sizeof(needRPM[0]))
-
-// motor one/A front
-#define m1enA 3 // GPA3 PWM1
-#define m1enB 2 // GPA2
-#define m1pwm1 0 // GPA0
-#define m1pwm2 1 // GPA1
-#define m1encA 12 // GPB4
-#define m1encB 13 // GPB5
-// motor two/B left
-#define m2enA 7 // GPA7 PWM2
-#define m2enB 6 // GPA6
-#define m2pwm1 4 // GPA4
-#define m2pwm2 5 // GPA5
-#define m2encA 14 // GPB6
-#define m2encB 15 // GPB7
-// motor three/C right
-#define m3enA 11 // GPB3 PWM3
-#define m3enB 10 // GPB2
-#define m3pwm1 8 // GPB0
-#define m3pwm2 9 // GPB1
-#define m3encA 24 // teensy port 24
-#define m3encB 9 // teensy port 9
-
-double sp = 1200.000; //speed in RPM ~0-1800
-const int maxspeed = 1000;
-
-//calibration data
-int Amotordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-int Bmotordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-int Cmotordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-
-int AneedRPM = 0;
-int BneedRPM = 0;
-int CneedRPM = 0;
-
-
-//kiwidrive
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-
-//encoder
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-
-//softPWM
-volatile int PWMval1 = 0; // PWM m1enA value 0-100
-volatile int PWMval2 = 0; // PWM m2enA value 0-100
-volatile int PWMval3 = 0; // PWM m3enA value 0-100
-
-
-Adafruit_MCP23X17 mcp2;
-
-void setup(){
- if (!mcp2.begin_I2C(0x22)) {
- Serial.println("Error initializing MCP23017 at 0x22.");
- //while (1);
- }
- // set all the motor control pins
- mcp2.pinMode(m1enA, OUTPUT);
- mcp2.pinMode(m1enB, OUTPUT);
- mcp2.pinMode(m2enA, OUTPUT);
- mcp2.pinMode(m2enB, OUTPUT);
- mcp2.pinMode(m3enA, OUTPUT);
- mcp2.pinMode(m3enB, OUTPUT);
- mcp2.pinMode(m1pwm1, OUTPUT);
- mcp2.pinMode(m1pwm2, OUTPUT);
- mcp2.pinMode(m2pwm1, OUTPUT);
- mcp2.pinMode(m2pwm2, OUTPUT);
- mcp2.pinMode(m3pwm1, OUTPUT);
- mcp2.pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins
- mcp2.pinMode(m1encA, INPUT);
- mcp2.pinMode(m1encB, INPUT);
- mcp2.pinMode(m2encA, INPUT);
- mcp2.pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM1);
- Timer3.attachInterrupt(updatePWM2);
- Timer3.attachInterrupt(updatePWM3);
-
-}
-void updatePWM1() {
- static int counter1 = 0;
-
- if (counter1 < PWMval1) {
- mcp2.digitalWrite(m1enA, HIGH);
- } else {
- mcp2.digitalWrite(m1enA, LOW);
- }
-
- counter1++;
- if (counter1 >= 100) {
- counter1 = 0;
- }
-}
-void updatePWM2() {
- static int counter2 = 0;
-
- if (counter2 < PWMval2) {
- mcp2.digitalWrite(m2enA, HIGH);
- } else {
- mcp2.digitalWrite(m2enA, LOW);
- }
-
- counter2++;
- if (counter2 >= 100) {
- counter2 = 0;
- }
-}
-void updatePWM3() {
- static int counter3 = 0;
-
- if (counter3 < PWMval3) {
- mcp2.digitalWrite(m3enA, HIGH);
- } else {
- mcp2.digitalWrite(m3enA, LOW);
- }
-
- counter3++;
- if (counter3 >= 100) {
- counter3 = 0;
- }
-}
-void mcpsoftpwm(int pin, int vall){
- //M1enA = 3 = GPA3
- //M2enA = 7 = GPA7
- //M3enA = 11 = GPB3
- Serial.print("softPWM pin: ");
- Serial.print(pin);
- Serial.print(", value: ");
- Serial.println(vall);
- if (pin = 3){
- PWMval1 = vall;
- Serial.print("Motor 1 enA PWM set");
- }
- if (pin = 7){
- PWMval2 = vall;
- Serial.print("Motor 2 enA PWM set");
- }
- if (pin = 11){
- PWMval3 = vall;
- Serial.print("Motor 3 enA PWM set");
- }
-
-}
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-void Aresetenc(){
- ACtime = micros();
- ALtime = ACtime;
- Aencount = 0;
-}
-void Bresetenc(){
- BCtime = micros();
- BLtime = BCtime;
- Bencount = 0;
-}
-void Cresetenc(){
- CCtime = micros();
- CLtime = CCtime;
- Cencount = 0;
-}
-void Amove(double Rsped) {
- double sped = nearest(Rsped, Amotordata, ArrayElementCount(Amotordata));
- spdA = abs(sped) * 0.1;
- mcpsoftpwm(m1enA, spdA);
- mcp2.digitalWrite(m1enB, LOW);
- if (sped < 0) {
- Serial.print("Motor A back ");
- mcp2.digitalWrite(m1pwm1, LOW);
- mcp2.digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("Motor A forward ");
- mcp2.digitalWrite(m1pwm1, HIGH);
- mcp2.digitalWrite(m1pwm2, LOW);
- }
- Serial.println(spdA);
-}
-void Bmove(double Rsped) {
- double sped = nearest(Rsped, Bmotordata, ArrayElementCount(Bmotordata));
- spdB = abs(sped) * 0.1;
- mcpsoftpwm(m2enA, spdB);
- mcp2.digitalWrite(m2enB, LOW);
- if (sped < 0) {
- Serial.print("Motor B back ");
- mcp2.digitalWrite(m2pwm1, LOW);
- mcp2.digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("Motor B forward ");
- mcp2.digitalWrite(m2pwm1, HIGH);
- mcp2.digitalWrite(m2pwm2, LOW);
- }
- Serial.println(spdB);
-}
-void Cmove(double Rsped) {
- double sped = nearest(Rsped, Cmotordata, ArrayElementCount(Cmotordata));
- spdC = abs(sped) * 0.1;
- mcpsoftpwm(m3enA, spdC);
- mcp2.digitalWrite(m3enB, LOW);
- if (sped < 0) {
- Serial.print("Motor C back ");
- mcp2.digitalWrite(m3pwm1, LOW);
- mcp2.digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("Motor C forward ");
- mcp2.digitalWrite(m3pwm1, HIGH);
- mcp2.digitalWrite(m3pwm2, LOW);
- }
- Serial.println(spdC);
-}
-
-void moveohmi(int speed, int direction){
- Amove(0);
- Bmove(0);
- Cmove(0);
-
- double dirrad = (direction*71.0000) / 4068.0000;
- Serial.println(dirrad);
- //vector ontb in x en y
- double y = sin(dirrad);
- double x = cos(dirrad);
- Serial.println((String)"x:"+x+" y:"+y);
- double spdeA = y*speed;
- double spdeB = (-0.500*x - 0.8660054*y)*speed;
- double spdeC = (-0.500*x + 0.8660054*y)*speed;
- Amove(spdeA);
- Bmove(spdeB);
- Cmove(spdeC);
- Serial.println();
- Serial.println();
-}
-void rotate(int rodeg, int speed){
- //use compas heading
- //inacurate compas data
-}
-void demo(){
- Amove(sp);
- Bmove(sp);
- Cmove(sp);
- Serial.println("seperate A B C rotation");
- delay(1000);
-
- Amove(0);
- Bmove(0);
- Cmove(0);
- Serial.println("seperate A B C stop");
- delay(1000);
-
- Amove(-sp);
- Bmove(-sp);
- Cmove(-sp);
- Serial.println("seperate A B C -rotation");
- delay(1000);
-
- moveohmi(0, 0);
- Serial.println("ohmi stop");
- delay(1000);
-
- rotate(90, sp);
- Serial.println("rotation function 90deg");
- rotate(90, sp);
- Serial.println("rotation function -90deg");
- delay(1000);
-
- moveohmi(sp, 35);
- Serial.println("ohmi move 35deg");
- delay(1000);
-
- moveohmi(sp, 240);
- Serial.println("ohmi move 215deg");
- delay(1000);
-
- for(int i = 0; i<360; i++){
- moveohmi(sp, i);
- Serial.println(i);
- delay(50);
- }
- Serial.println("ohmi move circle");
- delay(1000);
-}
-void loop(){
- demo();
- delay(100);
-
-}
-int nearest(int x, int myArray[], int elements)
-{
- //https://forum.arduino.cc/t/search-for-nearest-number-in-an-array-help/245843/5
- int idx = 0; // by default near first element
-
- int distance = abs(myArray[idx] - x);
- for (int i = 1; i < elements; i++)
- {
- int d = abs(myArray[i] - x);
- if (d < distance)
- {
- idx = i;
- distance = d;
- }
- }
- return idx;
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/nomultiplexer/nomultiplexer.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/nomultiplexer/nomultiplexer.ino
deleted file mode 100644
index f6f839c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/nomultiplexer/nomultiplexer.ino
+++ /dev/null
@@ -1,254 +0,0 @@
-//moveohmi = https://robotics.stackexchange.com/questions/7829/how-to-program-a-three-wheel-omni
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//
-// motor one/A front
-int m1enA = 1;
-int m1enB = 2;
-int m1pwm1 = 3;
-int m1pwm2 = 4;
-int m1encA = 13;
-int m1encB = 14;
-// motor two/B left
-int m2enA = 5;
-int m2enB = 6;
-int m2pwm1 = 7;
-int m2pwm2 = 8;
-int m2encA = 15;
-int m2encB = 16;
-// motor three/C right
-int m3enA = 9;
-int m3enB = 10;
-int m3pwm1 = 11;
-int m3pwm2 = 12;
-int m3encA = 17;
-int m3encB = 18;
-
-double sp = 1.000; //speed in 0-1
-
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-
-void setup()
-{
- // set all the motor control pins to outputs
- pinMode(m1enA, OUTPUT);
- pinMode(m1enB, OUTPUT);
- pinMode(m2enA, OUTPUT);
- pinMode(m2enB, OUTPUT);
- pinMode(m3enA, OUTPUT);
- pinMode(m3enB, OUTPUT);
-
- pinMode(m1pwm1, OUTPUT);
- pinMode(m1pwm2, OUTPUT);
- pinMode(m2pwm1, OUTPUT);
- pinMode(m2pwm2, OUTPUT);
- pinMode(m3pwm1, OUTPUT);
- pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins to input
- pinMode(m1encA, INPUT);
- pinMode(m1encB, INPUT);
- pinMode(m2encA, INPUT);
- pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-}
-
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-
-void Amove(double sped) {
- spdA = abs(sped) * 255.000;
- analogWrite(m1enA, spdA);
- digitalWrite(m1enB, LOW);
- if (sped < 0) {
- Serial.print("Motor A back ");
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("Motor A forward ");
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
- }
- Serial.println(spdA);
-}
-void Bmove(double sped) {
- spdB = abs(sped) * 255.000;
- analogWrite(m2enA, spdB);
- digitalWrite(m2enB, LOW);
- if (sped < 0) {
- Serial.print("Motor B back ");
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("Motor B forward ");
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
- }
- Serial.println(spdB);
-}
-void Cmove(double sped) {
- spdC = abs(sped) * 255.000;
- analogWrite(m3enA, spdC);
- digitalWrite(m3enB, LOW);
- if (sped < 0) {
- Serial.print("Motor C back ");
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("Motor C forward ");
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
- }
- Serial.println(spdC);
-}
-
-
-void moveohmi(int speed, int direction){
- Amove(0);
- Bmove(0);
- Cmove(0);
-
- double dirrad = (direction*71.0000) / 4068.0000;
- Serial.println(dirrad);
- //vector ontb in x en y
- double y = sin(dirrad);
- double x = cos(dirrad);
- Serial.println((String)"x:"+x+" y:"+y);
- double spdeA = y*speed;
- double spdeB = (-0.500*x - 0.8660054*y)*speed;
- double spdeC = (-0.500*x + 0.8660054*y)*speed;
- Amove(spdeA);
- Bmove(spdeB);
- Cmove(spdeC);
- Serial.println();
- Serial.println();
-}
-void rotate(int rodeg, int speed){
-//use compas heading
-}
-void demo(){
- Amove(sp);
- Bmove(sp);
- Cmove(sp);
- Serial.println("seperate A B C rotation");
- delay(1000);
-
- Amove(0);
- Bmove(0);
- Cmove(0);
- Serial.println("seperate A B C stop");
- delay(1000);
-
- Amove(-sp);
- Bmove(-sp);
- Cmove(-sp);
- Serial.println("seperate A B C -rotation");
- delay(1000);
-
- moveohmi(0, 0);
- Serial.println("ohmi stop");
- delay(1000);
-
- rotate(90, sp);
- Serial.println("rotation function 90deg");
- rotate(90, sp);
- Serial.println("rotation function -90deg");
- delay(1000);
-
- moveohmi(sp, 35);
- Serial.println("ohmi move 35deg");
- delay(1000);
-
- moveohmi(sp, 240);
- Serial.println("ohmi move 215deg");
- delay(1000);
-
- for(int i = 0; i<360; i++){
- moveohmi(sp, i);
- Serial.println(i);
- delay(50);
- }
- Serial.println("ohmi move circle");
- delay(1000);
-}
-void loop(){
- demo();
- delay(100);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor/onemotor.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor/onemotor.ino
deleted file mode 100644
index 33f0c5c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor/onemotor.ino
+++ /dev/null
@@ -1,86 +0,0 @@
-int enA = 1;
-int enB = 2;
-int pwm1 = 3;
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-int speed = 1; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Serial.begin(9600);
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*255;
- analogWrite(enA, sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- delay(1000);
- readenc();
-
-
- move(0);
- resetenc();
- delay(1000);
- readenc();
-
- move(-speed);
- delay(1000);
- readenc();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM/onemotor_softPWM.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM/onemotor_softPWM.ino
deleted file mode 100644
index 2f57d59..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM/onemotor_softPWM.ino
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <TimerThree.h>
-
-int enA = 1; //PWM pin
-int enB = 2; //GND
-int pwm1 = 3; //
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-int speed = 1000; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-
- move(0);
- delay(1000);
- resetenc();
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-
- move(500);
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino
deleted file mode 100644
index 5c8ff2a..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino
+++ /dev/null
@@ -1,128 +0,0 @@
-#include <TimerThree.h>
-#include <Adafruit_MCP23X17.h>
-
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
-
-Adafruit_MCP23X17 mcp;
-
-int enA = 0; // GPA0 -PWM
-int enB = 1; // GPA1 -GND
-int pwm1 = 2; // GPA2 -HIGH/LOW
-int pwm2 = 3; // GPA3 -HIGH/LOW
-int encoA = 4; // GPA4 -read
-int encoB = 5; // GPA5 -read
-
-int speed = 100; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-
-void setup() {
- Serial.begin(9600);
- if (!mcp.begin_I2C(0x20)) {
- Serial.println("Error initializing MCP23017 at 0x20.");
- while (1);
- }
-
- mcp.pinMode(enA, OUTPUT);
- mcp.pinMode(enB, OUTPUT);
- mcp.pinMode(pwm1, OUTPUT);
- mcp.pinMode(pwm2, OUTPUT);
-
- mcp.pinMode(encoA, INPUT_PULLUP);
- mcp.pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- mcp.digitalWrite(enA, HIGH);
- } else {
- mcp.digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*1;
- mcpsoftpwm(sp);
- mcp.digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- mcp.digitalWrite(pwm1, LOW);
- mcp.digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- mcp.digitalWrite(pwm1, HIGH);
- mcp.digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- delay(1000);
- readenc();
-
-
- move(0);
- resetenc();
- delay(1000);
- readenc();
-
- move(-speed);
- delay(1000);
- readenc();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/softPWM/softPWM.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/softPWM/softPWM.ino
deleted file mode 100644
index ab74715..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/softPWM/softPWM.ino
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <TimerThree.h>
-#include <Arduino.h>
-
-int pwmPin = 3;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-void setup() {
- pinMode(pwmPin, OUTPUT);
- Serial.begin(9600);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(pwmPin, HIGH);
- } else {
- digitalWrite(pwmPin, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: 3, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void loop() {
- mcpsoftpwm(100); // Set PWM to 100%
- delay(1000);
- mcpsoftpwm(50); // Set PWM to 50%
- delay(1000);
- Serial.println("loop");
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/tree_motor_calibration/tree_motor_calibration.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/tree_motor_calibration/tree_motor_calibration.ino
deleted file mode 100644
index 4608903..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/motordriver/tree_motor_calibration/tree_motor_calibration.ino
+++ /dev/null
@@ -1,427 +0,0 @@
-#include <TimerThree.h>
-#include <Adafruit_MCP23X17.h>
-#include <SD.h>
-#include <SPI.h>
-
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
-
-// motor one/A front
-#define m1enA 3 // GPA3 PWM1
-#define m1enB 2 // GPA2
-#define m1pwm1 0 // GPA0
-#define m1pwm2 1 // GPA1
-#define m1encA 12 // GPB4
-#define m1encB 13 // GPB5
-// motor two/B left
-#define m2enA 7 // GPA7 PWM2
-#define m2enB 6 // GPA6
-#define m2pwm1 4 // GPA4
-#define m2pwm2 5 // GPA5
-#define m2encA 14 // GPB6
-#define m2encB 15 // GPB7
-// motor three/C right
-#define m3enA 11 // GPB3 PWM3
-#define m3enB 10 // GPB2
-#define m3pwm1 8 // GPB0
-#define m3pwm2 9 // GPB1
-#define m3encA 24 // teensy port 24
-#define m3encB 9 // teensy port 9
-
-const int maxspeed = 1000;
-
-double sp = 0.00;
-//encoder
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-
-//kiwidrive
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-
-//softPWM
-volatile int PWMval1 = 0; // PWM m1enA value 0-100
-volatile int PWMval2 = 0; // PWM m2enA value 0-100
-volatile int PWMval3 = 0; // PWM m3enA value 0-100
-
-volatile int PWMval = 0; // PWM value 0-100
-File ;
-File avrage;
-Sd2Card card;
-SdVolume volume;
-SdFile root;
-const int chipSelect = BUILTIN_SDCARD;
-int x = 1;
-
-int Nloop = 0;
-int Atotloopdata[maxspeed] = {};
-int Btotloopdata[maxspeed] = {};
-int Ctotloopdata[maxspeed] = {};
-
-Adafruit_MCP23X17 mcp2;
-
-void setup() {
- if (!mcp2.begin_I2C(0x22)) {
- Serial.println("Error initializing MCP23017 at 0x22.");
- //while (1);
- }
- // set all the motor control pins
- mcp2.pinMode(m1enA, OUTPUT);
- mcp2.pinMode(m1enB, OUTPUT);
- mcp2.pinMode(m2enA, OUTPUT);
- mcp2.pinMode(m2enB, OUTPUT);
- mcp2.pinMode(m3enA, OUTPUT);
- mcp2.pinMode(m3enB, OUTPUT);
- mcp2.pinMode(m1pwm1, OUTPUT);
- mcp2.pinMode(m1pwm2, OUTPUT);
- mcp2.pinMode(m2pwm1, OUTPUT);
- mcp2.pinMode(m2pwm2, OUTPUT);
- mcp2.pinMode(m3pwm1, OUTPUT);
- mcp2.pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins
- mcp2.pinMode(m1encA, INPUT);
- mcp2.pinMode(m1encB, INPUT);
- mcp2.pinMode(m2encA, INPUT);
- mcp2.pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM1);
- Timer3.attachInterrupt(updatePWM2);
- Timer3.attachInterrupt(updatePWM3);
-}
-
-void updatePWM1() {
- static int counter1 = 0;
-
- if (counter1 < PWMval1) {
- mcp2.digitalWrite(m1enA, HIGH);
- } else {
- mcp2.digitalWrite(m1enA, LOW);
- }
-
- counter1++;
- if (counter1 >= 100) {
- counter1 = 0;
- }
-}
-void updatePWM2() {
- static int counter2 = 0;
-
- if (counter2 < PWMval2) {
- mcp2.digitalWrite(m2enA, HIGH);
- } else {
- mcp2.digitalWrite(m2enA, LOW);
- }
-
- counter2++;
- if (counter2 >= 100) {
- counter2 = 0;
- }
-}
-void updatePWM3() {
- static int counter3 = 0;
-
- if (counter3 < PWMval3) {
- mcp2.digitalWrite(m3enA, HIGH);
- } else {
- mcp2.digitalWrite(m3enA, LOW);
- }
-
- counter3++;
- if (counter3 >= 100) {
- counter3 = 0;
- }
-}
-void mcpsoftpwm(int pin, int vall){
- //M1enA = 3 = GPA3
- //M2enA = 7 = GPA7
- //M3enA = 11 = GPB3
- Serial.print("softPWM pin: ");
- Serial.print(pin);
- Serial.print(", value: ");
- Serial.println(vall);
- if (pin = 3){
- PWMval1 = vall;
- Serial.print("Motor 1 enA PWM set");
- }
- if (pin = 7){
- PWMval2 = vall;
- Serial.print("Motor 2 enA PWM set");
- }
- if (pin = 11){
- PWMval3 = vall;
- Serial.print("Motor 3 enA PWM set");
- }
-
-}
-
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-void Aresetenc(){
- ACtime = micros();
- ALtime = ACtime;
- Aencount = 0;
-}
-void Bresetenc(){
- BCtime = micros();
- BLtime = BCtime;
- Bencount = 0;
-}
-void Cresetenc(){
- CCtime = micros();
- CLtime = CCtime;
- Cencount = 0;
-}
-
-void Amove(double sped) {
- spdA = abs(sped) * 0.1;
- mcpsoftpwm(m1enA, spdA);
- mcp2.digitalWrite(m1enB, LOW);
- if (sped < 0) {
- //Serial.print("Motor A back ");
- mcp2.digitalWrite(m1pwm1, LOW);
- mcp2.digitalWrite(m1pwm2, HIGH);
- } else {
- //Serial.print("Motor A forward ");
- mcp2.digitalWrite(m1pwm1, HIGH);
- mcp2.digitalWrite(m1pwm2, LOW);
- }
- //Serial.println(spdA);
-}
-void Bmove(double sped) {
- spdB = abs(sped) * 0.1;
- mcpsoftpwm(m2enA, spdB);
- mcp2.digitalWrite(m2enB, LOW);
- if (sped < 0) {
- //Serial.print("Motor B back ");
- mcp2.digitalWrite(m2pwm1, LOW);
- mcp2.digitalWrite(m2pwm2, HIGH);
- } else {
- //Serial.print("Motor B forward ");
- mcp2.digitalWrite(m2pwm1, HIGH);
- mcp2.digitalWrite(m2pwm2, LOW);
- }
- //Serial.println(spdB);
-}
-void Cmove(double sped) {
- spdC = abs(sped) * 0.1;
- mcpsoftpwm(m3enA, spdC);
- mcp2.digitalWrite(m3enB, LOW);
- if (sped < 0) {
- //Serial.print("Motor C back ");
- mcp2.digitalWrite(m3pwm1, LOW);
- mcp2.digitalWrite(m3pwm2, HIGH);
- } else {
- //Serial.print("Motor C forward ");
- mcp2.digitalWrite(m3pwm1, HIGH);
- mcp2.digitalWrite(m3pwm2, LOW);
- }
- //Serial.println(spdC);
-}
-void move(double sped) {
- Amove(sped);
- Bmove(sped);
- Cmove(sped);
-}
-void readenc() {
- Areadenc();
- Breadenc();
- Creadenc();
-}
-void resetenc() {
- Aresetenc();
- Bresetenc();
- Cresetenc();
-}
-
-void loop() {
- move(0);
- delay(2000);
- for (int i = 0; i < maxspeed; i++) {
- Serial.println("0,0");
- }
- int Acurrentloopdata[maxspeed] = {};
- int Bcurrentloopdata[maxspeed] = {};
- int Ccurrentloopdata[maxspeed] = {};
- for (int i = 0; i < maxspeed; i++) {
- move(i);
- delay(100);
- readenc();
- Serial.print(i);
- Serial.print(",");
- Serial.print(Arpm);
- Acurrentloopdata[i] = Arpm;
- Serial.print(",");
- Serial.print(Brpm);
- Acurrentloopdata[i] = Brpm;
- Serial.print(",");
- Serial.print(Crpm);
- Acurrentloopdata[i] = Crpm;
- Serial.print(",");
- Serial.println(Atotloopdata[i]);
- Serial.print(",");
- Serial.println(Btotloopdata[i]);
- Serial.print(",");
- Serial.println(Ctotloopdata[i]);
- }
- Acurrentloopdata[0] = 0;
- Bcurrentloopdata[0] = 0;
- Ccurrentloopdata[0] = 0;
- if (Nloop == 0){
- for (int i = 0; i < maxspeed; i++) {
- Atotloopdata[i] = Acurrentloopdata[i];
- Btotloopdata[i] = Bcurrentloopdata[i];
- Ctotloopdata[i] = Ccurrentloopdata[i];
- }
- }else{
- for (int i = 0; i < maxspeed; i++) {
- Atotloopdata[i] = ((Atotloopdata[i]*Nloop)+Acurrentloopdata[i])/(Nloop+1);
- Btotloopdata[i] = ((Btotloopdata[i]*Nloop)+Bcurrentloopdata[i])/(Nloop+1);
- Ctotloopdata[i] = ((Ctotloopdata[i]*Nloop)+Ccurrentloopdata[i])/(Nloop+1);
- }
- }
- resetenc();
- SD.remove("Aavrage_motor_values.dat");
- SD.remove("Bavrage_motor_values.dat");
- SD.remove("Cavrage_motor_values.dat");
- File AdataFile = SD.open("Aavrage_motor_values.dat", FILE_WRITE);
- if (AdataFile) {
- for (int i = 0; i < maxspeed; i++) {
- AdataFile.print(Atotloopdata[i]);
- AdataFile.print(", ");
- }
- AdataFile.close();
- }
- File BdataFile = SD.open("Aavrage_motor_values.dat", FILE_WRITE);
- if (BdataFile) {
- for (int i = 0; i < maxspeed; i++) {
- BdataFile.print(Btotloopdata[i]);
- BdataFile.print(", ");
- }
- BdataFile.close();
- }
- File CdataFile = SD.open("Aavrage_motor_values.dat", FILE_WRITE);
- if (CdataFile) {
- for (int i = 0; i < maxspeed; i++) {
- CdataFile.print(Ctotloopdata[i]);
- CdataFile.print(", ");
- }
- CdataFile.close();
- }
- SD.remove("ABC_avrage_motor_values.csv");
- File debugFile = SD.open("ABC_avrage_motor_values.csv", FILE_WRITE);
- if (debugFile) {
- debugFile.println("");
- debugFile.println("Motor A values");
- debugFile.println("");
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(Atotloopdata[i]);
- }
- debugFile.println("");
- debugFile.println("Motor B values");
- debugFile.println("");
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(Btotloopdata[i]);
- }
- debugFile.println("");
- debugFile.println("Motor C values");
- debugFile.println("");
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(Ctotloopdata[i]);
- }
- }
-
- if (!card.init(SPI_HALF_SPEED, chipSelect)) {
- Serial.println("FAILED TO FIND SD CARD");
- Serial.println("* is a card inserted?");
- Serial.println("* is your wiring correct?");
- Serial.println("* did you change the chipSelect pin to match your shield or module?");
- }
-
-
- Nloop++;
-
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/tcs34725/tcs34725.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/tcs34725/tcs34725.ino
deleted file mode 100644
index 88d1467..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/debugprewk/debug/tcs34725/tcs34725.ino
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <Wire.h>
-#include "Adafruit_TCS34725.h"
-
-/* Example code for the Adafruit TCS34725 breakout library */
-
-/* Connect SCL to analog 5
- Connect SDA to analog 4
- Connect VDD to 3.3V DC
- Connect GROUND to common ground */
-
-/* Initialise with default values (int time = 2.4ms, gain = 1x) */
-// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
-
-/* Initialise with specific int time and gain values */
-Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);
-
-void setup(void) {
- Serial.begin(9600);
-
- if (tcs.begin()) {
- Serial.println("Found sensor");
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- while (1);
- }
-
- // Now we're ready to get readings!
-}
-
-void loop(void) {
- uint16_t r, g, b, c, colorTemp, lux;
-
- tcs.getRawData(&r, &g, &b, &c);
- // colorTemp = tcs.calculateColorTemperature(r, g, b);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
-
- Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
- Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
- Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
- Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
- Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
- Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
- Serial.println(" ");
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/i2c_scanner/i2c_scanner.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/i2c_scanner/i2c_scanner.ino
deleted file mode 100644
index d3d4570..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/i2c_scanner/i2c_scanner.ino
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
-i2c port scanner based on:
- in wire library examples i2c_scanner
- https://learn.adafruit.com/adafruit-pca9548-8-channel-stemma-qt-qwiic-i2c-multiplexer/arduino
-
-
- *
- */
-
-#include <Wire.h>
-
-#define PCAADDR 0x70 //i2c address of the i2c multiplexer
-
-
-void setup() {
- Serial.begin(115200);
- while (!Serial); // Leonardo: wait for Serial Monitor
- Serial.println("\nI2C Scanner");
-
-}
-
-void pcaselect(uint8_t i) {
- if (i > 7) return;
-
- Wire.beginTransmission(PCAADDR);
- Wire.write(1 << i);
- Wire.endTransmission();
-}
-
-
-
-
-void scandirectports(){
- Wire.begin();
- int nDevices = 0;
- Serial.println("Scanning for i2c ports on board...");
-
- for (byte address = 1; address < 127; ++address) {
- // The i2c_scanner uses the return value of
- // the Wire.endTransmission to see if
- // a device did acknowledge to the address.
- Wire.beginTransmission(address);
- byte error = Wire.endTransmission();
-
- if (error == 0) {
- Serial.print("I2C device found at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.print(address, HEX);
- Serial.println(" !");
-
- ++nDevices;
- } else if (error == 4) {
- Serial.print("Unknown error at address 0x");
- if (address < 16) {
- Serial.print("0");
- }
- Serial.println(address, HEX);
- }
- }
- if (nDevices == 0) {
- Serial.println("No I2C devices found\n");
- } else {
- Serial.println("done\n");
- }
- Serial.println("done scanning for i2c ports on board");
-}
-void scani2cmultiplexer(){
- Serial.println("Scanning for i2c ports on i2c multiplexer...");
- for (uint8_t t=0; t<8; t++) {
- pcaselect(t);
- Serial.print("PCA Port #"); Serial.println(t);
-
- for (uint8_t addr = 0; addr<=127; addr++) {
- if (addr == PCAADDR) continue;
- Wire.beginTransmission(addr);
- if (!Wire.endTransmission()) {
- Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
- }
- }
- }
- Serial.println("done scanning for i2c ports on i2c multiplexer");
-}
-
-
-
-void loop() {
- scandirectports();
- delay(1000);
- scani2cmultiplexer();
- delay(1000);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID/PID.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID/PID.ino
deleted file mode 100644
index c7f351a..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID/PID.ino
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <TimerThree.h>
-#include <QuickPID.h>
-
-
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-
-
-float Setpoint, Input, Output;
-float Kp = 2, Ki = 5, Kd = 1;
-QuickPID myPID(&Input, &Output, &Setpoint);
-
-
-int enA = 1; // PWM pin
-int enB = 2; // GND
-int pwm1 = 3; // Motor control pin 1
-int pwm2 = 4; // Motor control pin 2
-int encoA = 5; // Encoder pin A
-int encoB = 6; // Encoder pin B
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-1000
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-
- // PID settings
- Input = rpm;
- Setpoint = 500;
- myPID.SetTunings(Kp, Ki, Kd);
- myPID.SetMode(myPID.Control::automatic);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 1000) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 1000) value = 1000;
-
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime); // Adjust the encoder counts per revolution here if necessary
- encount = 0;
-}
-
-void resetenc() {
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped) * 0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
-}
-
-void loop() {
- Input = rpm;
- myPID.Compute();
- move(Output);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID.py b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID.py
deleted file mode 100644
index e24dbd6..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID.py
+++ /dev/null
@@ -1,131 +0,0 @@
-import serial
-import time
-from simple_pid import PID
-import matplotlib.pyplot as plt
-from matplotlib.widgets import Slider, Button
-
-# Initialize serial communication
-arduino = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=.1)
-
-# Function to write to and read from Arduino
-def write_read(x):
- arduino.write(bytes(x, 'utf-8'))
- time.sleep(0.05)
- data = arduino.readline().decode().strip()
- return data
-
-# Real-time plotting setup
-fig, (ax1, ax2) = plt.subplots(2, 1)
-feedback_list = []
-control_list = []
-setpoint_list = []
-
-def clamp(feedback, min_value, max_value):
- return max(min(feedback, max_value), min_value)
-
-def update_plot(feedback, control, setpoint):
- feedback_clamped = clamp(feedback, 0, 1000) # Clamp feedback value between 0 and 1000
- feedback_list.append(feedback_clamped)
- control_list.append(control)
- setpoint_list.append(setpoint)
-
- # Limit lists to 50 items for smoother plotting
- if len(feedback_list) > 50:
- feedback_list.pop(0)
- control_list.pop(0)
- setpoint_list.pop(0)
-
- ax1.clear()
- ax2.clear()
-
- ax1.plot(feedback_list, label="Feedback")
- ax1.plot(setpoint_list, label="Setpoint")
- ax1.legend()
-
- ax2.plot(control_list, label="Control")
- ax2.legend()
-
- ax1.set_ylabel('RPM')
- ax2.set_ylabel('Control Signal')
- ax2.set_xlabel('Time')
-
- plt.tight_layout()
- plt.pause(0.05) # Pause to allow plot to update
-
-# Initialize PID controller with output limits
-initial_setpoint = 500 # Initial setpoint
-pid = PID(0, 0, 0, output_limits=(0, 1000))
-pid.setpoint = initial_setpoint
-
-# Initialize PID parameters (preserved across resets)
-preserved_parameters = {
- 'Kp': 0,
- 'Ki': 0,
- 'Kd': 0,
- 'setpoint': initial_setpoint
-}
-
-# Function to update PID parameters
-def update_pid(val):
- pid.Kp = s_kp.val
- pid.Ki = s_ki.val
- pid.Kd = s_kd.val
- preserved_parameters['Kp'] = s_kp.val
- preserved_parameters['Ki'] = s_ki.val
- preserved_parameters['Kd'] = s_kd.val
- setpoint = s_setpoint.val
- pid.setpoint = setpoint
- preserved_parameters['setpoint'] = setpoint
- print(f"Setpoint: {setpoint}, Kp: {pid.Kp}, Ki: {pid.Ki}, Kd: {pid.Kd}")
-
-# Create sliders for PID parameters and setpoint
-axcolor = 'lightgoldenrodyellow'
-ax_setpoint = plt.axes([0.15, 0.1, 0.65, 0.03], facecolor=axcolor)
-ax_kp = plt.axes([0.15, 0.15, 0.65, 0.03], facecolor=axcolor)
-ax_ki = plt.axes([0.15, 0.2, 0.65, 0.03], facecolor=axcolor)
-ax_kd = plt.axes([0.15, 0.25, 0.65, 0.03], facecolor=axcolor)
-
-s_setpoint = Slider(ax_setpoint, 'Setpoint', 0, 1000, valinit=initial_setpoint)
-s_kp = Slider(ax_kp, 'Kp', 0, 10, valinit=preserved_parameters['Kp'])
-s_ki = Slider(ax_ki, 'Ki', 0, 10, valinit=preserved_parameters['Ki'])
-s_kd = Slider(ax_kd, 'Kd', 0, 10, valinit=preserved_parameters['Kd'])
-
-s_setpoint.on_changed(update_pid)
-s_kp.on_changed(update_pid)
-s_ki.on_changed(update_pid)
-s_kd.on_changed(update_pid)
-
-# Function to reset algorithm and set speed to zero
-def reset_algorithm(event):
- global feedback_list, control_list, setpoint_list
- feedback_list.clear()
- control_list.clear()
- setpoint_list.clear()
- pid.reset()
- s_setpoint.set_val(preserved_parameters['setpoint'])
- s_kp.set_val(preserved_parameters['Kp'])
- s_ki.set_val(preserved_parameters['Ki'])
- s_kd.set_val(preserved_parameters['Kd'])
- print("Algorithm reset")
- time.sleep(1) # Delay of 1 second after reset
-
-# Create reset button
-ax_reset = plt.axes([0.8, 0.02, 0.1, 0.05])
-btn_reset = Button(ax_reset, 'Reset')
-btn_reset.on_clicked(reset_algorithm)
-
-# Function to update Arduino with clamped control signal
-def update_arduino_control(control):
- control_clamped = clamp(control, 0, 1000)
- write_read(str(control_clamped))
-
-# Control loop
-while True:
- feedback = float(write_read(str(pid.setpoint)))
- feedback_clamped = clamp(feedback, 0, 1000) # Clamp feedback value between 0 and 1000
- control = pid(feedback_clamped)
- update_arduino_control(control)
- update_plot(feedback_clamped, control, pid.setpoint)
-
-# Keep plot open
-plt.show()
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID_autotune.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID_autotune.ino
deleted file mode 100644
index ab99c50..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/PID_autotune.ino
+++ /dev/null
@@ -1,82 +0,0 @@
-int enA = 1;
-int enB = 2;
-int pwm1 = 3;
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-int speed = 1; // speed 0-1000
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-int mess;
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Serial.begin(115200);
- Serial.setTimeout(1);
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- /*Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
- */
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*2.55;
- analogWrite(enA, sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- //Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- //Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- //Serial.println(sp);
-}
-
-void loop() {
- while (!Serial.available());
- mess = Serial.readString().toInt();
- move(mess);
- readenc();
- Serial.print(rpm);
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/man_test.py b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/man_test.py
deleted file mode 100644
index 52c84e3..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/PID_autotune/man_test.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import serial
-import time
-
-arduino = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=.1)
-
-def write_read(x):
- arduino.write(bytes(x, 'utf-8'))
- time.sleep(0.05)
- data = arduino.readline()
- return data
-
-while True:
- num = input("Enter a number: ") # Taking input from user
- value = write_read(num)
- print(value) # printing the value
-
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master.zip b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master.zip
deleted file mode 100644
index dc713b7..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master.zip
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/.gitignore b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/.gitignore
deleted file mode 100644
index 1605aab..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-SoftPWM.h.gch \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/README.md b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/README.md
deleted file mode 100644
index 46e5456..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/README.md
+++ /dev/null
@@ -1,75 +0,0 @@
-arduino-softpwm
-===============
-
-Software PWM library for [Arduino](https://arduino.cc/), and other compatible AVR boards.
-
-AVR microcontrollers provide hardware PWM on some pins but if you need PWM on other pins then it must be implemented in software. This library provides easy and efficient software PWM on any pin. Each channel can be set to a different PWM duty cycle.
-
-This library is licensed under [BSD3](https://opensource.org/licenses/BSD-3-Clause)
-
-#### Installation
-- Download the most recent version here: https://github.com/Palatis/arduino-softpwm/archive/master.zip
-- Using Arduino IDE 1.0.x:
- - Sketch > Import Library... > Add Library... > select the downloaded file > Open
-- Using Arduino IDE 1.5+:
- - Sketch > Include Library > Add ZIP Library... > select the downloaded file > Open
-
-
-#### Usage
-See **File > Examples > arduino-softpwm > SoftPWM_example** for demonstration of library usage.
-
-Everything in this library except for preprocessor defines are wrapped in `namespace Palatis {}`, so if your compiler blames you about symbol not found, try add `Palatis::` before that thing. For example, `Palatis::SoftPWM.size()`.
-
-Alternatively, you can add `using namespace Palatis;` at the top of the source file to import everything under the `Palatis` namespace, this might be convenient if you're using my other libraries.
-
-`#define SOFTPWM_OUTPUT_DELAY` - Add this line above `#include <SoftPWM.h>` for a 1 PWM clock cycle delay between outputs to prevent large in-rush currents.
-
-`SOFTPWM_DEFINE_CHANNEL(CHANNEL, PMODE, PORT, BIT)` - Configure a pin for software PWM use. Consult the datasheet for your microcontroller for the appropriate `PORT` and `BIT` values for the physical pin. This information is shown in the pinout diagram, for example: [ATmega328P datasheet](http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Summary.pdf) **Figure 1-1** found on page 3. If you want to determine the Arduino pin assigned to the physical pin http://www.pighixxx.com/test/pinoutspg/boards/ provides this information for the most popular Arduino boards or you can look at the pins_arduino.h file in the **variant** folder used by your board.
-- Parameter: **CHANNEL** - The channel number is used as an ID for the pin.
-- Parameter: **PMODE** - DDRx register of the pin's port. Append the port letter to `DDR`. For example: The [Arduino UNO diagram](http://www.pighixxx.com/test/portfolio-items/uno/?portfolioID=314) shows that Arduino pin 13 is **PB5** which means that the port is **B** so you should use the value `DDRB` for that pin.
-- Parameter: **PORT** - The port of the pin. For example: Arduino pin 13 is **PB5** so you should use the value `PORTB` for that pin.
-- Parameter: **BIT** - The bit of the pin. For example: Arduino pin 13 is **PB5** so you should use the value `PORTB5` for that pin.
-
-`SOFTPWM_DEFINE_CHANNEL_INVERT( CHANNEL, PMODE, PORT, BIT )` - Depending on your application you may prefer to invert the output. See `SOFTPWM_DEFINE_CHANNEL()` for description of parameters.
-
-`SOFTPWM_DEFINE_OBJECT(CHANNEL_CNT)` - Define the softPWM object with the default 256 PWM levels.
-- Parameter: **CHANNEL_CNT** - The number of channels that are defined.
-
-`SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS)` - Define the softPWM object with the specified number of PWM levels.
-- Parameter: **CHANNEL_CNT** - The number of channels that are defined.
-- Parameter: **PWM_LEVELS** - The number of PWM levels. Using less PWM levels may allow a higher PWM frequency. The maximum value is 256.
-
-`SOFTPWM_DEFINE_EXTERN_OBJECT(CHANNEL_CNT)` - Add this if you want to use the SoftPWM object outside where it's defined. See `SOFTPWM_DEFINE_OBJECT()` for description of the parameter.
-
-`SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS)` - Add this if you want to use the SoftPWM object outside where it's defined. See `SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS()` for description of parameters.
-
-`SoftPWM.begin(hertz)` - Initialize SoftPWM.
-- Parameter: **hertz** - The PWM frequency. Setting the value too high will cause incorrect operation, too low will cause a visible flicker.
- - Type: long
-
-`SoftPWM.printInterruptLoad()` - Prints diagnostic information to the serial monitor. This can be used to find the optimal PWM frequency by setting different PWM frequency values in begin() and then checking the resulting interrupt load. Calling this function will momentarily turn off the PWM on all channels.
-
-`SoftPWM.set(channel_idx, value)` - Set the PWM level of the given channel.
-- Parameter: **channel_idx** - The channel to set.
- - Type: int
-- Parameter: **value** - The PWM level to set.
- - Type: byte
-
-`SoftPWM.size()`
-- Returns: Number of channels defined.
- - Type: size_t
-
-`SoftPWM.PWMlevels()`
-- Returns: The number of PWM levels.
- - Type: unsigned int
-
-`SoftPWM.allOff()` - Set the PWM value of all channels to 0.
-
-
-#### Troubleshooting
-- LEDs have a visible flicker, especially noticeable when the LED is moving relative to the viewer.
- - The PWM frequency set in `SoftPWM.begin()` is too low. Use `SoftPWM.printInterruptLoad()` to determine the optimum PWM frequency. You may be able to achieve a higher PWM frequency by setting less PWM levels with `SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS()` or `SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS()`.
-- Erratic PWM operation
- - The interrupt load is too high. Use `SoftPWM.printInterruptLoad()` to determine the interrupt load. You can decrease the interrupt load by setting less PWM levels with `SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS()` or `SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS()` or setting the PWM frequency lower in `SoftPWM.begin()`.
-- LED brightness changes between low brightness PWM values are larger than at brighter PWM values.
- - This is caused by the way LEDs work and is not caused by a problem with the library. If possible, use more PWM levels or never allow the LED to get dimmer than the level below which the difference between PWM levels is too distinct.
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino
deleted file mode 100644
index 96fc0b2..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/examples/SoftPWM_example/SoftPWM_example.ino
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- Arduino-SoftPWM: a software PWM library for Arduino
- Copyright 2016, Victor Tseng <palatis@gmail.com>
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <SoftPWM.h>
-
-/* pins_arduino.h defines the pin-port/bit mapping as PROGMEM so
- you have to read them with pgm_read_xxx(). That's generally okay
- for ordinary use, but really bad when you're writing super fast
- codes because the compiler doesn't treat them as constants and
- cannot optimize them away with sbi/cbi instructions.
-
- Therefore we have to tell the compiler the PORT and BIT here.
- Hope someday we can find a way to workaround this.
-
- Check the manual of your MCU for port/bit mapping.
-
- The following example demonstrates setting channels for all pins
- on the ATmega328P or ATmega168 used on Arduino Uno, Pro Mini,
- Nano and other boards. */
-SOFTPWM_DEFINE_CHANNEL(0, DDRD, PORTD, PORTD0); //Arduino pin 0
-SOFTPWM_DEFINE_CHANNEL(1, DDRD, PORTD, PORTD1); //Arduino pin 1
-SOFTPWM_DEFINE_CHANNEL(2, DDRD, PORTD, PORTD2); //Arduino pin 2
-SOFTPWM_DEFINE_CHANNEL(3, DDRD, PORTD, PORTD3); //Arduino pin 3
-SOFTPWM_DEFINE_CHANNEL(4, DDRD, PORTD, PORTD4); //Arduino pin 4
-SOFTPWM_DEFINE_CHANNEL(5, DDRD, PORTD, PORTD5); //Arduino pin 5
-SOFTPWM_DEFINE_CHANNEL(6, DDRD, PORTD, PORTD6); //Arduino pin 6
-SOFTPWM_DEFINE_CHANNEL(7, DDRD, PORTD, PORTD7); //Arduino pin 7
-SOFTPWM_DEFINE_CHANNEL(8, DDRB, PORTB, PORTB0); //Arduino pin 8
-SOFTPWM_DEFINE_CHANNEL(9, DDRB, PORTB, PORTB1); //Arduino pin 9
-SOFTPWM_DEFINE_CHANNEL(10, DDRB, PORTB, PORTB2); //Arduino pin 10
-SOFTPWM_DEFINE_CHANNEL(11, DDRB, PORTB, PORTB3); //Arduino pin 11
-SOFTPWM_DEFINE_CHANNEL(12, DDRB, PORTB, PORTB4); //Arduino pin 12
-SOFTPWM_DEFINE_CHANNEL(13, DDRB, PORTB, PORTB5); //Arduino pin 13
-SOFTPWM_DEFINE_CHANNEL(14, DDRC, PORTC, PORTC0); //Arduino pin A0
-SOFTPWM_DEFINE_CHANNEL(15, DDRC, PORTC, PORTC1); //Arduino pin A1
-SOFTPWM_DEFINE_CHANNEL(16, DDRC, PORTC, PORTC2); //Arduino pin A2
-SOFTPWM_DEFINE_CHANNEL(17, DDRC, PORTC, PORTC3); //Arduino pin A3
-SOFTPWM_DEFINE_CHANNEL(18, DDRC, PORTC, PORTC4); //Arduino pin A4
-SOFTPWM_DEFINE_CHANNEL(19, DDRC, PORTC, PORTC5); //Arduino pin A5
-
-
-/* Or you may want inverted outputs: */
-/*
- SOFTPWM_DEFINE_CHANNEL_INVERT(0, DDRD, PORTD, PORTD0); //Arduino pin 0
- SOFTPWM_DEFINE_CHANNEL_INVERT(1, DDRD, PORTD, PORTD1); //Arduino pin 1
- SOFTPWM_DEFINE_CHANNEL_INVERT(2, DDRD, PORTD, PORTD2); //Arduino pin 2
- SOFTPWM_DEFINE_CHANNEL_INVERT(3, DDRD, PORTD, PORTD3); //Arduino pin 3
- SOFTPWM_DEFINE_CHANNEL_INVERT(4, DDRD, PORTD, PORTD4); //Arduino pin 4
- SOFTPWM_DEFINE_CHANNEL_INVERT(5, DDRD, PORTD, PORTD5); //Arduino pin 5
- SOFTPWM_DEFINE_CHANNEL_INVERT(6, DDRD, PORTD, PORTD6); //Arduino pin 6
- SOFTPWM_DEFINE_CHANNEL_INVERT(7, DDRD, PORTD, PORTD7); //Arduino pin 7
- SOFTPWM_DEFINE_CHANNEL_INVERT(8, DDRB, PORTB, PORTB0); //Arduino pin 8
- SOFTPWM_DEFINE_CHANNEL_INVERT(9, DDRB, PORTB, PORTB2); //Arduino pin 9
- SOFTPWM_DEFINE_CHANNEL_INVERT(10, DDRB, PORTB, PORTB2); //Arduino pin 10
- SOFTPWM_DEFINE_CHANNEL_INVERT(11, DDRB, PORTB, PORTB3); //Arduino pin 11
- SOFTPWM_DEFINE_CHANNEL_INVERT(12, DDRB, PORTB, PORTB4); //Arduino pin 12
- SOFTPWM_DEFINE_CHANNEL_INVERT(13, DDRB, PORTB, PORTB5); //Arduino pin 13
- SOFTPWM_DEFINE_CHANNEL_INVERT(14, DDRC, PORTC, PORTC0); //Arduino pin A0
- SOFTPWM_DEFINE_CHANNEL_INVERT(15, DDRC, PORTC, PORTC1); //Arduino pin A1
- SOFTPWM_DEFINE_CHANNEL_INVERT(16, DDRC, PORTC, PORTC2); //Arduino pin A2
- SOFTPWM_DEFINE_CHANNEL_INVERT(17, DDRC, PORTC, PORTC3); //Arduino pin A3
- SOFTPWM_DEFINE_CHANNEL_INVERT(18, DDRC, PORTC, PORTC4); //Arduino pin A4
- SOFTPWM_DEFINE_CHANNEL_INVERT(19, DDRC, PORTC, PORTC5); //Arduino pin A5
-*/
-
-/* Here you make an instance of desired channel counts you want
- with the default 256 PWM levels (0 ~ 255). */
-//SOFTPWM_DEFINE_OBJECT(20);
-
-/* Or you can make one with only 100 PWM levels (0 ~ 99).
- By using less PWM levels, you may be able to use higher
- pwm frequencies. */
-SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(20, 100);
-
-/* If you want to use the SoftPWM object outside where it's defined,
- add the following line to the file. */
-//SOFTPWM_DEFINE_EXTERN_OBJECT(16);
-SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(20, 100);
-
-void setup() {
- Serial.begin(19200);
-
- // begin with 60hz pwm frequency
- Palatis::SoftPWM.begin(60);
-
- // print interrupt load for diagnostic purposes
- Palatis::SoftPWM.printInterruptLoad();
-}
-
-static volatile uint8_t v = 0;
-void loop() {
- for (uint8_t i = 0; i < Palatis::SoftPWM.size(); ++i) {
- Serial.print(micros());
- Serial.print(" loop(): ");
- Serial.println(i);
-
- unsigned long const WAIT = 1000000 / Palatis::SoftPWM.PWMlevels() / 2;
- unsigned long nextMicros = 0;
- for (int v = 0; v < Palatis::SoftPWM.PWMlevels() - 1; ++v) {
- while (micros() < nextMicros);
- nextMicros = micros() + WAIT;
- Palatis::SoftPWM.set(i, v);
- }
- for (int v = Palatis::SoftPWM.PWMlevels() - 1; v >= 0; --v) {
- while (micros() < nextMicros);
- nextMicros = micros() + WAIT;
- Palatis::SoftPWM.set(i, v);
- }
- }
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/keywords.txt b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/keywords.txt
deleted file mode 100644
index 61d42b7..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/keywords.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-#######################################
-# Syntax Coloring Map SoftPWM
-#######################################
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-Palatis KEYWORD1
-SoftPWM KEYWORD1
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-begin KEYWORD2
-set KEYWORD2
-size KEYWORD2
-PWMlevels KEYWORD2
-allOff KEYWORD2
-update KEYWORD2
-printInterruptLoad KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-SOFTPWM_DEFINE_PINMODE LITERAL1
-SOFTPWM_DEFINE_CHANNEL LITERAL1
-SOFTPWM_DEFINE_CHANNEL_INVERT LITERAL1
-SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS LITERAL1
-SOFTPWM_DEFINE_OBJECT LITERAL1
-SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS LITERAL1
-SOFTPWM_DEFINE_EXTERN_OBJECT LITERAL1
-SOFTPWM_OUTPUT_DELAY LITERAL1
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/library.properties b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/library.properties
deleted file mode 100644
index 174c19b..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/library.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-name=arduino-softpwm
-version=1.0.1
-author=Victor Tseng <palatis@gmail.com>
-maintainer=Victor Tseng <palatis@gmail.com>
-sentence=Software PWM library for Arduino.
-paragraph=Provides PWM on any pin.
-category=Signal Input/Output
-url=https://github.com/Palatis/arduino-softpwm
-architectures=avr
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/src/SoftPWM.h b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/src/SoftPWM.h
deleted file mode 100644
index c315a4e..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/arduino-softpwm-master/src/SoftPWM.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- Arduino-SoftPWM: a software PWM library for Arduino
- Copyright 2016, Victor Tseng <palatis@gmail.com>
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef _SOFTPWM_H_
-#define _SOFTPWM_H_
-
-#include <Arduino.h>
-
-// helper macros
-#define SOFTPWM_DEFINE_PINMODE(CHANNEL, PMODE, PORT, BIT) \
- namespace Palatis { \
- template <> \
- inline void pinModeStatic<CHANNEL>(uint8_t const mode) { \
- if (mode == INPUT) { \
- bitClear(PMODE, BIT); bitClear(PORT, BIT); \
- } \
- else if (mode == INPUT_PULLUP) { \
- bitClear(PMODE, BIT); bitSet(PORT, BIT); \
- } \
- else { \
- bitSet(PMODE, BIT); \
- } \
- } \
- }
-
-#define SOFTPWM_DEFINE_CHANNEL(CHANNEL, PMODE, PORT, BIT) \
- namespace Palatis { \
- template <> \
- inline void bitWriteStatic<CHANNEL>(bool const value) { \
- bitWrite( PORT, BIT, value ); \
- } \
- } \
- SOFTPWM_DEFINE_PINMODE(CHANNEL, PMODE, PORT, BIT)
-
-#define SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, PMODE, PORT, BIT) \
- namespace Palatis { \
- template <> \
- inline void bitWriteStatic<CHANNEL>(bool const value) { \
- bitWrite(PORT, BIT, !value); \
- } \
- } \
- SOFTPWM_DEFINE_PINMODE(CHANNEL, PMODE, PORT, BIT)
-
-#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
-#define SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS) \
- namespace Palatis { \
- CSoftPWM<CHANNEL_CNT, PWM_LEVELS> SoftPWM; \
- } \
- ISR(TIM1_COMPA_vect) { \
- interrupts(); \
- Palatis::SoftPWM.update(); \
- }
-#else
- #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__)
- #define TIMSK1 TIMSK
- #endif
-#define SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS) \
- namespace Palatis { \
- CSoftPWM<CHANNEL_CNT, PWM_LEVELS> SoftPWM; \
- } \
- ISR(TIMER1_COMPA_vect) { \
- interrupts(); \
- Palatis::SoftPWM.update(); \
- }
-#endif
-
-#define SOFTPWM_DEFINE_OBJECT(CHANNEL_CNT) \
- SOFTPWM_DEFINE_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, 0)
-
-#define SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, PWM_LEVELS) \
- namespace Palatis { \
- extern CSoftPWM<CHANNEL_CNT, PWM_LEVELS> SoftPWM; \
- }
-
-#define SOFTPWM_DEFINE_EXTERN_OBJECT(CHANNEL_CNT) \
- SOFTPWM_DEFINE_EXTERN_OBJECT_WITH_PWM_LEVELS(CHANNEL_CNT, 0)
-
-// here comes the magic @o@
-namespace Palatis {
-
-template <int channel> inline void bitWriteStatic(bool value) {}
-template <int channel> inline void pinModeStatic(uint8_t mode) {}
-
-template <int channel>
-struct bitWriteStaticExpander {
- void operator() (bool value) const {
- bitWriteStatic<channel>(value);
- bitWriteStaticExpander < channel - 1 > ()(value);
- }
-
- void operator() (uint8_t const &count, uint8_t const * const &channels) const {
-#ifdef SOFTPWM_OUTPUT_DELAY
- bitWriteStatic<channel>((count + channel) < channels[channel]);
-#else
- bitWriteStatic<channel>(count < channels[channel]);
-#endif
- bitWriteStaticExpander < channel - 1 > ()(count, channels);
- }
-};
-
-template <>
-struct bitWriteStaticExpander < -1 > {
- void operator() (bool) const {}
- void operator() (uint8_t const &, uint8_t const * const &) const {}
-};
-
-template <int channel>
-struct pinModeStaticExpander {
- void operator() (uint8_t const mode) const
- {
- pinModeStatic<channel>(mode);
- pinModeStaticExpander < channel - 1 > ()(mode);
- }
-};
-
-template <>
-struct pinModeStaticExpander < -1 > {
- void operator() (uint8_t const mode) const {}
-};
-
-template <unsigned int num_channels, unsigned int num_PWM_levels>
-class CSoftPWM {
- public:
- void begin(const unsigned long hertz) {
- allOff(); //this prevents inverted channels from momentarily going LOW
- asm volatile ("/************ pinModeStaticExpander begin ************/");
- const uint8_t oldSREG = SREG;
- noInterrupts();
- pinModeStaticExpander < num_channels - 1 > ()( OUTPUT );
- SREG = oldSREG;
- asm volatile ("/************ pinModeStaticExpander end ************/");
-
- /* the setup of timer1 is stolen from ShiftPWM :-P
- http://www.elcojacobs.com/shiftpwm/ */
- asm volatile ("/************ timer setup begin ************/");
- TCCR1A = 0b00000000;
- TCCR1B = 0b00001001;
- OCR1A = (F_CPU - hertz * PWMlevels() / 2) / (hertz * PWMlevels());
- bitSet(TIMSK1, OCIE1A);
- asm volatile ("/************ timer setup end ************/");
-
- _count = 0;
- }
-
- void set(const int channel_idx, const uint8_t value) {
- _channels[channel_idx] = value;
- }
-
- size_t size() const {
- return num_channels;
- }
-
- unsigned int PWMlevels() const {
- return num_PWM_levels ? num_PWM_levels : 256;
- }
-
- void allOff() {
- asm volatile ("/********** CSoftPWM::allOff() begin **********/");
- const uint8_t oldSREG = SREG;
- noInterrupts();
- for (int i = 0; i < num_channels; ++i)
- _channels[i] = 0;
- bitWriteStaticExpander < num_channels - 1 > ()(false);
- SREG = oldSREG;
- asm volatile ("/********** CSoftPWM::allOff() end **********/");
- }
-
- /* This function cannot be private because the ISR uses it, and I have
- no idea about how to make friends with ISR. :-( */
- void update() __attribute__((always_inline)) {
- asm volatile ("/********** CSoftPWM::update() begin **********/");
- const uint8_t count = _count;
- bitWriteStaticExpander < num_channels - 1 > ()(count, _channels);
- ++_count;
- if (_count == PWMlevels())
- _count = 0;
- asm volatile ("/********** CSoftPWM::update() end **********/");
- }
-
- #if defined(HAVE_HWSERIAL0)
- /* this function is stolen from ShiftPWM :-P
- http://www.elcojacobs.com/shiftpwm/ */
- void printInterruptLoad() {
- unsigned long time1, time2;
-
- bitSet(TIMSK1, OCIE1A); // enable interrupt
- time1 = micros();
- delayMicroseconds(5000);
- time1 = micros() - time1;
-
- bitClear(TIMSK1, OCIE1A); // disable interrupt
- time2 = micros();
- delayMicroseconds(5000);
- time2 = micros() - time2;
-
- const double load = static_cast<double>(time1 - time2) / time1;
- const double interrupt_frequency = static_cast<double>(F_CPU) / (OCR1A + 1);
- const double cycles_per_interrupt = load * F_CPU / interrupt_frequency;
-
- Serial.println(F("SoftPWM::printInterruptLoad():"));
- Serial.print(F(" Load of interrupt: "));
- Serial.println(load, 10);
- Serial.print(F(" Clock cycles per interrupt: "));
- Serial.println( cycles_per_interrupt );
- Serial.print(F(" Interrupt frequency: "));
- Serial.print(interrupt_frequency);
- Serial.println(F(" Hz"));
- Serial.print(F(" PWM frequency: "));
- Serial.print(interrupt_frequency / PWMlevels());
- Serial.println(F(" Hz"));
- Serial.print(F(" PWM levels: "));
- Serial.println(PWMlevels());
-
- bitSet(TIMSK1, OCIE1A); // enable interrupt again
- }
- #endif
-
- private:
- uint8_t _channels[num_channels];
- uint8_t _count;
-};
-
-} // namespace Palatis
-#endif // #ifndef _SOFTPWM_H_
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/calibrated_motor/calibrated_motor.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/calibrated_motor/calibrated_motor.ino
deleted file mode 100644
index 60e2c04..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/calibrated_motor/calibrated_motor.ino
+++ /dev/null
@@ -1,155 +0,0 @@
-#include <TimerThree.h>
-
-#define ArrayElementCount(needRPM) (sizeof(needRPM) / sizeof(needRPM[0]))
-
-int enA = 1; //PWM pin
-int enB = 2; //GND
-int pwm1 = 3; //
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-const int maxspeed = 1000;
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-int motordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-int needRPM = 41;
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- //Serial.print("softPWM pin: enA, value: ");
- //Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- //Serial.print("RPM: ");
- //Serial.print(rpm);
- //Serial.print(" Sample period:");
- //Serial.print(Ptime);
- //Serial.print("ms, encoder count:");
- //Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- //Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- //Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- //Serial.println(sp);
-}
-void RPMmove(int Rsped) {
- int idx = nearest(Rsped, motordata, ArrayElementCount(motordata));
- move(idx);
-}
-
-
-void loop() {
- for (int i = 0; i < maxspeed; i++) {
- Serial.print(motordata[i]);
- Serial.print(", ");
- }
- Serial.println("");
- int idx = nearest(needRPM, motordata, ArrayElementCount(motordata));
- Serial.print(needRPM);
- Serial.print(", ");
- Serial.print(idx);
- Serial.print(", ");
- Serial.println(motordata[idx]);
- delay(2500);
- move(idx);
- delay(1000);
- resetenc();
- delay(100);
- readenc();
- Serial.println(rpm);
- delay(10);
-
-
-
-}
-int nearest(int x, int myArray[], int elements)
-{
- //https://forum.arduino.cc/t/search-for-nearest-number-in-an-array-help/245843/5
- int idx = 0; // by default near first element
-
- int distance = abs(myArray[idx] - x);
- for (int i = 1; i < elements; i++)
- {
- int d = abs(myArray[i] - x);
- if (d < distance)
- {
- idx = i;
- distance = d;
- }
- }
- return idx;
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/kiwidrive_calc.svg b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/kiwidrive_calc.svg
deleted file mode 100644
index 3ca09e2..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/kiwidrive_calc.svg
+++ /dev/null
@@ -1,323 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="210mm"
- height="297mm"
- viewBox="0 0 210 297"
- version="1.1"
- id="svg8"
- inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
- sodipodi:docname="kiwidrive_calc.svg">
- <defs
- id="defs2" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1.4"
- inkscape:cx="350.96101"
- inkscape:cy="562.71867"
- inkscape:document-units="mm"
- inkscape:current-layer="layer1"
- inkscape:document-rotation="0"
- showgrid="false"
- inkscape:window-width="1920"
- inkscape:window-height="1125"
- inkscape:window-x="2560"
- inkscape:window-y="0"
- inkscape:window-maximized="1" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1">
- <ellipse
- style="fill:#ff0000;fill-rule:evenodd;stroke-width:0.264583"
- id="path10"
- cx="99.888367"
- cy="134.68913"
- rx="39.564999"
- ry="38.587662" />
- <path
- style="fill:#a0a0a0;stroke:none;stroke-width:0.0944941"
- d="m 139.72661,146.01799 c -1.63175,-1.14292 -2.20174,-11.72757 -0.90654,-16.83422 0.39799,-1.56917 0.89479,-2.32023 1.34986,-2.04073 0.45996,0.2825 0.99183,1.8708 1.27726,3.81422 0.51922,3.53519 0.43362,9.37384 -0.18105,12.34962 -0.43334,2.09796 -0.99722,3.09095 -1.53953,2.71111 z"
- id="path22" />
- <path
- style="fill:#a0a0a0;stroke:none;stroke-width:0.0944941"
- d="m 63.718331,112.73542 c -0.31847,-1.96659 6.871434,-9.75535 11.435089,-12.38756 1.402322,-0.808823 2.287091,-0.976383 2.404045,-0.455293 0.1182,0.526683 -0.64948,2.015393 -1.843555,3.575053 -2.17208,2.83712 -6.417053,6.84677 -8.978746,8.48104 -1.806017,1.15218 -2.910982,1.44035 -3.016833,0.78676 z"
- id="path22-3" />
- <path
- style="fill:#a0a0a0;stroke:none;stroke-width:0.0944941"
- d="m 74.709966,169.73071 c -1.970594,0.29267 -9.664519,-6.99861 -12.236726,-11.59635 -0.790382,-1.4128 -0.946345,-2.29969 -0.423758,-2.4098 0.528179,-0.11131 2.0067,0.67581 3.550588,1.89022 2.808431,2.20905 6.762138,6.50618 8.362712,9.08905 1.12843,1.82096 1.402097,2.9296 0.747184,3.02688 z"
- id="path22-3-6"
- inkscape:transform-center-x="37.420481"
- inkscape:transform-center-y="-21.837511" />
- <rect
- style="fill:#0000ff;fill-rule:evenodd;stroke-width:0.264583"
- id="rect64"
- width="186.92551"
- height="1.8174417"
- x="17.333752"
- y="135.38728" />
- <rect
- style="fill:#0000ff;fill-rule:evenodd;stroke-width:0.264583"
- id="rect64-7"
- width="186.92551"
- height="1.8174417"
- x="31.72876"
- y="-100.25121"
- transform="rotate(89.560511)" />
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="197.80376"
- y="132.93736"
- id="text88"><tspan
- sodipodi:role="line"
- id="tspan86"
- x="197.80376"
- y="132.93736"
- style="stroke-width:0.264583">x</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="101.31552"
- y="42.965397"
- id="text92"><tspan
- sodipodi:role="line"
- id="tspan90"
- x="101.31552"
- y="42.965397"
- style="stroke-width:0.264583">y</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="92.677986"
- y="145.29591"
- id="text96"><tspan
- sodipodi:role="line"
- id="tspan94"
- x="92.677986"
- y="145.29591"
- style="stroke-width:0.264583">0</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="142.35989"
- y="149.98514"
- id="text96-5"><tspan
- sodipodi:role="line"
- id="tspan94-3"
- x="142.35989"
- y="149.98514"
- style="stroke-width:0.264583">1</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="94.360558"
- y="101.32148"
- id="text96-5-5"><tspan
- sodipodi:role="line"
- id="tspan94-3-6"
- x="94.360558"
- y="101.32148"
- style="stroke-width:0.264583">1</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="46.688869"
- y="147.24464"
- id="text96-5-5-2"><tspan
- sodipodi:role="line"
- x="46.688869"
- y="147.24464"
- style="stroke-width:0.264583"
- id="tspan170">-1</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="88.356491"
- y="186.57739"
- id="text96-5-5-2-1"><tspan
- sodipodi:role="line"
- x="88.356491"
- y="186.57739"
- style="stroke-width:0.264583"
- id="tspan170-2">-1</tspan></text>
- <circle
- id="path198"
- style="fill:#000000;stroke:#000000;stroke-width:0.264583"
- cx="144.59926"
- cy="132.06937"
- r="0.012488274" />
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="140.65088"
- y="140.43587"
- id="text202"><tspan
- sodipodi:role="line"
- id="tspan200"
- x="140.65088"
- y="140.43587"
- style="font-size:4.23333px;stroke-width:0.264583">0rad</tspan><tspan
- sodipodi:role="line"
- x="140.65088"
- y="153.66498"
- style="stroke-width:0.264583"
- id="tspan204" /></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:4.23333px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="59.606441"
- y="102.25119"
- id="text208"><tspan
- sodipodi:role="line"
- id="tspan206"
- x="59.606441"
- y="102.25119"
- style="font-size:4.23333px;stroke-width:0.264583">2.09rad</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:4.23333px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="53.299278"
- y="167.29311"
- id="text212"><tspan
- sodipodi:role="line"
- id="tspan210"
- x="53.299278"
- y="167.29311"
- style="font-size:4.23333px;stroke-width:0.264583">4.18rad</tspan></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="142.78784"
- y="135.75781"
- id="text216"><tspan
- sodipodi:role="line"
- id="tspan214"
- x="142.78784"
- y="135.75781"
- style="stroke-width:0.264583">A</tspan><tspan
- sodipodi:role="line"
- x="142.78784"
- y="148.98694"
- style="stroke-width:0.264583"
- id="tspan218" /><tspan
- sodipodi:role="line"
- x="142.78784"
- y="162.21606"
- style="stroke-width:0.264583"
- id="tspan220" /></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="68.655945"
- y="112.41339"
- id="text216-7"><tspan
- sodipodi:role="line"
- id="tspan214-0"
- x="68.655945"
- y="112.41339"
- style="stroke-width:0.264583">B</tspan><tspan
- sodipodi:role="line"
- x="68.655945"
- y="125.64252"
- style="stroke-width:0.264583"
- id="tspan218-9" /><tspan
- sodipodi:role="line"
- x="68.655945"
- y="138.87164"
- style="stroke-width:0.264583"
- id="tspan220-3" /></text>
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="67.528885"
- y="164.8815"
- id="text216-7-6"><tspan
- sodipodi:role="line"
- id="tspan214-0-0"
- x="67.528885"
- y="164.8815"
- style="stroke-width:0.264583">C</tspan><tspan
- sodipodi:role="line"
- x="67.528885"
- y="178.11063"
- style="stroke-width:0.264583"
- id="tspan298" /><tspan
- sodipodi:role="line"
- x="67.528885"
- y="191.33975"
- style="stroke-width:0.264583"
- id="tspan218-9-6" /><tspan
- sodipodi:role="line"
- x="67.528885"
- y="204.56888"
- style="stroke-width:0.264583"
- id="tspan220-3-2" /></text>
- <rect
- style="fill:#c900ff;fill-opacity:1;fill-rule:evenodd;stroke-width:0.264583"
- id="rect318"
- width="40.081783"
- height="3.5191765"
- x="-9.3766651"
- y="166.49748"
- transform="rotate(-39.971721)" />
- <rect
- style="fill:#c900ff;fill-opacity:1;fill-rule:evenodd;stroke-width:0.12328"
- id="rect318-6"
- width="27.441587"
- height="1.1159221"
- x="104.34172"
- y="135.77676"
- transform="matrix(0.99998555,0.0053753,-0.01704694,0.99985469,0,0)" />
- <rect
- style="fill:#c900ff;fill-opacity:1;fill-rule:evenodd;stroke-width:0.127056"
- id="rect318-6-1"
- width="29.147621"
- height="1.1159564"
- x="-135.70338"
- y="128.97763"
- transform="matrix(-0.00379001,-0.99999282,0.9999488,0.01011907,0,0)" />
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:4.58611px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
- x="102.17614"
- y="135.32759"
- id="text208-8"><tspan
- sodipodi:role="line"
- id="tspan206-7"
- x="102.17614"
- y="135.32759"
- style="font-size:4.58611px;stroke-width:0.264583">0.52rad</tspan></text>
- <rect
- style="fill:#c98b00;fill-opacity:1;fill-rule:evenodd;stroke-width:0.121786"
- id="rect318-6-1-0"
- width="26.779816"
- height="1.1159475"
- x="-135.58972"
- y="138.72464"
- transform="matrix(-0.00412511,-0.99999149,0.99995678,0.00929711,0,0)" />
- </g>
-</svg>
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swp b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swp
deleted file mode 100644
index 3b62227..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/.avrage_motor_values.dat.kate-swp
+++ /dev/null
Binary files differ
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/avrage_motor_values.dat b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/avrage_motor_values.dat
deleted file mode 100644
index dbbfee0..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/example_outp/avrage_motor_values.dat
+++ /dev/null
@@ -1 +0,0 @@
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910, \ No newline at end of file
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/motor_calibration.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/motor_calibration.ino
deleted file mode 100644
index 362d130..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motor_calibration/motor_calibration.ino
+++ /dev/null
@@ -1,231 +0,0 @@
-#include <TimerThree.h>
-#include <SD.h>
-#include <SPI.h>
-
-int enA = 1; //PWM pin
-int enB = 2; //GND
-int pwm1 = 3; //
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-const int maxspeed = 1000;
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-File ;
-File avrage;
-Sd2Card card;
-SdVolume volume;
-SdFile root;
-const int chipSelect = BUILTIN_SDCARD;
-int x = 1;
-
-int Nloop = 0;
-int totloopdata[maxspeed] = {};
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- //Serial.print("softPWM pin: enA, value: ");
- //Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- //Serial.print("RPM: ");
- //Serial.print(rpm);
- //Serial.print(" Sample period:");
- //Serial.print(Ptime);
- //Serial.print("ms, encoder count:");
- //Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- //Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- //Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- //Serial.println(sp);
-}
-
-void loop() {
- move(0);
- //max
- /*
- Serial.println();
- Serial.println();
- Serial.println();
- move(maxspeed);
- Serial.print("max speed: ");
- delay(1000);
- resetenc();
- delay(1000);
- readenc();
- Serial.print(rpm);
- Serial.print("rpm, with input: ");
- Serial.println(maxspeed);
- delay(250);
- move(0);
-
- //min
- delay(5000);
- Serial.print("min speed: ");
- for (int i = 0; i < maxspeed; i++) {
- move(i);
- delay(1000);
- readenc();
- if ((rpm > 10) && (i>5)) {
- Serial.print(rpm);
- Serial.print("rpm, with input: ");
- Serial.println(i);
- break;
- }
- }
- */
- delay(2000);
- for (int i = 0; i < maxspeed; i++) {
- Serial.println("0,0");
- }
- int currentloopdata[maxspeed] = {};
- for (int i = 0; i < maxspeed; i++) {
- move(i);
- delay(100);
- readenc();
- Serial.print(i);
- Serial.print(",");
- Serial.print(rpm);
- currentloopdata[i] = rpm;
- Serial.print(",");
- Serial.println(totloopdata[i]);
- }
- /*
- for (int i = 0; i < maxspeed; i++) {
- move(0);
- delay(200);
- move(i);
- delay(1000);
- resetenc();
- delay(100);
- readenc();
- Serial.print(i);
- Serial.print(",");
- Serial.print(rpm);
- currentloopdata[i] = rpm;
- Serial.print(",");
- Serial.println(totloopdata[i]);
- }
- */
- currentloopdata[0] = 0;
- if (Nloop == 0){
- for (int i = 0; i < maxspeed; i++) {
- totloopdata[i] = currentloopdata[i];
- }
- }else{
- for (int i = 0; i < maxspeed; i++) {
- //Serial.print(currentloopdata[i]);
- //Serial.print(", ");
- //Serial.print(totloopdata[i]);
- totloopdata[i] = ((totloopdata[i]*Nloop)+currentloopdata[i])/(Nloop+1);
- }
- }
- for (int i = 0; i < maxspeed; i++) {
- //Serial.print(currentloopdata[i]);
- //Serial.print(", ");
- }
-
- resetenc();
- SD.remove("avrage_motor_values.dat");
- File dataFile = SD.open("avrage_motor_values.dat", FILE_WRITE);
- if (dataFile) {
- for (int i = 0; i < maxspeed; i++) {
- dataFile.print(totloopdata[i]);
- dataFile.print(", ");
- }
- dataFile.close();
- }
- SD.remove("avrage_motor_values.csv");
- File debugFile = SD.open("avrage_motor_values.csv", FILE_WRITE);
- if (debugFile) {
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(totloopdata[i]);
- }
- }
-
- if (!card.init(SPI_HALF_SPEED, chipSelect)) {
- Serial.println("FAILED TO FIND SD CARD");
- Serial.println("* is a card inserted?");
- Serial.println("* is your wiring correct?");
- Serial.println("* did you change the chipSelect pin to match your shield or module?");
- }
-
-
- Nloop++;
-
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motordriver.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motordriver.ino
deleted file mode 100644
index 2f1c225..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/motordriver.ino
+++ /dev/null
@@ -1,386 +0,0 @@
-#include <Adafruit_MCP23X17.h>
-#include <TimerThree.h>
-//moveohmi = https://stackoverflow.com/questions/3748037/how-to-control-a-kiwi-drive-robot
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
-
-
-#define ArrayElementCount(needRPM) (sizeof(needRPM) / sizeof(needRPM[0]))
-
-// motor one/A front
-#define m1enA 3 // GPA3 PWM1
-#define m1enB 2 // GPA2
-#define m1pwm1 0 // GPA0
-#define m1pwm2 1 // GPA1
-#define m1encA 12 // GPB4
-#define m1encB 13 // GPB5
-// motor two/B left
-#define m2enA 7 // GPA7 PWM2
-#define m2enB 6 // GPA6
-#define m2pwm1 4 // GPA4
-#define m2pwm2 5 // GPA5
-#define m2encA 14 // GPB6
-#define m2encB 15 // GPB7
-// motor three/C right
-#define m3enA 11 // GPB3 PWM3
-#define m3enB 10 // GPB2
-#define m3pwm1 8 // GPB0
-#define m3pwm2 9 // GPB1
-#define m3encA 24 // teensy port 24
-#define m3encB 9 // teensy port 9
-
-double sp = 1200.000; //speed in RPM ~0-1800
-const int maxspeed = 1000;
-
-//calibration data
-int Amotordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-int Bmotordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-int Cmotordata[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 0, 1, 1, 1, 0, 14, 12, 14, 9, 11, 16, 9, 9, 9, 16, 28, 28, 32, 42, 39, 29, 29, 45, 36, 30, 60, 102, 109, 113, 124, 154, 153, 154, 151, 172, 183, 214, 243, 288, 302, 306, 320, 336, 337, 338, 356, 420, 438, 451, 465, 501, 499, 492, 509, 519, 528, 561, 567, 611, 632, 610, 616, 638, 641, 641, 667, 705, 721, 735, 724, 772, 756, 761, 748, 773, 774, 810, 817, 849, 840, 840, 861, 858, 876, 857, 883, 917, 917, 920, 932, 954, 936, 925, 918, 963, 951, 960, 995, 1011, 1011, 1008, 1011, 1052, 1022, 1033, 1014, 1059, 1059, 1092, 1053, 1092, 1080, 1056, 1062, 1097, 1111, 1096, 1094, 1170, 1131, 1137, 1134, 1158, 1174, 1137, 1185, 1234, 1198, 1203, 1192, 1223, 1194, 1207, 1204, 1241, 1222, 1252, 1229, 1291, 1232, 1241, 1226, 1246, 1244, 1225, 1230, 1298, 1295, 1271, 1270, 1306, 1300, 1280, 1265, 1357, 1283, 1278, 1307, 1369, 1297, 1337, 1299, 1357, 1326, 1326, 1316, 1375, 1341, 1373, 1366, 1351, 1366, 1326, 1314, 1404, 1364, 1373, 1366, 1417, 1431, 1381, 1349, 1468, 1383, 1367, 1352, 1460, 1411, 1420, 1400, 1471, 1435, 1415, 1429, 1455, 1424, 1432, 1406, 1506, 1447, 1444, 1416, 1511, 1438, 1442, 1476, 1578, 1498, 1444, 1440, 1521, 1539, 1448, 1448, 1539, 1492, 1518, 1464, 1604, 1565, 1503, 1468, 1539, 1479, 1492, 1481, 1582, 1549, 1495, 1525, 1618, 1543, 1515, 1546, 1631, 1597, 1532, 1569, 1712, 1577, 1537, 1557, 1621, 1596, 1532, 1546, 1721, 1572, 1566, 1562, 1645, 1602, 1592, 1580, 1708, 1587, 1587, 1599, 1639, 1566, 1576, 1540, 1699, 1664, 1561, 1593, 1731, 1589, 1613, 1563, 1695, 1608, 1628, 1597, 1721, 1737, 1613, 1613, 1772, 1665, 1670, 1656, 1758, 1645, 1649, 1603, 1772, 1702, 1688, 1678, 1782, 1685, 1718, 1650, 1863, 1793, 1687, 1717, 1804, 1782, 1695, 1704, 1789, 1769, 1674, 1715, 1867, 1795, 1675, 1702, 1761, 1673, 1676, 1667, 1765, 1708, 1721, 1667, 1792, 1728, 1681, 1674, 1792, 1770, 1745, 1698, 1816, 1797, 1715, 1776, 1938, 1796, 1742, 1745, 1911, 1832, 1800, 1772, 1930, 1752, 1721, 1714, 1920, 1805, 1730, 1711, 1864, 1862, 1700, 1762, 1897, 1805, 1753, 1761, 1951, 1790, 1749, 1773, 1947, 1781, 1712, 1782, 1901, 1799, 1732, 1724, 1856, 1772, 1759, 1751, 1923, 1846, 1765, 1765, 1944, 1822, 1791, 1776, 1945, 1854, 1830, 1800, 1921, 1860, 1776, 1748, 1954, 1874, 1858, 1773, 2035, 1852, 1775, 1826, 2072, 1934, 1859, 1897, 2003, 2054, 1860, 1887, 2214, 1993, 1970, 1874, 2041, 2043, 1894, 1839, 2080, 1905, 1822, 1907, 2124, 1935, 1857, 1883, 1957, 1940, 1860, 1870, 1865, 1877, 1876, 1846, 2092, 1928, 1825, 1833, 1979, 1914, 1920, 1837, 1988, 1900, 1867, 1825, 2049, 1964, 1834, 1857, 1979, 1893, 1815, 1874, 2002, 2023, 1803, 1877, 1894, 1989, 1840, 1846, 2001, 1958, 1861, 1867, 2066, 1952, 1853, 1806, 1894, 1880, 1769, 1767, 1893, 1840, 1780, 1787, 1857, 1814, 1780, 1722, 1859, 1920, 1800, 1840, 1853, 1823, 1776, 1771, 1843, 1871, 1819, 1769, 1900, 1876, 1792, 1809, 1908, 1944, 1859, 1920, 2073, 1985, 1913, 1917, 1940, 1897, 1883, 1807, 1910, 1910, 1873, 1826, 1917, 1893, 1802, 1802, 1886, 2008, 1859, 1814, 1930, 1905, 1850, 1833, 1909, 2019, 1850, 1807, 2012, 2010, 1938, 1856, 2051, 1890, 1848, 1842, 1958, 1950, 1874, 1915, 2029, 1947, 1827, 1867, 1949, 2022, 1957, 1941, 2161, 2040, 2018, 1894, 2005, 2118, 1986, 1951, 1936, 1927, 1946, 1978, 2025, 2019, 1888, 1904, 1964, 1914, 1822, 1834, 1945, 1924, 1873, 1853, 1995, 1975, 1830, 1894, 1958, 1958, 1848, 1786, 1907, 1959, 1952, 1964, 2020, 1927, 1901, 1903, 1986, 1931, 1921, 1985, 1972, 1993, 2028, 1859, 1927, 1901, 1904, 1861, 1936, 1937, 1928, 1902, 1937, 1971, 1944, 1840, 1948, 1972, 1955, 1942, 1972, 2073, 2057, 1924, 1925, 2036, 1893, 1836, 2008, 2060, 1947, 1957, 2156, 1976, 1905, 1914, 2022, 1985, 1947, 1920, 2058, 1968, 1893, 1929, 2042, 2052, 1975, 1867, 2063, 1962, 2011, 1948, 2070, 1957, 1911, 1843, 1944, 1945, 1902, 1878, 1964, 1864, 1930, 1870, 1942, 1958, 1941, 1898, 1898, 1923, 1948, 1921, 1957, 1934, 1952, 1924, 1942, 1901, 1950, 1894, 2016, 2062, 1975, 1893, 1921, 1978, 1935, 1857, 1955, 1921, 1866, 1841, 1890, 1876, 1821, 1855, 1961, 1895, 1877, 1852, 1873, 1857, 1915, 1820, 1850, 1897, 1856, 1833, 1921, 1915, 1823, 1807, 1904, 1830, 1817, 1790, 1911, 1864, 1883, 1843, 1915, 1989, 1917, 1863, 1921, 1951, 1958, 1971, 1958, 1983, 1901, 1934, 1934, 1987, 2011, 1979, 2023, 2059, 2026, 1890, 2052, 1931, 1917, 1923, 2126, 2036, 1965, 1899, 1971, 1913, 1870, 1835, 1911, 1962, 2005, 1971, 2039, 2050, 1986, 1857, 1993, 1958, 2041, 2025, 1969, 2004, 2012, 1931, 2101, 1939, 2006, 2063, 2035, 2146, 1971, 1972, 2018, 2028, 1917, 1835, 1923, 1988, 1884, 1924, 1947, 1894, 1968, 1952, 1931, 1909, 1914, 1883, 1901, 1933, 2001, 1952, 1992, 2019, 1938, 1952, 1921, 2009, 1999, 1982, 1985, 1949, 1907, 1968, 1911, 2006, 1935, 1944, 1921, 1924, 1981, 1930, 1928, 2046, 1877, 1811, 1888, 1912, 1866, 1887, 1918, 1929, 1913, 1922, 1923, 1915, 1918, 1918, 1937, 1981, 1948, 1959, 1978, 1972, 1981, 1920, 1994, 1995, 1987, 1890, 1929, 1985, 1978, 2042, 2070, 2006, 1999, 1948, 1961, 2046, 1971, 1984, 2097, 1942, 1937, 1887, 2011, 1999, 2016, 1979, 2008, 1992, 2034, 2003, 1988, 2052, 2025, 1931, 2030, 1952, 1900, 1878, 1930, 2038, 1954, 1941, 2003, 2013, 1992, 1920, 2005, 1957, 1960, 1911, 1931, 1954, 1927, 1935, 1971, 2023, 1931, 1900, 1962, 1952, 1979, 1941, 1957, 1985, 1944, 1961, 2029, 1998, 1995, 1946, 1955, 1949, 1938, 1921, 1908, 1941, 1943, 1932, 1948, 1924, 1989, 1974, 1977, 1994, 2033, 1948, 1907, 1948, 1880, 1915, 1941, 1921, 1949, 1938, 1958, 1956, 1937, 1931, 2032, 1996, 2008, 1937, 1937, 1935, 1962, 1941, 1938, 2029, 2013, 1999, 2021, 2029, 1899, 1886, 2013, 1871, 1853, 1901, 1860, 1907, 1880, 1910, 1943, 1881, 1893, 1873, 1870, 1908, 1917, 1908, 1904, 1895, 1854, 1889, 1900, 1857, 1934, 1873, 1936, 1920, 1900, 1903, 1925, 1910, 1886, 1924, 1891, 1905, 1883, 1854, 1918, 1860, 1912, 1879, 1913, 1898, 1905, 1874, 1893, 1870, 1910};
-
-int AneedRPM = 0;
-int BneedRPM = 0;
-int CneedRPM = 0;
-
-
-//kiwidrive
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-
-//encoder
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-
-//softPWM
-volatile int PWMval1 = 0; // PWM m1enA value 0-100
-volatile int PWMval2 = 0; // PWM m2enA value 0-100
-volatile int PWMval3 = 0; // PWM m3enA value 0-100
-
-
-Adafruit_MCP23X17 mcp2;
-
-void setup(){
- if (!mcp2.begin_I2C(0x22)) {
- Serial.println("Error initializing MCP23017 at 0x22.");
- //while (1);
- }
- // set all the motor control pins
- mcp2.pinMode(m1enA, OUTPUT);
- mcp2.pinMode(m1enB, OUTPUT);
- mcp2.pinMode(m2enA, OUTPUT);
- mcp2.pinMode(m2enB, OUTPUT);
- mcp2.pinMode(m3enA, OUTPUT);
- mcp2.pinMode(m3enB, OUTPUT);
- mcp2.pinMode(m1pwm1, OUTPUT);
- mcp2.pinMode(m1pwm2, OUTPUT);
- mcp2.pinMode(m2pwm1, OUTPUT);
- mcp2.pinMode(m2pwm2, OUTPUT);
- mcp2.pinMode(m3pwm1, OUTPUT);
- mcp2.pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins
- mcp2.pinMode(m1encA, INPUT);
- mcp2.pinMode(m1encB, INPUT);
- mcp2.pinMode(m2encA, INPUT);
- mcp2.pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM1);
- Timer3.attachInterrupt(updatePWM2);
- Timer3.attachInterrupt(updatePWM3);
-
-}
-void updatePWM1() {
- static int counter1 = 0;
-
- if (counter1 < PWMval1) {
- mcp2.digitalWrite(m1enA, HIGH);
- } else {
- mcp2.digitalWrite(m1enA, LOW);
- }
-
- counter1++;
- if (counter1 >= 100) {
- counter1 = 0;
- }
-}
-void updatePWM2() {
- static int counter2 = 0;
-
- if (counter2 < PWMval2) {
- mcp2.digitalWrite(m2enA, HIGH);
- } else {
- mcp2.digitalWrite(m2enA, LOW);
- }
-
- counter2++;
- if (counter2 >= 100) {
- counter2 = 0;
- }
-}
-void updatePWM3() {
- static int counter3 = 0;
-
- if (counter3 < PWMval3) {
- mcp2.digitalWrite(m3enA, HIGH);
- } else {
- mcp2.digitalWrite(m3enA, LOW);
- }
-
- counter3++;
- if (counter3 >= 100) {
- counter3 = 0;
- }
-}
-void mcpsoftpwm(int pin, int vall){
- //M1enA = 3 = GPA3
- //M2enA = 7 = GPA7
- //M3enA = 11 = GPB3
- Serial.print("softPWM pin: ");
- Serial.print(pin);
- Serial.print(", value: ");
- Serial.println(vall);
- if (pin = 3){
- PWMval1 = vall;
- Serial.print("Motor 1 enA PWM set");
- }
- if (pin = 7){
- PWMval2 = vall;
- Serial.print("Motor 2 enA PWM set");
- }
- if (pin = 11){
- PWMval3 = vall;
- Serial.print("Motor 3 enA PWM set");
- }
-
-}
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-void Aresetenc(){
- ACtime = micros();
- ALtime = ACtime;
- Aencount = 0;
-}
-void Bresetenc(){
- BCtime = micros();
- BLtime = BCtime;
- Bencount = 0;
-}
-void Cresetenc(){
- CCtime = micros();
- CLtime = CCtime;
- Cencount = 0;
-}
-void Amove(double Rsped) {
- double sped = nearest(Rsped, Amotordata, ArrayElementCount(Amotordata));
- spdA = abs(sped) * 0.1;
- mcpsoftpwm(m1enA, spdA);
- mcp2.digitalWrite(m1enB, LOW);
- if (sped < 0) {
- Serial.print("Motor A back ");
- mcp2.digitalWrite(m1pwm1, LOW);
- mcp2.digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("Motor A forward ");
- mcp2.digitalWrite(m1pwm1, HIGH);
- mcp2.digitalWrite(m1pwm2, LOW);
- }
- Serial.println(spdA);
-}
-void Bmove(double Rsped) {
- double sped = nearest(Rsped, Bmotordata, ArrayElementCount(Bmotordata));
- spdB = abs(sped) * 0.1;
- mcpsoftpwm(m2enA, spdB);
- mcp2.digitalWrite(m2enB, LOW);
- if (sped < 0) {
- Serial.print("Motor B back ");
- mcp2.digitalWrite(m2pwm1, LOW);
- mcp2.digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("Motor B forward ");
- mcp2.digitalWrite(m2pwm1, HIGH);
- mcp2.digitalWrite(m2pwm2, LOW);
- }
- Serial.println(spdB);
-}
-void Cmove(double Rsped) {
- double sped = nearest(Rsped, Cmotordata, ArrayElementCount(Cmotordata));
- spdC = abs(sped) * 0.1;
- mcpsoftpwm(m3enA, spdC);
- mcp2.digitalWrite(m3enB, LOW);
- if (sped < 0) {
- Serial.print("Motor C back ");
- mcp2.digitalWrite(m3pwm1, LOW);
- mcp2.digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("Motor C forward ");
- mcp2.digitalWrite(m3pwm1, HIGH);
- mcp2.digitalWrite(m3pwm2, LOW);
- }
- Serial.println(spdC);
-}
-
-void moveohmi(int speed, int direction){
- Amove(0);
- Bmove(0);
- Cmove(0);
-
- double dirrad = (direction*71.0000) / 4068.0000;
- Serial.println(dirrad);
- //vector ontb in x en y
- double y = sin(dirrad);
- double x = cos(dirrad);
- Serial.println((String)"x:"+x+" y:"+y);
- double spdeA = y*speed;
- double spdeB = (-0.500*x - 0.8660054*y)*speed;
- double spdeC = (-0.500*x + 0.8660054*y)*speed;
- Amove(spdeA);
- Bmove(spdeB);
- Cmove(spdeC);
- Serial.println();
- Serial.println();
-}
-void rotate(int rodeg, int speed){
- //use compas heading
- //inacurate compas data
-}
-void demo(){
- Amove(sp);
- Bmove(sp);
- Cmove(sp);
- Serial.println("seperate A B C rotation");
- delay(1000);
-
- Amove(0);
- Bmove(0);
- Cmove(0);
- Serial.println("seperate A B C stop");
- delay(1000);
-
- Amove(-sp);
- Bmove(-sp);
- Cmove(-sp);
- Serial.println("seperate A B C -rotation");
- delay(1000);
-
- moveohmi(0, 0);
- Serial.println("ohmi stop");
- delay(1000);
-
- rotate(90, sp);
- Serial.println("rotation function 90deg");
- rotate(90, sp);
- Serial.println("rotation function -90deg");
- delay(1000);
-
- moveohmi(sp, 35);
- Serial.println("ohmi move 35deg");
- delay(1000);
-
- moveohmi(sp, 240);
- Serial.println("ohmi move 215deg");
- delay(1000);
-
- for(int i = 0; i<360; i++){
- moveohmi(sp, i);
- Serial.println(i);
- delay(50);
- }
- Serial.println("ohmi move circle");
- delay(1000);
-}
-void loop(){
- demo();
- delay(100);
-
-}
-int nearest(int x, int myArray[], int elements)
-{
- //https://forum.arduino.cc/t/search-for-nearest-number-in-an-array-help/245843/5
- int idx = 0; // by default near first element
-
- int distance = abs(myArray[idx] - x);
- for (int i = 1; i < elements; i++)
- {
- int d = abs(myArray[i] - x);
- if (d < distance)
- {
- idx = i;
- distance = d;
- }
- }
- return idx;
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/nomultiplexer/nomultiplexer.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/nomultiplexer/nomultiplexer.ino
deleted file mode 100644
index f6f839c..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/nomultiplexer/nomultiplexer.ino
+++ /dev/null
@@ -1,254 +0,0 @@
-//moveohmi = https://robotics.stackexchange.com/questions/7829/how-to-program-a-three-wheel-omni
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//
-// motor one/A front
-int m1enA = 1;
-int m1enB = 2;
-int m1pwm1 = 3;
-int m1pwm2 = 4;
-int m1encA = 13;
-int m1encB = 14;
-// motor two/B left
-int m2enA = 5;
-int m2enB = 6;
-int m2pwm1 = 7;
-int m2pwm2 = 8;
-int m2encA = 15;
-int m2encB = 16;
-// motor three/C right
-int m3enA = 9;
-int m3enB = 10;
-int m3pwm1 = 11;
-int m3pwm2 = 12;
-int m3encA = 17;
-int m3encB = 18;
-
-double sp = 1.000; //speed in 0-1
-
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-
-void setup()
-{
- // set all the motor control pins to outputs
- pinMode(m1enA, OUTPUT);
- pinMode(m1enB, OUTPUT);
- pinMode(m2enA, OUTPUT);
- pinMode(m2enB, OUTPUT);
- pinMode(m3enA, OUTPUT);
- pinMode(m3enB, OUTPUT);
-
- pinMode(m1pwm1, OUTPUT);
- pinMode(m1pwm2, OUTPUT);
- pinMode(m2pwm1, OUTPUT);
- pinMode(m2pwm2, OUTPUT);
- pinMode(m3pwm1, OUTPUT);
- pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins to input
- pinMode(m1encA, INPUT);
- pinMode(m1encB, INPUT);
- pinMode(m2encA, INPUT);
- pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-}
-
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-
-void Amove(double sped) {
- spdA = abs(sped) * 255.000;
- analogWrite(m1enA, spdA);
- digitalWrite(m1enB, LOW);
- if (sped < 0) {
- Serial.print("Motor A back ");
- digitalWrite(m1pwm1, LOW);
- digitalWrite(m1pwm2, HIGH);
- } else {
- Serial.print("Motor A forward ");
- digitalWrite(m1pwm1, HIGH);
- digitalWrite(m1pwm2, LOW);
- }
- Serial.println(spdA);
-}
-void Bmove(double sped) {
- spdB = abs(sped) * 255.000;
- analogWrite(m2enA, spdB);
- digitalWrite(m2enB, LOW);
- if (sped < 0) {
- Serial.print("Motor B back ");
- digitalWrite(m2pwm1, LOW);
- digitalWrite(m2pwm2, HIGH);
- } else {
- Serial.print("Motor B forward ");
- digitalWrite(m2pwm1, HIGH);
- digitalWrite(m2pwm2, LOW);
- }
- Serial.println(spdB);
-}
-void Cmove(double sped) {
- spdC = abs(sped) * 255.000;
- analogWrite(m3enA, spdC);
- digitalWrite(m3enB, LOW);
- if (sped < 0) {
- Serial.print("Motor C back ");
- digitalWrite(m3pwm1, LOW);
- digitalWrite(m3pwm2, HIGH);
- } else {
- Serial.print("Motor C forward ");
- digitalWrite(m3pwm1, HIGH);
- digitalWrite(m3pwm2, LOW);
- }
- Serial.println(spdC);
-}
-
-
-void moveohmi(int speed, int direction){
- Amove(0);
- Bmove(0);
- Cmove(0);
-
- double dirrad = (direction*71.0000) / 4068.0000;
- Serial.println(dirrad);
- //vector ontb in x en y
- double y = sin(dirrad);
- double x = cos(dirrad);
- Serial.println((String)"x:"+x+" y:"+y);
- double spdeA = y*speed;
- double spdeB = (-0.500*x - 0.8660054*y)*speed;
- double spdeC = (-0.500*x + 0.8660054*y)*speed;
- Amove(spdeA);
- Bmove(spdeB);
- Cmove(spdeC);
- Serial.println();
- Serial.println();
-}
-void rotate(int rodeg, int speed){
-//use compas heading
-}
-void demo(){
- Amove(sp);
- Bmove(sp);
- Cmove(sp);
- Serial.println("seperate A B C rotation");
- delay(1000);
-
- Amove(0);
- Bmove(0);
- Cmove(0);
- Serial.println("seperate A B C stop");
- delay(1000);
-
- Amove(-sp);
- Bmove(-sp);
- Cmove(-sp);
- Serial.println("seperate A B C -rotation");
- delay(1000);
-
- moveohmi(0, 0);
- Serial.println("ohmi stop");
- delay(1000);
-
- rotate(90, sp);
- Serial.println("rotation function 90deg");
- rotate(90, sp);
- Serial.println("rotation function -90deg");
- delay(1000);
-
- moveohmi(sp, 35);
- Serial.println("ohmi move 35deg");
- delay(1000);
-
- moveohmi(sp, 240);
- Serial.println("ohmi move 215deg");
- delay(1000);
-
- for(int i = 0; i<360; i++){
- moveohmi(sp, i);
- Serial.println(i);
- delay(50);
- }
- Serial.println("ohmi move circle");
- delay(1000);
-}
-void loop(){
- demo();
- delay(100);
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor/onemotor.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor/onemotor.ino
deleted file mode 100644
index 8833a51..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor/onemotor.ino
+++ /dev/null
@@ -1,81 +0,0 @@
-int enA = 27;
-int enB = 26;
-int pwm1 = 24;
-int pwm2 = 25;
-int encoA = 5;
-int encoB = 6;
-int speed = 1; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
- pinMode(LED_BUILTIN, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
- digitalWrite(LED_BUILTIN, HIGH);
-
- Serial.begin(9600);
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*255;
- analogWrite(enA, sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- digitalWrite(enA, HIGH);
- digitalWrite(enB, LOW);
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- delay(1000);
- readenc();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM/onemotor_softPWM.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM/onemotor_softPWM.ino
deleted file mode 100644
index 2f57d59..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM/onemotor_softPWM.ino
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <TimerThree.h>
-
-int enA = 1; //PWM pin
-int enB = 2; //GND
-int pwm1 = 3; //
-int pwm2 = 4;
-int encoA = 5;
-int encoB = 6;
-
-int speed = 1000; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-
-void setup() {
- pinMode(enA, OUTPUT);
- pinMode(enB, OUTPUT);
- pinMode(pwm1, OUTPUT);
- pinMode(pwm2, OUTPUT);
-
- pinMode(encoA, INPUT_PULLUP);
- pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-
- Serial.begin(9600);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(enA, HIGH);
- } else {
- digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*0.1;
- mcpsoftpwm(sp);
- digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- digitalWrite(pwm1, LOW);
- digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- digitalWrite(pwm1, HIGH);
- digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-
- move(0);
- delay(1000);
- resetenc();
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-
- move(500);
- delay(1000);
- readenc();
- delay(1000);
-
- Serial.println();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino
deleted file mode 100644
index 5c8ff2a..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/onemotor_softPWM_multiplexer/onemotor_softPWM_multiplexer.ino
+++ /dev/null
@@ -1,128 +0,0 @@
-#include <TimerThree.h>
-#include <Adafruit_MCP23X17.h>
-
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
-
-Adafruit_MCP23X17 mcp;
-
-int enA = 0; // GPA0 -PWM
-int enB = 1; // GPA1 -GND
-int pwm1 = 2; // GPA2 -HIGH/LOW
-int pwm2 = 3; // GPA3 -HIGH/LOW
-int encoA = 4; // GPA4 -read
-int encoB = 5; // GPA5 -read
-
-int speed = 100; // speed 0-1
-
-double sp = 0.00;
-double rpm = 0.00;
-volatile long encount = 0;
-unsigned long Ltime = 0;
-unsigned long Ctime = 0;
-unsigned long Ptime = 0;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-
-void setup() {
- Serial.begin(9600);
- if (!mcp.begin_I2C(0x20)) {
- Serial.println("Error initializing MCP23017 at 0x20.");
- while (1);
- }
-
- mcp.pinMode(enA, OUTPUT);
- mcp.pinMode(enB, OUTPUT);
- mcp.pinMode(pwm1, OUTPUT);
- mcp.pinMode(pwm2, OUTPUT);
-
- mcp.pinMode(encoA, INPUT_PULLUP);
- mcp.pinMode(encoB, INPUT_PULLUP);
-
- attachInterrupt(digitalPinToInterrupt(encoA), encoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(encoB), encoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- mcp.digitalWrite(enA, HIGH);
- } else {
- mcp.digitalWrite(enA, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: enA, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void encoderISR() {
- encount++;
-}
-
-void readenc() {
- Ctime = micros();
- Ptime = Ctime - Ltime;
- Ltime = Ctime;
- rpm = (encount / 211.2) * (60000000.0 / Ptime);
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" Sample period:");
- Serial.print(Ptime);
- Serial.print("ms, encoder count:");
- Serial.println(encount);
-
- encount = 0;
-}
-void resetenc(){
- Ctime = micros();
- Ltime = Ctime;
- encount = 0;
-}
-
-void move(int sped) {
- sp = abs(sped)*1;
- mcpsoftpwm(sp);
- mcp.digitalWrite(enB, LOW);
- if (sped < 0) {
- Serial.print("back ");
- mcp.digitalWrite(pwm1, LOW);
- mcp.digitalWrite(pwm2, HIGH);
- } else {
- Serial.print("forward ");
- mcp.digitalWrite(pwm1, HIGH);
- mcp.digitalWrite(pwm2, LOW);
- }
- Serial.println(sp);
-}
-
-void loop() {
- move(speed);
- delay(1000);
- readenc();
-
-
- move(0);
- resetenc();
- delay(1000);
- readenc();
-
- move(-speed);
- delay(1000);
- readenc();
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/softPWM/softPWM.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/softPWM/softPWM.ino
deleted file mode 100644
index ab74715..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/softPWM/softPWM.ino
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <TimerThree.h>
-#include <Arduino.h>
-
-int pwmPin = 3;
-
-volatile int PWMval = 0; // PWM value 0-100
-
-void setup() {
- pinMode(pwmPin, OUTPUT);
- Serial.begin(9600);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM);
-}
-
-void updatePWM() {
- static int counter = 0;
-
- if (counter < PWMval) {
- digitalWrite(pwmPin, HIGH);
- } else {
- digitalWrite(pwmPin, LOW);
- }
-
- counter++;
- if (counter >= 100) {
- counter = 0;
- }
-}
-
-void mcpsoftpwm(int value) {
- if (value < 0) value = 0;
- if (value > 100) value = 100;
-
- Serial.print("softPWM pin: 3, value: ");
- Serial.println(value);
- PWMval = value;
-}
-
-void loop() {
- mcpsoftpwm(100); // Set PWM to 100%
- delay(1000);
- mcpsoftpwm(50); // Set PWM to 50%
- delay(1000);
- Serial.println("loop");
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/tree_motor_calibration/tree_motor_calibration.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/tree_motor_calibration/tree_motor_calibration.ino
deleted file mode 100644
index 4608903..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/motordriver/tree_motor_calibration/tree_motor_calibration.ino
+++ /dev/null
@@ -1,427 +0,0 @@
-#include <TimerThree.h>
-#include <Adafruit_MCP23X17.h>
-#include <SD.h>
-#include <SPI.h>
-
-//https://www.pololu.com/product/2997
-//https://www.pololu.com/product/4861
-//https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
-
-// motor one/A front
-#define m1enA 3 // GPA3 PWM1
-#define m1enB 2 // GPA2
-#define m1pwm1 0 // GPA0
-#define m1pwm2 1 // GPA1
-#define m1encA 12 // GPB4
-#define m1encB 13 // GPB5
-// motor two/B left
-#define m2enA 7 // GPA7 PWM2
-#define m2enB 6 // GPA6
-#define m2pwm1 4 // GPA4
-#define m2pwm2 5 // GPA5
-#define m2encA 14 // GPB6
-#define m2encB 15 // GPB7
-// motor three/C right
-#define m3enA 11 // GPB3 PWM3
-#define m3enB 10 // GPB2
-#define m3pwm1 8 // GPB0
-#define m3pwm2 9 // GPB1
-#define m3encA 24 // teensy port 24
-#define m3encB 9 // teensy port 9
-
-const int maxspeed = 1000;
-
-double sp = 0.00;
-//encoder
-double Arpm = 0.00;
-volatile long Aencount = 0;
-unsigned long ALtime = 0;
-unsigned long ACtime = 0;
-unsigned long APtime = 0;
-double Brpm = 0.00;
-volatile long Bencount = 0;
-unsigned long BLtime = 0;
-unsigned long BCtime = 0;
-unsigned long BPtime = 0;
-double Crpm = 0.00;
-volatile long Cencount = 0;
-unsigned long CLtime = 0;
-unsigned long CCtime = 0;
-unsigned long CPtime = 0;
-
-//kiwidrive
-double dirA = 0.00;
-double dirB = 0.00;
-double dirC = 0.00;
-double spdA = 0.00;
-double spdB = 0.00;
-double spdC = 0.00;
-double dirrad = 0.00;
-double pi = 3.1415926535897;
-
-//softPWM
-volatile int PWMval1 = 0; // PWM m1enA value 0-100
-volatile int PWMval2 = 0; // PWM m2enA value 0-100
-volatile int PWMval3 = 0; // PWM m3enA value 0-100
-
-volatile int PWMval = 0; // PWM value 0-100
-File ;
-File avrage;
-Sd2Card card;
-SdVolume volume;
-SdFile root;
-const int chipSelect = BUILTIN_SDCARD;
-int x = 1;
-
-int Nloop = 0;
-int Atotloopdata[maxspeed] = {};
-int Btotloopdata[maxspeed] = {};
-int Ctotloopdata[maxspeed] = {};
-
-Adafruit_MCP23X17 mcp2;
-
-void setup() {
- if (!mcp2.begin_I2C(0x22)) {
- Serial.println("Error initializing MCP23017 at 0x22.");
- //while (1);
- }
- // set all the motor control pins
- mcp2.pinMode(m1enA, OUTPUT);
- mcp2.pinMode(m1enB, OUTPUT);
- mcp2.pinMode(m2enA, OUTPUT);
- mcp2.pinMode(m2enB, OUTPUT);
- mcp2.pinMode(m3enA, OUTPUT);
- mcp2.pinMode(m3enB, OUTPUT);
- mcp2.pinMode(m1pwm1, OUTPUT);
- mcp2.pinMode(m1pwm2, OUTPUT);
- mcp2.pinMode(m2pwm1, OUTPUT);
- mcp2.pinMode(m2pwm2, OUTPUT);
- mcp2.pinMode(m3pwm1, OUTPUT);
- mcp2.pinMode(m3pwm2, OUTPUT);
-
- //set encoder pins
- mcp2.pinMode(m1encA, INPUT);
- mcp2.pinMode(m1encB, INPUT);
- mcp2.pinMode(m2encA, INPUT);
- mcp2.pinMode(m2encB, INPUT);
- pinMode(m3encA, INPUT);
- pinMode(m3encB, INPUT);
- attachInterrupt(digitalPinToInterrupt(m1encA), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m1encB), AencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encA), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m2encB), BencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encA), CencoderISR, CHANGE);
- attachInterrupt(digitalPinToInterrupt(m3encB), CencoderISR, CHANGE);
-
- Timer3.initialize(800); // 800 microseconds or 1.25kHz
- Timer3.attachInterrupt(updatePWM1);
- Timer3.attachInterrupt(updatePWM2);
- Timer3.attachInterrupt(updatePWM3);
-}
-
-void updatePWM1() {
- static int counter1 = 0;
-
- if (counter1 < PWMval1) {
- mcp2.digitalWrite(m1enA, HIGH);
- } else {
- mcp2.digitalWrite(m1enA, LOW);
- }
-
- counter1++;
- if (counter1 >= 100) {
- counter1 = 0;
- }
-}
-void updatePWM2() {
- static int counter2 = 0;
-
- if (counter2 < PWMval2) {
- mcp2.digitalWrite(m2enA, HIGH);
- } else {
- mcp2.digitalWrite(m2enA, LOW);
- }
-
- counter2++;
- if (counter2 >= 100) {
- counter2 = 0;
- }
-}
-void updatePWM3() {
- static int counter3 = 0;
-
- if (counter3 < PWMval3) {
- mcp2.digitalWrite(m3enA, HIGH);
- } else {
- mcp2.digitalWrite(m3enA, LOW);
- }
-
- counter3++;
- if (counter3 >= 100) {
- counter3 = 0;
- }
-}
-void mcpsoftpwm(int pin, int vall){
- //M1enA = 3 = GPA3
- //M2enA = 7 = GPA7
- //M3enA = 11 = GPB3
- Serial.print("softPWM pin: ");
- Serial.print(pin);
- Serial.print(", value: ");
- Serial.println(vall);
- if (pin = 3){
- PWMval1 = vall;
- Serial.print("Motor 1 enA PWM set");
- }
- if (pin = 7){
- PWMval2 = vall;
- Serial.print("Motor 2 enA PWM set");
- }
- if (pin = 11){
- PWMval3 = vall;
- Serial.print("Motor 3 enA PWM set");
- }
-
-}
-
-void AencoderISR() {
- Aencount++;
-}
-void BencoderISR() {
- Bencount++;
-}
-void CencoderISR() {
- Cencount++;
-}
-
-void Areadenc() {
- ACtime = micros();
- APtime = ACtime - ALtime;
- ALtime = ACtime;
- Arpm = (Aencount / 211.2) * (60000000.0 / APtime);
- Serial.print("Motor A RPM: ");
- Serial.print(Arpm);
- Serial.print(" Sample period:");
- Serial.print(APtime);
- Serial.print("ms, encoder count:");
- Serial.println(Aencount);
- Aencount = 0;
-}
-void Breadenc() {
- BCtime = micros();
- BPtime = BCtime - BLtime;
- BLtime = BCtime;
- Brpm = (Bencount / 211.2) * (60000000.0 / BPtime);
- Serial.print("Motor B RPM: ");
- Serial.print(Brpm);
- Serial.print(" Sample period: ");
- Serial.print(BPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Bencount);
- Bencount = 0;
-}
-void Creadenc() {
- CCtime = micros();
- CPtime = CCtime - CLtime;
- CLtime = CCtime;
- Crpm = (Cencount / 211.2) * (60000000.0 / CPtime);
- Serial.print("Motor C RPM: ");
- Serial.print(Crpm);
- Serial.print(" Sample period: ");
- Serial.print(CPtime);
- Serial.print(" ms, encoder count: ");
- Serial.println(Cencount);
- Cencount = 0;
-}
-void Aresetenc(){
- ACtime = micros();
- ALtime = ACtime;
- Aencount = 0;
-}
-void Bresetenc(){
- BCtime = micros();
- BLtime = BCtime;
- Bencount = 0;
-}
-void Cresetenc(){
- CCtime = micros();
- CLtime = CCtime;
- Cencount = 0;
-}
-
-void Amove(double sped) {
- spdA = abs(sped) * 0.1;
- mcpsoftpwm(m1enA, spdA);
- mcp2.digitalWrite(m1enB, LOW);
- if (sped < 0) {
- //Serial.print("Motor A back ");
- mcp2.digitalWrite(m1pwm1, LOW);
- mcp2.digitalWrite(m1pwm2, HIGH);
- } else {
- //Serial.print("Motor A forward ");
- mcp2.digitalWrite(m1pwm1, HIGH);
- mcp2.digitalWrite(m1pwm2, LOW);
- }
- //Serial.println(spdA);
-}
-void Bmove(double sped) {
- spdB = abs(sped) * 0.1;
- mcpsoftpwm(m2enA, spdB);
- mcp2.digitalWrite(m2enB, LOW);
- if (sped < 0) {
- //Serial.print("Motor B back ");
- mcp2.digitalWrite(m2pwm1, LOW);
- mcp2.digitalWrite(m2pwm2, HIGH);
- } else {
- //Serial.print("Motor B forward ");
- mcp2.digitalWrite(m2pwm1, HIGH);
- mcp2.digitalWrite(m2pwm2, LOW);
- }
- //Serial.println(spdB);
-}
-void Cmove(double sped) {
- spdC = abs(sped) * 0.1;
- mcpsoftpwm(m3enA, spdC);
- mcp2.digitalWrite(m3enB, LOW);
- if (sped < 0) {
- //Serial.print("Motor C back ");
- mcp2.digitalWrite(m3pwm1, LOW);
- mcp2.digitalWrite(m3pwm2, HIGH);
- } else {
- //Serial.print("Motor C forward ");
- mcp2.digitalWrite(m3pwm1, HIGH);
- mcp2.digitalWrite(m3pwm2, LOW);
- }
- //Serial.println(spdC);
-}
-void move(double sped) {
- Amove(sped);
- Bmove(sped);
- Cmove(sped);
-}
-void readenc() {
- Areadenc();
- Breadenc();
- Creadenc();
-}
-void resetenc() {
- Aresetenc();
- Bresetenc();
- Cresetenc();
-}
-
-void loop() {
- move(0);
- delay(2000);
- for (int i = 0; i < maxspeed; i++) {
- Serial.println("0,0");
- }
- int Acurrentloopdata[maxspeed] = {};
- int Bcurrentloopdata[maxspeed] = {};
- int Ccurrentloopdata[maxspeed] = {};
- for (int i = 0; i < maxspeed; i++) {
- move(i);
- delay(100);
- readenc();
- Serial.print(i);
- Serial.print(",");
- Serial.print(Arpm);
- Acurrentloopdata[i] = Arpm;
- Serial.print(",");
- Serial.print(Brpm);
- Acurrentloopdata[i] = Brpm;
- Serial.print(",");
- Serial.print(Crpm);
- Acurrentloopdata[i] = Crpm;
- Serial.print(",");
- Serial.println(Atotloopdata[i]);
- Serial.print(",");
- Serial.println(Btotloopdata[i]);
- Serial.print(",");
- Serial.println(Ctotloopdata[i]);
- }
- Acurrentloopdata[0] = 0;
- Bcurrentloopdata[0] = 0;
- Ccurrentloopdata[0] = 0;
- if (Nloop == 0){
- for (int i = 0; i < maxspeed; i++) {
- Atotloopdata[i] = Acurrentloopdata[i];
- Btotloopdata[i] = Bcurrentloopdata[i];
- Ctotloopdata[i] = Ccurrentloopdata[i];
- }
- }else{
- for (int i = 0; i < maxspeed; i++) {
- Atotloopdata[i] = ((Atotloopdata[i]*Nloop)+Acurrentloopdata[i])/(Nloop+1);
- Btotloopdata[i] = ((Btotloopdata[i]*Nloop)+Bcurrentloopdata[i])/(Nloop+1);
- Ctotloopdata[i] = ((Ctotloopdata[i]*Nloop)+Ccurrentloopdata[i])/(Nloop+1);
- }
- }
- resetenc();
- SD.remove("Aavrage_motor_values.dat");
- SD.remove("Bavrage_motor_values.dat");
- SD.remove("Cavrage_motor_values.dat");
- File AdataFile = SD.open("Aavrage_motor_values.dat", FILE_WRITE);
- if (AdataFile) {
- for (int i = 0; i < maxspeed; i++) {
- AdataFile.print(Atotloopdata[i]);
- AdataFile.print(", ");
- }
- AdataFile.close();
- }
- File BdataFile = SD.open("Aavrage_motor_values.dat", FILE_WRITE);
- if (BdataFile) {
- for (int i = 0; i < maxspeed; i++) {
- BdataFile.print(Btotloopdata[i]);
- BdataFile.print(", ");
- }
- BdataFile.close();
- }
- File CdataFile = SD.open("Aavrage_motor_values.dat", FILE_WRITE);
- if (CdataFile) {
- for (int i = 0; i < maxspeed; i++) {
- CdataFile.print(Ctotloopdata[i]);
- CdataFile.print(", ");
- }
- CdataFile.close();
- }
- SD.remove("ABC_avrage_motor_values.csv");
- File debugFile = SD.open("ABC_avrage_motor_values.csv", FILE_WRITE);
- if (debugFile) {
- debugFile.println("");
- debugFile.println("Motor A values");
- debugFile.println("");
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(Atotloopdata[i]);
- }
- debugFile.println("");
- debugFile.println("Motor B values");
- debugFile.println("");
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(Btotloopdata[i]);
- }
- debugFile.println("");
- debugFile.println("Motor C values");
- debugFile.println("");
- for (int i = 0; i < maxspeed; i++) {
- debugFile.print(i);
- debugFile.print(", ");
- debugFile.println(Ctotloopdata[i]);
- }
- }
-
- if (!card.init(SPI_HALF_SPEED, chipSelect)) {
- Serial.println("FAILED TO FIND SD CARD");
- Serial.println("* is a card inserted?");
- Serial.println("* is your wiring correct?");
- Serial.println("* did you change the chipSelect pin to match your shield or module?");
- }
-
-
- Nloop++;
-
-
-}
diff --git a/OLD_CODE_REMOVE_LATER/debug/prewk/tcs34725/tcs34725.ino b/OLD_CODE_REMOVE_LATER/debug/prewk/tcs34725/tcs34725.ino
deleted file mode 100644
index 88d1467..0000000
--- a/OLD_CODE_REMOVE_LATER/debug/prewk/tcs34725/tcs34725.ino
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <Wire.h>
-#include "Adafruit_TCS34725.h"
-
-/* Example code for the Adafruit TCS34725 breakout library */
-
-/* Connect SCL to analog 5
- Connect SDA to analog 4
- Connect VDD to 3.3V DC
- Connect GROUND to common ground */
-
-/* Initialise with default values (int time = 2.4ms, gain = 1x) */
-// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
-
-/* Initialise with specific int time and gain values */
-Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);
-
-void setup(void) {
- Serial.begin(9600);
-
- if (tcs.begin()) {
- Serial.println("Found sensor");
- } else {
- Serial.println("No TCS34725 found ... check your connections");
- while (1);
- }
-
- // Now we're ready to get readings!
-}
-
-void loop(void) {
- uint16_t r, g, b, c, colorTemp, lux;
-
- tcs.getRawData(&r, &g, &b, &c);
- // colorTemp = tcs.calculateColorTemperature(r, g, b);
- colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
- lux = tcs.calculateLux(r, g, b);
-
- Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
- Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
- Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
- Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
- Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
- Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
- Serial.println(" ");
-}
diff --git a/code/debug/communication/rx/rx_decode_teensy/.gitignore b/code/debug/communication/rx/rx_decode_teensy/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/communication/rx/rx_decode_teensy/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/communication/rx/rx_teensy/.gitignore b/code/debug/communication/rx/rx_teensy/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/communication/rx/rx_teensy/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/communication/rx/rx_teensy/src/main.cpp b/code/debug/communication/rx/rx_teensy/src/main.cpp
index f8e33a1..768b70b 100644
--- a/code/debug/communication/rx/rx_teensy/src/main.cpp
+++ b/code/debug/communication/rx/rx_teensy/src/main.cpp
@@ -15,5 +15,6 @@ void loop() {
incomingbyte = Serial3.read();
Serial.print(char(incomingbyte));
}
+ milis(1);
-} \ No newline at end of file
+} \ No newline at end of file
diff --git a/code/debug/communication/tx/tx-IR/include/README b/code/debug/communication/tx/tx-IR/include/README
new file mode 100644
index 0000000..49819c0
--- /dev/null
+++ b/code/debug/communication/tx/tx-IR/include/README
@@ -0,0 +1,37 @@
+
+This directory is intended for project header files.
+
+A header file is a file containing C declarations and macro definitions
+to be shared between several project source files. You request the use of a
+header file in your project source file (C, C++, etc) located in `src` folder
+by including it, with the C preprocessing directive `#include'.
+
+```src/main.c
+
+#include "header.h"
+
+int main (void)
+{
+ ...
+}
+```
+
+Including a header file produces the same results as copying the header file
+into each source file that needs it. Such copying would be time-consuming
+and error-prone. With a header file, the related declarations appear
+in only one place. If they need to be changed, they can be changed in one
+place, and programs that include the header file will automatically use the
+new version when next recompiled. The header file eliminates the labor of
+finding and changing all the copies as well as the risk that a failure to
+find one copy will result in inconsistencies within a program.
+
+In C, the convention is to give header files names that end with `.h'.
+
+Read more about using header files in official GCC documentation:
+
+* Include Syntax
+* Include Operation
+* Once-Only Headers
+* Computed Includes
+
+https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
diff --git a/code/debug/communication/tx/tx-IR/lib/README b/code/debug/communication/tx/tx-IR/lib/README
new file mode 100644
index 0000000..9379397
--- /dev/null
+++ b/code/debug/communication/tx/tx-IR/lib/README
@@ -0,0 +1,46 @@
+
+This directory is intended for project specific (private) libraries.
+PlatformIO will compile them to static libraries and link into the executable file.
+
+The source code of each library should be placed in a separate directory
+("lib/your_library_name/[Code]").
+
+For example, see the structure of the following example libraries `Foo` and `Bar`:
+
+|--lib
+| |
+| |--Bar
+| | |--docs
+| | |--examples
+| | |--src
+| | |- Bar.c
+| | |- Bar.h
+| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
+| |
+| |--Foo
+| | |- Foo.c
+| | |- Foo.h
+| |
+| |- README --> THIS FILE
+|
+|- platformio.ini
+|--src
+ |- main.c
+
+Example contents of `src/main.c` using Foo and Bar:
+```
+#include <Foo.h>
+#include <Bar.h>
+
+int main (void)
+{
+ ...
+}
+
+```
+
+The PlatformIO Library Dependency Finder will find automatically dependent
+libraries by scanning project source files.
+
+More information about PlatformIO Library Dependency Finder
+- https://docs.platformio.org/page/librarymanager/ldf.html
diff --git a/code/debug/communication/tx/tx-IR/platformio.ini b/code/debug/communication/tx/tx-IR/platformio.ini
new file mode 100644
index 0000000..87a4592
--- /dev/null
+++ b/code/debug/communication/tx/tx-IR/platformio.ini
@@ -0,0 +1,14 @@
+; PlatformIO Project Configuration File
+;
+; Build options: build flags, source filter
+; Upload options: custom upload port, speed and extra flags
+; Library options: dependencies, extra library storages
+; Advanced options: extra scripting
+;
+; Please visit documentation for the other options and examples
+; https://docs.platformio.org/page/projectconf.html
+
+[env:seeed_xiao]
+platform = atmelsam
+board = seeed_xiao
+framework = arduino
diff --git a/code/debug/communication/tx/tx-IR/src/main.cpp b/code/debug/communication/tx/tx-IR/src/main.cpp
new file mode 100644
index 0000000..43d396f
--- /dev/null
+++ b/code/debug/communication/tx/tx-IR/src/main.cpp
@@ -0,0 +1,86 @@
+#include <Arduino.h>
+
+int ir1 = 0;
+int ir2 = 1;
+int ir3 = 9;
+int ir4 = 2;
+int ir5 = 3;
+int ir6 = 4;
+int ir7 = 5;
+int ir8 = 8;
+
+int dir1 = 1; // data IR1
+int dir2 = 1; // data IR2
+int dir3 = 1; // etc
+int dir4 = 1;
+int dir5 = 1;
+int dir6 = 1;
+int dir7 = 1;
+int dir8 = 1;
+
+volatile long IRcount1 = 0;
+volatile long IRcount2 = 0;
+volatile long IRcount3 = 0;
+volatile long IRcount4 = 0;
+volatile long IRcount5 = 0;
+volatile long IRcount6 = 0;
+volatile long IRcount7 = 0;
+volatile long IRcount8 = 0;
+
+void setup() {
+ pinMode(ir1, INPUT);
+ pinMode(ir2, INPUT);
+ pinMode(ir3, INPUT);
+ pinMode(ir4, INPUT);
+ pinMode(ir5, INPUT);
+ pinMode(ir6, INPUT);
+ pinMode(ir7, INPUT);
+ pinMode(ir8, INPUT);
+
+ Serial.begin(9600);
+ Serial1.begin(9600);
+ Serial.println("start");
+ Serial1.println("start");
+
+ Serial.println("Starting loop");
+ Serial1.println("Starting loop");
+}
+
+void loop() {
+ unsigned long p1 = pulseIn(ir1, HIGH); //pulse width in microseconds
+ unsigned long p2 = pulseIn(ir2, HIGH); //pulse width in microseconds
+ unsigned long p3 = pulseIn(ir3, HIGH); //pulse width in microseconds
+ unsigned long p4 = pulseIn(ir4, HIGH); //pulse width in microseconds
+ unsigned long p5 = pulseIn(ir5, HIGH); //pulse width in microseconds
+ unsigned long p6 = pulseIn(ir6, HIGH); //pulse width in microseconds
+ unsigned long p7 = pulseIn(ir7, HIGH); //pulse width in microseconds
+ unsigned long p8 = pulseIn(ir8, HIGH); //pulse width in microseconds
+
+ //one seeed xiao uses S-R the other uses B-E as start and end
+ // it returns data like this:
+ // S0, 0, 0, 0, 0, 0, 0, 0R
+ //or
+ // B0, 0, 0, 0, 0, 0, 0, 0E
+
+ //Serial1print("B"); //uncomment this line to use B-E
+ Serial1.print("S"); //uncomment this line to use S-R
+ Serial1.print(p1);
+ Serial1.print(", ");
+ Serial1.print(p2);
+ Serial1.print(", ");
+ Serial1.print(p3);
+ Serial1.print(", ");
+ Serial1.print(p4);
+ Serial1.print(", ");
+ Serial1.print(p5);
+ Serial1.print(", ");
+ Serial1.print(p6);
+ Serial1.print(", ");
+ Serial1.print(p7);
+ Serial1.print(", ");
+ Serial1.println(p8);
+ //Serial1.println("E"); //uncomment this line to use B-E
+ Serialq.println("R"); //uncomment this line to use S-R
+
+ delay(100); // delay to avoid flooding the serial port
+} \ No newline at end of file
diff --git a/code/debug/communication/tx/tx-IR/test/README b/code/debug/communication/tx/tx-IR/test/README
new file mode 100644
index 0000000..9b1e87b
--- /dev/null
+++ b/code/debug/communication/tx/tx-IR/test/README
@@ -0,0 +1,11 @@
+
+This directory is intended for PlatformIO Test Runner and project tests.
+
+Unit Testing is a software testing method by which individual units of
+source code, sets of one or more MCU program modules together with associated
+control data, usage procedures, and operating procedures, are tested to
+determine whether they are fit for use. Unit testing finds problems early
+in the development cycle.
+
+More information about PlatformIO Unit Testing:
+- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
diff --git a/code/debug/communication/tx/tx_rand_XIAO/.gitignore b/code/debug/communication/tx/tx_rand_XIAO/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/communication/tx/tx_rand_XIAO/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp b/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp
index 3e9444b..d164e3d 100644
--- a/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp
+++ b/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp
@@ -29,6 +29,26 @@ void loop() {
rn7 = random(1500);
rn8 = random(1500);
+ Serial.print("S");
+ //Serial.print("B");
+ Serial.print(rn1);
+ Serial.print(", ");
+ Serial.print(rn2);
+ Serial.print(", ");
+ Serial.print(rn3);
+ Serial.print(", ");
+ Serial.print(rn4);
+ Serial.print(", ");
+ Serial.print(rn5);
+ Serial.print(", ");
+ Serial.print(rn6);
+ Serial.print(", ");
+ Serial.print(rn7);
+ Serial.print(", ");
+ Serial.println(rn8);
+ Serial.println("R");
+ //Serial.print("E");
+
Serial1.print("S");
//Serial1.print("B");
Serial1.print(rn1);
diff --git a/code/debug/motors/3m_test/.gitignore b/code/debug/motors/3m_test/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/motors/3m_test/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/motors/PWM/.gitignore b/code/debug/motors/PWM/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/motors/PWM/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/motors/PWM/src/main.cpp b/code/debug/motors/PWM/src/main.cpp
index 7564056..53369e4 100644
--- a/code/debug/motors/PWM/src/main.cpp
+++ b/code/debug/motors/PWM/src/main.cpp
@@ -1,13 +1,46 @@
-#include "SoftPWM.h"
#include <Arduino.h>
-int pwmPin = 3;
+int pwmPin = 3; //pin for PWM output
+int pwmacc = 1000; //how accurate the PWM is, means you can enter value from 0 to the value of pwmacc
+int PWMval = 0; //value of the PWM, means you can enter value from 0 to the value of pwmacc
+
+void setup() {
+}
void setup() {
- SoftPWMBegin();
+
+ Timer3.initialize(800); // 800 microseconds or 1.25Hz
+ Timer3.attachInterrupt(updatePWM);
+}
+
+void updatePWM() {
+ static int counter = 0;
+ if PWMval < 0) {
+ PWMval = 0;
+ }
+ if (PWMval > pwmacc) {
+ PWMval = pwmacc;
+ }
+
+ if (counter < PWMval) {
+ digitalWrite(pwmPin, HIGH);
+ } else {
+ digitalWrite(pwmPin, LOW);
+ }
+
+ counter++;
+ if (counter >= pwmacc) {
+ counter = 0;
+ }
}
void loop() {
- SoftPWMSetFadeTime(pwmPin, 2500, 2500);
- delay(1000);
+ for i (0; i < pwmacc; i++) {
+ PWMval = i;
+ delay(10);
+ }
+ for i (pwmacc; i > 0; i--) {
+ PWMval = i;
+ delay(10);
+ }
} \ No newline at end of file
diff --git a/code/debug/motors/base_drive/.gitignore b/code/debug/motors/base_drive/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/motors/base_drive/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/main/XIAO_ir/.gitignore b/code/main/XIAO_ir/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/main/XIAO_ir/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/main/teensy_goalie/.gitignore b/code/main/teensy_goalie/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/main/teensy_goalie/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/main/teensy_player/.gitignore b/code/main/teensy_player/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/main/teensy_player/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch