python-microscope / microscope

Python library for control of microscope devices, supporting hardware triggers and distribution of devices over the network for performance and flexibility.
https://www.python-microscope.org
GNU General Public License v3.0
67 stars 39 forks source link

Zaber LED hardware triggers. #181

Open iandobbie opened 3 years ago

iandobbie commented 3 years ago

We have a new Zaber LED controller that has digital triggers. The email below explains how they are implemented. As witht he CoolLed we need some way to enable the light source but not turn it on until the digital trigger is sent. I assume that David's changes this week can relatively easily be applied to the Zaber LED module.

My early advice yesterday wasn't wholly accurate. I was right that the triggers are shipping enabled - but the controller is actually actioning on the rising or falling edge of the signal, rather than if the signal is high or low. This should only affect initial start-up conditions, if signal is high when the controller starts, it will not switch on till it goes low, and then returns high. Triggers will effectively issue a lamp on command internally, so if you have a mixture of RS232 commands and triggers, it's good to know that the lamp on/off behaviour will only be affected by the edges.

In software, in order to set the triggers up, it would need to be done as follows:

trigger 1 when io di 1 == 1 trigger 1 action a 1 lamp on trigger 2 when io di 1 == 0 trigger 2 action a 1 lamp off trigger 3 when io di 2 == 1 trigger 3 action a 2 lamp on trigger 4 when io di 2 == 0 trigger 4 action a 2 lamp off trigger 5 when io di 3 == 1 trigger 5 action a 3 lamp on trigger 6 when io di 3 == 0 trigger 6 action a 3 lamp off trigger 7 when io di 4 == 1 trigger 7 action a 4 lamp on trigger 8 when io di 4 == 0 trigger 8 action a 4 lamp off

trigger 1 enable trigger 2 enable trigger 3 enable trigger 4 enable trigger 5 enable trigger 6 enable trigger 7 enable trigger 8 enable

this would need the deviceID number before hand - so if the controller is number 4 in the chain, each line would be 4 trigger ... etc.

To disable the triggers just run through trigger 1-8 and use "trigger # disable".

Likewise, as can be seen from the setup code, you can change the trigger conditions for each di to be switched, so when di # == 1 ; lamp off, and when di # == 0 lamp on - just by switching around the trigger conditions.

The di inputs and trigger commands are all standard Zaber triggers so more information can be found in the protocol manual here: https://www.zaber.com/protocol-manual?protocol=ASCII#topic_command_trigger

Any questions at all, just let me know. Should be straight forward knowing the complexity of all the code you guys already work with.

Best Regards, Paul

Dr Paul Williams Account Manager, Field Sales Telephone: +44 (0) 1933 461 666 Direct Dial: +44 (0) 1933 462 109 Mobile: +44 (0) 7487 847 281 laser2000.co.uk

iandobbie commented 3 years ago

This all works, but we are not yet setting up the hw triggers, just using the existing triggers. We should probably create a function that will set and clear these triggers. Once set they are preserved between reboots as far as I can tell. Having a function to do this would reduce errors if we have to set or clear all the triggers at any point.