This sample shows how to access DIO from VS2005. A short description and required registry modifications are include.
For IO configuration you can use the tool "WinNDCUCfg" in the "tools" section under http://www.fs-net.de/download/bin/.
This sample shows how to access DIO from VS2005. A short description and required registry modifications are include.
For IO configuration you can use the tool "WinNDCUCfg" in the "tools" section under http://www.fs-net.de/download/bin/.
Hello
What means the X's in your description in the DWORD Value?:
value UseAsIO DWORD 0xFFXXFF
Is it right, that there comes new Reg-values when I wont to use your example?
Timo
Hello,
X is labeled as arbitrary in my description that means the user can set these bits to 0 or 1 without affect the basic functionallty of this program sample.
But this sample is created for NetDCUX (your registry screen shot is from PicoMOD). Of course the funtions for access DIO works on PicoMOD as well as on NetDCUX but the HW is quite different. Please also note, that the pin assigment in the "PicoMOD1_DeviceDriver_eng.pdf" refers to the PicoMOD and not to the PicoMOD Startinterface! So for adjust your registry setting follow:
On PicoMOD you can also use I2C IO-chips (e.g. PCA9555) for increase number (and speed) of IOs.
Hello,
thereby a sample (includes registry settings) which use the IOs on PicoMOD Starterkit J9.
Hello
Is it correct, that first, I need the DIGITIO.DLL on my picMod in \FFDISK or \Windows? Because I don't have anything there.
' P/Invoke calls to DIGITIO.DLL (digital IO driver) via win32 API (coredll.dll)
' CreateFileW()
Timo
Hello,
by default the dio driver shoud be loaded. You will find the driver in \windows, e.g. using telnet "attrib \windows\*.dll.
You can also check if the driver is active by:
- boot out on serial line
- under registry key: [HKLM]\drivers\active\XX
Check if the "hPort" value is a valid handel, only then you can access to the driver.
Hello
Thank you for your example. With your example, we can OPEN the following Ports as OUTPUT:
IO_A: 1, 2, 3, 4
IO_B: 1
But what we need is
IO_B: 2 (A=0, B=4)
What does that mean:
' PORT 33221100
Why, we can not change the "0" Binary to a "1" to make it as OUTPUT:
' reg set value UseAsIOA DWORD 0x0003E000
' reg set value DataDirA DWORD 0x0003E000 '1111110000000000000 --> 7E000 --> 253952
############################################3
For what is the value bValue:
Public Class Form1
Dim DIO As New DIOport
Dim ValuePort1 As Byte = 0 'tree msb bits from porta1
Dim ValuePort2 As Byte = 1 'two lsb bits from porta2
Sub Write(ByVal bValue As Byte)
DIO.SetPort(1)
DIO.WriteByte(ValuePort1)
Label1.Text = ValuePort1.ToString()
DIO.SetPort(2)
DIO.WriteByte(ValuePort2)
Label3.Text = ValuePort2.ToString()
'ValuePort1 <<= 1
If ValuePort1 = 0 Then
ValuePort1 = 64
End If
If ValuePort2 = 1 Then
ValuePort2 = 2
Else
ValuePort2 = 1
End If
End Sub
Quote from "Nase"Why, we can not change the "0" Binary to a "1" to make it as OUTPUT:
It has no effect when you change the registry at runtime. The driver is loaded when the system starts and then reads the registry settings. They can not be changed later anymore. Therefore you have to set the registry to reflect your needs, and then reboot your board. Now the new settings should take effect.
Regards,
H. Keller
I know this. But the problem is, that we DONT KNOW, what value is to set in the registry. Because we did't found any document hwo let's us understand, how it works.
Here is my first IO experiment: http://www.fscan.com/MyFirstIO.mp3
Made in VB.NET
Just for fun.
Enjoy
Quote from "Nase"I know this. But the problem is, that we DONT KNOW, what value is to set in the registry. Because we did't found any document hwo let's us understand, how it works.
Is it really this difficult? Regarding to the document "NetDCU_DeviceDriver_eng.pdf" available on the CD or here:
For each pin there is a bit in the UseAsIOBit entry. If you want to use this pin for I/O, set the bit to 1, otherwise leave it as 0. Then, for any of these pins with the 1-bit, set 0 or 1 in DataDirBit, depending on your need for input (0) or output (1). And finally, for all pins with 1-bit for the direction, you have to specify if the port starts with low (0) or high (1) when being initialized. This is set in the entry DataInitBit.
So where is the problem?
Regards,
H. Keller
I received a CD from F&S and a PicoMod1. The correct file name on the CD is: "NetDCU_DeviceDriver.pdf". But it is under the folder "NetDCU". and under the folder "German", there is no german description. I program in VB.NET and all examples are in C++. There are more than 15 documents with about 50 pages and every time I have to think, if it is the right document for my PicoMod. Last time we discuss about this and we did't know some settings eighter with Mr. Zutter.
I'm not a machine.
Hello,
there is only one document for PicoMOD device driver!
With the PicoMOD sample in this thread you can write to 5 IO pins, j1 is on PicoMOD, j9 is on StartIntf:
J9/Pin3 = GPE0 = J1/Pin35 = Port1/Bit5 = UseAsIOA/Bit13
J9/Pin4 = GPE1 = J1/Pin36 = Port1/Bit6 = UseAsIOA/Bit14
J9/Pin5 = GPE2 = J1/Pin37 = Port1/Bit7 = UseAsIOA/Bit15
J9/Pin6 = GPE3 = J1/Pin38 = Port2/Bit0 = UseAsIOA/Bit16
J9/Pin7 = GPE4 = J1/Pin39 = Port2/Bit1 = UseAsIOA/Bit17
J9/Pin8 = EINT3 = J1/Pin24 = Port1/Bit5 = UseAsIOA/Bit9
These 5 pins located on different ports, a1 and a2. A0 and a3 are not used also any pin from port b is in use. After CreateFile() you can "jump" from porta1 to porta0 use SetPort().
The code documentation says:
The port number above the UseAsIOA assigns to which porta this pins belong. If you like to use UseDirA/Bit15 for read you have to set this bit to zero:
If you like to use other IOPins as in this sample you have to check if they are available (see VIO Interface HW docu.)!
Quote from "Nase"I received a CD from F&S and a PicoMod1. The correct file name on the CD is: "NetDCU_DeviceDriver.pdf". But it is under the folder "NetDCU". and under the folder "German", there is no german description.
Sorry, my mistake. I hadn't realized that it was for the PicoMOD1. Then the correct file is PicoMOD1_DeviceDriver_eng.pdf
As the PicoMOD1 has more I/O pins than the standard NetDCUs, there is in fact a difference when using them. Mr. Zutter already explained that.
QuoteI program in VB.NET and all examples are in C++.
Yes, this is a big problem. The .NET languages are getting more and more popular, but the drivers provide their interface in C only. However as all drivers use the file interface (CreateFile(), ReadFile(), WriteFile(), SetFilePointer(), DeviceIoControl(), CloseHandle()), using a .NET language you have two ways of accessing them:
It is very difficult to provide all documents in all languages and for all programming environments. For example if we have one document for C/C++, one for C#, one for VB, and then each of them at least in German and English, this is quite a lot to do.
Therefore our main goal is to provide the English documentation and the C interface as a minimum. English is understood by most software people and this is also the reason why we prefer English here in the forum. And when the C interface is known, you can usually transfer the call to .NET somehow rather easily.
Best regards,
H. Keller
Hello
Thank you both for your response. I'll try it next week.
Of course you can not write all codes in any language. For that, it's just fine to have access to this forum
Timo
Hallo!
Was ist zur Benutzung dieses Beispiels per WinNDCUCfg einzustellen?
2-9(OUT) und 17-24(IN)? (& Haken in Generate...)
Bei der Ausführung bekomme ich nur einen WinMain Fehler.
In meiner Anwendung in C# bleibe ich bei dem ReadFile hängen, mit dem LastError 6. Woran kann dies liegen?
Welches der Beispiele(auch AnalogIO) ist in C#? Habe leider keines gefunden.
MfG
Hallo,
der Fehler "WinMain(), CreateFile Failed" kommt schon wenn Sie die Schnittstelle öffnen möchten! Es hat also nichts mit den Einstellungen die Sie über WinNDCUCfg erzeugen zu tun. In WinNDCUCfg können Sie z.Z. für den DIO nur festlegen welche Funktion ein einzelner DIO Pin haben kann (IN oder OUT).
Im vorliegenden Beispiel (für die NetDCU8) wird die DIO Schnittstelle mit dem Namen "DIO0:" geöffnet, d.h. Sie müssen den Wert "Index" unter "HKLM\Drivers\BuiltIn\DIO" auf "0" setzen (übrigens müssen Sie auch den Wert für den "Port" anpassen - oder SetFilePointer() verwenden).
Im Quellkode ist das im Kopf genau beschrieben:
QuoteDisplay More...
' This sample write data to Port0. Data (0...254) is written by click the "write" button.
' The data is read from Port2 by click the "read" button. For this you have to connect
' Port0 Bit0 with Port2 Bit0
' Port0 Bit1 with Port2 Bit1
' ...
' Port0 Bit7 with Port2 Bit7.
' Futher you have to configure the WCE Registry under HKLM\Drivers\BuiltIn\DigitalIO as follow:
' X=arbitrary (Port1 not in use for this sample)
' reg set value Port DWORD 0
' reg set value Index DWORD 0
' reg set value UseAsIO DWORD 0xFFXXFF
' reg set value DataDir DWORD 0xXXFF
' reg set value DirInit DWORD 0xXX00
' Ensure that no ohter driver (keyboard, spi, i2c) uses "your" IOPins.
...
d.h. für "WinNDCUCfg": die Pins von Port 0 sind Ausgänge und die Pins von Port 2 Eingänge. Die Werte "Index" und "Port" sind manuell auf "0" einzustellen - oder das Programm muss entsprechend angepasst werden.
In C# und VB sind die Funktionsnamen identisch Sie müssen nur die Schreibweise anpassen!
Danke soweit, jedoch hab ich noch folgendes:
Read lt. DIO_VBTest:
mit der Funktion:
Leider erhalte ich jedoch einen LastError 87, sprich falsche Parameter. und als Wert von data[0] = 255. Sehen Sie den Fehler?
sorry, falsche Funktion, das oben war nur ein Versuch:
QuoteDisplay Morepublic byte ReadByte()
{
int error = GetLastError();
byte[] data = new byte[1];
uint NumberOfBytesToRead = 1;
uint NumberOfBytesRead = 0;
int value = 0;
value = ReadFile(hPort, data, NumberOfBytesToRead, NumberOfBytesRead, IntPtr.Zero);
error = GetLastError();
if (value == 0)
{
Console.WriteLine("Read failed");
Console.WriteLine("GetLastError: " + error);
}
return data[0];
}
bitte um Beantwortung