1
0
forked from M-Labs/kirdy
kirdy-firmware/pykirdy/asyncio_exmaple.py
linuswck 0380c8d30b Unify naming and unit in firmware and driver
- mA, uA -> A
- K -> Degree Celsius
- tec -> thermostat
2024-03-18 15:55:05 +08:00

48 lines
1.6 KiB
Python

from driver.kirdy_async import Kirdy
import asyncio
async def main():
kirdy = Kirdy()
await kirdy.start_session(host='192.168.1.128', port=1337, timeout=0.25)
await kirdy.device.set_active_report_mode(False)
await kirdy.laser.set_power_on(False)
await kirdy.laser.clear_alarm()
await kirdy.laser.set_i(0)
await kirdy.laser.set_i_soft_limit(0.25)
await kirdy.laser.set_power_on(True)
await kirdy.thermostat.set_power_on(False)
await kirdy.thermostat.clear_alarm()
await kirdy.thermostat.set_sh_r0(10.0*1000)
await kirdy.thermostat.set_sh_t0(25)
await kirdy.thermostat.set_sh_beta(3900)
await kirdy.thermostat.set_temperature_setpoint(25)
await kirdy.thermostat.set_temp_mon_upper_limit(40)
await kirdy.thermostat.set_temp_mon_lower_limit(10)
await kirdy.thermostat.set_pid_kp(0.15668282198105507)
await kirdy.thermostat.set_pid_ki(0.002135962407793784)
await kirdy.thermostat.set_pid_kd(0.829254515277143)
await kirdy.thermostat.set_pid_output_max(1.0)
await kirdy.thermostat.set_pid_output_min(-1.0)
await kirdy.thermostat.config_temp_adc_filter("Sinc5Sinc1With50hz60HzRejection", "F16SPS")
await kirdy.thermostat.set_power_on(True)
await kirdy.thermostat.set_pid_control_mode()
await kirdy.laser.set_default_pwr_on(False)
await kirdy.thermostat.set_default_pwr_on(True)
await kirdy.device.save_current_settings_to_flash()
async for data in kirdy.report_mode():
print(data)
await kirdy.end_session()
if __name__ == "__main__":
asyncio.run(main())