mchid.dll in excell

The book series by Vincent Himpe

Postby jla » Wed Jan 23, 2013 12:00 am

It is possible to read out a rs232 port in excell.
Is there some one who dith this with a usb port.
I do not mean with a virtuel comm port but with the mchid.dll so that i can read out a usb poort (i2cprobe) in excell or word.
I hope that some one has this information for me.
jla
 
Posts: 8
Joined: Thu Jan 02, 2014 10:38 am

Postby ag » Wed Jan 23, 2013 12:00 am

Hi JLa,

I personally have not tried doing it, but I found an interesting link which might give you some help in trying:

http://www.vbforums.com/showthread.php?625348-Automation-Error

The author of the link seems to want to do just what you are wanting to do, and seemed to be getting very close in succeeding. Maybe there is enough there to help you get you up and running, so check it out.

Regards,
Ag
Ag
ag
 
Posts: 533
Joined: Thu Jan 02, 2014 10:37 am

Postby vincent_himpe » Wed Jan 23, 2013 12:00 am

VBA is NOT the same as regular VB. There are things that do not work.
One of the problems you are going to run into is the data reception. mchid gives a callback and you need to feed it the handler for that. This is done using the 'addressof' function. i do not know if VBA supports that.

i need to take a look at some code i wrote , maybe it is portable to VBA. Alternatively we could use a timer to wait a fixed time and then just go fetch the data.

Something that most people don;t know is that you can instantiate 'missing' elements from VBA at runtime.

dim systimer as new timerdim timerflag as boolean = falsesub form_load     systimer.interval = 10    systimer.enabled=falseend subfunction Exchange ( outgoing as string) as string   ' write to probe here   systimer.enabled=true   launchtimer   while not (timerflag)      doevents  wend  ' read result here  return resultend functionsub launchtimer      timerflag = false      systimer.enabled=trueend launchtimersub systimer_tick      timerflag = true      systimer.enabled=falseend sub



the above code sends the usb string and then starts the systimer. the code goes into a while wend loop and monitors a flag ( timerflag). when the timer expires it sets the flag and disables itself. Then you simply read.

this function 'exchange' takes a string and returns a string. since this is a monolithic function that does 'ping-pong' (string out , string in ) there is no risk for buffer overflows.

i have a piece of code that implements this on the probe. i believe it should be portable to vba.

give me a few days to dig it up ...
vincent_himpe
 
Posts: 23
Joined: Thu Jan 02, 2014 10:38 am

Postby jla » Mon Feb 11, 2013 12:00 am

I have google many time's.
It look like's that no one has built the mchid.dll in a excell sheet.
Visual basic is working but visual basic in excell is a problem.
I hope that it is possible i am waiting.

Suc6
jla
 
Posts: 8
Joined: Thu Jan 02, 2014 10:38 am

Postby vincent_himpe » Mon Feb 11, 2013 12:00 am

The problem is the callback. Incoming data from the USB port raises an internal windows event. That event needs to be attached to the program that wants to be notified.

in a regular VB program this is your main form.
in VBA this would be 'excel'. Since excel doesn't know what this is it rejects it. You would need to find a way to bind the receive interrupt to the form running the VBA code... i'm not even sure that is possible as , when the VBA code stops running the form is destroyed leaving the interrupt pointing nowhere... the form is created upon start and destroyed on exit.

there may be a way , by writing entry and exit code, to grab the interurpt at startup and release it prior to VBA termination but this requires knowing how windows deals with function pointers and how to set them up to grab the receive event. I'm not a programmer i have no clue.
vincent_himpe
 
Posts: 23
Joined: Thu Jan 02, 2014 10:38 am

Postby jla » Tue Feb 12, 2013 12:00 am

Is it possible or is it a virtueel comport:

http://www.youtube.com/watch?v=3KFDLQXWKvQ

suc6
jla
 
Posts: 8
Joined: Thu Jan 02, 2014 10:38 am

Postby vincent_himpe » Tue Feb 12, 2013 12:00 am

what those guys do is create an external program that interacts with excel. they have aprogram running that interfaces with their unit and connects to excel to exchange data.

They give an example on their website. they use a toolkit called Excel-dna.
vincent_himpe
 
Posts: 23
Joined: Thu Jan 02, 2014 10:38 am


Return to LabWorX

Who is online

Users browsing this forum: No registered users and 1 guest