industrialNETworXnetx

TomP

TomP

| 26.11.2009 | 15:07 | 28 replies

DP-Master on a CIFX 50

Hello everyone,

i am tying to implement a DP-Master. I can not use any Windows tool, so i have to configure everything over sending the right packets with the right content to the right Mailbox.
But this Mailbox-System is making making my crazy.
Sometimes i get a timeout when i call xChannelGetPacket after i called xChannelPutPacket without any error. Sometimes i get the packet with the second call of xChannelGetPacket, sometimes not.
I write a different SrcId to every Packet to make this sure.
And i am already waiting 2 seconds between the calls and call with a timeout of 5 seconds !!!
I don't know what i am doing wrong on this one!

The second Problem is that i get a error code back, while setting the slave params, that is not documented in the header or pdf files.
The error is 0xC039003D and this is the content of CIFX_PACKET packet.tHeader.ulState in the confirming packet of PROFIBUS_FSPMM_CMD_DOWNLOAD_REQ.

Can some one help me on that one?

Kind regards

Tom

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 27.11.2009 | 10:34

Hi TomP,

TomP wrote:
Sometimes i get a timeout when i call xChannelGetPacket after i called xChannelPutPacket without any error. Sometimes i get the packet

Maybe you can post the complete command including the used parameters.

TomP wrote:
The error is 0xC039003D

The error code 0xC039003D stands for "TLR_DIAG_E_PROFIBUS_OUTPUT_OVERLAP" and point to an overlap in the output data.

TomP

TomP

| 27.11.2009 | 11:51

Hi AJ,

thx a lot for providing me the interpretation of the error code. In this way i found my bug. But now i get a new undocumented code: 0xC039003B.
Is it possible that you send me the Header file with all 0xC039xxxx codes? My ProfibusApm_error.h is ending with 0xC039000B ....

The Problem with the Mailbox is not solved yet but better then befor, after i fixed my bug in the slave params ... but why meters the content of a packet in this way?

Following sequence with the slave param bug:
xChannelPutPacket with master params -> no answer after waiting several seconds -> no answer after second try
xChannelPutPacket with slave params -> right answer but ulState gots the error code 0xC039003D
xChannelPutPacket to change mode in USIF_OPERATE -> right answer with error code 0xC0380002

Following sequence with the fixed slave param bug:
xChannelPutPacket with master params -> right answer with no error! (i did not change anything else then the one bug in the slave params!)
xChannelPutPacket with slave params -> right answer but ulState gots the error code 0xC039003B
xChannelPutPacket to change mode in USIF_OPERATE -> right answer with error code 0xC0380002

And is it possible to get any sample code on a Profibus-Master-DP implementation? I read here in the forum that there is sample code for the slave implementation. So i wondered if i could get master sample code. In this way it might be easier to avoid future mistakes.

Kind regards

Tom

Daniel Trautmann

Daniel Trautmann

IBHsoftec GmbH

| 27.11.2009 | 12:07

Hello,

the error code 0xC039003B stands for TLR_DIAG_E_PROFIBUS_MAX_OUTPUT_OFFSET and means "Maximum output offset reached". I found this coden in the file TLR_Diagnostic.h.

Kind regards
dj999

TomP

TomP

| 27.11.2009 | 12:44

Now its 0xC039003C ... can some post content of this TLR_Diagnostic.h I dont have this one.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 27.11.2009 | 12:53

0xC039003C stands for "TLR_DIAG_E_PROFIBUS_MAX_INPUT_OFFSET" and means that the maximum input offset is reached.

Enclosed is the requested header file.
[attachment=0]TLR_Diagnostic.zip[/attachment]

TomP

TomP

| 27.11.2009 | 13:02

Hi AJ,

thx a lot for the header! This will prevent me for asking after every error code :)

But there is still the Problem with the Mailboxes ... ok with the communication channel seems to be alright for now. But i am unhappy that i do not know the reason for the change in the behavior.
But why do i have to post a second packet to get the answer of the first packet?

Kind regards

Tom

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 30.11.2009 | 07:49

Hi TomP,

as long you do not post your packages which you sent and on which you get the problem I am really unable to say, what is going wrong.

TomP

TomP

| 11.12.2009 | 13:50

Hey,

i could solve the problem with the slave params. I made some mistakes in the Structure and then the stack did not accept it.

But:
If i try to get the common status block with the function xChannelCommonStatusBlock. This one is returning 0x800C0012 (CIFX_DEV_NOT_RUNNING) always.
What did i miss?

Calling the function xChannelHostState returns no error and HostState is CIFX_HOST_STATE_READY.
Calling the function xChannelBusState returns no error and BusState is CIFX_BUS_STATE_ON.

And trying to set the mode of the DP-Master to CLEAR oder OPERATE is also returning a error (C0380002). Is it in this case the meaning TLR_DIAG_E_PROFIBUS_FSPMM_DMPMM_BUS_PARAMETER_REJECTED or TLR_E_PROFIBUS_FSPMM_INV_BUSMODE? I think it could be both. I may have still something wrong in my param for the bus or slave. Or is it because of the CIFX_DEV_NOT_RUNNING?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 14.12.2009 | 10:26

Is the stack configured?

TomP

TomP

| 14.12.2009 | 10:31

Actually, i am not sure. Can you tell me how make sure, please?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 14.12.2009 | 10:36

As long as the stack did not have a valid configuration you will get "CIFX_DEV_NOT_RUNNING".

You have to sent a configuration package to the stack at first.
The stack needs to know about the network. Baudrate, how many slaves, ....

The easiest way is to create a configuration with Sycon.net and export it as a *.nxd file.
This file can be loaded to the card over the same mechanism like you have done it with the FW-file it self.

TomP

TomP

| 14.12.2009 | 11:19

Yes, i know this way. But i can't do it like this because it needs be executable without any tools.
What i did:
xSysdeviceOpen: no error
xChannelOpen: no error
xChannelInfo: no error
check the addresses base+0x50 (this addresses belongs to Communication Channel 0) -> channel Type is DP-Master
check DeviceInstance->lInitError: no error
send PROFIBUS_DL_CMD_SET_VALUE_BUS_PARAMETER_SET_REQ: no error
read PROFIBUS_DL_CMD_SET_VALUE_BUS_PARAMETER_SET_CNF: no error
send PROFIBUS_FSPMM_CMD_DOWNLOAD_REQ: no error
read PROFIBUS_FSPMM_CMD_DOWNLOAD_CNF: no error
send PROFIBUS_FSPMM_CMD_SET_MODE_REQ to CLEAR: no error
read PROFIBUS_FSPMM_CMD_SET_MODE_CNF: 0xC0380002
read xChannelBusState: 1
read xChannelHostState: 1
read xChannelControlBlock: CIFX_DEV_NOT_RUNNING

Did i miss anything? What do you think tells me the error 0xC0380002 within in the context of PROFIBUS_FSPMM_CMD_SET_MODE_CNF

EDIT:

From net_dpm_interface.pdf:
RUNNING #define RCX_COMM_COS_RUN 0x00000002
The Running flag is set when the protocol stack has been configured properly. Then the protocol
stack is awaiting a network connection. Now both the Ready flag and the Running flag are set.

So, i think it looks like i still have Problems with die configuration and the error in PROFIBUS_FSPMM_CMD_SET_MODE_CNF packet is telling me the same probably ...

EDIT2:

I could send a configuration where read PROFIBUS_FSPMM_CMD_SET_MODE_CNF return no error!
But reading xChannelControlBlock still returns CIFX_DEV_NOT_RUNNING.

So my questions would be now: What else do i have to do to get started with mit DP-Network?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 14.12.2009 | 15:38

Hi TomP,

I would suggest that you start with the Sycon.net at first.
Just to see, how this works and to understand, what you need to configure.
The result will be a *.nxd file. This can be downloaded to your device.
Then you should get the stack up an running, without the message "CIFX_DEV_NOT_RUNNING".

If you have done this and the stack is up and running and communicating with the slave(s) you should investigate in the configuration via the API.
Otherwise you will struggle, because you did not know, where the problem appears.

TomP

TomP

| 14.12.2009 | 16:15

So it is possible to read out the message whit all slave params?
I configured the slave via SYCON and printed out all params. With this params I started writing the message to configure the slave via mailbox.
So how can i read out the message for this slave after the bus is running?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 14.12.2009 | 18:15

Hi TomP,

please do one step after the other.

- Export your configuration into a *.nxd file.
- Download the nxd file to the card

See if the bus is running.

TomP

TomP

| 15.12.2009 | 10:24

"ulTraceLevel=1 Successfully downloaded the configuration to device"

I exproted the configuration with SYCON via right click menu at cifX Device to a nxd file and downloaded it. Whats next?

EDIT:

After I downloaded successfully the configuration to the device I kept going with my routines like usual. But i still get CIFX_DEV_NOT_RUNNING calling xChannelControlBlock. And now the xChannelBusState is 0 not 1 ...
But the configuration file is the one which uses SYCON to successfully start up the network.

What functions need to be called after i download the configuration file?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 15.12.2009 | 11:21

Have you connected any slave to the card?
As long there is no slave available you will not get the device running flag.

TomP

TomP

| 15.12.2009 | 11:31

I did not change anything between the two situation except of switching the driver.
Running situation:
configuration file downloaded via SYCON -> even the debug modus is running
Other situation:
configuration file downloaded vie the functions provided by toolkit -> xChannelBusState is 0 and xChannelControlBlock returns CIFX_DEV_NOT_RUNNING

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 15.12.2009 | 11:48

Sorry, but I do not know your created configuration.
When you have created a configuration (Master <-> Slave) and you export this, download it and start it, it should work.
Did you get any errors in Sycon.net

As I wrote before, as long there is no slave device connected to the master you will get the "CIFX_DEV_NOT_RUNNING".

TomP

TomP

| 15.12.2009 | 12:02

AJ wrote:
Sorry, but I do not know your created configuration.
When you have created a configuration (Master <-> Slave) and you export this, download it

I did this
AJ wrote:
and start it, it should work.

What do you mean exactly with "start it"

AJ wrote:
As I wrote before, as long there is no slave device connected to the master you will get the "CIFX_DEV_NOT_RUNNING".

Of course! Thats why i kepp connected the one slave always.

If I didn't mention, I'm sorry.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 15.12.2009 | 12:09

Sorry :( , I have no more ideas. Please get in contact with the Hilscher hotline.
Maybe they have an idea.

TomP

TomP

| 15.12.2009 | 12:19

all right I will let you know if I can make any progress ;)

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 15.12.2009 | 12:23

Hi,

that would be great. This will help other users, too.

TomP

TomP

| 13.01.2010 | 12:09

Hello,

i've got some news.
I manged to run the stack in the following way:
1. Download Slave Parameter Set with PROFIBUS_FSPMM_CMD_DOWNLOAD_REQ
2. initialize the stack and set bus parameter with PROFIBUS_FSPMM_CMD_INIT_REQ (using PROFIBUS_DL_CMD_SET_VALUE_BUS_PARAMETER_SET_REQ results in the error 0x800C0012 CIFX_DEV_NOT_RUNNING if trying to call xChannelControlBlock or xChannelCommonStatusBlock)
3. setting HostState to 1 with xChannelHostState (i am not sure if this is realy necessary)
4. start the DL Layer with PROFIBUS_DL_CMD_START_DLE_REQ !
5. changes the current operation mode of the Profibus DP master stack to USIF_OPERATE with PROFIBUS_FSPMM_CMD_SET_MODE_REQ

Now i can read out the following flags:
- ulCommunicationCOS: 0×07 → READY, RUNNING, BUS ON
- ulApplicationCOS: 0×03 → APPLICATION READY, BUS ON

*edit*

solved the configuration problem as well. In the struct PROFIBUS_DL_SL_PRM_DATA_T is the TLR_UINT16 usIdent_Number member. This one says for which slave this configuration is used.
I filled the ident_number like every TLR_UINT16.

usIdent_Number = 0x1234;

BUT here, you have to switch the lower byte with the higher byte!!

usIdent_Number = 0x3412;

TomP

TomP

| 25.01.2010 | 11:50

Ok, so i solved my problems and found a new one.
I can read the IOs with the function xChannelIORead.
But i can not write with xChannelIOWrite. I use it the same way and if i have a look at the memory and looks like it have to be but the slave does not shoe the new values. Do i have to do anything else then calling the function xChannelIOWrite? Remember: xChannelIORead works fine.
It is the controlled / buffered mode active.

I also tried to write the outputs with the Sycon software. This does not work too.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 25.01.2010 | 11:57

Hi,

do you receive any error when you call the xChannelIOWrite function?

TomP

TomP

| 25.01.2010 | 12:52

No errors on this function. What this function is supposed to do is to write the output values at the right place in the Output Data Area 0, isn't it? This works fine, I can see the values in the memory. And I looks exactly like this if I'm using the the Sycon tool.

Do you think I can read out some other registers to find out where the problem is?

*edit*

Found it. The analog slots of the slave may need some warmstart params or something like this. As long I'm working with digital IOs all is working fine.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 26.01.2010 | 16:52

Hi TomP,

:D good to hear.

Login