BASIC

Author Topic: DLL help  (Read 16540 times)

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #15 on: 2006-Nov-02 »
Tonight it WILL work!

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #16 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...

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
DLL help
« Reply #17 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.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10719
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
DLL help
« Reply #18 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.

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #19 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)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10719
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
DLL help
« Reply #20 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?

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #21 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...

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10719
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
DLL help
« Reply #22 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.

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #23 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

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
DLL help
« Reply #24 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.
-
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #25 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

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
DLL help
« Reply #26 on: 2006-Nov-10 »
so changing the input from 15 to 1 or 0 helps then?
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
DLL help
« Reply #27 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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10719
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
DLL help
« Reply #28 on: 2006-Nov-12 »
He missed some dlls - it's working now!