Line Connection#
連接訊號用於控制相機的某些功能。例如,「TWI SDA」和「TWI SCL」訊號用於 Two-Wire Interface 通訊之用。
使用功能#
設定Line Connection#
要設定線路連接:
- 將相機中的
LineSelector參數設為所需的 GPIO 線. - 將相機中的
BslLineConnection參數設定為以下值之一:ConnectionOff: 目前選取的行未設定連線訊號。TwiSda: TWI SDA 訊號已針對目前選取的行進行設定。TwiScl: TWI SCL 訊號已針對目前選取的行進行設定。LightControl: 已針對目前選取的行設定燈光控制訊號。
- 請確保
LineMode參數設為InOut. 這讓您可以將 GPIO 線用作輸入/輸出線。如果該參數未自動設定為InOut, 請手動設定。
確定Line Connection#
要確定線路連接方式:
- 將相機中的
LineSelector將參數設定至所需的 I/O 線。 - 取得
BslLineConnection用於確定 I/O 線路當前連接狀態的參數。
範例程式碼#
INodeMap& nodemap = camera.GetNodeMap();
// Select Line 2
CEnumParameter(nodemap, "LineSelector").SetValue("Line2");
// Set the line connection to TWI SDA
CEnumParameter(nodemap, "BslLineConnection").SetValue("TwiSda");
// Get the current line connection
String_t e = CEnumParameter(nodemap, "BslLineConnection").GetValue();
// Select Line 2
camera.Parameters[PLCamera.LineSelector].SetValue(PLCamera.LineSelector.Line2);
// Set the line connection to TWI SDA
camera.Parameters[PLCamera.BslLineConnection].SetValue(PLCamera.BslLineConnection.TwiSda);
// Get the current line connection
string e = camera.Parameters[PLCamera.BslLineConnection].GetValue();
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
size_t len = 0;
char e_str[64] = {0};
/* Select Line 2 */
errRes = PylonDeviceFeatureFromString(hdev, "LineSelector", "Line2");
CHECK(errRes);
/* Set the line connection to TWI SDA */
errRes = PylonDeviceFeatureFromString(hdev, "BslLineConnection", "TwiSda");
CHECK(errRes);
/* Get the current line connection */
len = sizeof(e_str);
errRes = PylonDeviceFeatureToString(hdev, "BslLineConnection", e_str, &len);
CHECK(errRes);
您也可以 use the pylon Viewer 來輕鬆設定參數。