把动作变成实验事件
Sanworks开放行为控制系统,有南洋理工Nature Neuroscience研究及IBL实际集成证据。选r2+成品主机加自制单端口,逐件原BOM、十章装配照片、光门测试与清水校准;含视频概览及版本差异说明。
alan000
Nature Neuroscience(外部应用研究) 2023
按“成品主机 + 一只自制端口”配置采购,避免把自制主板零件重复计入。
1. 准备一台 Bpod r2+、原配 12 V 阀电源、USB 数据线、CAT5e 线和一套自制端口。
2. 本教程只装一个行为口,不按完整 2AFC 装置采购;选鼻触端口和接口板 BOM。原主板全 BOM 仅用于选择 DIY 主机路线时参考。
**检查**:主机、阀电源、USB、CAT5e 和单端口零件均已备齐。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

打印端口外壳并备好焊接线材和金属管。
1. 使用原 CAD 当前修订,打印壳体、护套和底座;采用外露传感器版本,避免透光不良的旧版 XT 覆盖结构。
2. 剪 6 根 70 mm、22 AWG 导线:红色 3 根、紫色 3 根;两端各剥 4 mm。
3. 另备 6 段 12 mm 热缩管;从 12 英寸钢管料切出 35 mm 一段并去毛刺。
**检查**:打印件、线段数量、热缩管数量和 35 mm 钢管段均齐全。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

将红外发射器、接收器和指示 LED 接到导线上。
1. 先按元件数据手册确认发射器和光电晶体管引脚,不单凭照片左右位置判断极性。
2. 焊接时将紫线接地、红线接正;白色 LED 长脚为正极。
3. 焊前套入热缩管,焊后逐点绝缘;留出应力缓冲,避免导线拉力作用于器件脚。
4. 逐点检查导通,确认红线与紫线之间没有短路。
**检查**:器件引脚和极性已按数据手册确认,焊点牢固且导线无短路。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

把钢管、LED 和红外对管装入端口结构。
1. 按现版 CAD 确认 M4 孔及螺纹规格;如果加工图和工具标注不一致,先停止攻牙并核对 CAD。
2. 装入 35 mm 去毛刺钢管,再压入白色 LED。
3. 装螺钉与对管;从端口正面观察、钢管位于下方时,蓝色发射器在右、黑色接收器在左。
4. 检查打印件毛边没有遮住传感器。
**检查**:钢管、LED 和对管均固定,光路无遮挡。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

装端口护套并完成通孔接口板焊接。
1. 将护套压入端口,整理出口处导线。
2. 焊接接口板前逐个核对 10 Ω、499 Ω、15 kΩ 电阻阻值,再依次焊电阻、500 Ω 电位器、六位/两位端子和 RJ45。
3. 对照原理图核对各导线定义;用 M3 支柱将 PCB 底面与安装面隔开。
4. 安装原 Lee 阀及封帽,按实际阀型号核对流向和封口位置。
**检查**:元件位置与原理图相符,PCB 底面不接触安装面,阀连接无松脱。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

断电接好端口、主机和清水测试回路。
1. 将传感器与 LED 接到接口板,阀接两位端子;用 CAT5e 连接行为口 1。此 RJ45 是专用电路接口,不接以太网交换机。
2. USB 连接主机与电脑;原 12 V 适配器只供阀侧。
3. 将高位储液器经软管接阀入口,阀出口接端口钢管,出水端放入收集容器。
4. 液体与 PCB 分开放置;排出气泡、检查泄漏并固定液面高度。软管/接头的采购规格尚未闭合,未确认兼容接口前不要通液。
**检查**:连接无误、回路无泄漏且液体远离电子板;接口规格未确认时停在通液前。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

将锁定版本的 API 加入 MATLAB,并确认 r2+ 与固件状态。
1. 准备 MATLAB r2013a 或更新版本及其有效许可。
2. 下载锁定提交的 Bpod_Gen2,将仓库根目录 Add Path;不要使用 Add with subfolders。
3. 连接成品主机并核对型号和系统信息;本版本记录的 CurrentFirmwareList 为 23.10。
4. 只有需要更新时才从独立 StateMachine 固件仓库选择 r2+ 预配置固件;不要刷入其他 Arduino 程序。
**检查**:MATLAB 可找到 API,主机被识别为 r2+;固件不匹配时先停止,不继续运行例程。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

先验证单端口光门,不连接动物,也不启用自动给液。
1. 仅使能已接的端口 1,断开阀电源。
2. 用不透明卡片遮挡和移开光门,观察 Port1In、Port1Out 事件及控制台指示。
3. 手动切换 LED 亮灭与强度,学习 OneState/TwoState 状态机的建立、保存和事件记录。
4. 不要直接运行当前 Operant 例程:该例程需要端口 1 和 3,本配置只有一个端口。
**检查**:遮挡/放开能产生对应事件,LED 可手动控制;阀保持断电。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

用清水测量本机阀的开阀时长与出水量关系。
1. 确认回路无泄漏后接通阀电源,用 VLV 手动短开关检查出水。
2. 在 Settings 的液体校准页选择端口 1;对多个开阀时长分别累计脉冲出水。
3. 将收集容器去皮,称净水质量并按水的密度换算体积;每次固定液面高度和软管位置。
4. 按界面使用 Suggest Points、Measure Pending 和 Test curve;用累计 100 个脉冲复核曲线。
5. 保存本机校准结果并替换示例文件;不要把默认 5 µL 当作已验证的出水量。
**检查**:称重记录、校准曲线和 100 脉冲复核数据已保存,清水回路无泄漏。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)

归档单端口台架测试证据,并保留后续实验边界。
1. 记录板号、固件/API 版本和端口照片。
2. 保存手动遮挡事件、阀称重原始记录及曲线复核误差。
3. 调阀、换管或改变液面高度后重新校准;若要量测时间性能,使用示波器记录,不能用 GUI 响应代替硬件延迟。
4. 本页仅覆盖单端口、卡片和清水台架;动物研究须另行准备机构批准方案和设施。
**检查**:记录可对应到本次硬件与校准状态。
\
[原端口图解](https://sanworks.github.io/Bpod_Wiki/assembly/mouse-behavior-port-assembly/) · [接口板](https://sanworks.github.io/Bpod_Wiki/assembly/port-breakout-board-assembly/) · [锁定API与例程](https://github.com/sanworks/Bpod_Gen2/tree/8e5b008dc235c3f30ae371c6831f3e59e4ea1ec9)
