Closed jondoesntgit closed 3 years ago
Hi Jonathan, before I comment in too much detail, is there a specific reason you are wanting to use NI digital lines to generate an SPI signal? Does the SPI command need to be precisely timed? Is a single digital trigger, to a custom microcontroller like a Arduino or raspberry pi Pico, that in turn sends an SPI command not sufficient for some reason (e.g. precise timing)?
The SPI command doesn't need to be precisely precisely timed. I imagine that using a microcontroller that runs an interrupt-service routine based on a psuedoclock input would be more than sufficient for our application.
We have an abundance of digital lines that we can use, and so I was thinking of looking into the bitbanging approach to save on installing additional hardware. However, it may be simpler in the long run to do as you're suggesting and solve the issue with additional hardware rather than hacked-together software.
Cool, a microcontroller is definitely the way to go if you want manual control from a BLACS tab as well. I doubt that software timed control of digital outputs would be sufficient for sending SPI commands. So you would effectively be programming in a shot as part of a manual command. So rather than trying to control the digital lines manually, you would probably actually just need to compile and submit shots to send single SPI commands from a BLACS tab in manual mode....which is doable, but less elegant than using a microcontroller (and probably has a bunch of caveats)
FYI there is support for adding custom tabs to BLACS, it's just not documented. It's called a PluginTab
- most details are in an archived pull request on the Bitbucket archive.
Despite that - I would still recommend the microcontroller route as it more closely follows the standard labscript-suite pattern.
Excellent. Thanks.
I'm wondering if one of the devs can help with an implementation question.
We've assembled a box that contains a few pieces of hardware in it. The hardware is programmed over an SPI interface, where multiple components have a shared clock, shared data line, and their own respective chip-select lines. I'd like to make a BLACS tab for this box where we can enter in settings as AnalogWidgets and a worker thread programs the specific piece of hardware. This would make debugging and setting up experiments a lot easier.
I've tried looking through examples online and in the thesis, but I can't find something in labscript that does this right now. The closest thing is a Shutter, which extends an NI DigitalOut functionality, and runs either go_high or go_low with some configurable delay. But what I'm looking for is something that can take several NI DigitalOuts and we can say in BLACS "set the internal setting to 18 on device 3", and then does the following:
I can do this just fine in an experiment.py file, but like I said, I'd love to be able to do this in BLACs.
So far, I've thought of two ways to do this:
Neither of these seems particularly elegant. Then again, bitbanging in general is not very elegant. I'm open to your wisdom.