Edu05

Hello,

I just bought your EDU05 educational system and I find it very interresting but I have a problem to write the C++ instructions.

I’m new in C++ programing but I know other procedural languages. It is very difficult to me to write the instructions in the beginning of the program;

Is it possible to give me a very short example of program in C++ to, for example, write a message on the LCD board?

Thanks.

At the moment there is no C++ example code available for the EDU05.
A simple example can be done anyhow.
What is your favorite C++ compiler?
Do you like to make a console application or Windows Forms application?

[quote=“VEL255”]At the moment there is no C++ example code available for the EDU05.
A simple example can be done anyhow.
What is your favorite C++ compiler?
Do you like to make a console application or Windows Forms application?[/quote]

I use DEV C++ Compiler version 4.9.9.2 from Broodshed Software and I like to make a console application.

Thank you for your answers to my question!

Now the Dev-C++ example for the EDU05 is ready.
Here is the link to download the project files: box.com/s/qn3or2y3j1lz20x8bgk4

[code]#include
#include <windows.h>
#include

using namespace std;

typedef int (__stdcall *VOID2INT)(void);
typedef int (__stdcall *INT2INT)(int);
typedef void (__stdcall *VOID2VOID)(void);
typedef void (__stdcall *INT2VOID)(int);
typedef void (__stdcall *CHARPINT2VOID)(char *, int);
typedef void (__stdcall *INTINT2VOID)(int, int);

VOID2INT OpenDevice;
VOID2VOID CloseDevice;
INT2INT ReadAnalogChannel;
INTINT2VOID SetPWM;
INT2VOID OutputAllDigital;
INT2VOID ClearDigitalChannel;
VOID2VOID ClearAllDigital;
INT2VOID SetDigitalChannel;
VOID2VOID SetAllDigital;
VOID2INT ReadAllDigital;
INT2VOID InOutMode;
VOID2INT Connected;
VOID2VOID LCDClear;
CHARPINT2VOID LCDWriteString;

HINSTANCE hDLL;
int foundDLL = 0;

int init();

int main(void)
{
int dataIn;
int h;
char message1[] = “Hello World!”;

h = init();
if (!h)
{
	cout << "EDU05D.DLL opened" << endl;
	foundDLL = 1;
}
else
{
	cout << "Error to open / read EDU05D.DLL " << endl;
	cout << "Error code: " << h << endl;
    cout << "Press Enter to exit." << endl;
    cin.get();
}
if (foundDLL)
{
	h = OpenDevice();
    switch (h)
    {
            case 0:
                    cout << "Card not found." << endl;
                    break;
            case 1:
                    cout << "Card connected." << endl;
                    break;
    }
}
if (foundDLL)
{                      
    cout << "Press Enter to write \"Hello World!\" on LCD" << endl;
    cin.get();
    InOutMode(0); 
    LCDClear();       
    LCDWriteString(message1,0);    
    //LCDWriteString("Hello World!",0);       // alternative method       
             
                  
    cout << "Press Enter to \"Set All Digital\"" << endl;
    cin.get();
    InOutMode(0);        
    SetAllDigital();
    
    cout << "Press Enter to \"Output All Digital 0x55\"" << endl;
    cin.get();
    OutputAllDigital(0x55);
    
    cout << "Press Enter to \"Clear All Digital\"" << endl;
    cin.get();        
    ClearAllDigital();
    
    cout << "Press Enter to \"Read All Digital\"" << endl;
    cin.get();
    InOutMode(1); 
    int i = ReadAllDigital();
    cout << i << endl;        

    cout << "Press Enter to \"Set PWM 2 to 255\"" << endl;
    cin.get();
    SetPWM(2, 255);   
         
    cout << "Press Enter to \"Read Analog channel #1\"" << endl;
    cin.get();
    dataIn = ReadAnalogChannel(1);       
    cout << dataIn << endl;
    
    cout << "Press Enter to \"Close Device\" and to \"Free Library\"" << endl;
    cin.get();          	
    CloseDevice();
    FreeLibrary(hDLL);
}
return EXIT_SUCCESS;    

}

int init()
{
hDLL = LoadLibrary(“EDU05D.dll”);
if (hDLL == NULL)
{
return -1;
}
else
{
OpenDevice = (VOID2INT) GetProcAddress(hDLL, “OpenDevice”);
CloseDevice = (VOID2VOID) GetProcAddress(hDLL, “CloseDevice”);
ReadAnalogChannel = (INT2INT) GetProcAddress(hDLL, “ReadAnalogChannel”);
SetPWM = (INTINT2VOID) GetProcAddress(hDLL, “SetPWM”);
OutputAllDigital = (INT2VOID) GetProcAddress(hDLL, “OutputAllDigital”);
ClearDigitalChannel = (INT2VOID) GetProcAddress(hDLL, “ClearDigitalChannel”);
ClearAllDigital = (VOID2VOID) GetProcAddress(hDLL, “ClearAllDigital”);
SetDigitalChannel = (INT2VOID) GetProcAddress(hDLL, “SetDigitalChannel”);
SetAllDigital = (VOID2VOID) GetProcAddress(hDLL, “SetAllDigital”);
ReadAllDigital = (VOID2INT) GetProcAddress(hDLL, “ReadAllDigital”);
InOutMode = (INT2VOID) GetProcAddress(hDLL, “InOutMode”);
Connected = (VOID2INT) GetProcAddress(hDLL, “Connected”);
LCDClear = (VOID2VOID) GetProcAddress(hDLL, “LCDClear”);
LCDWriteString = (CHARPINT2VOID) GetProcAddress(hDLL, “LCDWriteString”);

 if (!OpenDevice || !CloseDevice || !ReadAnalogChannel || !SetPWM 
      || !OutputAllDigital || !ClearDigitalChannel
      || !ClearAllDigital || !SetDigitalChannel || !SetAllDigital 
      || !ReadAllDigital || !InOutMode || !Connected
      || !LCDClear || !LCDWriteString)
    {
            FreeLibrary(hDLL);
            return -2;
    }
    return 0;   

}
}[/code]

Great!

Its just wat I needed!

Thanks for all!

Hi! I use Dev-C++5.8.2 and get an error when runnig your C++ example (Error to open/read EDU05D.DLL). The .exe file works fine. Is there a special location neccesarry for the DLL on a Windows7 64bit PC?

Yes, please put it to Windows\SysWOW64 folder or to the same folder with your project files.

I tried both and get always the same error with code -1.

Please compile a 32 bit exe.
The EDU05D.DLL is also 32 bit.
It is not “found” if your application is 64 bit.

That’s it. Thank you.

No problem. Glad it’s OK now.