Connect with us

Servo control with vb after packaging problems

Discussion in 'Electronic Basics' started by Mitch__, Mar 26, 2007.

Scroll to continue with content
  1. Mitch__

    Mitch__ Guest

    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

    Dim icount As Integer
    For icount = 1 To 75
    Call PortOut(888, 1)
    Call PortOut(888, 0)
    Next icount

    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?
  2. Bob Masta

    Bob Masta Guest

    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
    Scope, Spectrum, Spectrogram, Signal Generator
    Science with your sound card!
  3. Mitch__

    Mitch__ Guest

    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..
  4. 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

    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:

    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
  5. Mitch__

    Mitch__ Guest

    thank you very much.
  6. Gilles Kohl

    Gilles Kohl Guest

    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.)

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day