Shop OBEX P1 Docs P2 Docs Learn Events
PULSOUT maths — Parallax Forums

PULSOUT maths

ArchiverArchiver Posts: 46,084
edited 2001-10-16 00:24 in General Discussion
This works for me. Try this code with your servo.

'Servo signal on pin0
'Fully CW = 180
'Fully CCW = 1170



'Variables & Constants
Counter Var Byte
Position Var Word
ToServo Con 0

'*********************Main Program

Start:

For Position = 180 To 1170 Step 20
Pulsout ToServo, Position
Pause 15
Next

For Position = 1170 To 180 Step 20
Pulsout ToServo, Position
Pause 15
Next

Goto Start



Original Message
From: Justin [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=TkTPFnWuK0aWtAWo7_wmKPlCOLazo2iUZIVyx_PbRg-gBCnae1fAiHvfqJpkjvoohviBbv8de8JOSUVJjw]justin@j...[/url
Sent: Monday, October 15, 2001 9:35 AM
To: Basicstamps (E-mail)
Subject: [noparse][[/noparse]basicstamps] PULSOUT maths

Hi all.

Can someone please check my reasoning here ? I want to generate a 1.5ms
pulse from a BS2-SX to control a servo.

The stamp manual (v2.0) states that the BS2-SX handles Period values in
0.8us increments.

Given that 1us = 1/1000000 = 0.000001s
and 0.8us = 0.000001 / 10 * 8 = 0.0000008s

Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s), I
need to use the following sum;

0.0015 / 0.0000008 = 1875

But, when I run my program, the servo receiving the pulse won't stand still
!

I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
pulse and all is ok - it stops nicely and goes forward or backwards when the
pulse moves either side of 1.5ms.

I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.

I know this is a very basic question but I've spent too many late nights
trying to figure it out ! Can anyone tell me what stupid mistake I've made
?

Thanks in advance,
Justin.



To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 14:35
    Hi all.

    Can someone please check my reasoning here ? I want to generate a 1.5ms
    pulse from a BS2-SX to control a servo.

    The stamp manual (v2.0) states that the BS2-SX handles Period values in
    0.8us increments.

    Given that 1us = 1/1000000 = 0.000001s
    and 0.8us = 0.000001 / 10 * 8 = 0.0000008s

    Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s), I
    need to use the following sum;

    0.0015 / 0.0000008 = 1875

    But, when I run my program, the servo receiving the pulse won't stand still
    !

    I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
    pulse and all is ok - it stops nicely and goes forward or backwards when the
    pulse moves either side of 1.5ms.

    I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.

    I know this is a very basic question but I've spent too many late nights
    trying to figure it out ! Can anyone tell me what stupid mistake I've made
    ?

    Thanks in advance,
    Justin.
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 14:37
    Two things to consider:

    You *should* run your servos off a separate battery from the Stamp. Be sure
    the grounds for the servo and Stamp batteries are tied together. If you
    can't run two batteries, you need to make sure the battery you are using can
    supply enough power to run both the servo and Stamp, and you must provide
    some filtering to prevent the servo motor noise from making the Stamp reset.
    When the stamp resets the servo may chatter or move slightly.

    The values for calculating the PULSOUT units are an average. Because the
    clock frequency on the Stamp will vary slightly, these figures will also
    vary. On my BS2SX robot 1550 is the PULSOUT value to move the servo to the
    center of the travel. If you have too high or low a value, the servo will
    turn all the way one way or the other, bang against the stops and chatter
    away.

    Original Message

    > Can someone please check my reasoning here ? I want to generate a 1.5ms
    > pulse from a BS2-SX to control a servo.
    >
    > The stamp manual (v2.0) states that the BS2-SX handles Period values in
    > 0.8us increments.
    >
    > Given that 1us = 1/1000000 = 0.000001s
    > and 0.8us = 0.000001 / 10 * 8 = 0.0000008s
    >
    > Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s), I
    > need to use the following sum;
    >
    > 0.0015 / 0.0000008 = 1875
    >
    > But, when I run my program, the servo receiving the pulse won't stand
    still
    > !
    >
    > I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
    > pulse and all is ok - it stops nicely and goes forward or backwards when
    the
    > pulse moves either side of 1.5ms.
    >
    > I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.
    >
    > I know this is a very basic question but I've spent too many late nights
    > trying to figure it out ! Can anyone tell me what stupid mistake I've
    made
    > ?
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 14:46
    Thanks for the offer but the servo still won't play. Are you running your
    code on a BS2-SX ?

    Original Message
    From: Dennie Bishop [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=C5c61XrDkdtLDGZ9s1XyVyL6mQTnPpnOLfShebRePyFtvziW13zefcf-1v6MnAWKpJPCuhI9Zqd1eygpURq3Nbww0vsXzy4wwwiO]dbishop@e...[/url
    Sent: 15 October 2001 14:28
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] PULSOUT maths


    This works for me. Try this code with your servo.

    'Servo signal on pin0
    'Fully CW = 180
    'Fully CCW = 1170



    'Variables & Constants
    Counter Var Byte
    Position Var Word
    ToServo Con 0

    '*********************Main Program

    Start:

    For Position = 180 To 1170 Step 20
    Pulsout ToServo, Position
    Pause 15
    Next

    For Position = 1170 To 180 Step 20
    Pulsout ToServo, Position
    Pause 15
    Next

    Goto Start



    Original Message
    From: Justin [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=-G32xZZ2bEuchcApSx6uammAB99Y050DyOhSH-QdgS97owkD-MngQvlxTdiw2_2y8mB2fivnF99H-Z8vxWkRwZbJ]justin@j...[/url
    Sent: Monday, October 15, 2001 9:35 AM
    To: Basicstamps (E-mail)
    Subject: [noparse][[/noparse]basicstamps] PULSOUT maths

    Hi all.

    Can someone please check my reasoning here ? I want to generate a 1.5ms
    pulse from a BS2-SX to control a servo.

    The stamp manual (v2.0) states that the BS2-SX handles Period values in
    0.8us increments.

    Given that 1us = 1/1000000 = 0.000001s
    and 0.8us = 0.000001 / 10 * 8 = 0.0000008s

    Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s), I
    need to use the following sum;

    0.0015 / 0.0000008 = 1875

    But, when I run my program, the servo receiving the pulse won't stand still
    !

    I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
    pulse and all is ok - it stops nicely and goes forward or backwards when the
    pulse moves either side of 1.5ms.

    I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.

    I know this is a very basic question but I've spent too many late nights
    trying to figure it out ! Can anyone tell me what stupid mistake I've made
    ?

    Thanks in advance,
    Justin.



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 15:18
    Doh !
    I can't believe I forgot to tie the grounds together.

    Thanks :-)


    Original Message
    From: Rodent [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=BMmDTOKqTE2ylVdAMFX-La0_GZ5nTwswsg-jsx2RWxKSq9lTos6p3YVxwbPy4F6_NReGHnPfzK7x]daweasel@s...[/url
    Sent: 15 October 2001 14:37
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] PULSOUT maths


    Two things to consider:

    You *should* run your servos off a separate battery from the Stamp. Be sure
    the grounds for the servo and Stamp batteries are tied together. If you
    can't run two batteries, you need to make sure the battery you are using can
    supply enough power to run both the servo and Stamp, and you must provide
    some filtering to prevent the servo motor noise from making the Stamp reset.
    When the stamp resets the servo may chatter or move slightly.

    The values for calculating the PULSOUT units are an average. Because the
    clock frequency on the Stamp will vary slightly, these figures will also
    vary. On my BS2SX robot 1550 is the PULSOUT value to move the servo to the
    center of the travel. If you have too high or low a value, the servo will
    turn all the way one way or the other, bang against the stops and chatter
    away.

    Original Message

    > Can someone please check my reasoning here ? I want to generate a 1.5ms
    > pulse from a BS2-SX to control a servo.
    >
    > The stamp manual (v2.0) states that the BS2-SX handles Period values in
    > 0.8us increments.
    >
    > Given that 1us = 1/1000000 = 0.000001s
    > and 0.8us = 0.000001 / 10 * 8 = 0.0000008s
    >
    > Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s), I
    > need to use the following sum;
    >
    > 0.0015 / 0.0000008 = 1875
    >
    > But, when I run my program, the servo receiving the pulse won't stand
    still
    > !
    >
    > I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
    > pulse and all is ok - it stops nicely and goes forward or backwards when
    the
    > pulse moves either side of 1.5ms.
    >
    > I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.
    >
    > I know this is a very basic question but I've spent too many late nights
    > trying to figure it out ! Can anyone tell me what stupid mistake I've
    made
    > ?




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 15:26
    BTDT. Spend a week trying to get my first servo working.

    Original Message

    > Doh !
    > I can't believe I forgot to tie the grounds together.

    >
    Original Message

    > Two things to consider:
    >
    > You *should* run your servos off a separate battery from the Stamp. Be
    sure
    > the grounds for the servo and Stamp batteries are tied together. If you
    > can't run two batteries, you need to make sure the battery you are using
    can
    > supply enough power to run both the servo and Stamp, and you must provide
    > some filtering to prevent the servo motor noise from making the Stamp
    reset.
    > When the stamp resets the servo may chatter or move slightly.
    >
    > The values for calculating the PULSOUT units are an average. Because the
    > clock frequency on the Stamp will vary slightly, these figures will also
    > vary. On my BS2SX robot 1550 is the PULSOUT value to move the servo to the
    > center of the travel. If you have too high or low a value, the servo will
    > turn all the way one way or the other, bang against the stops and chatter
    > away.
    >
    >
    Original Message
    >
    > > Can someone please check my reasoning here ? I want to generate a 1.5ms
    > > pulse from a BS2-SX to control a servo.
    > >
    > > The stamp manual (v2.0) states that the BS2-SX handles Period values in
    > > 0.8us increments.
    > >
    > > Given that 1us = 1/1000000 = 0.000001s
    > > and 0.8us = 0.000001 / 10 * 8 = 0.0000008s
    > >
    > > Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s),
    I
    > > need to use the following sum;
    > >
    > > 0.0015 / 0.0000008 = 1875
    > >
    > > But, when I run my program, the servo receiving the pulse won't stand
    > still
    > > !
    > >
    > > I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
    > > pulse and all is ok - it stops nicely and goes forward or backwards when
    > the
    > > pulse moves either side of 1.5ms.
    > >
    > > I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.
    > >
    > > I know this is a very basic question but I've spent too many late nights
    > > trying to figure it out ! Can anyone tell me what stupid mistake I've
    > made
    > > ?
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 15:46
    DOH!

    I have to double-triple-check alot my work because my brain takes a holiday
    periodically. I can remember the right way to do something, but my hands go
    off on their own and do the wrong things.

    Original Message

    > Yeah - but this isn't my first servo !!
    >
    >
    Original Message

    > BTDT. Spend a week trying to get my first servo working.
    >
    >
    Original Message
    >
    > > Doh !
    > > I can't believe I forgot to tie the grounds together.
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 15:52
    Yeah - but this isn't my first servo !!

    Original Message
    From: Rodent [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Cbs5ZxuJHHAf9dnGpI5p92cIUZjJFb9ZyY16w2yVsYPRTsAPKs6suyi0eU1BnlAgUF-oJdGA4ul0]daweasel@s...[/url
    Sent: 15 October 2001 15:26
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] PULSOUT maths


    BTDT. Spend a week trying to get my first servo working.

    Original Message

    > Doh !
    > I can't believe I forgot to tie the grounds together.

    >
    Original Message

    > Two things to consider:
    >
    > You *should* run your servos off a separate battery from the Stamp. Be
    sure
    > the grounds for the servo and Stamp batteries are tied together. If you
    > can't run two batteries, you need to make sure the battery you are using
    can
    > supply enough power to run both the servo and Stamp, and you must provide
    > some filtering to prevent the servo motor noise from making the Stamp
    reset.
    > When the stamp resets the servo may chatter or move slightly.
    >
    > The values for calculating the PULSOUT units are an average. Because the
    > clock frequency on the Stamp will vary slightly, these figures will also
    > vary. On my BS2SX robot 1550 is the PULSOUT value to move the servo to the
    > center of the travel. If you have too high or low a value, the servo will
    > turn all the way one way or the other, bang against the stops and chatter
    > away.
    >
    >
    Original Message
    >
    > > Can someone please check my reasoning here ? I want to generate a 1.5ms
    > > pulse from a BS2-SX to control a servo.
    > >
    > > The stamp manual (v2.0) states that the BS2-SX handles Period values in
    > > 0.8us increments.
    > >
    > > Given that 1us = 1/1000000 = 0.000001s
    > > and 0.8us = 0.000001 / 10 * 8 = 0.0000008s
    > >
    > > Ok, I think this means that to generate a 1.5ms pulse (1.5ms = 0.0015s),
    I
    > > need to use the following sum;
    > >
    > > 0.0015 / 0.0000008 = 1875
    > >
    > > But, when I run my program, the servo receiving the pulse won't stand
    > still
    > > !
    > >
    > > I have tested and calibrated the servo with a BS-1 which outputs a 1.5ms
    > > pulse and all is ok - it stops nicely and goes forward or backwards when
    > the
    > > pulse moves either side of 1.5ms.
    > >
    > > I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.
    > >
    > > I know this is a very basic question but I've spent too many late nights
    > > trying to figure it out ! Can anyone tell me what stupid mistake I've
    > made
    > > ?




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-15 23:30
    Make sure you have the pause or delay between the pulses to
    move the stamp.

    Like this:

    vector var word
    vector = 2000
    servo:
    pulsout pin,vector
    pause 20
    goto servo

    Change the vector variable to move the servo. If there is sufficient
    delay in your program between the servo pulses, you may or ,ay
    not need the pause line.

    Doug
    This will move the servo to the 2000 location and hold it there.


    On 15 Oct 2001, at 14:35, Justin wrote:

    > Hi all.
    >
    > Can someone please check my reasoning here ? I want to generate a
    > 1.5ms pulse from a BS2-SX to control a servo.
    >
    > The stamp manual (v2.0) states that the BS2-SX handles Period values
    > in 0.8us increments.
    >
    > Given that 1us = 1/1000000 = 0.000001s
    > and 0.8us = 0.000001 / 10 * 8 = 0.0000008s
    >
    > Ok, I think this means that to generate a 1.5ms pulse (1.5ms =
    > 0.0015s), I need to use the following sum;
    >
    > 0.0015 / 0.0000008 = 1875
    >
    > But, when I run my program, the servo receiving the pulse won't stand
    > still !
    >
    > I have tested and calibrated the servo with a BS-1 which outputs a
    > 1.5ms pulse and all is ok - it stops nicely and goes forward or
    > backwards when the pulse moves either side of 1.5ms.
    >
    > I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.
    >
    > I know this is a very basic question but I've spent too many late
    > nights trying to figure it out ! Can anyone tell me what stupid
    > mistake I've made ?
    >
    > Thanks in advance,
    > Justin.
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-16 00:24
    Thanks for the suggestion - it was because I'm using separate power supplies
    for the CPU and the servos and I hadn't tied the grounds together. At least
    I know my maths were right !!

    Justin.


    Original Message
    From: veewee77@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=srtVS7hAMGeu0R8ghyAPiGotTc96124fLEFJZim3nvmhM8iFRhnrEAtLYzU8YIWLOQYvM60Yz5G-lLaC1w]veewee77@a...[/url
    Sent: 15 October 2001 23:31
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] PULSOUT maths


    Make sure you have the pause or delay between the pulses to
    move the stamp.

    Like this:

    vector var word
    vector = 2000
    servo:
    pulsout pin,vector
    pause 20
    goto servo

    Change the vector variable to move the servo. If there is sufficient
    delay in your program between the servo pulses, you may or ,ay
    not need the pause line.

    Doug
    This will move the servo to the 2000 location and hold it there.


    On 15 Oct 2001, at 14:35, Justin wrote:

    > Hi all.
    >
    > Can someone please check my reasoning here ? I want to generate a
    > 1.5ms pulse from a BS2-SX to control a servo.
    >
    > The stamp manual (v2.0) states that the BS2-SX handles Period values
    > in 0.8us increments.
    >
    > Given that 1us = 1/1000000 = 0.000001s
    > and 0.8us = 0.000001 / 10 * 8 = 0.0000008s
    >
    > Ok, I think this means that to generate a 1.5ms pulse (1.5ms =
    > 0.0015s), I need to use the following sum;
    >
    > 0.0015 / 0.0000008 = 1875
    >
    > But, when I run my program, the servo receiving the pulse won't stand
    > still !
    >
    > I have tested and calibrated the servo with a BS-1 which outputs a
    > 1.5ms pulse and all is ok - it stops nicely and goes forward or
    > backwards when the pulse moves either side of 1.5ms.
    >
    > I've tried values from 1250 ( 1ms) to 2500 (2ms) but with no luck.
    >
    > I know this is a very basic question but I've spent too many late
    > nights trying to figure it out ! Can anyone tell me what stupid
    > mistake I've made ?
    >
    > Thanks in advance,
    > Justin.
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sign In or Register to comment.