User Tools

Site Tools


tiger_programmable_logic_card

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tiger_programmable_logic_card [2024/12/30 14:18] – [Programming Logic Cells] jontiger_programmable_logic_card [2026/03/16 14:03] (current) – re-arranged examples jon
Line 2: Line 2:
  
 ASI's Programmable Logic Card (PLC) is a field-programmable card for digital logic, sort of a mini-FPGA inside the Tiger controller. It acts as a single axis device (by default, axis E) and occupies one Tiger address (e.g. 36 in a diSPIM TG-16). Its original use is to enable multi-laser control for diSPIM, but it is designed to be very flexible and can be used for other tasks involving digital signals. ASI's Programmable Logic Card (PLC) is a field-programmable card for digital logic, sort of a mini-FPGA inside the Tiger controller. It acts as a single axis device (by default, axis E) and occupies one Tiger address (e.g. 36 in a diSPIM TG-16). Its original use is to enable multi-laser control for diSPIM, but it is designed to be very flexible and can be used for other tasks involving digital signals.
- 
-The old PDF documentation can be found [[http://www.asiimaging.com/downloads/manuals/Programmable_Logic_Card.pdf|here]]. However, this wiki version is more up to date and should be used instead. 
  
 ===== Overview ===== ===== Overview =====
Line 17: Line 15:
 The evaluation cycle is triggered by a clock signal. By default, the evaluation clock comes from an 4kHz source on the PLC. It is also possible for the clock to be provided by another Tiger card for synchronization purposes, e.g. for diSPIM the micro-mirror card is the source of the signals being output by the PLC (e.g. camera triggers) so the micro-mirror is the master and its 4kHz clock is used to trigger PLC evaluations. Finally, the user can provide a clock on the first BNC input. The evaluation cycle is triggered by a clock signal. By default, the evaluation clock comes from an 4kHz source on the PLC. It is also possible for the clock to be provided by another Tiger card for synchronization purposes, e.g. for diSPIM the micro-mirror card is the source of the signals being output by the PLC (e.g. camera triggers) so the micro-mirror is the master and its 4kHz clock is used to trigger PLC evaluations. Finally, the user can provide a clock on the first BNC input.
 Note that there is an delay of one evaluation cycle because the outputs are updated at the start of the evaluation cycle; this is an intentional design choice so that the output timing is deterministic. Thus, an input signal with arbitrary phase relative to the evaluation clock is output with a delay between 1 and 2 times the period of the evaluation cycle clock.  Note that there is an delay of one evaluation cycle because the outputs are updated at the start of the evaluation cycle; this is an intentional design choice so that the output timing is deterministic. Thus, an input signal with arbitrary phase relative to the evaluation clock is output with a delay between 1 and 2 times the period of the evaluation cycle clock. 
 +
 +
 +===== Addresses  ===== 
 +
 +Fundamental to understanding PLC operation is that each cell and I/O has a specific address.  Each address has a boolean value, logic high "TRUE" or logic low "FALSE" at each instant in time.
 +
 +  * Address 0 has the meaning of "logic low" and address 64 has the meaning of "logic high".
 +  * Addresses 1-16 are the programmable logic cells.  Some firmware builds have additional logic cells, e.g. 1-24 are all programmable cells in some builds.
 +  * Addresses 33-40 are for the front panel connectors, address 33 for the first connector and so forth.
 +  * Addresses 41-48 are for the backpanel signals, address 41 for the TTL0 signal and so forth.
 +
 +In order to take the boolean inverse (NOT) of a signal simple simply add 64 to the address.
 +
 +Add 128 to the address in order to obtain a "rising edge" signal, in other words to derive a value that is logic high if and only if the input value is currently high but was low during the last evaluation cycle.
 +
 +Add 64+128 = 192 to the address in order to obtain a "falling edge" signal, in other words to derive a value that is logic high if and only if the input value is currently low but was high during the last evaluation cycle.
 +
 +Thus there are exactly 256 valid addresses.
 +
 +==== Address code reference table ====
 +
 +^ Address ^ Meaning ^ Type ^
 +|0 |always 0/low |constant |
 +|1-16 |logic cell 1-16 |logic cell |
 +|17-32 |reserved for future use |(expanded cell array) |
 +|33-40 |front panel connectors 1-8 |physical I/O |
 +|41-48 |Tiger backplane TTL 0-7 |physical I/O |
 +|49-63 |reserved for future use |(expanded I/O) |
 +|64-127 |0-63 with inversion | |
 +|128-191 |rising edge on 0-63 | |
 +|192-255 |falling edge on 0-63 | |
  
 ===== Programming ===== ===== Programming =====
Line 38: Line 67:
 Trigger and clock inputs are edge-sensitive __and are underlined__; all other inputs are level-sensitive. If the user sets an edge-sensitive input to address 0-127 then it will automatically be set to the corresponding edge-sensitive address 128-255. Address 192 (or 64) has a rising edge every evaluation cycle. Trigger and clock inputs are edge-sensitive __and are underlined__; all other inputs are level-sensitive. If the user sets an edge-sensitive input to address 0-127 then it will automatically be set to the corresponding edge-sensitive address 128-255. Address 192 (or 64) has a rising edge every evaluation cycle.
  
-^ Table: Cell Types ^^^^^^^^ +^ Table: Cell Types                                                                                                                                                                                      ||||||||| 
-^ Cell Type    ^ Cell Type \\ ''CCA Y''  ^ Configuration \\ ''CCA Z'' ^ Input 1 \\ ''CCB X''  ^ Input 2 \\ ''CCB Y''  ^ Input 3 \\ ''CCB Z''  ^ Input 4 \\ ''CCB F''  ^ Has State?  ^ Firmware ^ +^ Cell Type                          ^ Cell Type \\ ''CCA Y''  ^ Configuration \\ ''CCA Z''       ^ Input 1 \\ ''CCB X''  ^ Input 2 \\ ''CCB Y''  ^ Input 3 \\ ''CCB Z''  ^ Input 4 \\ ''CCB F''  ^ Has State?  ^ Firmware  ^ 
-| constant                       | 0                      | 0 for 0, 1 for 1                 | -                      | -                     | -                     | -                     | -           | all | +| constant                           | 0                       | 0 for 0, 1 for 1                 | -                     | -                     | -                     | -                     | -           | all       | 
-| D-flop                         | 1                      | -                                | Din                    | __clock__             | reset                 | preset                | Yes         | +| D-flop                             | 1                       | -                                | Din                   | __clock__             | reset                 | preset                | Yes         | all       | 
-| 2-input LUT                    | 2                      | LUT values                       | A                      | B                     | -                     | -                     | -           | +| 2-input LUT                        | 2                       | LUT values                       | A                     | B                     | -                     | -                     | -           | all       | 
-| 3-input LUT                    | 3                      | LUT values                       | A                      | B                     | C                     | -                     | -           | +| 3-input LUT                        | 3                       | LUT values                       | A                     | B                     | C                     | -                     | -           | all       | 
-| 4-input LUT                    | 4                      | LUT values                       | A                      | B                     | C                     | D                     | -           | +| 4-input LUT                        | 4                       | LUT values                       | A                     | B                     | C                     | D                     | -           | all       | 
-| AND2                           | 5                      | -                                | A                      | B                     | -                     | -                     | -           | +| AND2                               | 5                       | -                                | A                     | B                     | -                     | -                     | -           | all       | 
-| OR2                            | 6                      | -                                | A                      | B                     | -                     | -                     | -           | +| OR2                                | 6                       | -                                | A                     | B                     | -                     | -                     | -           | all       | 
-| XOR2                           | 7                      | -                                | A                      | B                     | -                     | -                     | -           | +| XOR2                               | 7                       | -                                | A                     | B                     | -                     | -                     | -           | all       | 
-| one-shot (retriggerable)      | 8                      | duration  (# clock pulses)       | __trigger__            | __clock__             | reset                 | -                     | Yes         | +| one-shot (retriggerable)           | 8                       | duration  (# clock pulses)       | __trigger__           | __clock__             | reset                 | -                     | Yes         | all       | 
-| delay (retriggerable)         | 9                      | delay to fire  (# clock pulses)  | __trigger__            | __clock__             | reset                 | -                     | Yes         | +| delay (retriggerable)              | 9                       | delay to fire  (# clock pulses)  | __trigger__           | __clock__             | reset                 | -                     | Yes         | all       | 
-| AND4                           | 10                     | -                                | A                      | B                     | C                     | D                     | -           | +| AND4                               | 10                      | -                                | A                     | B                     | C                     | D                     | -           | all       | 
-| OR4                            | 11                     | -                                | A                      | B                     | C                     | D                     | -           | +| OR4                                | 11                      | -                                | A                     | B                     | C                     | D                     | -           | all       | 
-| Synchronous D-flop             | 12                     | -                                | Din                    | __clock__             | reset(S)                 | preset(S)                | Yes         | +| Synchronous D-flop                 | 12                      | -                                | Din                   | __clock__             | reset(S)              | preset(S)             | Yes         | all       | 
-| JK-flop                        | 13                     | -                                | J                      | K                     | __clock__             | -                     | Yes         | +| JK-flop                            | 13                      | -                                | J                     | K                     | __clock__             | -                     | Yes         | all       | 
-| one-shot (non-retriggerable)  | 14                     | duration  (# clock pulses)       | __trigger__            | __clock__             | reset                 | -                     | Yes         | +| one-shot (non-retriggerable)       | 14                      | duration  (# clock pulses)       | __trigger__           | __clock__             | reset                 | -                     | Yes         | all       | 
-| delay (non-retriggerable)     | 15                     | delay to fire  (# clock pulses)  | __trigger__            | __clock__             | reset                 | -                     | Yes         | +| delay (non-retriggerable)          | 15                      | delay to fire  (# clock pulses)  | __trigger__           | __clock__             | reset                 | -                     | Yes         | all       | 
-| one-shot OR2 (non-retriggerable)  | 16                     | duration  (# clock pulses)       | __trigger__ A            | __clock__             | reset                 | __trigger__ B                     | Yes         | +| one-shot OR2 (non-retriggerable)   | 16                      | duration  (# clock pulses)       | __trigger__ A         | __clock__             | reset                 | __trigger__ B         | Yes         | 3.50+     | 
-| delay OR2 (non-retriggerable)     | 17                     | delay to fire  (# clock pulses)  | __trigger__ A          | __clock__             | reset                 | __trigger__ B                     | Yes         | +| delay OR2 (non-retriggerable)      | 17                      | delay to fire  (# clock pulses)  | __trigger__ A         | __clock__             | reset                 | __trigger__ B         | Yes         | 3.50+     | 
-| Async/sync D-flop      | 18    | -  | Din | __clock__      | reset | reset(S)  | Yes         | +| Async/sync D-flop                  | 18                      | -                                | Din                   | __clock__             | reset                 | reset(S)              | Yes         | 3.51+     | 
-| counter AND2      | 19    | count (read-only)  | A  | __clock__      | reset   | B  | Yes         | +| counter AND2                       | 19                      | count (read-only)                | A                     | __clock__             | reset                 | B                     | Yes         | not yet   | 
-| counter OR2      | 20    | count (read-only)  | A   | __clock__      | reset   | B    | Yes         | +| counter OR2                        | 20                      | count (read-only)                | A                     | __clock__             | reset                 | B                     | Yes         | not yet   | 
-| counter timer      | 21   | count (read-only)  | __start__   | __clock__      | reset   | __stop__      | Yes         | +| counter timer                      | 21                      | count (read-only)                | __start__             | __clock__             | reset                 | __stop__              | Yes         | not yet   | 
-| counter timer (non-retriggerable)     | 22   | count (read-only)  | __start__   | __clock__      | reset   | __stop__      | Yes         |+| counter timer (non-retriggerable)  | 22                      | count (read-only)                | __start__             | __clock__             | reset                 | __stop__              | Yes         | not yet   |
  
-=== Address codes (used with ''CCB'' command as well as setting source address for physical I/O) === 
- 
-^ Address ^ Meaning ^ Type ^ 
-|0 |always 0/low |constant | 
-|1-16 |logic cell 1-16 |logic cell | 
-|17-32 |reserved for future use |(expanded cell array) | 
-|33-40 |front panel connectors 1-8 |physical I/O | 
-|41-48 |Tiger backplane TTL 0-7 |physical I/O | 
-|49-63 |reserved for future use |(expanded I/O) | 
-|64-127 |0-63 with inversion | | 
-|128-191 |rising edge on 0-63 | | 
-|192-255 |falling edge on 0-63 | | 
  
 === Logic Gates === === Logic Gates ===
Line 283: Line 300:
   * card trigger source   * card trigger source
  
-===== Example Logic =====+===== Example Logic and Scripts =====
  
 ==== Toggle ==== ==== Toggle ====
Line 568: Line 585:
 ==== Output the stage sync signal ==== ==== Output the stage sync signal ====
  
-For stage scanning there is an internal signal generated when the stage is scanning, and commonly the rising edge can be used to trigger other logic (e.g. camera that is free-running during the stage scan).  This script configures the internal signal to be immediately output on BNC #3 of the PLC.  Note that this stage sync signal requires a motorized 2-axis card with an appropriate jumper in place and also firmware with the SCAN_MODULE firmware (some documentation at http://asiimaging.com/docs/scan_module but needs to be augmented).  ((Note that there will be 0.25ms jitter because the internal stage sync signal is asychronous but the PLC is (almost always) sampling/outputing its signals on a 4kHz clock.  The corresponding positional jitter depends on the speed, e.g. at 40 um/s speed the positional jitter will be 0.25ms * 40 um/s = 10nm which is negligible.))+For stage scanning there is an internal signal generated when the stage is scanning, and commonly the rising edge can be used to trigger other logic (e.g. camera that is free-running during the stage scan).  This script configures the internal signal to be immediately output on BNC #3 of the PLC.  Note that this stage sync signal requires a motorized 2-axis card with an appropriate jumper in place and also firmware with the ''SCAN_MODULE'' firmware (some documentation at [[:scan_module|SCAN MODULE]] but needs to be augmented).  ((Note that there will be 0.25ms jitter because the internal stage sync signal is asychronous but the PLC is (almost always) sampling/outputing its signals on a 4kHz clock.  The corresponding positional jitter depends on the speed, e.g. at 40 um/s speed the positional jitter will be 0.25ms * 40 um/s = 10nm which is negligible.))
  
 --> Script: Stage sync signal on BNC#3 --> Script: Stage sync signal on BNC#3
Line 592: Line 609:
 </code> </code>
 <-- <--
-==== diSPIM 2 laser control ==== 
  
-Say we want to use two lasers with diSPIM where the laser color is changed on alternate volumes. The micro-mirror drive card of the Tiger outputs are a single laser trigger and a TTL side indicator. For two lasers where the laser is toggled ever volume, we to route the laser trigger to one laser for the first volume and the second laser on the next volume. This is accomplished by using a toggle flop (1-bit counter) that is toggled after every volume. This requires 3 logic cells, arranged as shown here. The BNC connectors on the front of the PLC provide the required additional physical connectors.  
  
-If instead we want to toggle the laser every slice, the logic is almost identical except that the toggle counter is connected to the laser trigger.  Some additional logic could be added to reset the counter between stacks in case an odd number of slices is used.+==== Conditional Synchronized Output Pulse ==== 
 + 
 +One customer wanted to trigger a laser for a set time synchronized to the camera trigger signal, but only if a condition had been met (specifically a trigger on the controller backplane indicating the laser should be fired). 
 +--> Script: output timed pulse synchronized to input 
 + 
 +<code java inoutsync.bsh> 
 +// output a timed pulse coincident with rising edge of input#1 if and only if input#2 has seen a rising edge since the last pulse 
 +// use to synchronize the output with input#1 
 +// currently set to output BNC#3 with input#1 of BNC#1 and input#2 of backplane TTL1  
 +// example use case: fire laser (output) when the camera trigger is just starting (input#1) if we are ready for it (input#2) 
 + 
 +// variables to be edited by user 
 +outputDurationInMs = 25;  // can be no more than 16.3 seconds with normal 4kHz clock 
 +int addrOutput = 35;  // 35 corresponds to BNC#3, change if want different output 
 +int addrInput1 = 33;   // 33 corresponds to BNC#1, change if want different input 
 +int addrInput2 = 42;   // 42 corresponds to TTL1 on backplane = laser shutter signal 
 + 
 +// variables that should not need to be edited by user 
 +// would like to define these variables as final, but this is 
 +//  not amenable to script which can run multiple times 
 +String plcName = "PLogic:E:36"; 
 +String propPosition = "PointerPosition"; 
 +String propCellType = "EditCellCellType"; 
 +String propCellConfig = "EditCellConfig"; 
 +String propCellInput1 = "EditCellInput1"; 
 +String propCellInput2 = "EditCellInput2"; 
 +String propCellInput3 = "EditCellInput3"; 
 +String propUpdates = "EditCellUpdateAutomatically"; 
 +String valNo = "No"; 
 +String valDFlop = "1 - D flop"; 
 +String valAND2 = "5 - 2-input AND"; 
 +String valOneShot = "14 - one shot (NRT)"; 
 +String valIOInput = "0 - input"; 
 +String valIOPushPull = "2 - output (push-pull)"; 
 +int ticsPerMs = 4; 
 +int addrInvert= 64; 
 +int addrEdge = 128; 
 +int addrInput2Capture = 1; 
 +int addrBothInputs = 2; 
 +int addrOneShotCell = 3; 
 + 
 + 
 +// figure out the high period in terms of PLC "tics" (4kHz) 
 +int outputDurationTics = (int) (outputDurationInMs*ticsPerMs + 0.5); 
 + 
 +// turn off updates to speed communication 
 +String valUpdatesOriginal = mmc.getProperty(plcName, propUpdates); 
 +mmc.setProperty(plcName, propUpdates, valNo); 
 + 
 +// use D-flops to latch rising edges of two inputs 
 +// (reset once output pulse starts) 
 +mmc.setProperty(plcName, propPosition, addrInput2Capture); 
 +mmc.setProperty(plcName, propCellType, valDFlop); 
 +mmc.setProperty(plcName, propCellInput1, addrInvert);  // connect D input to logic 1 
 +mmc.setProperty(plcName, propCellInput2, addrEdge + addrInput2); 
 +mmc.setProperty(plcName, propCellInput3, addrEdge + addrOneShotCell);  // reset once output pulse starts 
 + 
 +// use AND to combine edge of input#1 with latched signal from input#2 
 +mmc.setProperty(plcName, propPosition, addrBothInputs); 
 +mmc.setProperty(plcName, propCellType, valAND2); 
 +mmc.setProperty(plcName, propCellInput1, addrEdge + addrInput1); 
 +mmc.setProperty(plcName, propCellInput2, addrInput2Capture); 
 + 
 +// use non-retriggerable one-shot to output pulse 
 +mmc.setProperty(plcName, propPosition, addrOneShotCell); 
 +mmc.setProperty(plcName, propCellType, valOneShot); 
 +mmc.setProperty(plcName, propCellConfig, outputDurationTics); 
 +mmc.setProperty(plcName, propCellInput1, addrBothInputs); 
 +mmc.setProperty(plcName, propCellInput2, addrInvert + addrEdge);  // clock on every tic 
 + 
 +// make sure inputs are set as inputs 
 +mmc.setProperty(plcName, propPosition, addrInput1); 
 +mmc.setProperty(plcName, propCellType, valIOInput); 
 +mmc.setProperty(plcName, propPosition, addrInput2); 
 +mmc.setProperty(plcName, propCellType, valIOInput); 
 + 
 +// connect one shot to output and set as output 
 +mmc.setProperty(plcName, propPosition, addrOutput); 
 +mmc.setProperty(plcName, propCellType, valIOPushPull); 
 +mmc.setProperty(plcName, propCellConfig, addrOneShotCell); 
 + 
 +// restore updates 
 +mmc.setProperty(plcName, propUpdates, valUpdatesOriginal); 
 +</code> 
 +<-- 
 +==== Blinking outputs for testing ==== 
 + 
 +To check functionality of the outputs and receipt of the input trigger signal it is convenient to set the 8 outputs corresponding to a digital counter which is advanced every evaluation cycle.  Because the evaluation cycle is nominally 4 kHz visual inspection is easiest if only the highest bits of the counter are displayed.  This is accomplished by sending the following two serial commands to re-configure the cells to a useful test mode: 
 + 
 +''6 CCA X=4'' (sets cells 1-16 as a digital counter advanced each evaluation cycle) 
 + 
 +''6 CCA X=19'' (sets BNC outputs 1-8 to correspond to cells 9-16) 
 + 
 + 
 +==== Print internal configuration ==== 
 + 
 +The script below outputs the internal configuration of the PLC 
 + 
 +--> Script: print internal configuration# 
 +<code java printconfig.bsh> 
 +// print out to the terminal the internal configuration of the PLC 
 +String plcName = "PLogic:E:36"; 
 +String propPosition = "PointerPosition"; 
 +String propCellType = "EditCellCellType"; 
 +String propCellConfig = "EditCellConfig"; 
 +String propCellInput1 = "EditCellInput1"; 
 +String propCellInput2 = "EditCellInput2"; 
 +String propCellInput3 = "EditCellInput3"; 
 +String propCellInput4 = "EditCellInput4"; 
 + 
 +for (int cellNr=1; cellNr<=16; cellNr++) { 
 +   mmc.setProperty(plcName, propPosition, cellNr); 
 +   print("Cell " + cellNr + ":"); 
 +   print("  type: " + mmc.getProperty(plcName, propCellType)); 
 +   print("  config: " + mmc.getProperty(plcName, propCellConfig)); 
 +   print("  inputs: " + mmc.getProperty(plcName, propCellInput1) + ", " + 
 +   mmc.getProperty(plcName, propCellInput2) + ", " + 
 +   mmc.getProperty(plcName, propCellInput3) +  ", " + 
 +   mmc.getProperty(plcName, propCellInput4) ); 
 +} 
 + 
 +for (int ioNr=1; ioNr<=16; ioNr++) { 
 +   mmc.setProperty(plcName, propPosition, ioNr + 32); 
 +   print("I/O " + ioNr + ":"); 
 +   print("  type: " + mmc.getProperty(plcName, propCellType)); 
 +   print("  addr: " + mmc.getProperty(plcName, propCellConfig)); 
 +} 
 +</code> 
 +<--
  
-{{ :documentation:plc_counter.jpg?300 |}} 
  
-==== Micro-Manager ASIdiSPIM plugin ====+===== Micro-Manager ASIdiSPIM plugin =====
  
 The Micro-Manager ASIdiSPIM plugin uses the PLC for outputting the camera and laser triggers.  Here is the usage of the internal cells: The Micro-Manager ASIdiSPIM plugin uses the PLC for outputting the camera and laser triggers.  Here is the usage of the internal cells:
Line 927: Line 1069:
 <-- <--
  
-==== Constant-value Output ====+==== diSPIM 2 laser control ====
  
-One customer wanted to set the value of output #3 to be continuously high for the experiment.+Say we want to use two lasers with diSPIM where the laser color is changed on alternate volumes. The micro-mirror drive card of the Tiger outputs are a single laser trigger and a TTL side indicator. For two lasers where the laser is toggled ever volume, we to route the laser trigger to one laser for the first volume and the second laser on the next volume. This is accomplished by using a toggle flop (1-bit counter) that is toggled after every volume. This requires 3 logic cells, arranged as shown here. The BNC connectors on the front of the PLC provide the required additional physical connectors. 
  
---> Script: output 3 always high # +If instead we want to toggle the laser every slice, the logic is almost identical except that the toggle counter is connected to the laser trigger.  Some additional logic could be added to reset the counter between stacks in case an odd number of slices is used.
-<code java output3high.bsh> +
-// variables that should not need to be edited by user +
-// would like to define these variables as final, but this is +
-//  not amenable to script which can run multiple times +
-String plcName = "PLogic:E:36"; +
-String propPosition = "PointerPosition"; +
-String propCellConfig = "EditCellConfig"; +
-String propSaveSettings = "SaveCardSettings"; +
-String valSaveSettings = "Z - save settings to card (partial)"; +
-int addrOutput3 = 35; +
-int addrHigh= 64; +
-int addrLow = 0;+
  
 +{{ :documentation:plc_counter.jpg?300 |}}
  
-// output #3 assigned to be always high 
-mmc.setProperty(plcName, propPosition, addrOutput3); 
-mmc.setProperty(plcName, propCellConfig, addrHigh);  // output to be high 
-//mmc.setProperty(plcName, propCellConfig, addrLow);  // output to be low 
  
-// save settings +==== diSPIM separate lasers for two sides ====
-mmc.setProperty(plcName, propSaveSettings, valSaveSettings); +
-</code> +
-<--+
  
 +A long time ago diSPIM had capability of triggering 2 separate lasers for the two sides, but we moved to a scheme where there was a single signal for triggering a laser, another one for the laser side select switch hardware, and we added a software-set shutter signal using cell 8.  However there are still occasional cases that would have a separate laser separate (single-channel) laser for the 2 sides.
  
-==== Conditional Synchronized Output Pulse ====+Cell 10 internally is the "laser enable" signal and normally the correct BNC output is set to reflect that cell's state.  For this usage we need to also account for the laser side signal which is on address 42 (TTL3).  Here we use cells 14 and 15 to reflect whether the PathA and PathB lasers should be on respectively, and then assign those to BNC6 and BNC7 respectively.
  
-One customer wanted to trigger a laser for a set time synchronized to the camera trigger signal, but only if a condition had been met (specifically a trigger on the controller backplane indicating the laser should be fired). +--> Script: BNC6 is PathA laser on and BNC7 is PathB laser on # 
---> Script: output timed pulse synchronized to input+<code java Laser_TwoSided_BNC67.bsh>
  
-<code java inoutsync.bsh> +// BNC6 is PathA laser on and BNC7 is PathB laser on
-// output a timed pulse coincident with rising edge of input#1 if and only if input#2 has seen a rising edge since the last pulse +
-// use to synchronize the output with input#1 +
-// currently set to output BNC#3 with input#1 of BNC#1 and input#2 of backplane TTL1  +
-// example use case: fire laser (output) when the camera trigger is just starting (input#1) if we are ready for it (input#2) +
- +
-// variables to be edited by user +
-outputDurationInMs = 25;  // can be no more than 16.3 seconds with normal 4kHz clock +
-int addrOutput = 35;  // 35 corresponds to BNC#3, change if want different output +
-int addrInput1 = 33;   // 33 corresponds to BNC#1, change if want different input +
-int addrInput2 = 42;   // 42 corresponds to TTL1 on backplane = laser shutter signal+
  
 // variables that should not need to be edited by user // variables that should not need to be edited by user
Line 983: Line 1098:
 String propCellInput1 = "EditCellInput1"; String propCellInput1 = "EditCellInput1";
 String propCellInput2 = "EditCellInput2"; String propCellInput2 = "EditCellInput2";
-String propCellInput3 = "EditCellInput3"; +String propSaveSettings = "SaveCardSettings";
-String propUpdates = "EditCellUpdateAutomatically"; +
-String valNo = "No"; +
-String valDFlop = "1 - D flop";+
 String valAND2 = "5 - 2-input AND"; String valAND2 = "5 - 2-input AND";
-String valOneShot = "14 - one shot (NRT)"; +String valSaveSettings = "Z - save settings to card (partial)"; 
-String valIOInput = "0 - input"; +int addrOutputBNC6 = 38; 
-String valIOPushPull = "2 - output (push-pull)"; +int addrOutputBNC7 = 39; 
-int ticsPerMs = 4; +int addrLaserEnableCell = 10; 
-int addrInvert= 64; +int addrLaserSide = 44;  // TTL3 on Tiger backplane 
-int addrEdge = 128; +int addrPathACell = 14; 
-int addrInput2Capture = 1; +int addrPathBCell = 15; 
-int addrBothInputs = 2; +int addrInvert = 64;
-int addrOneShotCell = 3;+
  
  
-// figure out the high period in terms of PLC "tics" (4kHz) +// create cells re-using existing "laser enable" cell 10 that already accounts for software shutter and the main "laser on" signal 
-int outputDurationTics = (int) (outputDurationInMs*ticsPerMs + 0.5); +mmc.setProperty(plcName, propPosition, addrPathACell); 
- +mmc.setProperty(plcName, propCellType, valAND2); 
-// turn off updates to speed communication +mmc.setProperty(plcName, propCellInput1, addrLaserEnableCell); 
-String valUpdatesOriginal = mmc.getProperty(plcName, propUpdates); +mmc.setProperty(plcName, propCellInput2, addrLaserSide + addrInvert); 
-mmc.setProperty(plcName, propUpdates, valNo); +mmc.setProperty(plcName, propPosition, addrPathBCell);
- +
-// use D-flops to latch rising edges of two inputs +
-// (reset once output pulse starts) +
-mmc.setProperty(plcName, propPosition, addrInput2Capture); +
-mmc.setProperty(plcName, propCellType, valDFlop); +
-mmc.setProperty(plcName, propCellInput1, addrInvert);  // connect D input to logic 1 +
-mmc.setProperty(plcName, propCellInput2, addrEdge + addrInput2); +
-mmc.setProperty(plcName, propCellInput3, addrEdge + addrOneShotCell);  // reset once output pulse starts +
- +
-// use AND to combine edge of input#1 with latched signal from input#2 +
-mmc.setProperty(plcName, propPosition, addrBothInputs);+
 mmc.setProperty(plcName, propCellType, valAND2); mmc.setProperty(plcName, propCellType, valAND2);
-mmc.setProperty(plcName, propCellInput1, addrEdge + addrInput1); +mmc.setProperty(plcName, propCellInput1, addrLaserEnableCell); 
-mmc.setProperty(plcName, propCellInput2, addrInput2Capture);+mmc.setProperty(plcName, propCellInput2, addrLaserSide);
  
-// use non-retriggerable one-shot to output pulse +// connect cells to BNC output 
-mmc.setProperty(plcName, propPosition, addrOneShotCell); +mmc.setProperty(plcName, propPosition, addrOutputBNC6); 
-mmc.setProperty(plcName, propCellType, valOneShot); +mmc.setProperty(plcName, propCellConfig, addrPathACell); 
-mmc.setProperty(plcName, propCellConfig, outputDurationTics); +mmc.setProperty(plcName, propPosition, addrOutputBNC7); 
-mmc.setProperty(plcName, propCellInput1, addrBothInputs); +mmc.setProperty(plcName, propCellConfig, addrPathBCell);
-mmc.setProperty(plcName, propCellInput2, addrInvert + addrEdge);  // clock on every tic+
  
-// make sure inputs are set as inputs +// save settings 
-mmc.setProperty(plcName, propPosition, addrInput1); +mmc.setProperty(plcName, propSaveSettings, valSaveSettings);
-mmc.setProperty(plcName, propCellType, valIOInput); +
-mmc.setProperty(plcName, propPosition, addrInput2); +
-mmc.setProperty(plcName, propCellType, valIOInput);+
  
-// connect one shot to output and set as output 
-mmc.setProperty(plcName, propPosition, addrOutput); 
-mmc.setProperty(plcName, propCellType, valIOPushPull); 
-mmc.setProperty(plcName, propCellConfig, addrOneShotCell); 
- 
-// restore updates 
-mmc.setProperty(plcName, propUpdates, valUpdatesOriginal); 
 </code> </code>
 <-- <--
-==== Blinking outputs for testing ==== 
  
-To check functionality of the outputs and receipt of the input trigger signal it is convenient to set the 8 outputs corresponding to a digital counter which is advanced every evaluation cycle.  Because the evaluation cycle is nominally 4 kHz visual inspection is easiest if only the highest bits of the counter are displayed.  This is accomplished by sending the following two serial commands to re-configure the cells to a useful test mode: 
  
-''6 CCA X=4'' (sets cells 1-16 as a digital counter advanced each evaluation cycle)+==== Constant-value Output ====
  
-''6 CCA X=19'' (sets BNC outputs 1-8 to correspond to cells 9-16)+One customer wanted to set the value of output #3 to be continuously high for the experiment.
  
- +--> Script: output 3 always high # 
-==== Print internal configuration ==== +<code java output3high.bsh> 
- +// variables that should not need to be edited by user 
-The script below outputs the internal configuration of the PLC +// would like to define these variables as final, but this is 
- +//  not amenable to script which can run multiple times
---> Script: print internal configuration# +
-<code java printconfig.bsh> +
-// print out to the terminal the internal configuration of the PLC+
 String plcName = "PLogic:E:36"; String plcName = "PLogic:E:36";
 String propPosition = "PointerPosition"; String propPosition = "PointerPosition";
-String propCellType = "EditCellCellType"; 
 String propCellConfig = "EditCellConfig"; String propCellConfig = "EditCellConfig";
-String propCellInput1 = "EditCellInput1"; +String propSaveSettings = "SaveCardSettings"; 
-String propCellInput2 = "EditCellInput2"; +String valSaveSettings = "Z - save settings to card (partial)"; 
-String propCellInput3 = "EditCellInput3"; +int addrOutput3 = 35; 
-String propCellInput4 = "EditCellInput4";+int addrHigh= 64; 
 +int addrLow = 0;
  
-for (int cellNr=1; cellNr<=16; cellNr++) { 
-   mmc.setProperty(plcName, propPosition, cellNr); 
-   print("Cell " + cellNr + ":"); 
-   print("  type: " + mmc.getProperty(plcName, propCellType)); 
-   print("  config: " + mmc.getProperty(plcName, propCellConfig)); 
-   print("  inputs: " + mmc.getProperty(plcName, propCellInput1) + ", " + 
-   mmc.getProperty(plcName, propCellInput2) + ", " + 
-   mmc.getProperty(plcName, propCellInput3) +  ", " + 
-   mmc.getProperty(plcName, propCellInput4) ); 
-} 
  
-for (int ioNr=1; ioNr<=16; ioNr++) { +// output #3 assigned to be always high 
-   mmc.setProperty(plcName, propPosition, ioNr + 32); +mmc.setProperty(plcName, propPosition, addrOutput3); 
-   print("I/O " + ioNr + ":"); +mmc.setProperty(plcName, propCellConfig, addrHigh);  // output to be high 
-   print("  type: " + mmc.getProperty(plcName, propCellType)); +//mmc.setProperty(plcName, propCellConfig, addrLow);  // output to be low 
-   print("  addr: " + mmc.getProperty(plcName, propCellConfig)); + 
-}+// save settings 
 +mmc.setProperty(plcName, propSaveSettings, valSaveSettings);
 </code> </code>
 <-- <--
Line 1102: Line 1177:
 The standard TG-1000 backplane is configured as follows for diSPIM:  The standard TG-1000 backplane is configured as follows for diSPIM: 
  
-^ PLC Address ^ Signal6 ^ diSPIM use ^ +^ PLC Address  ^ Signal6  ^ diSPIM use               ^ 
-|41|TTL0|Camera Path A| +| 41           | TTL0     | Camera Path A            | 
-|42|TTL1|Laser 0 (laser trigger)| +| 42           | TTL1     | Laser 0 (laser trigger)  | 
-|43|TTL2|Camera Path B| +| 43           | TTL2     | Camera Path B            | 
-|44|TTL3|Laser 1 (laser side)| +| 44           | TTL3     | Laser 1 (laser side)     | 
-|45|TTL4|Piezo Path A| +| 45           | TTL4     | Piezo Path A             | 
-|46|TTL5|Trigger Input| +| 46           | TTL5     | Trigger from XY stage    | 
-|47|TTL6|Piezo Path B| +| 47           | TTL6     | Piezo Path B             | 
-|48|TTL7|Reserved|+| 48           | TTL7     | Unused                   |
  
 Laser 0 and Laser 1 outputs behave according to a firmware setting (''LED Z''). This setting is usually changed by the user to match the laser control configuration they are using. The outputs can be set as: Laser 0 and Laser 1 outputs behave according to a firmware setting (''LED Z''). This setting is usually changed by the user to match the laser control configuration they are using. The outputs can be set as:
Address: 29391 W Enid Rd. Eugene, OR 97402, USA | Phone: +1 (541) 461-8181
tiger_programmable_logic_card.1735586313.txt.gz · Last modified: by jon