Commit abf90a4b authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper

Adicionar suporte a termopar e lapma

parent a2b132ad
Pipeline #24 canceled with stages
...@@ -10,6 +10,8 @@ tqdm = "*" ...@@ -10,6 +10,8 @@ tqdm = "*"
sacada = {editable = true,path = "."} sacada = {editable = true,path = "."}
pyserial = "*" pyserial = "*"
click = "*" click = "*"
thermocouples-reference = "*"
scipy = "*"
[requires] [requires]
python_version = "3.5" python_version = "3.7"
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
from time import sleep from time import sleep
import click import click
from tqdm import tqdm from tqdm import tqdm
from thermocouples_reference import thermocouples
from sacada.SACADA import SACADA from sacada.SACADA import SACADA
typeR = thermocouples['R']
@click.group() @click.group()
@click.option('--port', default="/dev/ttyACM0", help='serial port location eg.: /dev/ttyACM0 (default)') @click.option('--port', default="/dev/ttyACM1", help='serial port location eg.: /dev/ttyACM0 (default)')
@click.pass_context @click.pass_context
def cli(ctx, port): def cli(ctx, port):
ctx.obj['s'] = SACADA(port) ctx.obj['s'] = SACADA(port)
...@@ -25,13 +28,68 @@ def read(ctx, channel): ...@@ -25,13 +28,68 @@ def read(ctx, channel):
@cli.command() @cli.command()
@click.argument('channel') @click.argument('channel')
@click.option('--interval', default=1000, help='interval bewteen readings (ms)') @click.option('--interval', default=1000, help='interval bewteen readings (ms)')
@click.option('--save', default='', help='file to save readings')
@click.pass_context
def monitor(ctx, channel, interval, save):
#with tqdm(total=256, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}mV") as bar:
#while True:
# bar.n = int(ctx.obj['s'].readVoltage(channel) * 1000)
# bar.refresh()
# sleep(interval/1000.0)
if not save:
while True:
click.echo(ctx.obj['s'].readVoltage(channel))
sleep(interval/1000.0)
else:
f = open(save, 'w')
try:
while True:
voltage = ctx.obj['s'].readVoltage(channel)
click.echo(voltage)
f.write(str(voltage) + '\n')
sleep(interval/1000.0)
except KeyboardInterrupt:
f.close()
@cli.command()
@click.option('--interval', default=1000, help='interval bewteen readings (ms)')
@click.option('--save', default='', help='file to save readings')
@click.pass_context @click.pass_context
def monitor(ctx, channel, interval): def lapma(ctx, interval, save):
with tqdm(total=18, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}V") as bar: #with tqdm(total=256, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}mV") as bar:
#while True:
# bar.n = int(ctx.obj['s'].readVoltage(channel) * 1000)
# bar.refresh()
# sleep(interval/1000.0)
if not save:
while True: while True:
bar.n = ctx.obj['s'].readVoltage(channel) click.echo(ctx.obj['s'].readVoltage(channel))
bar.refresh()
sleep(interval/1000.0) sleep(interval/1000.0)
else:
f = open(save, 'w')
try:
while True:
voltage = ctx.obj['s'].readVoltage("A3")
current = ctx.obj['s'].readVoltage("A4")
thermocouple = ctx.obj['s'].readVoltage("TC")
try:
temperature = typeR.inverse_CmV((thermocouple + 0.001453125034) * -1000, Tref=25)
except ValueError:
temperature = "Error"
click.echo("Voltage: {}".format(voltage))
click.echo("Current: {}".format(current))
click.echo("Power: {}".format(voltage * current))
click.echo("TC (mV): {}".format(thermocouple))
click.echo("TC (celsius): {}".format(temperature))
click.echo("-----------------")
f.write(str(voltage) + '\t')
f.write(str(current) + '\t')
f.write(str(thermocouple) + '\t')
f.write(str(temperature) + '\n')
sleep(interval/1000.0)
except KeyboardInterrupt:
f.close()
if __name__ == '__main__': if __name__ == '__main__':
cli(obj={}) cli(obj={})
...@@ -14,7 +14,7 @@ class SACADA(object): ...@@ -14,7 +14,7 @@ class SACADA(object):
with all SACADA boards. with all SACADA boards.
""" """
IN_CHANNELS = ["A0", "A1", "A2", "A3", "A4", "INSTR"] IN_CHANNELS = ["A0", "A1", "A2", "A3", "A4", "INSTR", "TC"]
OUT_CHANNELS = ["CH1", "CH2"] OUT_CHANNELS = ["CH1", "CH2"]
def __init__(self, location): def __init__(self, location):
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ with open("README.md", "r") as fh: ...@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup( setuptools.setup(
name="sacada-python", name="sacada-python",
version="0.0.2", version="0.0.3",
author="Pedro Henrique Capp Kopper", author="Pedro Henrique Capp Kopper",
author_email="pedro.kopper@ufrgs.br", author_email="pedro.kopper@ufrgs.br",
description="Python API for the SACADA data acquisition system", description="Python API for the SACADA data acquisition system",
...@@ -13,6 +13,7 @@ setuptools.setup( ...@@ -13,6 +13,7 @@ setuptools.setup(
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="https://git.cta.if.ufrgs.br/SACADA/sacada-python", url="https://git.cta.if.ufrgs.br/SACADA/sacada-python",
packages=['sacada'], packages=['sacada'],
scripts=['bin/sacada'],
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment