Line Connection#
連線訊號是用來控制特定的相機功能。例如,「TWI SDA」與「TWI SCL」訊號可用於 Two-Wire Interface 通訊。
使用功能#
設定 Line Connection#
若要設定 Line Connection:
- 將相機中的
LineSelector參數設為所需的 GPIO line. - 將相機中的
BslLineConnection參數設定為以下值之一:ConnectionOff:未為目前所選線路設定連線訊號。TwiSda:已為目前所選線路設定 TWI SDA 訊號。TwiScl:已為目前所選線路設定 TWI SCL 訊號。LightControl:已為目前所選線路設定 Light Control 訊號。
- 請確保
LineMode參數設為InOut。這可讓您將 GPIO 線路用作輸入輸出線路。如果參數未自動設定為InOut,請手動進行設定。
判斷 Line Connection#
若要判定 Line Connection:
- 將相機中的
LineSelector參數至所需的 I/O 線路。 - 取得
BslLineConnection參數可用以判定 I/O 線路的目前 Line Connection。
範例程式碼#
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 來輕鬆設定參數。