I2C is a simple two wire serial bus. To synchronize a behavioral experiment with imaging, ScanImage can act as a I2C bus slave. When an event occurs, the controller of the behavioral experiment can send data bytes to ScanImage. ScanImage will timestamp the incoming packet and log the data bytes to the Tiff header of the appropriate image frame. To learn more about the I2C protocol, review the I2C Wikipedia article.
The I2C bus is directly monitored by the ScanImage FPGA. The I2C bus requires both the Serial Data Line (SDA) and Serial Clock Line (SCL) to be pulled to VDD. For this purpose, +5V output on the breakout can serve as VDD. To calculate a resistance value for the pull-up resistors, please review this resource.
|Bus line||vDAQ Channel||SCB-19 Pin|
|SDA||Any channel in group 0, 1, or 2*||PFI0|
|SCL||Any channel in group 0, 1, or 2||PFI1|
*When "ack" output is enabled (see below) SDA must be in digital group 0 or 1
To configure ScanImage as an I2C slave, add the following lines to the 'ResScan' section of the Machine Data File:
I2C packet format
ScanImage saves received packets in the Tiff header of the appropriate image frame. When a start of packet signal is registered on the I2C bus, the FPGA generates a high precision time stamp which is saved with the data to the frame header. Depending on the Machine Data File setting 'I2CStoreAsChar' ScanImage stores the packet either as 'binary' byte array (each byte is a value of 0-255) or as string. If saved as a string, a received byte of value 0 is interpreted as the end of string.