Servo control with vb after packaging problems

Hi all this might be better asked in a vb group, but i would like to ask here as well.. I am controlling servos via lpt with VB Just giving servo 5v and pulsing out lpt line to servo with following code

Dim icount As Integer For icount = 1 To 75 Call PortOut(888, 1) Threading.Thread.Sleep(0.8) Call PortOut(888, 0) Next icount Return

Everything works great when i run project within VB

but the servos do not work correctly if i run from a Build or Publish of project,, any ideas? TIA Mike

Reply to
Mitch__
Loading thread data ...

I'm not a VB user, but I wonder what version of Windows you are using. The direct I/O commands should be fine in Win9x, but NT and later need a special Ring 0 driver for direct access. So, assuming you are runing a recent Windows version, can it be that the required driver is built into VB, but is not automatically included in Build or Publish versions? This is what I'd expect, since (as far as I can tell) the driver has to be loaded like other drivers, at system start-up, not at run time like a DLL.

If this is what is really happening, and VB doesn't provide a stand-alone port access driver, the two that I've heard of are GIVEIO and USERPORT. Maybe your code will run with one of those intalled.

Best regards,

Bob Masta D A Q A R T A Data AcQuisition And Real-Time Analysis

formatting link
Scope, Spectrum, Spectrogram, Signal Generator Science with your sound card!

Reply to
Bob Masta

Im runing xp pro, and i had to install a dll io.dll for my program to work correctly when i run the packaged exe, the servos move but not very much and not even 1/4 of the amount that they do when i am actually running from within VB .. thanks for the reply..

Reply to
Mitch__

Don't you need some delay here as well? I assume you're trying to make some kind of wave form here. If so, you need some idle time on the bottom as well. Otherwise your waves are going to have only the smallest low time. The EXE version would run faster making the pulse low time almost nonexistent.

To drive a standard RC servo, you want the pulse width to be between 1 and 2 mS with 1.5mS width representing the center position of the servo motor. If I understand, the SLEEP thing above is only pausing for 750uS (like I really believe that windos can successfully do that, repeatedly ;-). Seems like you should change the .8 to 1.5 and also add another SLEEP for about 50mS after the second call to PortOut to give the servo a rest. This would give you an update rate of a bit under 20 pulses per second, something the servo would like to see I'm sure. ;-)

Maybe this will help you too:

formatting link

Every once in a while I do something with VB and then when the project starts getting the slightest bit complicated, I remember why I don't use it much. IT DOESN'T WORK RIGHT, ARGHHHH! ;-)

Reply to
Anthony Fremont

too:

formatting link

thank you very much.

Reply to
Mitch__

Might be speed differences between running in the IDE and running the compiled version. Note that Thread.Sleep accepts an integer argument, not a floating point number. You can't reliably specify microseconds in there. (Might work in the current example because the 800uS get rounded to 1mS.)

Regards, Gilles.

Reply to
Gilles Kohl

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.