X64-CL iPro Series User's Manual

Add to My manuals
137 Pages

advertisement

X64-CL iPro Series User's Manual | Manualzz

X-I/O Module Sapera Interface

Sapera version 5.30 (or later) provides support for the X-I/O module via an I/O class and demonstration program. Users can use the demonstration program as is, or use the demo program source code to implement X-I/O controls within the custom imaging application.

This section describes configuring the X-I/O module power up state, using the X-I/O demo program, and describes the Sapera Class to program and read the X-I/O module along with sample code.

Configuring User Defined Power-up I/O States

The X-I/O module power up state is stored onboard in flash memory. User configuration of this initial state is performed by the Device Manager program. Run the program via the windows start menu: (Start

• Programs • DALSA • X64-CL iPro Device Driver • Device Manager).

The Device Manager provides information on the installed X64-CL iPro board and its firmware. With an

X-I/O module installed, click on XIO Board – Information, as shown in the following figure.

116 Appendix: X-I/O Module Option

X64-CL iPro Series User's Manual

The XIO information screen shows the current status of Device 0—the output device, and Device 1—the input device. A few items are user configurable for X-I/O board power up state. Click on the item to display a drop list of available capabilities, as described below.

Device 0 – Default Output Type choose Tristate mode (i.e. output disconnected), or PNP mode, or NPN mode.

Device 0 – Default Output Pin State

A window is displayed to select a logic low or high state for each output pin. Click on each pin that should be logic high by default.

Device 1 – Default Input Level

Select the input logic level as TTL 5 Volts or 24 Volts, dependent on the signal type being input to the X-I/O module.

Device 1 – Default Connector

DB37 is the supported output connector, as described in this section.

Programming the User Configuration

After changing any user configurable X-I/O mode from the factory default state, click on the Program button (located on the upper left), to write the new default state to flash memory. The Device Manager message output window will display "Successfully updated EEProm". The program can now be closed.

Using Sapera LT General I/O Demo

The Sapera General I/O demo program controls the I/O capabilities of the X-I/O module on the Sapera board product. The demo will present to the user only the controls pertaining to the selected hardware (in the case of multiple installed boards).

Run the demo via the windows start menu: (Start • Programs • DALSA • Sapera LT • Demos •

General I/O Demo). The first menu presents a drop list of all installed Sapera Acquisition Devices with

I/O capabilities. In the following figure the X64-CL iPro board is selected. Click OK to continue.

X64-CL iPro Series User's Manual

Appendix: X-I/O Module Option 117

General I/O Module Control Panel

The I/O module control demo presents the I/O capabilities of the installed hardware. The following figure shows the X-I/O module connected to the X64-CL iPro board.

Output Pins: The first column displays the current state of the eight output pins (I/O Device #0).

• The startup default state is user configured using the Device Manager program.

• The state of each output can be changed by clicking on its status button.

• Use the Signal Output drop menu to select the output mode (Tristate, PNP, NPN).

Input Pins: The second section provides input pin status (I/O device #1). Note that this program is a

demo, therefore no action takes place on an input event.

• The first column reads the logic level present on each input. The Input Level drop menu changes the logic level from 5V TTL to 24V logic. Use the Device Manager program to select the default logic level type.

• The second column demonstrates activating interrupts on individual inputs. In this demo program, use the Enable box to activate the interrupt on an input. The Count box will tally detected input events. Use the Signal Event drop menu to select which input signal edge to detect. The Reset button clears all event counts.

118 Appendix: X-I/O Module Option

X64-CL iPro Series User's Manual

X64-CL iPro Series User's Manual

Appendix: X-I/O Module Option 119

Sapera LT General I/O Demo Code Samples

The following source code was extracted from the General I/O demo program. The comments highlight the areas that an application developer needs for embedding X-I/O module controls within the imaging application.

Main I/O Demo code

BOOL CGioMainDlg::OnInitDialog()

{

[ . . . ]

// some declarations

UINT32 m_gioCount; int m_ServerIndex; int m_ResourceIndex;

// Show the Server Dialog to select the acquisition device

CGioServer dlg(this); if (dlg.DoModal() == IDOK)

{ m_ServerIndex = dlg.GetServerIndex(); m_ServerName = dlg.GetServerName(); if ( m_ServerIndex != -1)

{

// Get the number of resources from SapManager for ResourceGio type by using

// - the server index chosen in the dialog box

// - the resource type to enquire for Gio

m_gioCount=SapManager::GetResourceCount(m_ServerIndex,SapManager::ResourceGio);

// Create all objects [see the function following] if (!CreateObjects()) { EndDialog(TRUE); return FALSE; }

[ . . . ]

//Loop for all resources for (UINT32 iDevice = 0; (iDevice < MAX_GIO_DEVICE) && (iDevice < m_gioCount);

iDevice++)

{

[ . . . ]

// direct read access to low-level Sapera C library capability to check

// I/O Output module

(m_pGio[iDevice]->IsCapabilityValid(CORGIO_CAP_DIR_OUTPUT))

status

// direct read access to low-level Sapera C library capability to

// check I/O Input module

(m_pGio[iDevice]->IsCapabilityValid(CORGIO_CAP_DIR_INPUT))

120 Appendix: X-I/O Module Option

X64-CL iPro Series User's Manual

status

[ . . . ]

// Constructor used for I/O Output module dialog.

if

{ m_pDlgOutput[iDevice] = new CGioOutputDlg(this, iDevice, m_pGio[iDevice]);

}

[ . . . ]

// Constructor used for I/O Input module dialog. if (capInput)

{ m_pDlgInput[iDevice] = new CGioInputDlg(this, iDevice, m_pGio[iDevice]);

}

} //end for

} // end if

[ . . . ]

}

Function CreateObjects()

BOOL CreateObjects()

{

CWaitCursor wait;

// Loop for all I/O resources for (UINT32 iDevice = 0; (iDevice < MAX_GIO_DEVICE) && (iDevice < m_gioCount);

iDevice++)

{

// The SapLocation object specifying the server where the I/O resource is located

SapLocation location(m_ServerIndex, iDevice);

// The SapGio constructor is called for each resource found. m_pGio[iDevice] = new SapGio(location);

// Creates all the low-level Sapera resources needed by the I/O object if (m_pGio[iDevice] && !*m_pGio[iDevice] && !m_pGio[iDevice]->Create())

{

DestroyObjects();

FALSE;

}

} return TRUE;

}

X64-CL iPro Series User's Manual

Appendix: X-I/O Module Option 121

Output Dialog: CGioOutputDlg class (see Sapera Gui class)

void CGioOutputDlg::UpdateIO()

{

UINT32

UINT32

BOOL status;

[ . . . ]

// We loop to get all I/O pins. for (UINT32 iIO=0; iIO < (UINT32)m_pGio->GetNumPins(); iIO++)

{

[ . . . ]

// We set the current state of the current I/O pin by using

// - the pin number on the current I/O resource

// - the pointer to pin state

// ( SapGio ::PinLow if low and SapGio ::PinHigh if high) status = m_pGio->SetPinState(iIO, (SapGio::PinState)state);

}

}

Input Dialog: CGioInputDlg class. (see Sapera Gui class)

BOOL CGioInputDlg::Update()

{

SapGio::PinState state = SapGio::PinState::PinLow;

BOOL status = true;

UINT32 jIO; iIO;

UINT32 if (m_pGio == NULL)

return

// We loop to get all I/O pins. for (iIO=0; iIO < (UINT32)m_pGio->GetNumPins(); iIO++)

{

m_pGio->SetDisplayStatusMode(SapManager::StatusLog,

// We get the current state of the current I/O pin by using

// the pin number on the current I/O resource

// the pointer to pin state

// ( SapGio ::PinLow if low and SapGio ::PinHigh if high) status = m_pGio->GetPinState(iIO, &state);

NULL);

[ . . . ]

}

[ . . . ]

}

122 Appendix: X-I/O Module Option

X64-CL iPro Series User's Manual

I/O Event Handling

void CGioInputDlg::GioCallbackInfo(SapGioCallbackInfo *pInfo)

{

CGioInputDlg* pInputDlg;

CString strEventCount;

// We get the application context associated with I/O events pInputDlg = (CGioInputDlg*)pInfo->GetContext();

// We get the current count of I/O events

strEventCount.Format("%d",

// We get the I/O pin number that generated an I/O event and apply the changes.

pInputDlg->m_GioEventCount[pInfo->GetPinNumber()]++;

}

X64-CL iPro Series User's Manual

Appendix: X-I/O Module Option 123

124 Appendix: X-I/O Module Option

X64-CL iPro Series User's Manual

advertisement

Related manuals

Download PDF

advertisement

Table of contents