Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conecting to a Power Supply using a Dll and VB 6.0

Status
Not open for further replies.

Erdinger

Technical User
Joined
Jan 18, 2005
Messages
1
Location
DE
I am trying to control a power supply that is connected to my com port through Visual Basic 6.0. The manufacturer of the power supply provided me with a dll and some bad instruction on how to use it. I think I have figured out how to talk to the dll but I am not able to get a connection. Here is the code that I am using to try to connect:



Private Declare Function MBConnect Lib "C:\DllTest\MBMASTER.dll" (ByVal CommPort As Integer, ByVal Timeout As Integer, ByVal BaudRate As String, ByVal Parity As Byte, ByVal StopBits As Byte, ByVal Handshake1 As Boolean, ByVal Handshake2 As Boolean) As Long


and I call the code like this:
Handle = MBConnect(1, 1000, 19200, 0, 2, False, False)

(Handle is supposed to return a key that I use in other commands to reference the connection)

Any ideas??
 
Is the Timeout parameter seconds or miliseconds? If its miliseconds, you may not be allowing enough time (1000 = 1 second) for the function to return a response before the it times out.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
I've spent more time than I care to admit debugging code when the problem ended up being in the hardware so forgive me for asking if you can verify that the COM port, cable, and UPS are all actually working?

Does the manufacturer's software run? (ie: APC PowerChute)
 
Oh, and the hardware I was talking about was a UPS. I used to write control software for robotic systems and every system had a backup power supply.

I though I could save some money by not buying the manufacturer's $100 monitoring software and just writing a little app myself.

I wasted a lot of time trying to figure out why my program couldn't talk to the UPS. The problem turned out to be that it used a non-standard serial cable but I had never noticed it before because a cable always came packed with their software rather than with the UPS.
 
I'd revisit the declare statement...
If you read the [link]Converting C declarations to VB][/url] there are only 2 data types that map to integer.

You may have more luck changing the declarations of integer to long.

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
mattKnight makes an good point because in C the integers are 32 bits long but in VB they are only 16.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top