Ventura IPC - CAN-API / CANopen-API Instruction Manual - Kuhnke
Ventura IPC - CAN-API / CANopen-API Instruction Manual - Kuhnke
Ventura IPC - CAN-API / CANopen-API Instruction Manual - Kuhnke
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Kuhnke</strong> Electronics<br />
<strong>Instruction</strong> Booklet<br />
<strong>Ventura</strong> <strong>CAN</strong>-<strong>API</strong> / <strong>CAN</strong>open-<strong>API</strong><br />
for Windows XP embedded<br />
E 674-2 GB 3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
This instruction booklet is primarily intended for use by design, project, and delvelopment engineers. It does not contain any delivery<br />
information. Data is only given to describe a task solution and must not be regarded as guaranteed properties in the legal sense. Any<br />
claims for damages - on whatever legal grounds - are excluded except for instances of deliberate intent or gross negligence on our part.<br />
We reserve the rights for errors, omissions and modifications.<br />
Reproduction even of extracts only with the editor's express and written prior consent.<br />
E 674-2 GB 2<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
Table of Contents<br />
1 Introduction......................................................................................................................................................5<br />
2 General............................................................................................................................................................5<br />
3 Example: Using <strong>CAN</strong>-<strong>API</strong> with Delphi .............................................................................................................6<br />
3.1 Implementing <strong>CAN</strong>-<strong>API</strong>........................................................................................................................6<br />
3.2 Example Program "CanApiSmall"........................................................................................................6<br />
3.2.1 Open <strong>CAN</strong>open Interface...................................................................................................................7<br />
3.2.2 Set up Slave .......................................................................................................................................7<br />
3.2.3 Configure Slave..................................................................................................................................7<br />
4 <strong>Ventura</strong> <strong>CAN</strong>api.DLL.......................................................................................................................................8<br />
4.1.1 Open the <strong>CAN</strong> Interface.....................................................................................................................8<br />
4.1.2 Close <strong>CAN</strong> Interface ..........................................................................................................................8<br />
4.1.3 Attach Event Handle ..........................................................................................................................9<br />
4.1.4 <strong>CAN</strong>api State....................................................................................................................................10<br />
4.1.5 Reset Error .......................................................................................................................................10<br />
4.1.6 Write <strong>CAN</strong> Frame.............................................................................................................................11<br />
4.1.7 Read <strong>CAN</strong> Frame.............................................................................................................................12<br />
4.1.8 Set Filter for <strong>CAN</strong> Controller ............................................................................................................13<br />
4.2 <strong>Ventura</strong><strong>CAN</strong>open.DLL .......................................................................................................................14<br />
4.3 Set New Timeout (SDO) ....................................................................................................................14<br />
4.3.1 Upload Value to Station (SDO) ........................................................................................................14<br />
4.3.2 Get Value from Station's Object Dictionary (SDO) ..........................................................................15<br />
4.3.3 Change Station State to Operational (NMT) ....................................................................................15<br />
4.3.4 Change Station State to PreOperational (NMT) ..............................................................................16<br />
4.3.5 Change Station State to Stop (NMT) ...............................................................................................16<br />
4.3.6 Reset Station (NMT) ........................................................................................................................17<br />
4.3.7 Reset Communication of Station (NMT) ..........................................................................................17<br />
4.3.8 Sync Function (SYNC) .....................................................................................................................18<br />
4.3.9 Heartbeat Function...........................................................................................................................19<br />
4.3.10 Enable Heartbeat Monitor of <strong>CAN</strong> Station .....................................................................................19<br />
4.3.11 Set up SLAVE ................................................................................................................................20<br />
4.3.12 Delete Slave ...................................................................................................................................20<br />
4.3.13 Event Handles for Changes in Slave .............................................................................................20<br />
4.3.14 Check Events .................................................................................................................................21<br />
4.3.15 Upload PDO Data to <strong>CAN</strong>open Station .........................................................................................22<br />
4.3.16 Download PDO Data from <strong>CAN</strong>open Station.................................................................................22<br />
4.3.17 Download Emergency Data from <strong>CAN</strong>open Station ......................................................................23<br />
4.3.18 Have <strong>CAN</strong> Slave Send Heartbeat..................................................................................................23<br />
4.3.19 Monitor State Machine ...................................................................................................................24<br />
4.3.20 Get Number of Bootup Messages..................................................................................................24<br />
4.4 List of <strong>CAN</strong>open Errors ......................................................................................................................25<br />
5 Appendix........................................................................................................................................................26<br />
5.1 References.........................................................................................................................................26<br />
5.2 Sales & Service..................................................................................................................................27<br />
5.2.1 Main Factory in Malente...................................................................................................................27<br />
5.2.2 Sales Germany.................................................................................................................................27<br />
5.2.3 Customer Service.............................................................................................................................27<br />
E 674-2 GB 3<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
E 674-2 GB 4<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
1 Introduction<br />
2 General<br />
<strong>Ventura</strong>'s <strong>CAN</strong>-<strong>API</strong> is a programming interface for the Windows XP embedded<br />
and Windows CE operating systems allowing programmers to deploy a<br />
high-level language to gain direct access to <strong>Ventura</strong>'s <strong>CAN</strong> port. <strong>Ventura</strong>'s<br />
<strong>CAN</strong>-<strong>API</strong> (application programming interface) consists of a set of DLLs that<br />
the high-level language can run according to the current task.<br />
<strong>Ventura</strong><strong>CAN</strong>api.DLL is started by an application to directly process data<br />
delivered by any of the field bus components. It provides access to <strong>CAN</strong> bus<br />
layer 2 which controls <strong>CAN</strong> controller initialisation and the upload / download<br />
of <strong>CAN</strong> frames.<br />
<strong>Ventura</strong><strong>CAN</strong>open.DLL starts where <strong>Ventura</strong><strong>CAN</strong>api.DLL ends. To make<br />
things easier, <strong>Ventura</strong><strong>CAN</strong>open DLL contains all functions of <strong>Ventura</strong>-<br />
<strong>CAN</strong>api.<br />
The <strong>CAN</strong>open DLL opens users the gate towards the set of <strong>CAN</strong>open services.<br />
The registers of the <strong>CAN</strong> controller are stored in <strong>Ventura</strong>'s physical address<br />
space. Any interrupts generated are output to IRQ channel 11 which, obviously,<br />
needs to be reserved for access by this module.<br />
The BUS LED located on <strong>Ventura</strong>'s front panel is directly actuated by the<br />
<strong>CAN</strong> controller to indicate the current state of the interface.<br />
In systems platformed on Windows XP, interrupts may demand several milliseconds<br />
of latency. It is therefore best practice to leave an average 10ms<br />
between frames received.<br />
Windows XP embedded is not real-time-ready. There is not warranted time<br />
within which an interrupt routine would be started following the IRQ request.<br />
Please take this fact into account when developing and running your application.<br />
E 674-2 GB 5<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
3 Example: Using <strong>CAN</strong>-<strong>API</strong> with Delphi<br />
3.1 Implementing <strong>CAN</strong>-<strong>API</strong><br />
3.2 Example Program "CanApiSmall"<br />
Delphi applications are able to run <strong>CAN</strong>-<strong>API</strong> functions. This requires that developers<br />
have the <strong>CAN</strong>-<strong>API</strong> functions available as a unit.<br />
Delphi unit: '<strong>Ventura</strong>CanOpenDLL.pas'<br />
Be sure to add the unit to the project because failure to do so will disallow its<br />
use in the program or its being linked to an application later.<br />
• Run Delphi, pick 'Project', 'Add to project' from the menu, and select<br />
unit '<strong>Ventura</strong>CanOpenDLL.pas'.<br />
• Then go to the "uses" clause and add the unit name, i.e. "<strong>Ventura</strong>-<br />
CanOpenDLL".<br />
Your user program will now have full access to the <strong>CAN</strong> functions.<br />
The functions are described in chapter 4 "<strong>Ventura</strong> <strong>CAN</strong>api.DLL".<br />
"CanApiSmall" showcases a program including all functions required to properly<br />
interface a <strong>CAN</strong>open station with <strong>Ventura</strong> and the user program. This<br />
section describes the function you need.<br />
The hardware configuration is made up a <strong>Ventura</strong> on a Windows XP embedded<br />
platform and a <strong>CAN</strong>open station, i.e. <strong>Ventura</strong> Remote I/O<br />
16DI/16DO.<br />
E 674-2 GB 6<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
3.2.1 Open <strong>CAN</strong>open Interface<br />
Button 1, 'Open <strong>API</strong>', runs function 'VcoOpen'.<br />
It opens the <strong>CAN</strong>open interface at the set baud rate (500 kbps in our example).<br />
The value returned is shown as Label 1 immediately next to button 1,<br />
'Open <strong>API</strong>'. It should be 0 if opening was successful.<br />
3.2.2 Set up Slave<br />
3.2.3 Configure Slave<br />
The next step is to click on button 3 to run function 'SlaveCreate' which sets<br />
sup <strong>Ventura</strong> for communication with the <strong>CAN</strong>open station. In our example,<br />
the station has address 2 which is added to the function as a parameter.<br />
If the function returns 0 the setup is ok.<br />
Baud rate<br />
Address<br />
Now click on button 9, 'SDO Send', to transfer the configuration data to the<br />
station. You only need to take this step if the station is actually configurable.<br />
In our example, a <strong>Ventura</strong> Remote I/O will have address 2 under which it<br />
networks with <strong>Ventura</strong>. To run as intended, <strong>Ventura</strong> I/O needs to know at least<br />
the number of inputs and outputs provided by the basic module.<br />
Enter the values (2 for 16 inputs/16 outputs) into the object dictionary, index<br />
2000, sub-index 1 and 2.<br />
For further information about the object dictionary of <strong>Ventura</strong> Remote I/O<br />
refer to instruction manual E 698.<br />
address index sub-index length of object<br />
data array<br />
E 674-2 GB 7<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4 <strong>Ventura</strong> <strong>CAN</strong>api.DLL<br />
This DLL gives you access to <strong>CAN</strong> bus layer 2 which initialises the <strong>CAN</strong> controller<br />
and controls the upload / download of <strong>CAN</strong> frames.<br />
4.1.1 Open the <strong>CAN</strong> Interface<br />
int VcaOpen(WORD baud rate)<br />
4.1.2 Close <strong>CAN</strong> Interface<br />
DLL name: _VcaOpen@4<br />
Opens the <strong>CAN</strong> interface at the set baud rate.<br />
Input parameters:<br />
Parameter Function<br />
Baud rate<br />
Communication data interchange baud rate<br />
Value Transfer rate<br />
0x2F67 10 kbps<br />
0x2F53 20 kbps<br />
0x2F47 50 kbps<br />
0x2F43 100 kbps<br />
0x1C03 125 kbps<br />
0x1C01 250 kbps<br />
0x1C00 500 kbps<br />
0x1400 1000 kbps<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
Interface successfully opened.<br />
1 VCA_HW32 DRIVER_OPEN_ERROR<br />
Failure connecting with the hardware driver.<br />
2 VCA_BUSY_ERROR<br />
VcaOpen run previously.<br />
100 SJA1000_OPEN_ERROR<br />
<strong>CAN</strong> controller used by another application.<br />
int VcaClose(void)<br />
DLL name: _VcaClose@0<br />
Closes the <strong>CAN</strong> interface<br />
Input parameters: -<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
Interface successfully closed.<br />
3 VCA_NOT_OPEN_ERROR<br />
Nothing to close because interface was not open.<br />
E 674-2 GB 8<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.1.3 Attach Event Handle<br />
int VcaRegisterEvent(HANDLE CanEvent)<br />
DLL name: _VcaRegisterEvent@4<br />
Attaches an event handle to the DLL to be notified of receive events.<br />
Input parameters:<br />
Parameter Function<br />
CanEvent Handle of an object opened by CreateEvent.<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
Event registered successfully.<br />
3 VCA_NOT_OPEN_ERROR<br />
Nothing to close because interface was not open.<br />
E 674-2 GB 9<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.1.4 <strong>CAN</strong>api State<br />
4.1.5 Reset Error<br />
int VcaGetState(void)<br />
DLL name: _VcaGetState@0<br />
Returns the state of <strong>CAN</strong>api.<br />
Input parameters: -<br />
Output parameters: -<br />
Values returned:<br />
<strong>CAN</strong>api state The state is bit-coded.<br />
Bit Function<br />
0 0: <strong>CAN</strong> not active<br />
1: <strong>CAN</strong> active<br />
1 0: Data-out memory OK<br />
1: Data-out memory overflow, older outgoing data is lost. The<br />
application was too quick with uploading data to the DLL.<br />
2 0: Data-in memory OK<br />
1: Data-in memory overflow, older data is lost. The application<br />
failed to get data often enough.<br />
3 0: Data-in buffer of <strong>CAN</strong> controller OK<br />
1: Overflow of data-in buffer of <strong>CAN</strong> controller. Data is lost. Incoming<br />
<strong>CAN</strong> frames should leave an average 10ms delay between<br />
two frames (set filter or assign Inhibit timer to other stations).<br />
4 0: <strong>CAN</strong> controller alive on the bus<br />
1: <strong>CAN</strong> controller turned "Bus off". There were too many errors<br />
forcing the <strong>CAN</strong> controller to turn off. Close and reopen the interface.<br />
5 0: <strong>CAN</strong> controller OK<br />
1: <strong>CAN</strong> controller output a "warning". There were many bus errors,<br />
or the controller fails to find an addressee for its frame.<br />
The controller will quit that state when enough frames are correctly<br />
sent or received.<br />
6..15 not used<br />
Int VcaResetOverflow(void)<br />
DLL name: _VcaResetOverflow@0<br />
Resets errors "data-out memory overflow", "data-in memory overflow" and<br />
"<strong>CAN</strong> controller data-in buffer overflow".<br />
Input parameters: -<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
All errors correctly reset.<br />
3 VCA_NOT_OPEN_ERROR<br />
Nothing to close because interface was not open.<br />
E 674-2 GB 10<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.1.6 Write <strong>CAN</strong> Frame<br />
int VcaWrite(<strong>CAN</strong>_MSG *pMsg)<br />
DLL name: _VcaWrite@4<br />
Writes a <strong>CAN</strong> frame and puts it on data-out memory. The frame will be uploaded<br />
as quickly as possible.<br />
Input parameters:<br />
Parameter Function<br />
*pMsg<br />
Address of buffer for the frame to be uploaded.<br />
The buffer to contain the frame must comply with<br />
the following structure:<br />
Type Content<br />
double word ID<br />
(4 byte)<br />
byte mode (extended frame bit 7 = 1,<br />
remote frame bit 6 = 1)<br />
byte number of data bytes used<br />
byte data byte 1<br />
byte data byte 2<br />
byte data byte 3<br />
byte data byte 4<br />
byte data byte 5<br />
byte data byte 6<br />
byte data byte 7<br />
byte data byte 8<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
Frame uploaded.<br />
3 VCA_NOT_OPEN_ERROR<br />
Nothing to close because interface was not open.<br />
5 VCA_WRITE_QUEUE_OVERFLOW<br />
Upload memory overflow.<br />
E 674-2 GB 11<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.1.7 Read <strong>CAN</strong> Frame<br />
int VcaRead(<strong>CAN</strong>_MSG *pMsg)<br />
DLL name: _VcaRead@4<br />
Gets a <strong>CAN</strong> frame from the data-in memory.<br />
Input parameters: -<br />
Output parameters:<br />
Parameter Function<br />
*pMsg<br />
Address of buffer for the frame to be read.<br />
The buffer to contain the frame must comply with<br />
the following structure:<br />
Type Content<br />
double word ID<br />
(4 byte)<br />
byte mode (extended frame bit 7 = 1,<br />
remote frame bit 6 = 1)<br />
byte number of data bytes used<br />
byte data byte 1<br />
byte data byte 2<br />
byte data byte 3<br />
byte data byte 4<br />
byte data byte 5<br />
byte data byte 6<br />
byte data byte 7<br />
byte data byte 8<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
Frame read.<br />
3 VCA_NOT_OPEN_ERROR<br />
Nothing to close because interface was not open.<br />
5 VCA_NO_MSG<br />
No frame received yet.<br />
E 674-2 GB 12<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.1.8 Set Filter for <strong>CAN</strong> Controller<br />
int VcaSetFilter(WORD DontCareMask1, WORD Code1,WORD<br />
DontCareMask2, WORD Code2)<br />
DLL name: _VcaSetFilter@16<br />
Prepares or sets filters for the <strong>CAN</strong> controller. Try running this function before<br />
using VcaOpen because it will prepare the filters that VcaOpen will actually<br />
set.<br />
In case the interface is open already, it will be briefly closed to set the filters.<br />
An OR operation links the two filters.<br />
Filtered frames will be ignored by the controller, i.e. they will not provoke an<br />
interrupt.<br />
Input parameters:<br />
Parameter Function<br />
DontCareMask1 Bits set =1 will not be used for filtering.<br />
Code1 Specify the bit masks to be referenced for matching.<br />
The function will only match bits set =0 in the mask.<br />
DontCareMask2 same as mask 1<br />
Code2 same as code1<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 VCA_OK<br />
Filter set.<br />
E 674-2 GB 13<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.2 <strong>Ventura</strong><strong>CAN</strong>open.DLL<br />
This DLL starts where <strong>Ventura</strong><strong>CAN</strong>api.DLL ends. To make things easier,<br />
<strong>Ventura</strong><strong>CAN</strong>open DLL contains all functions of <strong>Ventura</strong><strong>CAN</strong>api. To distinguish<br />
between the two, <strong>CAN</strong>open functions begin with Vco instead of Vca.<br />
The <strong>CAN</strong>open DLL opens users the gate towards the set of <strong>CAN</strong>open services.<br />
4.3 Set New Timeout (SDO)<br />
4.3.1 Upload Value to Station (SDO)<br />
Int SdoSetTimeout(WORD Timeout)<br />
DLL name: _SdoSetTimeout@4<br />
Sets a new maximum time out for the WriteObject and ReadObject services.<br />
Default is 100 ms (SDO function).<br />
Input parameters:<br />
Parameter Function<br />
Timeout Maximum timeout in milliseconds<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
int SdoWriteObject(BYTE Address, WORD Index, BYTE SubIndex,<br />
BYTE Length, BYTE *pData)<br />
DLL name: _SdoWriteObject@20<br />
Adds a value to the object dictionary of a <strong>CAN</strong>open station alive on the <strong>CAN</strong><br />
bus (SDO function).<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127)<br />
Index Index labelling the object in the object dictionary<br />
SubIndex Sub-index labelling the object in the object dictionary<br />
Length Length of object in byte (1..4)<br />
pData Pointer to the buffer containing the data (length buffer<br />
size).<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 14<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.2 Get Value from Station's Object Dictionary (SDO)<br />
int SdoReadObject(BYTE Address, WORD Index, BYTE SubIndex,<br />
BYTE *pLength, BYTE *pData)<br />
DLL name: _SdoReadObject@20<br />
Reads a value contained in the object dictionary of a <strong>CAN</strong>open station alive<br />
on the <strong>CAN</strong> bus (SDO function).<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127)<br />
Index Index labelling the object in the object dictionary<br />
SubIndex Sub-index labelling the object in the object dictionary<br />
Output parameters:<br />
Parameter Function<br />
Length Length of object in byte (1..4)<br />
pData Pointer to data buffer (size=4 byte)<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.3 Change Station State to Operational (NMT)<br />
int NmtOperational(BYTE Address)<br />
DLL name: _NmtOperational@4<br />
Changes the state of one or all alive <strong>CAN</strong> bus stations to Operational (NMT<br />
function).<br />
In this state, the station affected is fully operational and can take the initiative<br />
to transfer frames (PDOs, emergency).<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127, 0 for all stations)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 15<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.4 Change Station State to PreOperational (NMT)<br />
int NmtPreOperational(BYTE Address)<br />
DLL name: _NmtPreOperational@4<br />
Changes the state of one or all alive <strong>CAN</strong> bus stations to PreOperational<br />
(NMT function).<br />
Stations in that state can be communicated with using SDOs. The node will<br />
not sustain PDO communication and neither will it transmit any emergency<br />
messages.<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127, 0 for all stations)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.5 Change Station State to Stop (NMT)<br />
int NmtStop(BYTE Address)<br />
Changes the state of one or all alive <strong>CAN</strong> bus stations to Stop (NMT function).<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127, 0 for all stations)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 16<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.6 Reset Station (NMT)<br />
int NmtResetNode(BYTE Address)<br />
DLL name: _NmtResetNode@4<br />
Resets one or all alive <strong>CAN</strong> bus stations (NMT function).<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127, 0 for all stations)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.7 Reset Communication of Station (NMT)<br />
int NmtResetCommunication(BYTE Address)<br />
DLL name: _NmtResetCommunication@4<br />
Resets the communication of one or all alive <strong>CAN</strong> bus stations (NMT function).<br />
Input parameters:<br />
Parameter Function<br />
Address <strong>CAN</strong>open station address (1..127, 0 for all stations)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 17<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.8 Sync Function (SYNC)<br />
int SyncEnable (WORD Time, DWORD Id)<br />
DLL name: _SyncEnable@8<br />
Enables cyclic transfer of the Sync frame (Sync function).<br />
Input parameters:<br />
Parameter Function<br />
Time Cycle time in milliseconds (min 10ms, 0 off)<br />
Id Frame identifier (entering 0 will default the system to<br />
Sync identifier 0x80)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 18<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.9 Heartbeat Function<br />
int HeartbeatEnableOwn (WORD Time, BYTE Address)<br />
DLL name: _HeartbeatEnableOwn@8<br />
Enables cyclic transfer of the station's own heartbeat frame (Heartbeat function).<br />
Input parameters:<br />
Parameter Function<br />
Time Cycle time in milliseconds (min 10ms, 0 off)<br />
Address Own address, must be unique among all bus stations<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.10 Enable Heartbeat Monitor of <strong>CAN</strong> Station<br />
int HeartbeatSetSlaveConsumerHeartbeat(BYTE Address,<br />
BYTE Factor)<br />
DLL name: _HeartbeatSetSlaveConsumerHeartbeat@8<br />
Enables the heartbeat monitor of a <strong>CAN</strong>open unit to control its own heartbeat.<br />
Requires the own heartbeat to be active (Heartbeat function).<br />
Input parameters:<br />
Parameter Function<br />
Address Address of the <strong>CAN</strong>open unit whose heartbeat monitor<br />
is to be enabled, e.g. controller/PC.<br />
Factor After Factor * Heartbeat Time (set by HeartbeatEnableOwn),<br />
the unit is to change its state to<br />
Error if it has not received a heartbeat signal. To<br />
properly enable the function, the minimum factor is 2.<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 19<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.11 Set up SLAVE<br />
4.3.12 Delete Slave<br />
int SlaveCreate (BYTE Address)<br />
DLL name: _SlaveCreate@4<br />
The slave is the destination of messages sent by a "real" <strong>CAN</strong>open unit attached<br />
to the bus.<br />
Mind that the slave needs to be configured according to the rules of the<br />
"Predefined Connection Set".<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
int SlaveDelete(BYTE Address)<br />
DLL name: _SlaveDelete@4<br />
Deletes a previously set-up slave from the list of slaves.<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.13 Event Handles for Changes in Slave<br />
int SlaveRegisterEvent(BYTE Address , HANDLE<br />
*pSlaveEvent)<br />
DLL name: _SlaveRegisterEvent@8<br />
Attaches an event handle to the DLL to be notified of changes occurring in<br />
the slave. The following events count as triggers:<br />
PDO received<br />
Emergency message received<br />
Bootup message received<br />
Heartbeat timeout<br />
Change of heartbeat state<br />
E 674-2 GB 20<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.14 Check Events<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
pSlaveEvent Pointer to the handle of an object previously opened<br />
using CreateEvent<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
int SlaveGetState(BYTE Address)<br />
DLL name: _SlaveGetState@4<br />
Function allows the program to check which events have occurred since the<br />
previous check.<br />
Every check clears the list of previous events.<br />
Possible events are listed below as "values returned".<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
pSlaveEvent Pointer to the handle of an object previously opened<br />
using CreateEvent<br />
Output parameters: -<br />
Values returned:<br />
Status of event is bit-coded<br />
Bit Function<br />
0 PDO 1 received<br />
1 PDO 2 received<br />
2 PDO 3 received<br />
3 PDO 4 received<br />
4 Emergency message received<br />
5 Bootup message received<br />
6 Heartbeat timeout<br />
7 Change of heartbeat state<br />
8 PDO read queue overflow<br />
9 Emergency receive buffer overflow<br />
10 Station set up<br />
E 674-2 GB 21<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.15 Upload PDO Data to <strong>CAN</strong>open Station<br />
int SlaveWritePdoData(BYTE Address, BYTE PdoNo, BYTE<br />
Length, BYTE *pData)<br />
DLL name: _SlaveWritePdoData@16<br />
Uploads PDO data to a <strong>CAN</strong>open station configured compliant to the "Predifined<br />
Connection Set".<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
PdoNo Number of Receive PDO (0..3)<br />
Length Number of data in byte (1..8)<br />
pData Pointer to the buffer containing the data<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.16 Download PDO Data from <strong>CAN</strong>open Station<br />
int SlaveReadPdoData(BYTE Address, BYTE PdoNo, BYTE<br />
*pLength, BYTE *pData)<br />
DLL name: _SlaveReadPdoData@16<br />
Downloads the PDO data contained in the buffer of a <strong>CAN</strong>open station set<br />
up using SlaveCreate. Configuration of station to conform to the "Predifined<br />
Connection Set".<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
PdoNo Number of Receive PDO (0..3)<br />
Output parameters:<br />
Parameter Function<br />
pLength Pointer to number of data in byte (1..8)<br />
pData Pointer to the buffer containing the uploaded data (8<br />
byte).<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 22<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.17 Download Emergency Data from <strong>CAN</strong>open Station<br />
int SlaveReadEmergency(BYTE Address, BYTE *pEmyData)<br />
DLL name: _SlaveReadEmergency@8<br />
Downloads the Emergency data contained in the buffer of a <strong>CAN</strong>open station<br />
set up using SlaveCreate.<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
Output parameters:<br />
Parameter Function<br />
pEmyData Pointer to the buffer containing the uploaded emergency<br />
data (8 byte).<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
4.3.18 Have <strong>CAN</strong> Slave Send Heartbeat<br />
int SlaveEnableHeartbeat(BYTE Address, WORD Time, BYTE<br />
Factor)<br />
DLL name: _SlaveEnableHeartbeat@12<br />
Makes a <strong>CAN</strong>open station send its heartbeat. The station must have been<br />
set up using SlaveCreate. The heartbeat sent is monitored afterwards. Use<br />
GetHeartbeatState to know the state of monitoring.<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
Time <strong>CAN</strong>open station's producer heartbeat time in milliseconds<br />
(min 10ms, 0 off)<br />
Factor Monitoring time: Factor * Time (min 2)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 No error<br />
> 0 � Error code, see list of errors<br />
E 674-2 GB 23<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.3.19 Monitor State Machine<br />
int SlaveGetHeartbeatState(BYTE Address)<br />
DLL name: _SlaveGetHeartbeatState@4<br />
Use this function to check the state of stations monitored by SlaveEnable-<br />
Heartbeat. The state refers to the <strong>CAN</strong>open state machine.<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 Heartbeat not enabled<br />
127 Preoperational<br />
4 Stop (prepared and ready)<br />
5 Operational<br />
4.3.20 Get Number of Bootup Messages<br />
int SlaveGetBootupCount(BYTE Address)<br />
DLL name: _SlaveGetBootupCount@4<br />
Counts the number of Bootup messages received since the last check from<br />
a <strong>CAN</strong>open station set up using SlaveCreate.<br />
Input parameters:<br />
Parameter Function<br />
Address Address of <strong>CAN</strong>open unit (set up by SlaveCreate)<br />
Output parameters: -<br />
Values returned:<br />
Value Function<br />
0 …n Count of Bootup frames received since the last check.<br />
E 674-2 GB 24<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
4.4 List of <strong>CAN</strong>open Errors<br />
Value Error<br />
0 VCO_ERROR_OK<br />
100 VCO_ERROR_PARAMETER_RANGE<br />
101 VCO_ERROR_SDO_TIMEOUT<br />
102 VCO_ERROR_SDO<br />
103 VCO_ERROR_SLAVE_IS_CREATED<br />
104 VCO_ERROR_NO_SLAVE_CREATED<br />
105 VCO_ERROR_PDO_WRITE_BUFFER_OVERFLOW<br />
106 VCO_ERROR_BUFFER_EMPTY<br />
107 VCO_ERROR_HEARTBEAT_TIMEOUT<br />
108 VCO_ERROR_HEARTBEAT_STATE_CHANGE<br />
109 VCO_ERROR_NOT_ACTIVE<br />
110 VCO_ERROR_HEARTBEAT_NOT_ACTIVE<br />
111 VCO_ERROR_OUT_OF_MEMORY<br />
E 674-2 GB 25<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
5 Appendix<br />
5.1 References<br />
Title / Subject Number Source<br />
<strong>CAN</strong>open<br />
Basics and Configuration<br />
<strong>Ventura</strong> <strong>IPC</strong> 300 / 700<br />
PC-based Controller<br />
<strong>Ventura</strong> Remote I/O<br />
Remote I/Os for <strong>CAN</strong>open and<br />
PROFIBUS-DP<br />
E 615 GB <strong>Kuhnke</strong> GmbH<br />
E 674 GB <strong>Kuhnke</strong> GmbH<br />
E 698 GB <strong>Kuhnke</strong> GmbH<br />
E 674-2 GB 26<br />
3 Jan 2006
KUHNKE Automation <strong>Ventura</strong> <strong>CAN</strong> <strong>API</strong><br />
5.2 Sales & Service<br />
5.2.1 Main Factory in Malente<br />
5.2.2 Sales Germany<br />
5.2.3 Customer Service<br />
Please visit our Internet site to find a comprehensive overview of our sales<br />
and service network including all the relevant addresses. You are, of course,<br />
always welcome to contact our staff at the main factory in Malente or at<br />
sales headquarters in Neuhausen:<br />
<strong>Kuhnke</strong> Automation GmbH & Co. KG<br />
Lütjenburger Straße 101<br />
D-23714 Malente<br />
Phone +49 (0)4523 402-0<br />
Fax +49 (0)4523 402-247<br />
Email sales@kuhnke.de<br />
Internet www.kuhnke.de<br />
<strong>Kuhnke</strong> Automation GmbH & Co. KG<br />
Stuttgart Branch Office<br />
Strohgäustraße 3<br />
D-73765 Neuhausen<br />
Phone +49 (0)7158 9074-0<br />
Fax +49 (0)7158 9074-80<br />
Email sales@kuhnke.de<br />
Internet www.kuhnke.de<br />
<strong>Kuhnke</strong> Automation GmbH & Co. KG<br />
Lütjenburger Str. 101<br />
D-23714 Malente<br />
Phone +49 (0)4523 402-200<br />
Fax +49 (0)4523 402-201<br />
Email service@kuhnke.de<br />
Internet www.kuhnke.com<br />
E 674-2 GB 27<br />
3 Jan 2006