Shop OBEX P1 Docs P2 Docs Learn Events
stamp1 and model train — Parallax Forums

stamp1 and model train

ArchiverArchiver Posts: 46,084
edited 2003-10-27 15:44 in General Discussion
what im trying to do is
read a high on pin 0 then pwm the moter clockwise via H-Bridge
read a high on pin 1 then pwm then motor anticlock via H-Bridge
There must be a better way ????
EG.
symbol fspeed =w1
symbol bspeed =w2
let dirs = %11110000
let pins = %00000000
fspeed = 0
bspeed = 0

start:
if pin0 = 1 then forw
if pin1 = 1 then back
if pin2 = 1 then trainstop
pwm 4,fspeed,1
pwm 5,bspeed,1
goto start

forw:
fspeed = fspeed +1
if fspeed =>255 then ffull
bspeed = 0
pause 50
goto start

back:
bspeed = bspeed +1
if bspeed =>255 then bfull
fspeed = 0
pause 50
goto start

trainstop:
fspeed = 0
bspeed = 0
pin4=0
pin5=0
goto start

ffull:
fspeed = 255
bspeed=0
goto start

bfull:
bspeed=255
fspeed=0
goto start

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-09-03 21:17
    Hi Andy,

    I use a motorcontroller which is used for truckmodels or small ships. It has
    a H-bridge in it and the input is the same pulse input as for a standard
    servomotor for aircraftmodels etc. The controller can do max ca. 15V at 1
    amp, the peakload is 2 amps.

    Stampcontrol is: pulsout .... ms and off you go!!!!!

    That's all.

    I hope y can find something like this in your neighbourhood.

    Klaus

    Oorspronkelijk bericht
    Van: Andy Quirot [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=APpfBvcIBefp4XBIXsd87FosQiPecvllNE59VDQj0vg4n8B78sdyXkloa5XQAbEejLTuvt--ggy40NBFTAc]andyquirot1@h...[/url
    Verzonden: 03 09 2003 20:13
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] re stamp1 and model train


    what im trying to do is
    read a high on pin 0 then pwm the moter clockwise via H-Bridge
    read a high on pin 1 then pwm then motor anticlock via H-Bridge
    There must be a better way ????
    EG.
    symbol fspeed =w1
    symbol bspeed =w2
    let dirs = %11110000
    let pins = %00000000
    fspeed = 0
    bspeed = 0

    start:
    if pin0 = 1 then forw
    if pin1 = 1 then back
    if pin2 = 1 then trainstop
    pwm 4,fspeed,1
    pwm 5,bspeed,1
    goto start

    forw:
    fspeed = fspeed +1
    if fspeed =>255 then ffull
    bspeed = 0
    pause 50
    goto start

    back:
    bspeed = bspeed +1
    if bspeed =>255 then bfull
    fspeed = 0
    pause 50
    goto start

    trainstop:
    fspeed = 0
    bspeed = 0
    pin4=0
    pin5=0
    goto start

    ffull:
    fspeed = 255
    bspeed=0
    goto start

    bfull:
    bspeed=255
    fspeed=0
    goto start





    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 2003-09-03 22:51
    If I recall, one of the first Basic Stamp books I read (The actual BS
    manual? One of the "Nuts and Volts of Basic Stamps" volumes?
    "Microcontroller Projects Using the BASIC Stamp"?) had a very interesting
    story describing how to use a Basic Stamp and an LCD display and c couple
    of buttons to control three z scale model trains. The article was
    WONDERFUL as it went over the design process, the limitations of hardware
    and then provided the finished code and schematics so anyone could
    replicate the results.

    I just can't remember *which* book had the description! I *think* it was
    maybe Al Williams that wrote the article? Maybe Jon? Dang it was a good
    article, wish I could give the source. Jon, Al? can you help jog my
    memory?

    [noparse]:)[/noparse]

    Vern

    --
    Vern Graner CNE/CNA/SSE | "If the network is down, then you're
    Senior Systems Engineer | obviously incompetent so why are we
    Texas Information Services | paying you? Of course, if the network
    vern@t... www.txis.com | is up, then we obviously don't need
    Cell 507-7851 Desk 328-8947 | you, so why are we paying you?" VLG



    Andy Quirot said:
    > what im trying to do is
    > read a high on pin 0 then pwm the moter clockwise via H-Bridge
    > read a high on pin 1 then pwm then motor anticlock via H-Bridge
    > There must be a better way ????
    > EG.
    > symbol fspeed =w1
    > symbol bspeed =w2
    > let dirs = %11110000
    > let pins = %00000000
    > fspeed = 0
    > bspeed = 0
    >
    > start:
    > if pin0 = 1 then forw
    > if pin1 = 1 then back
    > if pin2 = 1 then trainstop
    > pwm 4,fspeed,1
    > pwm 5,bspeed,1
    > goto start
    >
    > forw:
    > fspeed = fspeed +1
    > if fspeed =>255 then ffull
    > bspeed = 0
    > pause 50
    > goto start
    >
    > back:
    > bspeed = bspeed +1
    > if bspeed =>255 then bfull
    > fspeed = 0
    > pause 50
    > goto start
    >
    > trainstop:
    > fspeed = 0
    > bspeed = 0
    > pin4=0
    > pin5=0
    > goto start
    >
    > ffull:
    > fspeed = 255
    > bspeed=0
    > goto start
    >
    > bfull:
    > bspeed=255
    > fspeed=0
    > goto start
    >
    >
    >
    >
    >
    > 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 2003-09-04 23:12
    hmmm.. are my posts even getting through to the list?

    I was hoping Al or Jon might respond to this one...? Do either of you
    remember the article on controlling a set of three model trains with a
    BS1?

    Vernon Graner said:
    > If I recall, one of the first Basic Stamp books I read (The actual BS
    > manual? One of the "Nuts and Volts of Basic Stamps" volumes?
    > "Microcontroller Projects Using the BASIC Stamp"?) had a very interesting
    > story describing how to use a Basic Stamp and an LCD display and c couple
    > of buttons to control three z scale model trains. The article was
    > WONDERFUL as it went over the design process, the limitations of hardware
    > and then provided the finished code and schematics so anyone could
    > replicate the results.
    >
    > I just can't remember *which* book had the description! I *think* it was
    > maybe Al Williams that wrote the article? Maybe Jon? Dang it was a good
    > article, wish I could give the source. Jon, Al? can you help jog my
    > memory?
    >
    > [noparse]:)[/noparse]
    >
    > Vern
    >
    > Andy Quirot said:
    >> what im trying to do is
    >> read a high on pin 0 then pwm the moter clockwise via H-Bridge
    >> read a high on pin 1 then pwm then motor anticlock via H-Bridge
    >> There must be a better way ????
    >> EG.
    >> symbol fspeed =w1
    >> symbol bspeed =w2
    >> let dirs = %11110000
    >> let pins = %00000000
    >> fspeed = 0
    >> bspeed = 0
    >>
    >> start:
    >> if pin0 = 1 then forw
    >> if pin1 = 1 then back
    >> if pin2 = 1 then trainstop
    >> pwm 4,fspeed,1
    >> pwm 5,bspeed,1
    >> goto start
    >>
    >> forw:
    >> fspeed = fspeed +1
    >> if fspeed =>255 then ffull
    >> bspeed = 0
    >> pause 50
    >> goto start
    >>
    >> back:
    >> bspeed = bspeed +1
    >> if bspeed =>255 then bfull
    >> fspeed = 0
    >> pause 50
    >> goto start
    >>
    >> trainstop:
    >> fspeed = 0
    >> bspeed = 0
    >> pin4=0
    >> pin5=0
    >> goto start
    >>
    >> ffull:
    >> fspeed = 255
    >> bspeed=0
    >> goto start
    >>
    >> bfull:
    >> bspeed=255
    >> fspeed=0
    >> goto start
  • ArchiverArchiver Posts: 46,084
    edited 2003-09-05 00:20
    It wasn't me -- I haven't got the train bug....

    Al Williams
    AWC
    * NEW: PAK-VIa - Read PS/2 keyboards or mice -- double the buffer, lower
    current consumption.
    http://www.al-williams.com/awce/pak6.htm




    >
    Original Message
    > From: Vernon Graner [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Oeomsro7lj28MfCXjwsh7IaQa_PNuk1VTIvwpB1CONhd8W9iA1NiHnK11tIPijeOEK-zNg]vern@t...[/url
    > Sent: Thursday, September 04, 2003 5:13 PM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] re stamp1 and model train
    >
    >
    > hmmm.. are my posts even getting through to the list?
    >
    > I was hoping Al or Jon might respond to this one...? Do
    > either of you remember the article on controlling a set of
    > three model trains with a BS1?
    >
    > Vernon Graner said:
    > > If I recall, one of the first Basic Stamp books I read (The
    > actual BS
    > > manual? One of the "Nuts and Volts of Basic Stamps" volumes?
    > > "Microcontroller Projects Using the BASIC Stamp"?) had a very
    > > interesting story describing how to use a Basic Stamp and an LCD
    > > display and c couple of buttons to control three z scale
    > model trains.
    > > The article was WONDERFUL as it went over the design process, the
    > > limitations of hardware and then provided the finished code and
    > > schematics so anyone could replicate the results.
    > >
    > > I just can't remember *which* book had the description! I
    > *think* it
    > > was maybe Al Williams that wrote the article? Maybe Jon?
    > Dang it was a
    > > good article, wish I could give the source. Jon, Al? can
    > you help jog
    > > my memory?
    > >
    > > [noparse]:)[/noparse]
    > >
    > > Vern
    > >
    > > Andy Quirot said:
    > >> what im trying to do is
    > >> read a high on pin 0 then pwm the moter clockwise via
    > H-Bridge read a
    > >> high on pin 1 then pwm then motor anticlock via H-Bridge
    > There must
    > >> be a better way ???? EG.
    > >> symbol fspeed =w1
    > >> symbol bspeed =w2
    > >> let dirs = %11110000
    > >> let pins = %00000000
    > >> fspeed = 0
    > >> bspeed = 0
    > >>
    > >> start:
    > >> if pin0 = 1 then forw
    > >> if pin1 = 1 then back
    > >> if pin2 = 1 then trainstop
    > >> pwm 4,fspeed,1
    > >> pwm 5,bspeed,1
    > >> goto start
    > >>
    > >> forw:
    > >> fspeed = fspeed +1
    > >> if fspeed =>255 then ffull
    > >> bspeed = 0
    > >> pause 50
    > >> goto start
    > >>
    > >> back:
    > >> bspeed = bspeed +1
    > >> if bspeed =>255 then bfull
    > >> fspeed = 0
    > >> pause 50
    > >> goto start
    > >>
    > >> trainstop:
    > >> fspeed = 0
    > >> bspeed = 0
    > >> pin4=0
    > >> pin5=0
    > >> goto start
    > >>
    > >> ffull:
    > >> fspeed = 255
    > >> bspeed=0
    > >> goto start
    > >>
    > >> bfull:
    > >> bspeed=255
    > >> fspeed=0
    > >> goto start
    >
    >
    > 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 2003-09-05 01:02
    You're looking for BASIC Stamp app note 21, "Fun with Trains". Those
    app notes were written by Scott Edwards, I believe. You can download
    them from
    http://www.parallax.com
    http://www.parallax.com/dl/appnt/stamps/bs1%20appnotes.pdf

    Those app notes, even though written for the BS1, are still very
    informative today for the BS2 family.

    -- Tracy



    >hmmm.. are my posts even getting through to the list?
    >
    >I was hoping Al or Jon might respond to this one...? Do either of you
    >remember the article on controlling a set of three model trains with a
    >BS1?
    >
    >Vernon Graner said:
    >> If I recall, one of the first Basic Stamp books I read (The actual BS
    >> manual? One of the "Nuts and Volts of Basic Stamps" volumes?
    >> "Microcontroller Projects Using the BASIC Stamp"?) had a very interesting
    >> story describing how to use a Basic Stamp and an LCD display and c couple
    >> of buttons to control three z scale model trains. The article was
    >> WONDERFUL as it went over the design process, the limitations of hardware
    >> and then provided the finished code and schematics so anyone could
    >> replicate the results.
    >>
    >> I just can't remember *which* book had the description! I *think* it was
    >> maybe Al Williams that wrote the article? Maybe Jon? Dang it was a good
    >> article, wish I could give the source. Jon, Al? can you help jog my
    >> memory?
    >>
    >> [noparse]:)[/noparse]
    >>
    >> Vern
    >>
    >> Andy Quirot said:
    >>> what im trying to do is
    >>> read a high on pin 0 then pwm the moter clockwise via H-Bridge
    >>> read a high on pin 1 then pwm then motor anticlock via H-Bridge
    >>> There must be a better way ????
    >>> EG.
    >>> symbol fspeed =w1
    >>> symbol bspeed =w2
    >>> let dirs = %11110000
    >>> let pins = %00000000
    >>> fspeed = 0
    >>> bspeed = 0
    >>>
    >>> start:
    >>> if pin0 = 1 then forw
    >>> if pin1 = 1 then back
    >>> if pin2 = 1 then trainstop
    >>> pwm 4,fspeed,1
    >>> pwm 5,bspeed,1
    >>> goto start
    >>>
    >>> forw:
    >>> fspeed = fspeed +1
    >>> if fspeed =>255 then ffull
    >>> bspeed = 0
    >>> pause 50
    >>> goto start
    >>>
    >>> back:
    >>> bspeed = bspeed +1
    >>> if bspeed =>255 then bfull
    >>> fspeed = 0
    >>> pause 50
    >>> goto start
    >>>
    >>> trainstop:
    >>> fspeed = 0
    >>> bspeed = 0
    >>> pin4=0
    >>> pin5=0
    >>> goto start
    >>>
    >>> ffull:
    >>> fspeed = 255
    >>> bspeed=0
    >>> goto start
    >>>
    >>> bfull:
    >>> bspeed=255
    >>> fspeed=0
    >>> goto start
    >
    >
    >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 2003-09-05 08:45
    It is in the Parallax Basic Stamp Manual version 1.9 page 171.
    Regards
    ECO
    Original Message
    From: "Vernon Graner" <vern@t...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, September 05, 2003 12:12 AM
    Subject: Re: [noparse][[/noparse]basicstamps] re stamp1 and model train


    > hmmm.. are my posts even getting through to the list?
    >
    > I was hoping Al or Jon might respond to this one...? Do either of you
    > remember the article on controlling a set of three model trains with a
    > BS1?
    >
    > Vernon Graner said:
    > > If I recall, one of the first Basic Stamp books I read (The actual BS
    > > manual? One of the "Nuts and Volts of Basic Stamps" volumes?
    > > "Microcontroller Projects Using the BASIC Stamp"?) had a very interesting
    > > story describing how to use a Basic Stamp and an LCD display and c couple
    > > of buttons to control three z scale model trains. The article was
    > > WONDERFUL as it went over the design process, the limitations of hardware
    > > and then provided the finished code and schematics so anyone could
    > > replicate the results.
    > >
    > > I just can't remember *which* book had the description! I *think* it was
    > > maybe Al Williams that wrote the article? Maybe Jon? Dang it was a good
    > > article, wish I could give the source. Jon, Al? can you help jog my
    > > memory?
    > >
    > > [noparse]:)[/noparse]
    > >
    > > Vern
    > >
    > > Andy Quirot said:
    > >> what im trying to do is
    > >> read a high on pin 0 then pwm the moter clockwise via H-Bridge
    > >> read a high on pin 1 then pwm then motor anticlock via H-Bridge
    > >> There must be a better way ????
    > >> EG.
    > >> symbol fspeed =w1
    > >> symbol bspeed =w2
    > >> let dirs = %11110000
    > >> let pins = %00000000
    > >> fspeed = 0
    > >> bspeed = 0
    > >>
    > >> start:
    > >> if pin0 = 1 then forw
    > >> if pin1 = 1 then back
    > >> if pin2 = 1 then trainstop
    > >> pwm 4,fspeed,1
    > >> pwm 5,bspeed,1
    > >> goto start
    > >>
    > >> forw:
    > >> fspeed = fspeed +1
    > >> if fspeed =>255 then ffull
    > >> bspeed = 0
    > >> pause 50
    > >> goto start
    > >>
    > >> back:
    > >> bspeed = bspeed +1
    > >> if bspeed =>255 then bfull
    > >> fspeed = 0
    > >> pause 50
    > >> goto start
    > >>
    > >> trainstop:
    > >> fspeed = 0
    > >> bspeed = 0
    > >> pin4=0
    > >> pin5=0
    > >> goto start
    > >>
    > >> ffull:
    > >> fspeed = 255
    > >> bspeed=0
    > >> goto start
    > >>
    > >> bfull:
    > >> bspeed=255
    > >> fspeed=0
    > >> goto start
    >
    >
    > 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 2003-09-05 15:55
    Note the error in the schematic. The common for the diodes(pin 10) on the
    ULN2803 should not be connected to ground.
    > You're looking for BASIC Stamp app note 21, "Fun with Trains". Those
    > app notes were written by Scott Edwards, I believe. You can download
    > them from
    > http://www.parallax.com
    > http://www.parallax.com/dl/appnt/stamps/bs1%20appnotes.pdf
    >
    > Those app notes, even though written for the BS1, are still very
    > informative today for the BS2 family.
    >
    > -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2003-09-05 16:22
    You might want to check out http://www.geocities.com/jimforkin2003/
    for examples using a stamp to control motors, etc.

    jim

    Original Message
    From: K de Jong [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=R82AmSvLFm9LUyCYPMmbf0T1JltqA-o5sxgLj5N_g7_bPDVfbT_R_wEYtTfC8xfnp8QDmUU7viMTqqZP]Klaus.Jong@n...[/url
    Sent: Wednesday, September 03, 2003 4:17 PM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] re stamp1 and model train


    Hi Andy,

    I use a motorcontroller which is used for truckmodels or small ships. It has
    a H-bridge in it and the input is the same pulse input as for a standard
    servomotor for aircraftmodels etc. The controller can do max ca. 15V at 1
    amp, the peakload is 2 amps.

    Stampcontrol is: pulsout .... ms and off you go!!!!!

    That's all.

    I hope y can find something like this in your neighbourhood.

    Klaus

    Oorspronkelijk bericht
    Van: Andy Quirot [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=fCmwojAuptEJE_INgcF3XnMtSneRunhgQpFtezQyZr0IJ62wbC8gNE-VIbyc6S2kagxJxRQq50ki2dYeTzA]andyquirot1@h...[/url
    Verzonden: 03 09 2003 20:13
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] re stamp1 and model train


    what im trying to do is
    read a high on pin 0 then pwm the moter clockwise via H-Bridge
    read a high on pin 1 then pwm then motor anticlock via H-Bridge
    There must be a better way ????
    EG.
    symbol fspeed =w1
    symbol bspeed =w2
    let dirs = %11110000
    let pins = %00000000
    fspeed = 0
    bspeed = 0

    start:
    if pin0 = 1 then forw
    if pin1 = 1 then back
    if pin2 = 1 then trainstop
    pwm 4,fspeed,1
    pwm 5,bspeed,1
    goto start

    forw:
    fspeed = fspeed +1
    if fspeed =>255 then ffull
    bspeed = 0
    pause 50
    goto start

    back:
    bspeed = bspeed +1
    if bspeed =>255 then bfull
    fspeed = 0
    pause 50
    goto start

    trainstop:
    fspeed = 0
    bspeed = 0
    pin4=0
    pin5=0
    goto start

    ffull:
    fspeed = 255
    bspeed=0
    goto start

    bfull:
    bspeed=255
    fspeed=0
    goto start





    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 2003-09-08 05:02
    --- In basicstamps@yahoogroups.com, "Andy Quirot" <andyquirot1@h...>
    wrote:
    > what im trying to do is
    > read a high on pin 0 then pwm the moter clockwise via H-Bridge
    > read a high on pin 1 then pwm then motor anticlock via H-Bridge
    > There must be a better way ????

    Andy,
    Are you planning to use an H-Bridge driver or drive the bridge
    directly from the stamp? If you are going to use the driver I.C., you
    should free up one more output pin (dirs = %11100000) for the Disable
    control on the driver chip.
    I assume that the code you presented is more theory than practical
    as there is no control for the HIGH SIDE devices.
    That aside, the only other functional issue I see is that it is
    possible for the user to crank the motor (train (moving mass)) up to
    full speed and then 50 mS later give it a reverse command. I have
    firsthand knowledge of how rough that can be on electro-mechanical
    systems (I've sent a few elevators into strange vertical spasms,
    damaging machine and controller).
    My prefrence would be to use a +/-/stop system such as:
    speed range= 1(full reverse) to 247-265(stop) to 511(full forward)
    Then use increment-decrement buttons to step speed (by 10 )
    and stop button for ...stopping

    I'm a little rusty at bs1 but this should show you what I mean.

    symbol speed = w1
    swmbol pulse = B2
    speed = 256 'center or stop value

    dirs = %11100000 '(in 012)(out3 dis.)(out4,5 forw br.)(out 6,7 rev br.)
    pins = %00000000

    start:
    if pin0 = 1 then increase
    if pin1 = 1 then decrease
    if pin2 = 1 then stop
    goto motor_control
    goto start

    increase:
    speed = speed+10
    if 247<speed>265 then stop 'not sure if this works on stamp,
    if speed >=511 then Fful 'but it can be done with AND IF
    goto start

    Fful:
    speed = 511
    goto start

    decrease:
    speed = speed-10
    if 247<speed>265 then stop
    if speed >=1 then Rful
    goto start

    Rful:
    speed = 1
    goto start

    stop:
    pin3 = 0
    speed = 256
    pause 250
    goto start

    motor_control:
    if speed = 256 then stop
    if speed <=246 then reverse
    pulse = speed-256 'result from 10 to 255
    pin6 = 0 'reverse HI fet off
    pin7 = 0 'reverse lo fet off
    pin4 = 4 'forward hi fet on
    pin3 = 1 'enable H-bridge driver I.C.
    pwm 5,pulse,100 ' pulse forward low fet
    pause 50
    goto start

    reverse:
    pulse = 256-speed 'result from 10 to 255

    Yada yada yada..opposite of forward... I got carried away lol.
    That's just off the top of my head, i'm sure ther's a glitch or two,
    but it should serve to illustrate my point of view.

    Whew I'm tired now...the old man has gotta rest.
    I hope some of this made sense... let me know.

    Respectfully,
    C.C.


    > EG.
    > symbol fspeed =w1
    > symbol bspeed =w2
    > let dirs = %11110000
    > let pins = %00000000
    > fspeed = 0
    > bspeed = 0
    >
    > start:
    > if pin0 = 1 then forw
    > if pin1 = 1 then back
    > if pin2 = 1 then trainstop
    > pwm 4,fspeed,1
    > pwm 5,bspeed,1
    > goto start
    >
    > forw:
    > fspeed = fspeed +1
    > if fspeed =>255 then ffull
    > bspeed = 0
    > pause 50
    > goto start
    >
    > back:
    > bspeed = bspeed +1
    > if bspeed =>255 then bfull
    > fspeed = 0
    > pause 50
    > goto start
    >
    > trainstop:
    > fspeed = 0
    > bspeed = 0
    > pin4=0
    > pin5=0
    > goto start
    >
    > ffull:
    > fspeed = 255
    > bspeed=0
    > goto start
    >
    > bfull:
    > bspeed=255
    > fspeed=0
    > goto start
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-27 15:44
    check out http://www.geocities.com/jimforkin2003/ for a board to interface
    stamps to motors.
    jim


    Original Message
    From: K de Jong [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8Q0pWSfxykf2wAnrSVzC-B9Oc8OEBnvvsvO1gwtTMUVLq2Ht0nTxdo9sbzjgAiG6dBSWluGqMebIKPI]Klaus.Jong@n...[/url
    Sent: Wednesday, September 03, 2003 4:17 PM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] re stamp1 and model train


    Hi Andy,

    I use a motorcontroller which is used for truckmodels or small ships. It has
    a H-bridge in it and the input is the same pulse input as for a standard
    servomotor for aircraftmodels etc. The controller can do max ca. 15V at 1
    amp, the peakload is 2 amps.

    Stampcontrol is: pulsout .... ms and off you go!!!!!

    That's all.

    I hope y can find something like this in your neighbourhood.

    Klaus

    Oorspronkelijk bericht
    Van: Andy Quirot [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=pX7duy7YxZGBXE-biFK-ylT-wt9jETIncM2uKAD8EFxfFgKLLcFVqZcW2E6XbeQbFrz60GPvX26J-bPYMGtvsg]andyquirot1@h...[/url
    Verzonden: 03 09 2003 20:13
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] re stamp1 and model train


    what im trying to do is
    read a high on pin 0 then pwm the moter clockwise via H-Bridge
    read a high on pin 1 then pwm then motor anticlock via H-Bridge
    There must be a better way ????
    EG.
    symbol fspeed =w1
    symbol bspeed =w2
    let dirs = %11110000
    let pins = %00000000
    fspeed = 0
    bspeed = 0

    start:
    if pin0 = 1 then forw
    if pin1 = 1 then back
    if pin2 = 1 then trainstop
    pwm 4,fspeed,1
    pwm 5,bspeed,1
    goto start

    forw:
    fspeed = fspeed +1
    if fspeed =>255 then ffull
    bspeed = 0
    pause 50
    goto start

    back:
    bspeed = bspeed +1
    if bspeed =>255 then bfull
    fspeed = 0
    pause 50
    goto start

    trainstop:
    fspeed = 0
    bspeed = 0
    pin4=0
    pin5=0
    goto start

    ffull:
    fspeed = 255
    bspeed=0
    goto start

    bfull:
    bspeed=255
    fspeed=0
    goto start





    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.