GLBasic forum

Codesnippets => Inline / 3rd party => Topic started by: Maxheadroom on 2006-Oct-29

Title: DLL help
Post by: Maxheadroom on 2006-Oct-29
Ok I omit defeat with the inline command the problem is I just can’t work how it works, I even have the full description file from the supplier. If I send you the dll and the document, can you show me how to get one or two of the commands working, I am sure if you show me one or two I could work out the rest out!

Thanks, Max…

EDIT:
Problem is solved, COM port communication is working. See best answer here:
http://www.glbasic.com/forum/viewtopic.php?pid=2499#p2499
Title: DLL help
Post by: Hemlos on 2006-Oct-30
Ok you asked for it, heres an example :)

http://www.glbasic.com/forum/viewtopic.php?id=545
Title: DLL help
Post by: Maxheadroom on 2006-Oct-30
Ok that’s great!

Can we start with the simple stuff, I have loads more questions.

1, a Dll file will give GLBAISC extra commands? True/false
2, can I use the commands as if they were part of the glbasic
3, how do variables connect with glabsic variables?

 
thanks, Max
Title: DLL help
Post by: Kitty Hello on 2006-Oct-30
I got your mail. Oh boy. That's a lot of work. I tell you the basics, but I can't do it all for you.

If you read Visual Basic:

Code: GLBasic [Select]
Private Declare Function XY Lib "xyz.dll" (a As Long) As Double
You write:
Code: GLBasic [Select]
INLINE
extern "C" double (__stdcall* XY)(long a)=0;
DLLCALL("xyz.dll", "XY", (void**) &XY);
ENDINLINE
Now the details:
INLINE - that starts inline C++ programming

Then comes the function declaration - tell the compiler, there is a function called XY that takes a 'long' argument and returns a double.

extern "C" - the call is an extern "C" declaration - for VB callable DLLs it's always this:
extern "C" return_value(__stdcall* FunctionName) (arguments);

Code: GLBasic [Select]
double - that's the return value. Use these:
int - 32 bit integer - the same as 'long'
short - 16 bit integer (that's Integer in VB)
char - 8 bit integer
double - 64 bit floating point
float  - 32 bit floating point
char*  - a String
void*  - any pointer - you can use 'int' as well...
(__stdcall* - the calling convention. VB can only handle stdcall (double underscore at the beginning)

XY ) - The function name. That's the name you give the function internally (when you call it) It can differ from the real name.

(long a) - here comes the parameter list, separated by commas. You can leave the variable names 'a' if you want to. Only the types are of interest.

=0 - you say the function pointer equals '0'. This way can test if the function got loaded later.


DLLCALL( dll_name, function_name_witin_the_dll, (void**) &function_name_of_declaration);


If you want to call the function, you write:
Code: GLBasic [Select]
LOCAL retval, inval
INLINE
retval = XY(inval);
ENDINLINE
Read the reference for INLINE as well. It tells you how to connect/convert GLBasic data into C++ data.
Title: DLL help
Post by: Maxheadroom on 2006-Oct-30
your the man!, i will try it tonight very slowly. (Sure to have more questions later)

thank you very much for the pointers.
Title: DLL help
Post by: Maxheadroom on 2006-Oct-31
first i tryed this (not even working)?

Code: GLBasic [Select]
// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283

LET lt=1
LET chip=1

startup
setltp
setoutput

END


INLINE
DLLCALL("K8D.dll", "start_8000", (void**) &start_8000);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
extern "C" double (__stdcall* start_8000);
extern "C" double (__stdcall* SelectI2CprinterPort) (long lt);
extern "C" double (__stdcall* ConfigIOchipAsOutput) (long chip);
ENDINLINE


FUNCTION startup:
INLINE
start8000
ENDINLINE
ENDFUNCTION

FUNCTION setltp: it
INLINE
SelectI2CprinterPort (it)
ENDINLINE
ENDFUNCTION

FUNCTION setoutput: chip
INLINE
ConfigIOchipAsOutput (chip)
ENDINLINE
ENDFUNCTION
then i tryed this ?
Code: GLBasic [Select]
// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283

LET lt=1
LET chip=1

// load the start up io
INLINE
extern "C" double (__stdcall* start8000);
DLLCALL("K8D.dll", "start_8000", (void**) &start8000);
ENDINLINE

// load lpt1
INLINE
extern "C" double (__stdcall* setltp1) (long lt);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
ENDINLINE

// load lpt1
INLINE
extern "C" double (__stdcall* setltp1) (long chip);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
ENDINLINE

PRINT 100,100,lt
SHOWSCREEN
MOUSEWAIT
and that a some errors

Code: GLBasic [Select]
compiling:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:10: error: `LET' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:10: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:10: error: expected `;' before "lt"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:11: error: expected `;' before "chip"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:15: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:15: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:16: error: `start8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:23: error: `SelectI2CprinterPort' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:30: error: `ConfigIOchipAsOutput' undeclared (first use this function)

linking:
success
_______________________________________
*** Finished ***
Time: 1.4 sec
Build: 1 succeeded, 0 failed
Title: DLL help
Post by: Kitty Hello on 2006-Oct-31
Quote from: Maxheadroom
first i tried this (not even working)?

Code: GLBasic [Select]
// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283

// LET is dead. Please leave it.
lt=1
chip=1

// a function must be called with ( )
startup()
setltp(lt)
setoutput(chip)

END

// You must "end" the main game function
// this is done by forcing another function to
// begin and end
FUNCTION dummy:
ENDFUNCTION


INLINE
// here the order got messed up.
// first declaration and definition
// then linking to it

// also, don't forget the "=0", so you can check if
// the function has been loaded

extern "C" double (__stdcall* start_8000) = 0;
extern "C" double (__stdcall* SelectI2CprinterPort) (long lt) = 0;
extern "C" double (__stdcall* ConfigIOchipAsOutput) (long chip) = 0;

DLLCALL("K8D.dll", "start_8000", (void**) &start_8000);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);

ENDINLINE


FUNCTION startup:
INLINE
// in C++ always call functions with ( )
// and end a command with ';'

// also, check if the function could be loaded first:

if (start8000) // function pointer is good
{
   start8000();
}
else
{
   PRINT("Can't load function", 100, 100);
   SHOWSCREEN();
   MOUSEWAIT();
   END();
}
ENDINLINE
ENDFUNCTION

FUNCTION setltp: it
INLINE
SelectI2CprinterPort (it); // semicolon
ENDINLINE
ENDFUNCTION

FUNCTION setoutput: chip
INLINE
ConfigIOchipAsOutput (chip); // semicolon
ENDINLINE
ENDFUNCTION
Title: DLL help
Post by: Maxheadroom on 2006-Oct-31
Thanks that’s starting to make more sense, I will try it tonight, however should the call be  start_8000(); ?

thanks max...
Title: DLL help
Post by: Kitty Hello on 2006-Oct-31
Right. Typo from me. Just wanted to see if you read carefully ;)
Title: DLL help
Post by: Maxheadroom on 2006-Oct-31
so close but so far.

Code: GLBasic [Select]
// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283

// LET is dead. Please leave it.
lt=1
chip=1
info=10

// a function must be called with ( )


startup()

setltp(lt)

setoutput(chip)

output(chip, info)

END

INLINE
extern "C" double (__stdcall* start_8000) = 0;
extern "C" double (__stdcall* SelectI2CprinterPort) (long lt) = 0;
extern "C" double (__stdcall* ConfigIOchipAsOutput) (long chip) = 0;
extern "C" double (__stdcall* IOoutput) (long chip, long info) = 0;
DLLCALL("K8D.dll", "start_8000", (void**) &start_8000);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
DLLCALL("K8D.dll", "IOoutput", (void**) &IOoutput);
ENDINLINE

// You must "end" the main game function
// this is done by forcing another function to
// begin and end
FUNCTION dummy:
ENDFUNCTION



FUNCTION startup:
INLINE
// in C++ always call functions with ( )
// and end a command with ';'

// also, check if the function could be loaded first:

IF (start_8000) // function pointer is good
{
   start_8000();
}
ELSE
{
   PRINT("Can't load function", 100, 100);
   SHOWSCREEN();
   MOUSEWAIT();
   END();
}
ENDINLINE
ENDFUNCTION

FUNCTION setltp: it
INLINE
SelectI2CprinterPort (it); // semicolon
ENDINLINE
ENDFUNCTION

FUNCTION setoutput: chip
INLINE
ConfigIOchipAsOutput (chip); // semicolon
ENDINLINE
ENDFUNCTION

FUNCTION output: chip, info
INLINE
IOoutput (chip,info); // semicolon
ENDINLINE
ENDFUNCTION
out put of the complier
Code: GLBasic [Select]
_______________________________________
*** Configuration: WIN32 ***
precompiling...

GPC - GLBasic Precompiler V.2006.279 - 3D, NET
compiling...
k8000.gbas (1 KB)
Wordcount:10 commands

compiling:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:23: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:23: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:24: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:24: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:25: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:25: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:26: error: `start_8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:26: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:27: error: `SelectI2CprinterPort' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:28: error: `ConfigIOchipAsOutput' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: `IOoutput' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::startup()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:50: error: `start_8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:50: error: `IF' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:51: error: expected `;' before '{' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:55: error: `ELSE' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:55: error: expected `;' before '{' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::setltp(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:70: error: `SelectI2CprinterPort' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::setoutput(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:80: error: `ConfigIOchipAsOutput' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::output(DGInt, DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:90: error: `IOoutput' undeclared (first use this function)

linking:
success
_______________________________________
*** Finished ***
Time: 1.3 sec
Build: 1 succeeded, 0 failed
Title: DLL help
Post by: Kitty Hello on 2006-Nov-01
You forgot a:
FUNCTION End_My_Main:
ENDFUNCTION

after the "END"
Title: DLL help
Post by: Maxheadroom on 2006-Nov-01
gernot
is this bit ok it needs two verables

extern "C" double (__stdcall* IOoutput) (long chip, long info) = 0;
Title: DLL help
Post by: Kitty Hello on 2006-Nov-01
It says: "Private Declare Sub" in VB. Thus, this is a void function:

extern "C" void (__stdcall* IOoutput)(long, long)=0;

You're really close now, I guess.
Title: DLL help
Post by: Maxheadroom on 2006-Nov-01
it's all gone wrong, so i have striped it. however this will not build. i must be missing somthing: :D
Code: GLBasic [Select]
// --------------------------------- //
// Project:
// Start: Wednesday, November 01, 2006
// IDE Version: 3.283

up()

END
FUNCTION End_My_Main:
ENDFUNCTION


FUNCTION up:
INLINE
start_8000();
ENDINLINE
ENDFUNCTION



INLINE
extern "C" double (__stdcall* start_8000) = 0;
DLLCALL("K8D.dll", "start_8000", (void**) & start_8000);
ENDINLINE
the error
Code: GLBasic [Select]
*** Configuration: WIN32 ***
precompiling...

GPC - GLBasic Precompiler V.2006.279 - 3D, NET
compiling...
one.gbas (365 B )
Wordcount:3 commands

compiling:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::up()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:24: error: `start_8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:24: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: At global scope:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:31: error: `double*__GLBASIC__::start_8000' used prior to declaration
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:32: error: expected constructor, destructor, or type conversion before '(' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:32: error: expected `,' or `;' before '(' token

linking:
gpc_temp0.o:gpc_temp0.cpp:(.text+0x46): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x88): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xae): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xc8): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xd1): undefined reference to `__GLBASIC__::lt'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xde): undefined reference to `__GLBASIC__::chip'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xe4): undefined reference to `__GLBASIC__::info'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xea): undefined reference to `__GLBASIC__::info'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xf0): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x128): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x158): undefined reference to `__GLBASIC__::t'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x164): undefined reference to `__GLBASIC__::t'
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Time: 0.8 sec
Build: 0 succeeded, 1 failed
Title: DLL help
Post by: Kitty Hello on 2006-Nov-02
Code: GLBasic [Select]
up()

END

FUNCTION End_My_Main:
ENDFUNCTION

// Must declare function _before_ you use them!!
INLINE
extern "C" double (__stdcall* start_8000) = 0;
DLLCALL("K8D.dll", "start_8000", (void**) & start_8000);
ENDINLINE



FUNCTION up:
INLINE
start_8000();
ENDINLINE
ENDFUNCTION
Title: DLL help
Post by: Maxheadroom on 2006-Nov-02
Tonight it WILL work!
Title: DLL help
Post by: Maxheadroom on 2006-Nov-03
Gernot got the email:
sending one back:

Gernot is close to making this work, if so Glbasic can talk to the outside world in terms of electronics. The Velleman k8000 has sixteen digital input/output channels which can be used as either input or output as desired. In addition, there are eight analogue outputs with 6 bit resolution, one analogue output with 8 bit resolution, and four analogue inputs of 8 bit resolution. I would like to use the easy 3D function of GLBASIC and interface this to some of my robotic equipment I am working on. However there are many usages of this system. If you are interested the web site is below. The work Gernot has done so far is truly inspiring. and thats a big thank you from Me.

http://www.velleman.be/country.php

thanks, Max...
Title: DLL help
Post by: Hemlos on 2006-Nov-03
Awesome, that piece of electronic is called a DAC mechanism! Direct Acces Control.
Ive seen them used before with the original BASIC on some very old computers for robots.

Ive been wanting to build my own DAC but i couldnt figgure out how to get glbasic to write to the indivual pins of a printer port.
Title: DLL help
Post by: Kitty Hello on 2006-Nov-03
Is that what the dll does? Writing to the printer port? I've done some small projects with Microcontrollers (http://www.glbasic.com/main.php?site=microprocessor) but I never really got deep into it.

Never thought of all the stuff you come up using GLBasic for. It's nice.
Title: DLL help
Post by: Maxheadroom on 2006-Nov-03
Yes sort of i think it converts it into a serial bit steam and send it to a microcontroller on the board that converts it into code data, the codes unknown. There web site tell you all (almost). there might be extra code on that might help like a old dos bordland C++ code and Qbasic code. If you need help with the electronics I can help with digital however I am not that good at the analog. Nice frogga game by the way, may be adding com port support we could write a controller of our own!

Sorry back to the K8d.gbas the new file now complies and all the commands seem to process ok. However the board is waiting for input, there seems to be no communication with the LPT port there is a program LED the flashes when data is sent to the board from the test program but with k8d.gbas it is still. I have had a look and the Start_8000 function seems to be different to the rest? (I don’t know what I can do to help you with this)
Title: DLL help
Post by: Kitty Hello on 2006-Nov-04
Send me the small sample. The Start_8000 first loads all the functions from the dll to the prototype-pointers. Thus, alowing you to call them. Maybe there's some small thing missing now. Did you try any .exe from the website, so you can be sure the COM port BAUR and handshake is configured correclty?
Title: DLL help
Post by: Maxheadroom on 2006-Nov-04
yes the test software work on lpt1 (k8000.exe) fine: we must be missing somthing. code below
Code: GLBasic [Select]
// both switches are off and using LPT1
port = 1
chip_no = 1
data = 15


Start_K8000 ()

SelectI2CprinterPort (port)  //*SELECT lpt1 on mainboard

ClearIOchip (chip_no)          //*clear channels 1

ConfigIOchipAsOutput (chip_no) //*configure channels 1 AS outputs

IOoutput (Chip_no, Data)                // send data

PRINT "sent data",100,100
SHOWSCREEN
MOUSEWAIT

Stop_K8000()                                    //stop after use
PRINT "stopped",120,120
SHOWSCREEN
MOUSEWAIT

END
thanks, max...
Title: DLL help
Post by: Kitty Hello on 2006-Nov-06
I checked it twice. I can't find anything wrong...
The same program in VB does work!?
If you don't have V, send me the code - I'll make an .exe for you.
Title: DLL help
Post by: Maxheadroom on 2006-Nov-07
Gernot,
Looking at this step by step, hardware working (with there test software). The Start_K8000 () loads ok (if removed it causes an error), after that the SelectI2CprinterPort(X) this is unknown if this works, I am guessing not because of the select LED on the board is not active when our program is running but it is active with there test software. I have sent an email to Velleman to see if they can help us. i am sure is a very small problem we are over looking. Also I have emailed over the ‘c’ part I don’t know if the include file 'I2C.H' (looks like it the same as the DLL but in ‘c’) this might help with different angle of attack.
Hemols I tried the loop idea but it did the same.
i don't have VB to test the program (i like GLBASIC)


Below is the link to all there downloads for VB,C,QBASIC and all the manuals
http://www.velleman.de/ot/en/product/view/?id=9383


Thanks, Max
Title: DLL help
Post by: Hemlos on 2006-Nov-10
I was reading some of the information on the link you sent....
If channel 1 is an analog input(you must verify this and make the change yourself if it isnt), so im pretty sure you need a stream of data to make the DAC light up.

Issues with current code:
1. ic chips are turned on or off with 1 or 0, 15 might be an issue and might be a grey result.
2. analog is a continuous stream of data, chips read this as on or off, depending on the output.  If it is on or 1, then then chip is recieving 3.5 volts-5.0 volts. If it is off, the analog stream shows as,  0 volts-1.0 volts.  Being an electronics technician i can assure you of this.

So, Sending one small burst of infomation in one frame is not a sufficient for analog, this is fine for digital if it has a memory remembering the last input.
Furthermore, When a digital input is neither on or off, it is actually sending 1.1 volts-3.4 volts, resulting in the "grey" area of an ic chip...no output is resulted in the ic.

Thus, try this altered code, theoretically it should light the led for channel 1, for 5 minutes:
NOTE: i changed the output data to 1...this is ON status, 0 will be OFF, and anything else is "grey"

Code: GLBasic [Select]
limitfps 60  //used to limit frames persecond to allow 5 minute send
port = 1
chip_no = 1
data =1   //original code was 15; data output to an LED should be on or off...1 or 0
a=1  //start numeral of a 5 minute delay

Start_K8000 ()
SelectI2CprinterPort (port)  //*SELECT lpt1 on mainboard
ClearIOchip (chip_no)          //*clear channels 1
ConfigIOchipAsOutput (chip_no) //*configure channels 1 AS outputs

while a<18000  //loop here for 5 minute output stream
a=a+1
IOoutput (Chip_no, Data)        // send data
PRINT "SENDING #: "+a,100,100
SHOWSCREEN
wend

PRINT "sent data",100,100
SHOWSCREEN
MOUSEWAIT

Stop_K8000()                    //stop after use
PRINT "stopped",120,120
SHOWSCREEN
MOUSEWAIT

END
That should work...but if it doesnt try this(this has more information per frame to the chip):
Code: GLBasic [Select]
limitfps 60  //used to limit frames persecond to allow 5 minute send
port = 1
chip_no = 1
data =1   //original code was 15; data output to an LED should be on or off...1 or 0
a=1  //start numeral of a 5 minute delay


Start_K8000 ()

while a<18000  //loop here for 5 minute output stream
a=a+1
SelectI2CprinterPort (port)  //*SELECT lpt1 on mainboard
ClearIOchip (chip_no)          //*clear channels 1
ConfigIOchipAsOutput (chip_no) //*configure channels 1 AS outputs
IOoutput (Chip_no, Data)        // send data
PRINT "SENDING #: "+a,100,100
SHOWSCREEN
wend

PRINT "sent data",100,100
SHOWSCREEN
MOUSEWAIT

Stop_K8000()                    //stop after use
PRINT "stopped",120,120
SHOWSCREEN
MOUSEWAIT

END
PS:
 im reading the information in the code they have available, if i see any indescreptancies with my above code ill edit this particular code above, and ill make note below that it was altered with a timestamp...so check this thread again to see if i edited this section if i found something.

PPS. if it still doesnt work, try changing the channels, in the case this might only work for digital, as opposed to analog input.

Quote
note: this topic has extended to page 2, this is the last post on page 1, anymore replies pushes this topic onto page 2.
-
Title: DLL help
Post by: Maxheadroom on 2006-Nov-10
Gernot,
It’s working!!!!!!!!!!!!!!!!!
Lights are flashing, program below.


The fix was extra files needed to be added to the project dir.
List of files needed: (FOUND ON THE INSTALL CD)


K8D.DLL
K8E.EXE
DLPORTIO.SYS   

Thank you for all your help.
NOW I can unleash the power of GLBASIC. 

Hemlos
Thanks for the help; I can confirm that the output is latched, once set, they hold until a new value is sent.

program
Code: GLBasic [Select]
Start_K8000 ()
SelectI2CprinterPort(1)
ConfigIOchipAsOutput(0)  //*configure channels 1...8 AS outputs*/
ConfigIOchipAsOutput(1)  //*configure channels 9...16 AS outputs*/
ClearIOchip(0)           //*clear channels 1...8*/
ClearIOchip(1)           //*clear channels 9...16*/
loop:

FOR a = 1 TO 16
PRINT a,100,100
SHOWSCREEN
SetIOchannel(a)
UpdateIOchip(1)
UpdateIOchip(0)
FOR slow= 1 TO 10
PRINT slow,200,100
SHOWSCREEN
NEXT


IF KEY(57) = 1 THEN GOTO jum
NEXT
GOTO loop

jum:
Stop_K8000()
PRINT "stopped",120,120
SHOWSCREEN
MOUSEWAIT

END
Title: DLL help
Post by: Hemlos on 2006-Nov-10
so changing the input from 15 to 1 or 0 helps then?
Title: DLL help
Post by: Maxheadroom on 2006-Nov-10
this works as well: but the data is still held even after the program has stopped:
Code: GLBasic [Select]
Start_K8000 ()
SelectI2CprinterPort(1)
ConfigIOchipAsOutput(0)  //*configure channels 1...8 AS outputs*/
ConfigIOchipAsOutput(1)  //*configure channels 9...16 AS outputs*/
ClearIOchip(0)           //*clear channels 1...8*/
ClearIOchip(1)           //*clear channels 9...16*/



SetIOchannel(1)    //data
UpdateIOchip(1)    // send to chip1
UpdateIOchip(0)    // sean to chip0

loop:
IF KEY(57) = 1 THEN GOTO jum
GOTO loop

jum:
Stop_K8000()
PRINT "stopped",120,120
SHOWSCREEN
MOUSEWAIT

END
Title: DLL help
Post by: Kitty Hello on 2006-Nov-12
He missed some dlls - it's working now!