The Electronic Control

Introduction

The electronic module regroups all the classes and functions which are related to the reading of electronics components. The electronic components used here are:

The Data Acquisition Board

MASCARA uses the USB 1208FS mccdaq series. The datasheet relative to this device can be found on the website of mmcdaq. Below a quick diagram of the different types of outputs of the DAQ:

diagram of the output of the data acquisition board.

Diagram of the various outputs of the DAQ.

The DAQ has its own class to acces the functions embedded in the cbw32 dll. See DAQ.DAQ() for a description of the APIs.

The limit switches

The limit switches provide an analog way to verify the position of the roof of the MASCARA station. Until the switch is pushed, no current goes through the switch. We use the analog input and digital output of the DAQ to verify at any time the status of the limit switches. The limit-switches have their own class mascara_electronics.LimitSwitch().

The On-Off Objects

Several electronic components fall under the On-Off appelation:
  • the relays
  • the heaters
  • the LEDs

While each component has its specifics class, they are all subclasses from the mascara_electronics.OnOffObject() class.

The encoder

The encoder serves to verify the dome’s position during the open-close phases. Since the motors themselves do not provide a reading on their rotation, the encoder fulfills this role. The encoder is directly connected to the rotation axis of the dome. Thus the reading of the encoder provides a direct measurement of the position of the dome. The details on how to communicate with the encoder are in the mascara_electronics.Encoder.

Referece APIs

The DAQ class

class DAQ.DAQ(BoardNum=0, gain=1)[source]

mccdaq is a class for connecting with and reading the USB-1208FS+ data acquisition board. The functions defined here are the main functions embedded in the cbw32.dll

__init__(BoardNum=0, gain=1)[source]

The DAQ instance regroups all functions to communicate with the Data Acquisition board. The Board is defined by a board number (default 0). The gain is programmable but set to 1 per default.

configPorts(inout='out')[source]

ConfigPort configurates the digital ports for Output or input.

Keyword:
  • inout, if dqp.DIGITALOUT, the port delivers a voltage

    if dqp.DIGITALIN, the port read the voltage

dAllOut(bitValue)[source]

Sets the state of all digital output bits. This function treats all the DI/O ports of a particular type on the board as a single large port. The port should be configured as output beforehand.

Inputs:
  • port, the port considered (‘A’ or ‘B’)
  • bitValue, value of the byte (0-1)
dBitIn(channel, port='A')[source]

Reads the state of a single digital input bit.

Inputs:
  • channel, the bit to read
Outputs:
  • The value of the bit. If 1, logical high => ~ 5V If 0, logical low, => ~0V
dBitOut(channel, bitValue, port='A')[source]

Sets the state of a single digital output bit. This function treats all the DI/O ports of a particular type on the board as a single large port. The port should be configured as output beforehand.

Inputs:
  • port, the port considered (‘A’ or ‘B’)
  • channel, the channel considered (0-7)
  • bitValue, if 0 logic output low (~0V) if 1 logic input high (~5V)
dOut(byteValue, port='A')[source]

Sets the state of all digital output bits of a given port. This function treats all the DI/O ports of a particular type on the board as a single large port. The port should be configured as output beforehand.

Inputs:
  • port, the port considered (‘A’ or ‘B’)
  • byteValue, value of the byte (0-255)
flashLED()[source]

Flashes the led of the daq

getBoardName()[source]

Gives the name of the DAQ

vIn(channel)[source]

Reads an A/D input channel and returns a voltage value. The voltage is returned to data Inputs: Channel, the A/D channel number Outputs: the voltage

vOut(channel, voltage)[source]

Sets the value of a D/A output. Inputs: channel, channel of the analog output (0-1)

voltage, the desired voltage (0.0-5.0)

The OnOff class and its dependencies

class mascara_electronics.OnOffObject(daq, channel, inversed=False)[source]

A class for all the on-off objects: relays, heaters, LEDs. They are activated via relays.

__init__(daq, channel, inversed=False)[source]

Initialization of the relay

Parameters:
  • daq – an instance of the DAQ class representing the DAQ
  • channel – digital channel of the object

see :ref:`mascara_config` for existing channels

isOff()[source]

is the switch on?

isOn()[source]

is the switch on?

turnOff()[source]

Switches off

turnOn()[source]

Switches on

class mascara_electronics.Relay(daq, channel, inversed=False)[source]

A subclass of the OnOffObject class for the relays:

class mascara_electronics.CameraRelay(daq, channel, inversed=False)[source]

A subclass of the OnOffObject class for the relays:

class mascara_electronics.Heater(daq, channel)[source]

A subclass of the OnOffObject class for the heaters:

The Limit Switch class:

class mascara_electronics.LimitSwitch(daq, channelDOut, channelAIn)[source]

A class for the limit switches

__init__(daq, channelDOut, channelAIn)[source]

Initilization of the limit switch

Parameters:
  • daq – an instance of the DAQ class representing the DAQ
  • channelDOut – channel of the digital output of the limit switch
  • channelAIn – channel of the analog input of the limit switch

The Power Supply

class mascara_electronics.PowerSupply(daq, ID)[source]

Class for the power supplies

__init__(daq, ID)[source]

Initialize the power supply :param daq: an instance from the DAQ class :param ID: the ID of the power supply (1 or 2)

getCurrent()[source]

Gets output voltage of the power supply

getVoltage()[source]

Gets output voltage of the power supply

setCurrent(C)[source]

Sets output current of the power supply

setVoltage(V)[source]

Sets output voltage of the power supply Do NOT go higher than 24V, the peltiers will not like it

turnOff()[source]

Sets the voltage of the power supply to 0V, current to 0 A

turnOn(V=24, C=20)[source]

Sets the voltage of the power supply to 24V, current to 0 A

The PDUs

class mascara_electronics.PDU(ip, username='apc', password='apc', timeout=5)[source]
__init__(ip, username='apc', password='apc', timeout=5)[source]

Initilization of the PDU. The PDUs are accessed using Telnet protocol, thus they have each a username and password to access the PDU.

Parameters:
  • ip – the IP address of the PDU
  • username (str) – the identifier of the pdu
  • password (str) – the password to access the pdu
  • timeout (int) – timeout for reading the PDU buffer
close()[source]

close the connection to the PDU

connect()[source]

Connect to the PDU using telnet

get_current()[source]

Get total current draw in Amps

get_power()[source]

Get total power load

get_status()[source]

Get status of all outlets

reboot(outlet)[source]

Reboot a given outlet

reboot_all()[source]

Turn off all outlets

send(cmd)[source]

Sends a command (without carriage return) and returns the result as an array of strings

trysend(cmd, msg)[source]

Tries sending a command and try again once if it failed.

turn_all_off()[source]

Turn off all outlets

turn_all_on()[source]

Turn on all outlets

turn_off(outlet)[source]

Turn off a given outlet

turn_on(outlet)[source]

Turn on a given outlet

The Encoder

class mascara_electronics.Encoder[source]

Class for communicating with the #$% encoder using SSI protocol. SSI stands for synchronous Serial Interface. It means that in order to get any signal from the encoder, the computer has to send a continuous pulse of N-bits. The response from the encoder is 20 bits long:

  • the first 8 are the multiturn information,
  • the last 12 the singleturn information.

The communication are made in BitBang mode, and hex and were a pain to figure out.

ConverseWithEncoder()[source]

Wrapper around the writetoencoder and readencoder

ReadEncoder()[source]

Reads the response of the encoder. The response is already translated in the information multiand single turns.

Return mturns:the number of full turns
Return sturns:the fractional number of turns.
WritetoEncoder()[source]

Sending the pulse signal to the encoder

__init__()[source]

Initialise the encoder instance. Requires the ftd2xx.dll to be in the working directory. No libusb is required.

closeEncoder()[source]

Closes the conection to the encoder

openEncoder()[source]

Opens the connection with the serial encoder

purge()[source]

Purge the buffer of the input and output pins.

setBaudrate(baudrate=460800)[source]

Sets the baudrate for the communication. The encoder needs quite a high baudrate to even spit an answer. Default baudrate is 460800. Better not change it.

setBitMode(bitmode=4)[source]

Sets the special bitmode for conversing with the encoder.

  • Normal bitmode is 0
  • Asynchronous Bitbang is 1
  • Synchronous Bitbang is 4
setTimeout(timeout=20)[source]

sets the timeouts in milliseconds

The Temperature and Humidity sensors

class mascara_electronics.RHSensor(**kwargs)[source]

Class for humidity/temperature sensor

__init__(**kwargs)[source]

Initialize and open the connection with the humidity and temperature sensor.

Keywords:
  • port= ‘COM3’
  • idVendor = ‘0403
  • idProduct = ‘6001’
  • serialNumber = ‘FDXXXX’
  • timeout = 1
close()[source]

Closes the serial connection if it was closed

getAll()[source]

Reads humidity and temperature from sensor Args:

Return tuple (hum,temp):
 

where

  • hum, the humidity as a string
  • temp, the temperature as a string
getCAll(dt=0, npts=100, verbose=False, plotData=False)[source]

Gets a continuous reading of the humidity and temperature.

Parameters:
  • dt (int) – time interval to wait in seconds between two measurements (default = 0)
  • npts (int) – total number of points (default = 100)
Return tuple (t,hum,temp):
 

with:

  • t: time as a float
  • hum: humidity as a float
  • temp: temperature as a float
getCHumidity(dt=0, npts=100, verbose=False, plotData=False)[source]

Gets a continuous reading of the humidity. :param int dt: time interval to wait in seconds between two measurements (default = 0) :param int npts: total number of points (default = 100)

Returns tuple (t,hum):
 t, time as a float, and hum, humidity as a float
getCTemperature(dt=0, npts=100, verbose=False, plotData=False)[source]

Gets a continuous reading of the temperature. :param int dt: time interval to wait in seconds between two measurements (default = 0) :param int npts: total number of points (default = 100) :return tuple (t,hum): t, time as a float, and temp, temperature as a float

getHumidity()[source]

Reads humidity from sensor

Returns:

  • the humidity as a string
getInfo()[source]

Reads sensor model number and firmware version from humidity/temperature sensor

getStatus()[source]

Read from WMI the status of the device connected to a specific port.

Answers are:
  • OK
  • Error
  • Degraded
  • Unknown
  • PredFail
  • Starting
  • Stopping
  • NonRecover
  • No Contacct
  • Lost Comm
getTemperature()[source]

Reads temperature from sensor Args:

Returns:
the temperature as a string
isOpen()[source]

Checks if the serial connection is opened or closed

open()[source]

Opens the serial connection if it was closed