Módulos

mdaq

Python Drivers to work on MDAQ hardware

The current module have low leves drivers to interact through serial port with MDAQ-UNLP NIM modules.

Class:
mdaq.Instrument: Class of objects capables of interact with the hardware MDAQ through the serial port.
Func:
mdaq.wavesonfile mdaq.wavefromfile mdaq.hes2numlist mdaq.hesws2numlist
class mdaq.Instrument(port)

Intermediary between de MDAQ-UNLP Hardware and the python user.

El objeto queda definido solamente por el puerto serie donde se encuentra el dispositivo. Por ejemplo port=’/dev/ttyS0’ o ‘/dev/ttyUSB0’.

clear()

CLEAR the counters.

Send “Z” command to the instrument. Put the cycle counter and the memories on zero.

close()

Close the serial port.

getBinCounters(nbytes=4)

GET de COUNTERS in Binary format.

Send “I”,”J” or “V” commands to the Hardware.

Args:

nbytes: an of the integers = 1,2 or 4. They indicate the number of bytes per channel:

nbytes=1: return the LSB unsigned char [1024 bytes]

nbytes=2: return the LSB unsigned short [2048 bytes]

nbytes=4: return the LSB unsigned int [4096 bytes] <– default

Return: 1024 tuple with the counters.

getCounters()

GET the COUNTERS in Hexadecimal ASCII representation.

Send “Y” command to Hardware and return the response.

Returns:
The complet string returned by the instrument. It should be a 1024x4 chars string.
getCycleNumber()

GET the NUMBER of CYCLES being adquiring.

Send “W” command to Hardware.

Returns: An int number.

getStatus()

GET instrument STATUS. Send P to the instrument.

Returns:
The status string given by the Hardware, five four char hexadecimal which represents: Amplitude, central-channel, cycle-number, offset and time-base
Example:
output string: “0100 02A3 0010 0800 0FFF”+TERMINATOR correspond to Amplitude = 0x100, Central Channel = 0x2A3, Cycle Number 0x10, Offset = 0x800 and Time Base = 0xFFF
getWave()

GET WAVE from hardware.

Send “X” command to Hardware.

Returns: 4x1024 +2 length string. (Wave + LF + CR)

open()

Open the serial port.

reset()

RESET the hardware. Send “R” to the hardware.

Reset the hardware and clear the input buffer.

setAmplitude(K)

SET the AMPLITUDE of the wave. Send “K” command to the Instrument.

Args:
K: an integer between 0 and 4095.
setCentralChannel(Q)

Set the CENTRAL CHANNEL. Send “Q” command to the instrument.

Args:
Q: an integer betwenn 0 and 4095.
setCycleNumber(N)

SET the NUMBER of CYCLES to be adquired. Send “N” command to Hardware.

Args:
N: an integer between 0 and 0xFFFF.
setGate(ch0, ch1)

SET the GATE wave. Send G and g to the instrument.

Args:

ch0: Start-channel of the GATE signal.

ch1: End-channel of the GATE signal.

setOffset(Offset)

SET the OFFSET. Send “O” command to the Instrument.

Args:
Offset: an integer between 0 and 0xFFF.
setTimeBase(U)

SET the TIMEBASE on the instrument. Send “U” command to Hardware.

Args:
U: an integer between 0x500 (1280) and 0xFFFF (65535).
setWave(wavestr)

SET WAVE on hardware.

Send “W” command to Hardware.

Args:

The input argument (“wavestr”) must be an string with the WAVE values one each before the other in 4 hexadecimal digits without spaces and without end of line characters.

Expected input string: 4x1024 char wavestring.

Example:
wavestr=‘00000001000200030004......03FD03FE03FF’ correspond to a wave that start with the numbers 0,1,2,3,4 and end with the numbers 0x3FD,0x3FE and 0x3FF
start()

START the adquisition.

Send “S” command to Hardware.

stop()

STOP the adquisition.

Send “T” command to Hardware.

mdaq.MossbauerHard(port)

points to Instrument class. Deprecating function.

mdaq.hes2numlist(string, bn)

hexadecimal string to list of integers.

Args:
string: string with hexadecimal integers of the same char length without
separation character.

bn: integer. Number of characters per hexadecimal number.

Returns: A list of integers.

Example:
if string=‘0001000A000D...’ and bn = 4 then the function returns [1,10,13,...].
mdaq.heswis2numlist(string)

hexadecimal with sring string to list of integers.

Args:
string: string with hexadecimal integers of the same char length without
separation character.

bn: integer. Number of characters per hexadecimal number.

Returns: A list of integers.

Example:
if string=‘0001 000A 000D...’ and bn = 4 then the function returns [1,10,13,...].
mdaq.wavefromfile(datafile, label)

Takes the “label” wave from “datafile”.

Args:
datafile: a file with MDAQxxx waves. label: string that identifie the wave.
Returns:
wave in a list fo integers.

Read /auxilires/ondas.txt and /auxilires/ondas.dat for more information

mdaq.wavesonfile(datafile)

list the waves contents of datafile.

Args: datafile: the name of a file with MDAQ waves.

Returns: a list with the labels of the waves on the file.

mdaqtools

Herrmientas para trabajar en modo interactivo o conformar scripts con el módulo electrónico MDAQ-UNLP.

mdaqtools intenta extender las posibilidades del drive básico (mdaq). Esta pensado para trabajar en forma interactiva con un shell python. Como puede ser ipython. Al ser una extensión de los drivers se puede hacer todo lo que se hace con ellos más algunas propiedades útilies como.

  1. Tomar un mini espectro de un tiempo establesido [simplescan]
  2. Medir la tasa de conteo [rate]
  3. Ver en forma agradable e interpretada el estatus de la placa. [status]
  4. Bajar a disco información (espectro total, parcial, binario ascii o status) [down,down2,down3]
mdaqtools.initin(port, name='noname')

Inicia session en el puerto “port” con el nombre “name”

Por ejemplo initin(‘/dev/ttyS0’,’medida0’)

mdaqtools.readmdaqb(name)

Read binary mdaqb file.

Args:
name: a string with the name of the file.
Returns:
list of down3 instance. Each elemnet of the list is a tuple of two elemnts. The first the label of the down3 exectution and the second the saved object.
class mdaqtools.session(Instr, name='noname')

session de trabajo con mdaq

down()

Save to ascii status information

down2(who='counts')

Generate ASCII file with the counters. who can be: [counts] wave.

down3(who)

Baja a archivo en lo indicado en ‘who” en formato binario.

Args:
“who” is an string indicating what should be downloaded::

‘W’: wave array, ‘<c’ le 1024 unsigned char

‘C1’: counts array, ‘<B’ le 1024 unsigned char

‘C2’: counts array, ‘<H’ le 1024 unsigned short

‘C4’: counts array, ‘<I’ le 1024 unsigned int

‘K’: K parameter, ‘<H’ le 1 unsigned short

‘Q’: Q parameter, ‘<H’ le 1 unsigned short

‘N’: N parameter, ‘<H’ le 1 unsigned short

‘O’: O parameter, ‘<H’ le 1 unsigned short

‘U’: U parameter, ‘<H’ le 1 unsigned short

‘NC’: cycle numbers,’<H’ le 1 unsigned short

‘P’: stauts, ‘<H’ le 5 unsigned short

‘T’: time string, ‘<c’ le 24 chars

rate(t=1)

Measure the total counting rate during a given time.

simplescan(t=10, clear=True)

Makes a simple scan.

Args:

t: time (in seconds) to adquire.

clear: [True] or False. If True the counters are cleared before and after the adquisition.

Returns:
The array with the 1024 value of the counters.
status(quiet=False)

Prints or returns a pretty-status-string.

Args:
quiet: True or False. If False it print on stdout the pretty
status string.
Returns:
the pretty-status-string if quiet==True, and nothing otherwise.

Table Of Contents

Previous topic

Kit de desarrollo para software de interacción con la placa MDAQ107

Next topic

Historial de la versión

This Page