From 6f41373992767cb9e8e387d849c0496ce06d3f7e Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Thu, 29 Apr 2021 01:49:24 +0200 Subject: [PATCH] add scripts for debugging --- scripts/dw.sh | 7 +++++++ scripts/exitdw.sh | 3 +++ scripts/plot.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100755 scripts/dw.sh create mode 100755 scripts/exitdw.sh create mode 100644 scripts/plot.py diff --git a/scripts/dw.sh b/scripts/dw.sh new file mode 100755 index 0000000..b3455e8 --- /dev/null +++ b/scripts/dw.sh @@ -0,0 +1,7 @@ +make program +avrdude -c atmelice_isp -p m328p -U hfuse:w:0x99:m +echo "Power cycle now!" +read +avarice -5 -w -P atmega328p :4242 & +read +avrdude -c atmelice_isp -p m328p -U hfuse:w:0xD9:m diff --git a/scripts/exitdw.sh b/scripts/exitdw.sh new file mode 100755 index 0000000..9aa8ef7 --- /dev/null +++ b/scripts/exitdw.sh @@ -0,0 +1,3 @@ +avarice -5 -w -P atmega328p :4242 & +sleep 2 +avrdude -c atmelice_isp -p m328p -U hfuse:w:0xD9:m diff --git a/scripts/plot.py b/scripts/plot.py new file mode 100644 index 0000000..3ce7ad7 --- /dev/null +++ b/scripts/plot.py @@ -0,0 +1,43 @@ +import time +from simple_pid import PID +from itertools import count +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation + +import minimalmodbus + +tempSens = minimalmodbus.Instrument('/dev/ttyUSB0', 1) +tempSens.serial.baudrate = 38400 + +plt.style.use('fivethirtyeight') + +x_values = [] +y_values = [] + +index = count() + + +def animate(i): + try: + #temp1 = tempSens.read_float(1, functioncode=4, byteorder=0) / 100 + #temp2 = tempSens.read_float(3, functioncode=4, byteorder=0) / 100 + #temp3 = tempSens.read_float(5, functioncode=4, byteorder=0) / 100 + + #temp = tempSens.read_register(1) + temp2 = tempSens.read_float(3, functioncode=4) + + y_values.append(temp2) + x_values.append(next(index)) + print(tempSens.read_float(11, functioncode=4), end="\t") + print(temp2) + + plt.cla() + plt.scatter(x_values, y_values) + except Exception as e: print(e) + + +ani = FuncAnimation(plt.gcf(), animate, 2000) + + +plt.tight_layout() +plt.show()