Exceeding bandwidth limitations when using Format 7 partial image modes
Download PDF - Exceeding_Bandwidth_Limitations_with_FMT7
Overview
The purpose of this Technical Application Note is to illustrate a mechanism for effectively bypassing IEEE-1394 bus bandwidth negotiation when using cameras in Format 7 partial image mode. This functionality is useful in any situation where the user is trying to host multiple cameras on the same bus in a configuration that would normally exceed the bandwidth allocation, but where the cameras are configured to transmit data in a manner that does not exceed the total bandwidth. An example of this situation is where 3 cameras are on a 1394b bus, each configured to transmit 60MB/sec, running in external trigger mode and being triggered such that no camera was transmitting at the same time.
The method for achieving this functionality is similar to that outlined in the following article:
Maximum number of PGR IEEE-1394 cameras on a single 1394 bus.
Bus bandwidth negotiation is done with an initial (negotiated) byte per packet configuration. The byte per packet value is then changed outside of the bandwidth negotiation process to meet the desired bytes per packet.
Please refer to the PGR IEEE 1394 Register Reference for more details on accessing and the format of any registers referred to in this document.
Procedure Description
In order to configure the system, the following steps must be executed for all cameras:
- Configure the cameras to operate in Format 7, at the resolution desired, with the original negotiated packet size.
- Enable external trigger mode on all cameras.
- Disable isochronous data transmission on all cameras.
- Increase the byte per packet size for all cameras to the desired packet size insuring that exactly the same amount of data will be sent as when they were configured to transmit with the minimal packet size.
- Re-enable isochronous data transmission for all cameras.
Additional Details and Limitations
There are a number of very important details that need to be considered when configuring a system to work in this manner.
Format 7 configuration limitations
In order for configurations of this nature to work, the user must insure that changing the byte per packet register from the negotiated value to the desired value does not alter the total amount of data per image transmitted. If the amount of data transmitted changes, image corruption, and/or dropped images, and/or decreased frame rate will be observed. The result of this requirement is that there are a number of restrictions put on:
- the image size;
- the negotiated bytes per packet value; and
- the desired bytes per packet value.
The restrictions are as follows:
- The amount of data transmitted per image must remain constant in both the original negotiated and desired configurations. This value can be computed as follows:
Data_Sent = Packet_Size * CEIL(Image_Size / Packet_Size)
Note: If Image_Size is not a whole number multiple of the Packet_Size, padding data will be transmitted.
- The negotiated bytes per packet must be:
- a multiple of the UnitBytePerPacket as reported by the PACKET_PARA_INQ (040h) register; and
- a factor of the Data_Sent as computed above.
- The desired bytes per packet must be supported by the camera
As a result of these restrictions, negotiated and desired byte per packet values are generally determined using a brute force method such as a spreadsheet.
Note: Making sure that the total image size is a multiple of the unit packet size generally helps make it easier to find a minimum/maximum bytes/packet combination that will work.
Determining possible packet sizes
Given that the camera is configured in Format 7 for a given resolution and pixel format, the possible packet sizes can be determined by reading the PACKET_PARA_INQ (040h) register for the given mode. The UnitBytePerPacket field indicates the unit multiple of the packet size and the MaxBytePerPacket indicates the maximum sized packet that can be transmitted by the camera.
Bandwidth limitations
The bandwidth limitations of the IEEE-1394a and IEEE-1394b buses are as follows:
Bus |
Maximum Isochronous Bandwidth |
Maximum Packet Size |
IEEE-1394a |
4915 bytes/cycle |
4096 bytes/packet |
IEEE-1394b |
9830 bytes/cycle |
8192 bytes/packet |
The Maximum Isochronous Bandwidth is 80% of the total bus bandwidth. The remaining 20% is reserved for asynchronous data transmission. In some cases it is possible to exceed the 80% limitation the potential issues outlined in 1.6.6 need to be considered.
There are 8000 cycles per second in which data can be transmitted.
The Maximum Packet Size is the maximum amount of data that a single node can transmit during any given cycle.
Maximum DMA contexts
Implementations will be limited by the maximum number of DMA contexts supported by the 1394 Host Adapter Card. For more information, please refer to the following knowledge base article:
Differences to consider when selecting an IEEE-1394 PCI / PCMCIA adapter card
Time between triggers
Based on the assumptions that
- more than a single camera transmitting data at any one time will exceed the bus bandwidth, and
- both cameras are configured to consume the same bandwidth,
- both cameras are configured with the same shutter speed,
individual camera triggers will have to be timed such that no two cameras are transmitting at the same time. In the above case, the minimal time between triggers is simply the transmission time where transmission time is computed as follows:
Transmission_Time = Packets_Per_Frame / 8000 cycles per second
The number of packets per frame can be calculated using the following formula:
Packets Per Frame = CEIL( Image Size / Packet Size)
The more desirable method is to read it directly from the Packet_Per_Frame (048h) register on the camera after the BytePerPacket (044h) register has been written.
Using buffer fill mode
It is important to insure that the driver stack is configured to use buffer fill mode rather than packet per buffer mode. Configuring the stack to use packet per buffer mode adds the requirement that the number and size of packets remains constant.
pgrcam.sys - only operates in buffer fill mode and as such there are no configuration issues.
pgr1394b.sys – by default, this driver operates in buffer fill mode. Please refer to the section titled Switching Between Modes in the following kb article for confirming that the driver is in the correct mode:
Image divided or chopped into parts and frame rate decreases
Attempting to transmit data that will exceed the bus bandwidth
It is important to note that actually sending data at a rate that exceeds the bus bandwidth can/will result in negative consequences such as torn or corrupt images or bus resets.
Example Configuration
Determining Negotiated and Desired Byte Per Packet configurations
As mentioned above, the easiest way to compute negotiated and desired byte per packet configurations is through the use of a spreadsheet such as that shown below.
MaxBytePerPacket |
9792 |
UnitBytePerPacket |
12 |
Image Width |
2520 pixels |
Image Height |
2060 pixels |
Image Size |
5191200 bytes |
|
Packet Size |
Packets/Image |
Data Sent |
|
Desired |
9456 |
549 |
5191344 bytes |
|
|
12 |
432600 |
5191200 bytes |
- |
|
24 |
216300 |
5191200 bytes |
- |
|
36 |
144200 |
5191200 bytes |
- |
|
48 |
108150 |
5191200 bytes |
- |
|
60 |
86520 |
5191200 bytes |
- |
|
72 |
72100 |
5191200 bytes |
- |
|
84 |
61800 |
5191200 bytes |
- |
|
96 |
54075 |
5191200 bytes |
- |
|
108 |
48067 |
5191236 bytes |
- |
|
120 |
43260 |
5191200 bytes |
- |
|
132 |
39328 |
5191296 bytes |
- |
|
144 |
36050 |
5191200 bytes |
- |
|
156 |
33277 |
5191212 bytes |
- |
|
168 |
30900 |
5191200 bytes |
- |
|
180 |
28840 |
5191200 bytes |
- |
|
192 |
27038 |
5191296 bytes |
- |
|
204 |
25448 |
5191392 bytes |
- |
Negotiated |
216 |
24034 |
5191344 bytes |
valid |
|
228 |
22769 |
5191332 bytes |
- |
|
240 |
21630 |
5191200 bytes |
- |
For the purposes of this document, the negotiated byte per packet value should be 216 bytes. The reason for this is that it is the smallest factor of data sent that is a packet size supported by the camera.
- The Packet Size column is computed by starting with the UnitBytePerPacket value and simply incrementing by same
- The Packets/Image column is computed by computing the ceiling of Image Size divided by Packet Size.
- The Data Sent column is computed by multiplying Packets/Image by Packet Size.
The negotiated bytes per packet is the lowest packet size that results in the same amount of Data Sent as the desired value.
Camera configuration
Given the desired and negotiated settings determined above, the following example illustrates a configuration that will work.
Hardware |
|
1394 card |
SIIG FireWire 800 3-port PCIe |
Camera |
5MP |
Software |
|
FlyCapture SDK |
1.6 Release 19 |
Device Driver |
pgrcam.sys or pgr1394b.sys (in buffer fill mode) |
Image Capture |
FlyCap |
Camera Parameters |
|
Image Size |
2520 x 2060 |
Format 7 Mode |
Mode 0 |
Pixel Format |
Mono8 |
Minimum Packet Size |
12 bytes per packet |
Maximum Packet Size |
9792 bytes per packet |
Negotiated Packet Size |
216 bytes per packet (D8h) |
Desired Packet Size |
9456 bytes per packet (24F0h) |
Data transmitted per Frame |
5191344 bytes |
Padding |
144 bytes |
Using FlyCap with both cameras plugged into the same bus.
- Initialize each camera:
- Start FlyCap and select the camera
- Before initializing, click Configure Selected
- Select the Custom Image tab
- Configure the following values:
- Mode: Mode 0
- Pixel Format: Mono8
- Image Left: 0
- Image Right: 0
- Width: 2520
- Height: 2060
- Packet Size -> Current 216
- Click the Set button in the Custom Image tab, close the dialog and hit OK to start the camera.
- Put each camera into trigger mode:
- Open the Camera Control Dialog
- Access the GPIO/Trigger tab
- Enable the Trigger On/Off button
- Increase the bandwidth requirements:
For each camera, with the Register tab on the Camera Control Dialog open:
- Disable ISO Transmission by setting bit 0 of register 614h to 0
read |
614h |
0x80000000 |
write |
614h |
0x00000000 |
- Adjust the bytes per packet register by setting the first 16 bits of register A44h to 9456 (24F0h)
read |
A44h |
0x00D82640 |
write |
A44h |
0x24F02640 |
- Re-enable ISO data transmission by reading the value
read |
614h |
0x00000000 |
write |
614h |
0x80000000 |
- Determine minimum time between triggers by reading the Packets_Per_Frame register at A48h and dividing it by 8000 packets/sec.
read |
614h |
0x00000214 |
214h packets per frame = 532 packets per frame
532 packets/frame / 8000 cycles/second = 66.5ms/frame
- Fire trigger for each camera individually by hitting the Fire Software Trigger button on the GPIO/Trigger tab of the Camera Control Dialog.