Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsElectronicsBasicsRepairDesignCADComponentsEquipmentElectrical Engineering
ElectronicsKB.com
Contact UsLink To UsSearch & Site Map

Electronics Forum / Electronics / March 2007



Tip: Looking for answers? Try searching our database.

Servo control with vb after packaging problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mitch__ - 26 Mar 2007 01:47 GMT
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
The Real Andy - 26 Mar 2007 08:24 GMT
>Hi all
>this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 18 lines]
>TIA
>Mike

What version of VB are you using?
Mitch__ - 26 Mar 2007 23:08 GMT
> >Hi all
> >this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 22 lines]
>
> - Show quoted text -

vb 2005
Poxy - 26 Mar 2007 11:35 GMT
> Hi all
> this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 10 lines]
>                 Next icount
>                 Return

Forgive me if I'm missing something - I'm not a VB programmer, but servos
want a +ve pulse time of between 1ms and 2ms (the range varies with
different servos, but the mid point is generally around 1.5ms), with a -ve
time of around 10ms or longer. From the look of that code, the output goes
high for 0.8ms, then low and immediately loops and goes high again - it may
be that the low time is insufficient.

I'd suggest adding another Sleep command, after the output goes low, perhaps
10ms, but shorter may well work if you need it to. You also need to make
sure 0.8ms doesn't exceed the range of travel of your servo or you might
strip the gears.
Mitch__ - 26 Mar 2007 23:12 GMT
> > Hi all
> > this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 22 lines]
> sure 0.8ms doesn't exceed the range of travel of your servo or you might
> strip the gears.

hmm im using sleep for 0.8 to turn motor one way and 1.0 to move it
the other way,, but i do believe i am not controlling the servo
correctly, because i am just moving it one way or another for an
amount of time, when what i should be doing is pulsing properly and
the servo will move to its position and stay there,,
i think you are on to something for me here,, i am going to put a
second sleep in.
thanks
Poxy - 26 Mar 2007 23:42 GMT
> > > Hi all
> > > this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 31 lines]
> second sleep in.
> thanks

You are using common R/C servos? In that case, yes, they are designed to
move to a fixed position depending on the +ve pulse width - a 1ms pulse is
one extreme of the output shaft's travel, a 2ms pulse is the other extreme
and a 1.5ms pulse is halfway.
Brenden Ede - 28 Mar 2007 09:26 GMT
Hi Mitch,
        The real problem you're going to have with VB or any Windows
operating system is that they're not 'real time' designed.
The operating system doesn't give any program an exact number of cycles
per second and thus controlling servos, which require an accurately
timed signal, is really an uphill battle.

The normal method is to offload the 'real time' elements to a
microcontroller. There are lots of microcontroller based servo driver
boards that run from a serial RS232 port and even some USB ones.

If you would like I can give you firmware for a servo driver that runs
on a really cheap PIC12C50x or PIC12F50x and runs 4 servos. This runs
from 2400/4800 baud serial that can come from a serial port or
USB-Serial converter unit.

Then just use MSCOMM to send serial bytes to the port and the
microcontroller takes care of all the timing critical servo signal
generation.

For parts and postage cost I could send you the chips, pre programmed.

If you want some of these, please correct the deliberate spelling error
in my email and remove the nospam.

Regards,
        Brenden Ede

>>>> Hi all
>>>> this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 38 lines]
> one extreme of the output shaft's travel, a 2ms pulse is the other extreme
> and a 1.5ms pulse is halfway.
The Real Andy - 29 Mar 2007 09:38 GMT
>Hi Mitch,
>         The real problem you're going to have with VB or any Windows
[quoted text clipped - 23 lines]
>Regards,
>         Brenden Ede

You can get pretty damn close if you know where to look in the API. If
it is a hobby application then windows should suffice. Do a google for
performance counters, its well documented around the net. IIRC i have
also read about multimedia timers being quite accurate, but I know
nothing about them.

One point is worth mentioning, do it all by polling on a single
thread, not with events. :) ALso set thread priority to high!

>>>>> Hi all
>>>>> this might be better asked in a vb group, but i would like to ask here
[quoted text clipped - 38 lines]
>> one extreme of the output shaft's travel, a 2ms pulse is the other extreme
>> and a 1.5ms pulse is halfway.
Andy Wood - 26 Mar 2007 22:29 GMT
. . .
>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,,

Are you trying to run it on the same system you built it on?

Andy Wood
woodag@trap.ozemail.com.au
Mitch__ - 26 Mar 2007 23:07 GMT
> . . .
>
[quoted text clipped - 7 lines]
> Andy Wood
> woo...@trap.ozemail.com.au

yes same system
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.