DigitalIO-and AnalogIN

  • This sample project demonstrates how to configure and access DigitalIO-and AnalogIN ports. Port data are read and written by polling (timer) and extern IRQ. A possible circuit for testing is shown in the attached file "pict_1.bmp". The project classes CDIO and CAIN offers a starting point for generalisation or specialisation of port access. Required WCE registry configuration is documented in the file "config.txt".


    Please refer "NetDCUX_DeviceDriver.pdf" and "NetDCUX_Hardware.pdf" for detailed information.


    For IO configuration you can use the tool "WinNDCUCfg" in the "tools" section under http://www.fs-net.de/download/bin/.

    Files

    • AINandDIO.zip

      (96.84 kB, downloaded 550 times, last: )

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • I have tried it. The compiler reports the following error:


    ainanddio\dio.cpp(221) : fatal error C1010: unexpected end of file while looking for precompiled header directive


    I'm using eMbedded C++ V4 SP4.


    The applicatio "simple analog input" (also in this forum) does work correctly.


    Please advice.

  • Hello,
    there are no pch files available.
    You should select "Not using precompiled headers" under "menu: project->settings->category: precompiled headers".

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    sorry, select "Not using precompiled headers" under "menu: project->settings->select card C/C++->select from category listbox: precompiled headers".


    Now it may work!

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • OK, thanks.


    After having done the configuration (registry), all works fine.
    The simple GUI is self explaining.


    One problem: I can't get the IRQ be triggered. DIO0 (=GPIO0..7) do increment. AIN1 is read, too (however AIN0 is measured). Is the interrupt line that one on Pin 1 of the Starter Kit's I/O connector?

  • Hello,


    this program offers two possiblities for handle an external interrupt. Set the preproccesor instruction "TRIGGER" to:


    a) TRIGGER_EDGE
    for use a pin of the DIO port.
    These pins can be configured as IRQ as described in "Device Driver" dokument.


    b) TRIGGER_LEVEL
    for use J5 pin 1 as IRQ.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,
    I'm triying to write in my digital IO. The pins where i want write are: pin 5, 7 and 9 of my NetDCU10, that corresponds to IO-port 4, IO-port 2 and IO-Port 0 respectively. My problem is that when I use CreateFile, the handle always takes the value INVALID_HANDLE. I've configured the pins that i'm using as outputs with the winNDCUcgf.exe. Now, my digitalIO register is:
    OK -> reg enum value \
    00 "DataDir"=dword:21 \
    01 "UseAsIO"=dword:21 \
    02 "DataInit"=dword:0 \
    03 "IRQCfg2"=dword:0 \
    04 "IRQCfg1"=dword:0 \
    05 "IRQCfg0"=dword:0 \
    06 "Prefix"=string:DIO \
    07 "Dll"=string:DIGIO.dll \
    08 "Order"=dword:151 \
    09 "Index"=dword:1 \
    10 "Ioctl"=dword:4 \
    11 "Port"=dword:1 \
    12 "FriendlyName"=string:Digital I/O driver for NetDCU \


    Now, to work with the IO-port4, i use:


    hDIO= CreateFile(_T("DIO4:"),GENERIC_WRITE, 0, NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL );


    As a result, the handle hDIO takes an invalid result. What I'm doing wrong?
    Thanks

  • Hello,
    for "CreateFile" you have to use the "index" value for create the "filename" string. So in your case the string is _T("DIO1:"). After the file is open you can direct access to the port which is set in registry (in your case port1). To switch to an other port use "SetFilePointer".

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.