Configuring a new Device with RS422 or SPI

55 views
Skip to first unread message

Andrew Blackney

unread,
Feb 22, 2021, 5:18:21 PM2/22/21
to the labscript suite
Hello,
I have a Wavemeter that I would like to tie into my Labscript system to collect data from. the Wavemeter transmits over both SPI and RS422.  I have a copy of the python code for controlling and reading from the device. How would I go about configuring the device and is there an example device that I can reference?

Zak V

unread,
Feb 23, 2021, 2:03:03 PM2/23/21
to the labscript suite
Hi Andrew,

Chapter 7 of Phil Starkey's thesis explains how to integrate hardware into labscript, and there are a lot of examples in the labscript devices repo https://github.com/labscript-suite/labscript-devices/tree/master/labscript_devices. You can put the code that you write in the user_devices directory of your userlib.

It's particularly helpful to reference the code for devices with similar kinds of inputs/outputs when writing your own device code. Often your classes can inherit from the classes of an existing device and just overwrite methods as needed. If your wavemeter reads in some kind of waveform, then it would be a good idea to take a look at the tekscope device. If it just reads in a single analog value then you may want to take a look at some other devices, maybe even in an unofficial repo. There was a thread in this mailing list about reading in temperature data with arduino (https://groups.google.com/u/1/g/labscriptsuite/c/X0EfacRiXs4/m/g8aaCzHPBQAJ) which might have links to helpful code. If someone else has a suggested reference, feel free to chime in!

Note that the devices with their code organized into folders use the new style of registering classes (see footnote 2 of chapter 7 of Phil's thesis) so it's best to follow their layout in terms of how the code is divided into separate files and organized into a folder. The devices that use the old decorator-based approach with all of the code in one file still work though, so they are still good references.

Cheers,
Zak

Andrew Blackney

unread,
Mar 26, 2021, 12:17:20 PM3/26/21
to the labscript suite
Hey Zak thanks! I have made a lot of progress on this issue but I still have a probably python based issue. I keep getting the error 'module object is not callable'. I believe it has to do with the serial port initialization but I am not sure how to fix it.

Zak V

unread,
Mar 27, 2021, 8:26:03 AM3/27/21
to the labscript suite
Hi Andrew,

Glad you've been making progress!

Generally for discussions like this it's helpful to include the full traceback that python prints out when it raises the error because it typically contains very helpful information. It's also helpful to provide a minimum working example demonstrating how to reproduce the error. It's a bit difficult to help fix a bug if you can't see the code!

That said it sounds like you've imported a module and attempted to use it like a function or class. My guess is that you're running into an issue like the one that the commented code below demonstrates:

```
# Import serial, which is a module. Note that you'll need to pip or conda install
# the pyserial package in order to actually be able to run this code.
import serial

# Creating a connection starts by creating and instance of the Serial class.
# Note that the Serial class and the serial module are different things even though
# they have similar names; one is a module and one is a class.
my_connection = serial.Serial()

# The below will raise a TypeError because serial is a module, and modules can't
# be called like functions or classes.
serial()
```

I'm not sure if you're using the serial module; I've just used it as an example because it's particularly easy to confuse the module `serial` with its class `serial.Serial`. You may also find this stack overflow post helpful: https://stackoverflow.com/questions/4534438/typeerror-module-object-is-not-callable.

Cheers,
Zak

Andrew Blackney

unread,
Mar 31, 2021, 2:37:29 PM3/31/21
to the labscript suite
yeah the issue I was having is related to the fact that my devices example code creates a class that was the same as the class of the labscript uses for the intermediate device. I had a intermediate device class attempting to call a subclass of the same name in the blacs worker code.
Reply all
Reply to author
Forward
0 new messages