Hi,
Apologies for the delay getting back to you, your message got stuck in my spam filter..
It certainly would be possible to use one of the BNC digital inputs as a digital output by modifying the code - the BNC connectors are connected directly to pins on the pyboard microcontroller so no modification to the hardware would be necessary.
It should also be possible to modify the code to trigger a digital output based on the value of the photometry signal. The simplest way to do this would be if you could do all the data processing on the pyboard itself. Alternatively you could do the processing on the computer and tell the board when to trigger the pulse, but this would be more complicated to implement.
Assuming you can do all the processing on the pyboard, the only file you would have to modify is
photometry_upy.py. This file contains code that is transferred to the pyboard microcontroller and runs there, handing data acqusition and streaming data back to the computer. It defines a class called
Photometry, the GUI instantiates an instance of this class when it connects to the board, and calls methods of the class to start/stop acquisition, set the acquisition mode etc. The methods you would need to modify are:
- In the
__init__ method, when the digital pins are instantiated (line 31-32) you need to specify it is an output not an input (see micropython docs
here).
- In the start method, which is called at the start of data acqusition, you would need to initialise any variables that are going to be used for the data processing.
- The method
time_div_ISR is called by a timer twice each acqusition cycle. Each time it is called it acquires a sample from one of the analog and one of the digital channels. You would need to modify this function to set the value of the digital output pin based on the value of the analog signal. You should also set the self.dig_sample variable to match the state of the output pin, so that this gets sent to the GUI and plotted.
A couple of things to be aware of when working on this code:
- The file photometry_upy.py is uploaded to the pyboard when you connect to the board, so after you make changes to the file and save them on your computer, you will need to disconnect from the board using the GUI, then reconnect to upload the modified file.
- It may be tricky debugging changes to
photometry_upy.py because it runs on the pyboard not the computer, and errors that occur there may not always get saved to the ErrorLog.txt file. I need to check the logic of how errors occuring on the pyboard at different times are processed. I have a look at this over the next few days and get back to you.
best,
Thomas