Beruflich Dokumente
Kultur Dokumente
Notes:
SICOMP® is a registered brand name of Siemens AG.
IBM AT® and IBM PC® are registered brand names of International Business Machines Corp.
INTEL® is a registered brand name of INTEL Corp.
MS-DOS®, Windows® and Windows NT® are registered brand names of Microsoft.
CANAs and PowerCAN are brand names of SiE GmbH
All other designations in this documentation may be brand names whose use by third parties for their own purposes may violate
the rights of the owners.
Passing on and duplication of this document, utilization and revelation of its contents is not permitted without express
permission. Violators will be prosecuted. All rights reserved, particularly in the event a patent is granted or a utility model is
registered.
No liability is assumed with regard to the freedom of third party rights of the circuits, descriptions and tables specified. The
information in the technical descriptions specifies products but not characteristics. The product described in this documentation
may require a license. Ask your Siemens office.
Subject to changes in availability and technology without prior notice. ES43/Ka/WW8.0/VS5.0/A4
Table of Contents
1 Product Overview 5
2 Installation 7
7 Sample Application 54
1 Product Overview
During the last few years CAN has achieved an important position in automation since almost all
automation systems have devices which must communicate with each other. But there was a problem.
Since there was no standard which could be used in controller technology, many system developers
used their own protocols.
The library which we are describing here is an implementation of the "CANopen Communication
Profile for Industrial Applications" which was defined by "CAN in Automation International Users and
Manufacturers Group (CiA e.V.)." This communication profile is based on the CAN Applications Layer
(CAL). It contains the real-time communication model and protocol which all devices in the network
have in common. Device profiles describe device-specific functions.
This description will give you a basic understanding of the characteristics of the CANopen driver. It will
also help you to get started with a CAN application for IMC05. In addition, the individual C functions
will be described in detail.
Remember that this publication cannot possibly describe all unique features and capabilities of the
CAN bus. If you need such information, see the applicable standards of "CAN in Automation e.V." or
CiA for short (e.g., "CANopen Communication Profile DS-301").
IMC05
Device 1
CANopen library
Object directory
CAN bus
User
CAN driver
software
Device 2
The application is to exchange data with other devices via the CAN bus. Similar to a mailbox, the
object directory is used as the interface. Data which were sent by other bus stations can be received
and stored for the application in defined application objects (variables) of the object directory. This
information can also be requested specifically from other network nodes.
In reverse, various user data of the object directory can be made available to the other devices. This
can be done either automatically (i.e., cyclically at certain time intervals) or on request.
The CAN driver handles the complete data communication with the CANopen protocol using the
communication parameters in the object directory. In addition, the IMC05 is the NMT master (NMT =
network management) and is thus responsible for booting, monitoring, and synchronization of the
NMT slaves.
An electronic data sheet (EDS) with all standard settings of the IMC05 is used to add the variables,
process data objects (PDOs) and service data objects (SDOs) for your application and set the
standard values to those required by your application.
CANsetter then generates a device configuration file (DCF) (i.e., a complete and configured ASCII file
from the original EDS).
The DCFcomp service program then takes the information of the NAME.DCF device configuration file
and generates two files.
· A binary file - NAME.BIN - with all information of the object directory for loading to the flash
memory of the IMC05
· A header file - NAME.H - for linking the names from the object list to your application
If some entries in the object directory have to be changed later, you only have to load the new binary
file to the IMC05 afterwards and not the complete application.
1)
For example, from Vector Informatik GmbH in Stuttgart
2 Installation
2.1 CANopen Library
The following CADUL tools are required for program development and system generation.
· Compiler: Organon CC386, starting with V611 G
· Linker: Organon LINK386, starting with V181
· Assembler: Organon AS386, starting with V278
· Debugger: Organon XDB, starting with V250 F (not absolutely necessary)
Note:
A basic knowledge of RMOS is required for system generation using this description. Siemens offers
training programs. For details, contact your Siemens office.
Installed files
During installation, a subdirectory \SYSIMC5\CAN is set up in the RMOS directory with the following
files.
In addition, an APLCAN directory is set up. It contains a sample application for CAN and CANopen.
System generation
You will need CANIMC05.LIB, OBJDICT.C and CANOPN05.H for the normal functions of CANopen. If
you only need the fundamental CAN functions, use CANIMC05.LIB and BCAN05.H.
1. Enter the following lines in the RMOS builder file RM3E_EX.BLD.
...
VGA_IOSEG
(
BASE=00900000h,
LIMIT=0ffffh
),
CANCONTR_SEG
(
BASE=00910000h,
LIMIT=07fffh
),
PERIPH_SEG
(
BASE=00920000h,
LIMIT=07fffh
),
2. Adjust the generation file (e.g., GENSYSC.BAT) to link in CANIMC05.LIB and OBJDICT.C.
CANsetter must have already been installed. For more details, see manufacturer's information.
Installed files
During installation, the following files are set up or replaced in the CANsetter installation directory
(e.g., \CANSET).
There are two ways to set the CAN driver on the development computer to the CAN card which you
are using.
· Start the CAN driver from the CANsetter program group. Select the driver for the CAN card
(CANAs or PowerCAN), and then perform the rest of the installation.
Or
· Using a text editor, open the file CANDRV.INI from the Windows directory, and enter the CAN
card (CANAs or PowerCAN) and the related input/output address in the section [SiECAN]. An
example is shown below.
[SiECAN]
CardType=PowerCAN
IOAddress=0x300
...
As the name indicates, the communication-related section contains parameters required to exchange
data with other devices.
Process data objects (PDOs) are defined which are used for communication with real-time data. A
PDO is a CAN telegram which has an identifier. This identifier and the desired type of transmission are
set here just as are the application objects which are to be sent or received as user data (max. of 8
bytes) with the PDO. This assignment is called mapping. See chapter 4.1.12.
The following table shows the types of transmission for a receiving or sending PDO.
The following figure illustrates the meaning of the transmission type and the "communication cycle
period" and "synchronous window length" parameters. The standard identifier for the synchronization
telegram (no data bytes) is 80h.
Explanation
In addition to the PDOs, service data objects (SDOs) are also provided for the communication service.
They are confirmed. This means that, when SDOs are used, a response is always expected as to
success or failure of the service. If confirmation is not received within a certain period of time, the
SDO service is also not successful. Since there is always some dead time while waiting for
acknowledgments, SDOs are much slower than PDOs. For this reason, SDOs are usually used to
configure parameters of other network stations in the state "pre-operational." For the node which
begins the SDO service, this is a client SDO. For the others, this is a so-called server SDO.
The data to be transferred are not specified by mapping and may vary. The other station is specified
by its node ID for each SDO (point-to-point connection). In addition, a sending and a receiving
identifier must be established for each client or server SDO.
The manufacturer-related portion of the object directory is used to enter information on the
configuration of the network.
This information includes the transmission speed to be used and the number and characteristics of the
other devices in the network. All nodes are entered in a list here with their node IDs. In addition, it is
specified whether the minimum or the extended bootup is to be used for them as NMT slaves when
the IMC05 starts. In extended bootup, additional parameters (e.g., for node guarding) are specified.
With either type of bootup, either the preset values for the identifiers of the device PDOs (calculated
with the node ID) must be used or the identifiers must be set by SDOs before the start of the network
in the "pre-operational" state.
The IMC05 guards every device in the node list if this was specified during the start. This means that
the IMC05 sends a request telegram at certain time intervals (guard time) to the node and this node
must respond. If not, a guard error is triggered. In reverse, if the IMC05 fails to send a request
telegram within a certain time interval (guard time x lifetime factor), the node itself switches to the
"disconnected" state.
Caution
The guard time must be greater than the communication cycle period!
The application-related section of the object directory contains the actual process variables which the
application provides to other devices via the CAN bus or vice versa.
Only those data are transported via the CAN bus which are specified in the communication
parameters of the PDOs (mapping).
The IMC05 is a programmable device. It differs from "less complex" CAN nodes (e.g., input/output
modules) in that the required CANopen application variables cannot be specified from the outset (e.g.,
in a device profile). The various applications of the IMC05 as a CANopen device may have very
different constellations. This is why the IMC05 supports dynamic {variable} objects.
In principle, the application objects in the object directory can be defined as desired starting with index
6000h. However, for clarity's sake, we recommend combining these into type sectors (entered in an
array).
The following arrays are predefined for the IMC05 (based on CiA DS405 for programmable devices).
1) 1)
Start Index Input Array Access Start Index Output Array Access
A000h Integer8 ro A480h Integer8 rww
A040h Unsigned8 ro A4C0h Unsigned8 rww
A080h Boolean ro A500h Boolean rww
A0C0h Integer16 ro A540h Integer16 rww
A100h Unsigned16 ro A580h Unsigned16 rww
A1C0h Integer32 ro A640h Integer32 rww
A200h Unsigned32 ro A680h Unsigned32 rww
A240h Float (32) ro A6C0h Float (32) rww
1) ro = Read only
rww = Read and write, only write with PDOs
256 variables can be used for each array (subindex 0 to 255). If this is not sufficient, an additional
array of this type can be set up in the next index.
Note:
To avoid wasting the resources of the IMC05 unnecessarily, define only those objects (also PDOs
and SDOs) in the object directory which you actually need.
IMC05
Boot flash
03FF FFFF RS232
Boot loader program
To configure the IMC05 without any additional service programs, the entries of the object directory
must be defined for the desired configuration in the file OBJDICT.C
Note:
When making the entries, make absolutely sure that the sequence of index and subindex is correct.
When the system is generated, these object directory data are compiled and then made available as
the standard configuration after being loaded to the flash memory of the IMC05.
When the CANopen driver is initialized with the function CAN_fn_Init, all required objects and lists are
created dynamically in heap memory.
The CANsetter service program makes it much easier to configure the IMC05 as a CANopen network
node.
CANsetter uses an electronic data sheet (EDS) as the starting point of additional processing. All
general properties of the IMC05 CANopen node are specified here. These characteristics can be used
later as the framework for all special configurations.
The required application objects, PDOs and SDOs can be supplemented in the object directory with
CANsetter. In addition, the various values of the parameters can be set for the desired configuration.
Since several network nodes can be processed at the same time, you can coordinate the identifiers of
the PDO or SDO connections, for example. After all settings have been made, CANsetter generates a
device configuration file (.DCF = Device Configuration File).
The included service program DCFcomp creates a binary file and a header file from this file. The
header file can be integrated in the system application to permit access to the entries in the object
directory under their names. The binary file with the configuration data is loaded to the user flash
memory of the IMC05 where it replaces the standard configuration. When the CAN_fn_Init function
initializes the CANopen driver, the new configuration is used as the basis for the dynamic generation
of the objects and lists. This makes it easy to change the data of the CANopen configuration since the
complete system application doesn't have to be loaded to the IMC05 every time.
In addition, CANsetter can be used to read entries from the object directories on the IMC05 with SDO
accesses via the CAN bus and change them for testing purposes. After the system is restarted, the
configuration stored in the flash memory is used again.
This object describes the type of device to be configured and thus its functionality. The IMC05
complies with CiA DS405 for programmable devices.
Mandatory Yes
Value 405h
This object can be used to indicate internal errors of the device. The functions of the CANopen library
use the CAN_by_ErrorFlags variable internally.
Mandatory Yes
Standard value 0
This object contains information on the number of PDOs used. A distinction is made between sending
and receiving PDOs and between synchronous and asynchronous PDOs. See chapter 3.1.1.
Number of elements 3
Mandatory No (optional)
Number of receiving PDOs (16 bits) Number of sending PDOs (16 bits)
Standard value 0
Standard value 0
Standard value 0
This object specifies the identifier of the synchronization telegram and states whether the device
generates the synchronization telegram itself or only uses received synchronization telegrams. The
IMC05 generates the synchronization telegram itself.
Mandatory No (optional)
This object specifies the communication cycle period in microseconds. See chapter 3.1.1.
Mandatory No (optional)
This object specifies the synchronous window length in microseconds. See chapter 3.1.1.
Mandatory No (optional)
This object contains the own node ID of the IMC05 in the CAN network.
Mandatory No (optional)
Standard value 1
This object contains information on the number of SDOs used. A distinction is made between server
and client SDOs (see chapter 3.1.1). The first server SDO must always be present.
Mandatory No (optional)
Number of client SDOs (16 bits) Number of server SDOs (16 bits)
Standard value 1
These objects contain the parameters of those SDOs for which the IMC05 is the server. The first
server SDO (index 1200h) must be present as the standard SDO. All other server SDOs are optional.
Number of elements 4
Mandatory No (optional)
Value 3
These objects contain the parameters of those SDOs for which the IMC05 is the client.
Number of elements 4
Mandatory No (optional)
Value 3
These objects contain the communication parameters of those PDOs which the IMC05 is to receive.
Number of elements 5
Mandatory No (optional)
Value 4
These objects specify the mapping of the receiving PDOs (i.e., determine which application objects
will be received with the PDO of the IMC05). The maximum 64 data bits (8 bytes) of a PDO are
distributed on receipt to the application objects assigned here.
Number of elements 2 to 65
Mandatory No (optional)
Value range 1 to 64
The following distribution to the application objects applies to the corresponding receiving PDO.
PDO
Byte 0 Bytes 1 and 2 Byte 3
Object Directory
Index Subindex Name
... ... ...
6038h 00h Application object 1
... ... ...
6062h 00h Application object 2
... ... ...
6093h 02h Application object 3
These objects contain the communication parameters of those PDOs which the IMC05 is to send.
Number of elements 5
Mandatory No (optional)
Value 4
These objects specify the mapping of the sending PDOs (i.e., determine which application objects will
be sent with the PDO of the IMC05). During sending, the maximum 64 data bits (8 bytes) of a PDO are
filled with the application objects assigned here. Cf. example in chapter 4.1.12.
Number of elements 1 to 64
Mandatory No (optional)
Value range 1 to 64
This object specifies the number of existing slave nodes. When this value is changed, the CANopen
driver must be initialized again.
The parameters of the network nodes listed here are specified by indices 2100h to 21FFh.
Mandatory Yes
Standard value 0
This object specifies the transmission speed which the IMC05 is to use. The speed must be the same
value for all nodes in the CAN network. When this value is changed, the master node must be
initialized again.
Mandatory Yes
The parameters of the slave nodes in the network are set in these objects. The number of indices is
the value in object 2000h. When one of these values is changed, the CANopen driver must be
initialized again.
Number of elements 5
Mandatory No (optional)
Value range 4
Subindex 1: Node ID
When the header file generated by the service program DCFcomp is linked to the C program of the
application, the entries in the object directory can also be addressed by name and not only by index
and subindex.
DCFcomp uses the names which are specified in the device configuration file (.DCF). For arrays,
records and structures, the field name of the variables is added to the name of the structure and
separated by an "_." Blanks are also replaced by an underline.
...
CAN_fn_ReadObjectDict(baudrate, &dw_Baudrate);
CAN_fn_ReadObjectDict(number_of_slave_nodes, &dw_Data);
CAN_fn_WriteObjectDict(WeidmuellerDO8_modul1, 0xAA);
CAN_fn_WriteObjectDict(WeidmuellerDO8_modul2, 0x55);
Notes:
The general rules of ANSI-C apply to names (e.g., special characters are not permitted and only the
first 31 characters of the name are used). Longer names (e.g., for structures with field name) will
cause problems.
To obtain good code, use short, unique names.
DCFcomp doesn't check to determine whether the same name exists more than once.
Description This function initializes the communication task with the specified priority. The
function must be called before you can use the CANopen driver.
Description This function performs the basic initialization of the node. This gives you the
pre-operational state.
Only communication via SDOs is possible in this state. The standard COB-IDs
derived from the node IDs are used for this.
Description The NMT master uses this function to make all nodes sign themselves off,
perform their additional local initialization (based on the configuration
parameters) and then sign themselves on again.
Afterwards, all nodes in the network are identified, the parameters for node
guarding are set, and node guarding is started.
Description The NMT master uses this function to force one slave node or all slave nodes
in the network to assume the pre-operational state. Afterwards, PDOs can be
disabled or the configuration can be modified with SDOs.
If the own node ID is specified or all nodes are addressed, the master is also
set to the pre-operational state.
Description The NMT master uses this function to force the complete resetting of one
slave node or all slave nodes in the network. The application of the node and
the parameters of the entire object directory are set to the power-on values.
The node then assumes the pre-operational state.
If the own node ID is specified or all nodes are addressed, the master is also
reset.
Description The NMT master uses this function to force the communication parameters in
the object directory of a slave node or all slave nodes in the network to be
reset to the power-on values. The node then assumes the pre-operational
state.
Description This function reads an entry from the object directory if this entry exists and if
a read access is permitted. The read value is returned in the specified
variables.
if (CAN_fn_ReadObjectDict(0x609400, &dw_Data) != 1)
{
bg_outtext ("Not possible to read from!");
return;
}
dw_Data &= 0xFFFF; /* variable is Unsigned16 */
dw_Data += 16;
CAN_fn_WriteObjectDict(0x609400, dw_Data);
}
The entry for this variable must be defined in the object directory
(OBJDICT.C). See CANopen communication profile DS-301. For example:
/*Entry |Obj.|DataTyp|Low|High|Deflt|Acc.|Mapp*/
{0x609400, 0x7, 0x0006, 10, 230, 0x1F, rw, 1},
Description This function writes data to an entry of the object directory if this entry exists
and if a write access is permitted.
Description This function returns the lower limit for an entry of the object directory if this is
defined in the device configuration file.
It is the user's responsibility to ensure that the limit values are adhered to.
CAN_fn_ReadObjectDict(0x609400, &dw_Data);
dw_Limit = CAN_fn_GetLowLimit(0x609400);
if (dw_Data < dw_Limit)
{
w_Variable = dw_Limit;
CAN_fn_WriteObjectDict(0x609400, dw_Limit);
}
else
{
w_Variable = dw_Data;
}
}
Description This function returns the upper limit for an entry in the object directory if this is
defined in the device configuration file.
It is the user's responsibility to ensure that the limit values are adhered to.
CAN_fn_ReadObjectDict(0x609400, &dw_Data);
dw_Limit = CAN_fn_GetHighLimit(0x609400);
if (dw_Data > dw_Limit)
{
w_Variable = dw_Limit;
CAN_fn_WriteObjectDict(0x609400, dw_Limit);
}
else
{
w_Variable = dw_Data;
}
}
Description This function saves the application objects of a sending PDO which are
defined in its mapping parameters. Other nodes (clients) can then request to
read this PDO.
When the function is executed for a sending PDO which is already stored, this
is overwritten with the new data.
Note:
Only nine PDOs can be stored at the same time. When a tenth PDO is
saved, this overwrites the PDO which was stored first.
Description This function saves all application objects of a sending PDO which are defined
in its mapping parameters. The object is then reported to all other nodes
(clients) with synchronous or asynchronous transmission (depending on how
the transmission type is set).
Description This function requests a PDO from its server (asynchronous transmission).
The received data are entered in the application objects which are defined in
the mapping parameters of the receiving PDO.
Description This function is used to set a callback function for a receiving PDO. This is
called when the specified PDO is received (i.e., in the following situations).
· The CAN_fn_PDONotifyReq function was executed on the server of the
PDO.
· The PDO was sent cyclically.
· The client itself had executed the CAN_fn_PDOReadReq function before.
Note:
The callback function should be kept as short as possible.
dw_Counter++;
}
Description This function is used to set a callback function for a sending PDO. This is
called when the PDO is sent because it was requested by a client with the
CAN_PDOReadReq function.
Note:
The callback function should be kept as short as possible.
PDOs with a transmission type of 1 to 240 are automatically transmitted (synchronously). The
transmission type indicates how many synchronization telegrams there are between two PDO
transmissions. The user only has to ensure that the application objects which are specified in the
mapping parameters of the PDOs are updated in time.
Description This function reads back an entry from the object directory of the specified
slave node if this entry exists and a read access is permitted. The read value
is returned in the specified variables.
Description This function writes an entry to the object directory of the specified slave node
if this entry exists and a write access is permitted.
dw_Data = by_DigOutput1;
if (CAN_fn_WriteSlaveObjectDict(1, 0x620000,
&dw_Data) == 1)
{
bg_outtext ("Digital data given out");
}
else
{
bg_outtext ("Not possible to give out!");
}
}
When a defined server SDO is used, this service reads the object directory of this node.
When a defined server SDO is used, this service writes to the object directory of this node.
For instance, application data which were received with a synchronous PDO (command message) can
be updated and output again with the next synchronous PDO (actual message). When a
synchronization telegram arrives, a user-specific function is called in which the necessary application
data are updated.
Description This function sets a callback function which is to be called when triggered by a
synchronization telegram.
dw_Counter++;
}
5.6 Trouble-Shooting
An error variable is defined whose individual bits of the application indicate that a serious error has
occurred on the master or in a slave node.
When one of these bits is "1," this means that a particular error has occurred. The error flags must be
reset by the application.
Table 5.1 Meaning of the bits
Flag Error Effect
Bit 0 Bus-off for master Master node must be initialized again.
Bit 1 · With CANopen:
Monitoring error of the master Master is not ready.
· With standard CAN:
Overflow of receiving buffer Oldest telegram is overwritten.
Bit 2 Monitoring error (lifeguard error) of a slave All devices must be shut down and started
again.
Bit 3 Emergency telegram received –
Bit 4 Timing error of the synchronization window or All communication could not be executed since
the communication cycle there wasn't enough time.
Bit 5 No response to SDOs –
Bit 6 "Bus warning" state –
Bit 7 Bus error occurred –
Description This function sets the callback function which is to be called when an error flag
is set in CAN_by_ErrorFlags.
Proceed as shown below to generate the object directory data with the CANsetter service program.
1. Select the menu command Edit > New Node.
2. With the right mouse button, click the newly inserted node, and select the command
Configuration in the context menu.
3. In the dialog field Node Configuration, click the button Device Type.
4. In the dialog field Select EDS, click Siemens SICOMP-IMC05, and confirm with OK.
The basic configuration of the new node is generated with the standard settings from the
electronic data sheet of the IMC05 (IMC05.EDS).
5. In the dialog field Node Configuration, enter the remaining information, and confirm with OK.
The new node is indicated on the CANsetter desktop with the icon of the IMC05.
In either the dialog field Device Access or Variable list, you can then enter all required information in
the object directory of the IMC05. To do this, select either the command Device Access or Variables
list from the context menu of the IMC05.
· Add the variables, PDOs and SDOs, which you want to use, to your application, and adjust the
standard values to your configuration.
· Map your application variables for the generated PDOs, and select the identifier and the type of
transmission (cf. example).
· Set all configuration parameters such as node ID, number of PDOs and SDOs used,
communication cycle period, synchronous window length, number of slave nodes, slave
parameters, and so on.
· Then back up your project. CANsetter creates or adjusts the device configuration files (DCF) of all
nodes. You can read these files with the Windows editor.
Select the command Compile DCF in the context menu of the IMC05.
This creates two files from the information of the current configuration file NAME.DCF.
· A binary file called NAME.BIN containing all information of the object directory for loading to the
flash memory of the IMC05
· A header file called NAME.H for linking in the names from the object list to your application
Afterwards, you can load the binary file ( NAME.BIN) with the SEND.EXE IMC05 service program to
the IMC05. You can make the familiar settings for the required parameters in the subdirectory
\FLASHCAN of the CANsetter installation directory. See technical description of the SICOMP-IMC05.
The sector of flash memory which is to be written is selected by changing the value in the define
instruction for C_DCF_FL_SEG in the header file CANOPN05.H.
If some entries in the object directory have to be changed later, you only have to load the new binary
file to the IMC05 afterwards and not the complete application.
7 Sample Application
Using a simple example, this chapter gives you a concise overview of the basic procedures involved in
creating a CANopen project with the IMC05.
1. Set up a new project in CANsetter, and save (e.g., under "imc5demo").
2. A not yet configured node appears on the desktop. Using the right mouse button, select the
command Configuration from the context menu. Enter the name and the node ID, and select the
IMC05 from the device type list. If this is not possible, repeat the steps listed in chapter 2.2.
3. Add two new nodes. Configure one as a Weidmüller digital input module and the other as a
Weidmüller digital output module.
4. The object directory can be processed with the commands Variables list or Device Access from
the context menu of the particular node.
5. Several objects are now added to the object directory of the IMC05.
Weid8DO, SyncCounter and Pdo1RecvCounter are dynamic output variables. Weid8DI and
StartNodes are dynamic input variables.
Weid8DO is for transmitting the output value to the Weidmüller DO8 module. Weid8DI is for
reading the inputs of the Weidmüller DI8 module.
SyncCounter and Pdo1RecvCounter are counter variables which are to be available as status
information.
StartNodes is a boolean variable which is set to 1 when the network is to be started.
The transmission type is asynchronous. The standard identifier is calculated with 180h + 2 = 182h
in accordance with the input module.. The first data byte of the PDO is transferred to the object
Weid8DI with the index A4C0h and subindex 0.
7. Two sending PDOs are used to transfer the status information and set the digital outputs.
The type of transmission for both PDOs is cyclic, synchronous. The standard identifier for TPDO2
is calculated with 200h + 3 = 203h corresponding to the output module. No particular identifier is
selected for TPDO1.
Object Weid8DO with index A040h and subindex 0 is transferred with the first data byte of
TPDO2. SyncCounter occupies the first four bytes of TPDO1. Pdo1RecvCounter occupies the
next four bytes.
8. The remaining communication parameters must then be adjusted.
The number of available PDOs is set to two synchronous sending PDOs and one asynchronous
receiving PDO. The communication cycle period is set to 10 msec (value: 10000). The
synchronous window length is set to 5 msec (value: 5000).
9. Finally, the list of network nodes must be prepared and the transmission speed selected.
10. Now save your project. This generates the current device configuration file for IMC05.
11. Select the command Compile DCF from the context menu.
The service program DCFcomp generates the binary file and the header file.
12. Now create your application program, and link in the header file.
13. When the application is generated and loaded to the flash memory of the IMC05, the binary file
with the data of the CAN configuration can also be loaded retroactively from CANsetter. To do
this, select the command Load Flash from the context menu of the IMC05.
If the binary file cannot be loaded to the IMC05, check the configuration of the IMC05 node. See
chapter 6.
Below is the source code of the included sample application. When, for instance, you enter a 1 in the
"StartNodes" variable with CANsetter, the program starts the network, outputs two values alternately
on the output module, reads the current status of the input module, and signals when an error occurs.
/* ***********************************************************************
// CANTEST.C
//
//
// Task to test the CANOPEN.LIB for the IMC05/RMOS system
//
// version V2.0
// date January 22. 1999
//
// ********************************************************************** */
/*****************************************************************************/
/* incode identification */
/*****************************************************************************/
#if defined(_ARCHITECTURE_) || defined(CADUL)
const static char idstr [] =
{
"\0" "(C) SIEMENS AG 1997" "\0" /* In-code identification. */
"\1" "CANTEST.C" "\1"
"\2" "0002" "\2"
"\3" "SiE/Wein" "\3"
};
#endif /* defined(_ARCHITECTURE_) || defined(CADUL) */
CAN_fn_ReadObjectDict(U32Out_SyncCounter, &dw_Data);
dw_Data++;
CAN_fn_WriteObjectDict(U32Out_SyncCounter, dw_Data);
}
CAN_fn_ReadObjectDict(U32Out_Pdo1RecvCounter, &dw_Data);
dw_Data++;
CAN_fn_WriteObjectDict(U32Out_Pdo1RecvCounter, dw_Data);
}
/* ==================================================================== */
bg_cleardevice();
bg_settextcolor (BG_BLACK,BG_WHITE);
bg_setcursortype (BG_NOCURSOR, BG_NOAUTOCURSOR);
/* initialisation */
/* -------------- */
bg_gotoxy (50, 50, PIXEL);
bg_selectfont(3);
bg_outtext ("CAN_fn_Init...");
if (CAN_fn_Init(250) == 0)
{
RmEndTask();
}
CAN_fn_CreateNode();
CAN_fn_DefErrorCall(fn_ErrorOccured);
CAN_fn_StartNodes();
/* operation */
/* --------- */
CAN_fn_DefSyncCall(fn_SyncTrigger);
CAN_fn_PDODefRecvInd(1, fn_ReceivedPdo1);
CAN_fn_PDOStoreReq(2);
bg_cleardevice();
for (;;)
{
/* error occured ? */
if (b_ErrorOccured)
{
/* give out message */
sprintf(s_Ausgabe, "Error: %x ", CAN_by_ErrorFlags);
bg_gotoxy(50, 200, PIXEL);
bg_outtext (s_Ausgabe);
b_ErrorOccured = 0;
/* handle error */
if (CAN_by_ErrorFlags & 0x01)
{
/* -> bus off */
CAN_by_ErrorFlags = 0;
CAN_fn_CreateNode();
CAN_fn_StartNodes();
}
else if (CAN_by_ErrorFlags & 0x14)
{
/* -> life guarding or timing error */
CAN_by_ErrorFlags = 0;
CAN_fn_StartNodes();
}
}
CAN_fn_PDOReadReq(1);
CAN_fn_WriteObjectDict(U8Out_Weid8DO, by_Data);
RmPauseTask(500);
}
/*------------------------------------------------------*/
/* End this task now */
/*------------------------------------------------------*/
RmEndTask();
}
These functions should only be used when there is no way to access devices with CANopen.
Caution
Do not use these functions with the CANopen protocol.
Description This function initializes the CAN controller with the selected transmission
speed and the settings of the global identifier mask. For more information on
the register settings, see the manual of the Intel 82527 CAN controller.
Description This function sends the remote object with the specified identifier via message
object 3 of the Intel 82527 controller.
The BCAN_fn_ReadObject function can be used to read the received data from
the buffer.
Description This function sends the remote object with the specified identifier via message
object 4 of the Intel 82527 controller.
The BCAN_fn_ReadObject function can be used to read the received data from
the buffer.
Description This function returns a received object which was requested before with
BCAN_fn_TransmitRemote (byObjectNr = 3) or BCAN_fn_TransmitRemote2
(byObjectNr = 4).