Compare commits
2 Commits
master
...
flake-dev-
Author | SHA1 | Date | |
---|---|---|---|
f21f9257a7 | |||
417eb08cd3 |
@ -61,7 +61,6 @@
|
|||||||
pythermostat = pkgs.python3Packages.buildPythonPackage {
|
pythermostat = pkgs.python3Packages.buildPythonPackage {
|
||||||
pname = "pythermostat";
|
pname = "pythermostat";
|
||||||
version = "0.0.0";
|
version = "0.0.0";
|
||||||
format = "pyproject";
|
|
||||||
src = "${self}/pythermostat";
|
src = "${self}/pythermostat";
|
||||||
|
|
||||||
propagatedBuildInputs =
|
propagatedBuildInputs =
|
||||||
@ -95,7 +94,11 @@
|
|||||||
++ (with python3Packages; [
|
++ (with python3Packages; [
|
||||||
numpy
|
numpy
|
||||||
matplotlib
|
matplotlib
|
||||||
|
pythermostat
|
||||||
]);
|
]);
|
||||||
|
shellHook = ''
|
||||||
|
export PYTHONPATH=`git rev-parse --show-toplevel`/pythermostat:$PYTHONPATH
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import time
|
import time
|
||||||
from pythermostat.client import Client
|
from pythermostat.client import Client
|
||||||
|
|
||||||
thermostat = Client() #(host="localhost", port=6667)
|
tec = Client() #(host="localhost", port=6667)
|
||||||
thermostat.set_param("b-p", 1, "t0", 20)
|
tec.set_param("b-p", 1, "t0", 20)
|
||||||
print(thermostat.get_output())
|
print(tec.get_output())
|
||||||
print(thermostat.get_pid())
|
print(tec.get_pid())
|
||||||
print(thermostat.get_output())
|
print(tec.get_output())
|
||||||
print(thermostat.get_postfilter())
|
print(tec.get_postfilter())
|
||||||
print(thermostat.get_b_parameter())
|
print(tec.get_b_parameter())
|
||||||
while True:
|
while True:
|
||||||
print(thermostat.get_report())
|
print(tec.get_report())
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
[build-system]
|
|
||||||
requires = ["setuptools"]
|
|
||||||
build-backend = "setuptools.build_meta"
|
|
||||||
|
|
||||||
[project]
|
|
||||||
name = "pythermostat"
|
|
||||||
version = "0.0"
|
|
||||||
authors = [{name = "M-Labs"}]
|
|
||||||
description = "Python utilities for the Sinara 8451 Thermostat"
|
|
||||||
urls.Repository = "https://git.m-labs.hk/M-Labs/thermostat"
|
|
||||||
license = {text = "GPLv3"}
|
|
||||||
dependencies = [
|
|
||||||
"numpy >= 1.26.4",
|
|
||||||
"matplotlib >= 3.9.2"
|
|
||||||
]
|
|
||||||
|
|
||||||
[project.gui-scripts]
|
|
||||||
thermostat_plot = "pythermostat.plot:main"
|
|
||||||
|
|
||||||
[project.scripts]
|
|
||||||
thermostat_autotune = "pythermostat.autotune:main"
|
|
||||||
thermostat_test = "pythermostat.test:main"
|
|
@ -235,16 +235,16 @@ def main():
|
|||||||
|
|
||||||
# logging.basicConfig(level=logging.DEBUG)
|
# logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
thermostat = Client()
|
tec = Client()
|
||||||
|
|
||||||
data = thermostat.get_report()
|
data = tec.get_report()
|
||||||
ch = data[channel]
|
ch = data[channel]
|
||||||
|
|
||||||
tuner = PIDAutotune(target_temperature, output_step,
|
tuner = PIDAutotune(target_temperature, output_step,
|
||||||
lookback, noiseband, ch['interval'])
|
lookback, noiseband, ch['interval'])
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = thermostat.get_report()
|
data = tec.get_report()
|
||||||
|
|
||||||
ch = data[channel]
|
ch = data[channel]
|
||||||
|
|
||||||
@ -255,11 +255,11 @@ def main():
|
|||||||
|
|
||||||
tuner_out = tuner.output()
|
tuner_out = tuner.output()
|
||||||
|
|
||||||
thermostat.set_param("output", channel, "i_set", tuner_out)
|
tec.set_param("output", channel, "i_set", tuner_out)
|
||||||
|
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
thermostat.set_param("output", channel, "i_set", 0)
|
tec.set_param("output", channel, "i_set", 0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -151,11 +151,11 @@ class Client:
|
|||||||
"""Set configuration parameters
|
"""Set configuration parameters
|
||||||
|
|
||||||
Examples::
|
Examples::
|
||||||
thermostat.set_param("output", 0, "max_v", 2.0)
|
tec.set_param("output", 0, "max_v", 2.0)
|
||||||
thermostat.set_param("pid", 1, "output_max", 2.5)
|
tec.set_param("pid", 1, "output_max", 2.5)
|
||||||
thermostat.set_param("b-p", 0, "t0", 20.0)
|
tec.set_param("b-p", 0, "t0", 20.0)
|
||||||
thermostat.set_param("center", 0, "vref")
|
tec.set_param("center", 0, "vref")
|
||||||
thermostat.set_param("postfilter", 1, 21)
|
tec.set_param("postfilter", 1, 21)
|
||||||
|
|
||||||
See the firmware's README.md for a full list.
|
See the firmware's README.md for a full list.
|
||||||
"""
|
"""
|
||||||
|
@ -9,8 +9,8 @@ from pythermostat.client import Client
|
|||||||
def main():
|
def main():
|
||||||
TIME_WINDOW = 300.0
|
TIME_WINDOW = 300.0
|
||||||
|
|
||||||
thermostat = Client()
|
tec = Client()
|
||||||
target_temperature = thermostat.get_pid()[0]['target']
|
target_temperature = tec.get_pid()[0]['target']
|
||||||
print("Channel 0 target temperature: {:.3f}".format(target_temperature))
|
print("Channel 0 target temperature: {:.3f}".format(target_temperature))
|
||||||
|
|
||||||
class Series:
|
class Series:
|
||||||
@ -48,10 +48,10 @@ def main():
|
|||||||
|
|
||||||
quit = False
|
quit = False
|
||||||
|
|
||||||
def recv_data(thermostat):
|
def recv_data(tec):
|
||||||
global last_packet_time
|
global last_packet_time
|
||||||
while True:
|
while True:
|
||||||
data = thermostat.get_report()
|
data = tec.get_report()
|
||||||
ch0 = data[0]
|
ch0 = data[0]
|
||||||
series_lock.acquire()
|
series_lock.acquire()
|
||||||
try:
|
try:
|
||||||
@ -67,7 +67,7 @@ def main():
|
|||||||
break
|
break
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
thread = Thread(target=recv_data, args=(thermostat,))
|
thread = Thread(target=recv_data, args=(tec,))
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
|
21
pythermostat/setup.py
Normal file
21
pythermostat/setup.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="pythermostat",
|
||||||
|
version="0.0",
|
||||||
|
author="M-Labs",
|
||||||
|
url="https://git.m-labs.hk/M-Labs/thermostat",
|
||||||
|
description="Control TEC",
|
||||||
|
license="GPLv3",
|
||||||
|
install_requires=["setuptools"],
|
||||||
|
packages=find_packages(),
|
||||||
|
entry_points={
|
||||||
|
"gui_scripts": [
|
||||||
|
"thermostat_plot = pythermostat.plot:main",
|
||||||
|
],
|
||||||
|
"console_scripts": [
|
||||||
|
"thermostat_autotune = pythermostat.autotune:main",
|
||||||
|
"thermostat_test = pythermostat.test:main",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user