Commit 42832918 authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper
Browse files

Initial commit

parent de20f5df
name = "pypi"
url = ""
verify_ssl = true
tqdm = "*"
sacada = {editable = true,path = "."}
pyserial = "*"
click = "*"
python_version = "3.5"
#!/usr/bin/env python3
from time import sleep
import click
from tqdm import tqdm
from sacada.SACADA import SACADA
@click.option('--port', default="/dev/ttyACM0", help='serial port location eg.: /dev/ttyACM0 (default)')
def cli(ctx, port):
ctx.obj['s'] = SACADA(port)
def show(ctx):
def read(ctx, channel):
@click.option('--interval', default=1000, help='interval bewteen readings (ms)')
def monitor(ctx, channel, interval):
with tqdm(total=18, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}V") as bar:
while True:
bar.n = ctx.obj['s'].readVoltage(channel)
if __name__ == '__main__':
from serial import Serial
class InvalidChannel(Exception):
class InvalidOption(Exception):
class SACADA(object):
"""SACADA boards Python interface
Right now it just implements support for SACADA Mini using SCPI
over USB-CDC. The plan is to provide a generic base class for use
with all SACADA boards.
IN_CHANNELS = ["A0", "A1", "A2", "A3", "A4", "INSTR"]
def __init__(self, location):
def open(self, location):
self._serial = Serial(location, timeout=1) # We use USB-CDC so baud rate doesn't matter
def close(self):
def identify(self):
return self.sendSCPICommand("*IDN?")
def sendSCPICommand(self, command):
self._write(command + "\r\n") # SACADA Mini requires \r\n at the end of commands
return self._read()
def readVoltage(self, channel):
if channel not in self.IN_CHANNELS:
raise InvalidChannel("{} is not a valid input channel".format(channel))
return float(self.sendSCPICommand("MEAS:VOLT:DC? {}".format(channel)))
def setVoltage(self, channel, voltage):
if channel not in self.OUT_CHANNELS:
raise InvalidChannel("{} is not a valid output channel".format(channel))
return float(self.sendSCPICommand("SET:VOLT:DC {} {}".format(channel, voltage)))
def _write(self, m):
self._serial.write(bytes(m, "utf-8"))
def _read(self):
return self._serial.readline().strip()
from . import SACADA
from setuptools import setup, find_packages
setup(name='sacada', version='0.1', packages=['sacada'])
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