Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add seven channel shutter ttl + fix stage scan camera trigger #272

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ public boolean prepareControllerForAcquisition(
if (isInterleaved) {
numLines = 1; // assure in acquisition code that we can't have single-sided interleaved
}
numLines *= (int)((double)settings.numChannels() / computeScanChannelsPerPass(settings));
if (settings.isUsingChannels()) {
numLines = numLines * (settings.numChannels() / computeScanChannelsPerPass(settings));
}
xyStage_.setScanNumLines(numLines);

final boolean isStageScan2Sided = (settings.acquisitionMode() == AcquisitionMode.STAGE_SCAN)
Expand Down Expand Up @@ -611,7 +613,6 @@ private boolean cleanUpControllerAfterAcquisitionSide(
// break;
// }

//if (scanner_ != null && piezo_ != null) {
// make sure SPIM state machine is stopped
scanner_.setSPIMState(ASIScanner.SPIMState.IDLE);

Expand All @@ -624,7 +625,7 @@ private boolean cleanUpControllerAfterAcquisitionSide(
if (movePiezo) {
piezo_.setPosition(piezoPosition);
}
//}

// make sure we stop SPIM and SCAN state machines every time we trigger controller (in AcquisitionPanel code)
return true;
}
Expand Down Expand Up @@ -692,11 +693,17 @@ public boolean setupHardwareChannelSwitching(final DefaultAcquisitionSettingsSCA
plcLaser_.setCellInput(3, acquisitionFlagAddr + ASIPLogic.addrEdge);
}

if (plcLaser_.getShutterMode() == ASIPLogic.ShutterMode.SEVEN_CHANNEL_SHUTTER) {
// special 7-channel case
// there are 2 separate 7-channel cases different in the property value for "PLogicMode"
// 1. (original) with 7-channel laser on own PLogic card, seems to have some odd things that I won't change including only uses 6 lasers
// 2. (newer) with 7-channel TTL-triggered on PLogic card shared with single camera trigger output (i.e. not dual-view system)
// however they share some things like using cells 17-24 and building a 3-input LUT which code is just copy/paste right now
final boolean isSevenChannelShutter = plcLaser_.getShutterMode() == ASIPLogic.ShutterMode.SEVEN_CHANNEL_SHUTTER;
final boolean isSevenChannelShutterTTL = plcLaser_.getShutterMode() == ASIPLogic.ShutterMode.SEVEN_CHANNEL_SHUTTER;

if (isSevenChannelShutter) {
// original special 7-channel case
if (plcLaser_.getNumCells() < 24) {
// restore update setting
plcLaser_.setAutoUpdateCells(editCellUpdates);
plcLaser_.setAutoUpdateCells(editCellUpdates); // restore update setting
studio_.logs().showError("Require 24-cell PLC firmware to use hardware channel switching with 7-channel shutter");
return false;
}
Expand All @@ -722,6 +729,41 @@ public boolean setupHardwareChannelSwitching(final DefaultAcquisitionSettingsSCA
plcLaser_.setCellInput(2, counterMSBAddr);
plcLaser_.setCellInput(3, laserTriggerAddress);
}
} else if (isSevenChannelShutterTTL) {
// new 7-channel case with camera trigger on BNC #8
if (plcLaser_.getNumCells() < 24) {
plcLaser_.setAutoUpdateCells(editCellUpdates); // restore update setting
studio_.logs().showError("Require 24-cell PLC firmware to use hardware channel switching with 7-channel shutter");
return false;
}

// set cells 17-24 to control BNCs 1-8, but then immediately change BNC8 to reflect camera (firmware ensures all are set to push-pull outputs)
// note that the device adapter should have already set BNC8 to be the camera so this is just resetting it
plcLaser_.setPreset(ASIPLogic.Preset.BNC1_8_ON_17_24);
final int addrFrontPanel8 = 40;
final int addrInternalTTLCameraA = 41;
plcLaser_.setPointerPosition(addrFrontPanel8); // address 40 is front panel #8
plcLaser_.setCellType(ASIPLogic.CellType.OUTPUT_PUSH_PULL);
plcLaser_.setCellConfig(addrInternalTTLCameraA); // address 41 is internal TTL0 signal for CameraA

// now set cells 17-23, so they reflect the counter state used to track state as well as the global laser trigger
for (int laserNum = 1; laserNum <= 7; ++laserNum) {
plcLaser_.setPointerPosition(laserNum + 16);
plcLaser_.setCellType(ASIPLogic.CellType.LUT3);
int lutValue = 0;
// populate a 3-input lookup table with the combinations of lasers present
// the LUT "MSB" is the laserTrigger, then the counter MSB, then the counter LSB
for (int channelNum = 0; channelNum < settings.numChannels(); ++channelNum) {
if (doesPLogicChannelIncludeLaser(laserNum, settings.channels()[channelNum], settings.channelGroup())) {
// LUT adds 2^(code in decimal) for each setting, but trigger is MSB of this code
lutValue += (int) Math.pow(2, channelNum + 4);
}
}
plcLaser_.setCellConfig(lutValue);
plcLaser_.setCellInput(1, counterLSBAddr);
plcLaser_.setCellInput(2, counterMSBAddr);
plcLaser_.setCellInput(3, laserTriggerAddress);
}

} else {
// original 4-channel mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ public AcquisitionEvent run(AcquisitionEvent event) {
xyStage.setSpeedX(scanSpeedX_);
xyStage.setAccelerationX(scanAccelX_);
finalController.prepareStageScanForAcquisition(pos.x, pos.y, acqSettings_);
finalController.triggerControllerStartAcquisition(acqSettings_.acquisitionMode(),
acqSettings_.volumeSettings().firstView());
}
return event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ public enum ShutterMode {
NONE("None"),
FOUR_CHANNEL_SHUTTER("Four-channel shutter"),
DISPIM_SHUTTER("diSPIM Shutter"),
SEVEN_CHANNEL_SHUTTER("Seven-channel shutter");
SEVEN_CHANNEL_SHUTTER("Seven-channel shutter"),
SEVEN_CHANNEL_TTL_SHUTTER("Seven-channel TTL shutter");

private final String text_;

Expand Down
Loading