HilscherAutomation / netPI-netx-programming-examples

Sources of Dockerfile generated Docker image "netX programming"
MIT License
27 stars 5 forks source link

Using SyncEventCallback on the netPI #1

Closed jugglingcats closed 6 years ago

jugglingcats commented 7 years ago

Hi, we are writing an application for the forthcoming netPI and we're using the netHAT for development.

We'd like to handle field bus sync using system interrupts and we can see from the user manual for the netHAT that this signal is brought out to pin 22 on the pi header.

However, we are not seeing this pin fire either from our code or using logic analyser when we enable DC in TwinCAT using the EtherCAT firmware.

Is there a config setting we need to change to enable the interrupts?

Many thanks.

Hilscher commented 7 years ago

Dear jugglingcats,

we are sorry to say that neither netHAT nor netPI do have support for any synchronization signal between Rasberry CPU and netX fieldbus controller when an IO cycle happened on the EtherCAT side or any other industrial network that is supported by netX.

You mentioned the SIRQ Pin as stated in the getting started manual of netHAT. This pin is just there because it belongs to netX SPI reference circuit and whenever we make a design with SPI we provide connectivity also over SIRQ even if it is not in use like in this case.

Best regards

jugglingcats commented 7 years ago

Thanks for the response! Does that mean the example in the sources (https://github.com/Hilscher/netPI-netx-programming-examples/blob/master/files-to-copy-to-image/sources/ECS_simpleConfig.c#L125) is not going to work on the netPI? I think that example could cause confusion for people coming to the project.

Hilscher commented 7 years ago

The examples provided are exclusively made for netPI and tested also with one of the netPI beta devices successfully with a TwinCAT master.

The way hilschers network chip netX works is not different to how it is used on netPI. Once you get it initialized with the right parameter you call the chip from time to time to gather the latest master output that it has stored internally in its buffer.

This is exactly how the demo works. It calls the input read and the output write function when it comes to the IO demo part

jugglingcats commented 7 years ago

Hi we have the read and write of data working fine with the netHAT using xChannelIOWrite and xChannelIORead, thanks.

What's confusing is the registration of the sync event callback (ECS_simpleConfig.c line 830) using CIFX_NOTIFY_SYNC, which from the docs indicates "Fieldbus synchronous event occurred".

Will this event be fired on netPI? And if so, is it fired in keeping with the field bus clock sync (ie. distributed clock setting), and finally how reliable will it be on the netPI? Can we expect some events to be missed or simply delayed if the RPi is busy.

Sorry if I'm missing something basic...

Hilscher commented 7 years ago

Well, the synchronization method cannot be confirmed on netPI.

The source code you have in front of you is a common source code we provide to any netX controller chip user and is made also for those who use netX on our PC cards named cifX which supports a Dual-port memory instead of a SPI and DMA access. On those cards the synch mechanism is working fine. The only precondition to meet with the synch mechanism is that interrupt mode is enable as stated here in our knowledgebase https://kb.hilscher.com/display/CIFXDRV/CIFX+API when it comes to the services xChannelRegisterNotification().

The current implementation of the "Raspberry to netX" interactions are not supporting interrupt (as of our knowlegde today). This is because the IO interface of Raspberry supports event triggered interrupts only, but we need level triggered interrupts not to miss any interrupts. This is why today the driver between Raspberry and netX is only working in polling mode. So the callback functions will all not work as they come in the common source code you are referencing.

jugglingcats commented 7 years ago

Thanks again for the reply -- it is clear for us now. It would be good to put a comment in the code to this effect, that event notification is not supported on netPI.