Shop OBEX P1 Docs P2 Docs Learn Events
Newbie Question — Parallax Forums

Newbie Question

ArchiverArchiver Posts: 46,084
edited 2004-03-10 19:39 in General Discussion
I am trying to do something I thought fairly basic. I am trying to
use an ir to trigger a left or right turn. The Ir triggers and jumps
to the proper place in the code, but it doesn't actually execute the
loop. Here is a snip of the code.

main:
freqout 1, 1, 38000
rightIRdet = in0
debug home, ? rightIRdet
if rightIRdet=0 then test
goto main

test:
for x=1 to 10
pulsout left_servo,850
pulsout right_servo,650
pause 20
debug ? x
loop
goto main

The debug statement never runs, and the loop doesn't execute but
once. Am I missing something?? If I say goto test, the loop
executes exactly as written.

What is my problem?
Ben

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-10-19 03:48
    Ben:
    Where is your next statement?

    Ray McArthur

    Original Message
    From: Ben Brown <ben@h...>
    To: <basicstamps@egroups.com>
    Sent: Wednesday, October 18, 2000 10:01 PM
    Subject: [noparse][[/noparse]basicstamps] Newbie Question


    > I am trying to do something I thought fairly basic. I am trying to
    > use an ir to trigger a left or right turn. The Ir triggers and jumps
    > to the proper place in the code, but it doesn't actually execute the
    > loop. Here is a snip of the code.
    >
    > main:
    > freqout 1, 1, 38000
    > rightIRdet = in0
    > debug home, ? rightIRdet
    > if rightIRdet=0 then test
    > goto main
    >
    > test:
    > for x=1 to 10
    > pulsout left_servo,850
    > pulsout right_servo,650
    > pause 20
    > debug ? x
    > loop
    > goto main
    >
    > The debug statement never runs, and the loop doesn't execute but
    > once. Am I missing something?? If I say goto test, the loop
    > executes exactly as written.
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-19 15:56
    Sorry, I miss typed. This is the actual code that I downloaded to the stamp.

    main:
    freqout 1, 1, 38000
    rightIRdet = in0
    debug home, ? rightIRdet
    if rightIRdet=0 then test
    goto main

    test:
    for x=1 to 10
    pulsout left_servo,850
    pulsout right_servo,650
    pause 20
    debug ? x
    next
    goto main


    >Ben:
    >Where is your next statement?
    >
    >Ray McArthur
    >
    >
    Original Message
    >From: Ben Brown <ben@h...>
    >To: <basicstamps@egroups.com>
    >Sent: Wednesday, October 18, 2000 10:01 PM
    >Subject: [noparse][[/noparse]basicstamps] Newbie Question
    >
    >
    >> I am trying to do something I thought fairly basic. I am trying to
    >> use an ir to trigger a left or right turn. The Ir triggers and jumps
    >> to the proper place in the code, but it doesn't actually execute the
    >> loop. Here is a snip of the code.
    >>
    > > main:
    > > freqout 1, 1, 38000
    >> rightIRdet = in0
    >> debug home, ? rightIRdet
    >> if rightIRdet=0 then test
    >> goto main
    >>
    >> test:
    >> for x=1 to 10
    >> pulsout left_servo,850
    >> pulsout right_servo,650
    >> pause 20
    >> debug ? x
    > > loop
    > > goto main
    >>
    >> The debug statement never runs, and the loop doesn't execute but
    > > once. Am I missing something?? If I say goto test, the loop
    >> executes exactly as written.
  • ArchiverArchiver Posts: 46,084
    edited 2000-11-28 16:59
    Hi!

    I'm a newbie with the stamp. I have used it for one
    project, which worked great and am now using it for a
    new project. This one will also work great, but I ran
    into what is probably a conceptual problem on my part,
    rather than on the BS2's part.

    I wanted to use natural words for the output pins in
    my program, so I set up the following:

    OUT6=LATCH
    ON CON 1
    OFF CON 0

    Later in the program I set:

    LATCH=ON

    and even later in the program did the following:

    PULSOUT LATCH,5

    What I've discovered is that I have to replace LATCH
    with OUT6 before the pin works. Is there some easy way
    of setting up the definitions so I don't have to
    rewrite the code? Any ideas gratefully received.

    Thanks!

    __________________________________________________
    Do You Yahoo!?
    Yahoo! Shopping - Thousands of Stores. Millions of Products.
    http://shopping.yahoo.com/
  • ArchiverArchiver Posts: 46,084
    edited 2000-11-28 17:40
    >I wanted to use natural words for the output pins in
    >my program, so I set up the following:
    >
    >OUT6=LATCH
    >ON CON 1
    >OFF CON 0
    >
    >Later in the program I set:
    >
    >LATCH=ON
    >
    >and even later in the program did the following:
    >
    >PULSOUT LATCH,5
    >
    >What I've discovered is that I have to replace LATCH
    >with OUT6 before the pin works. Is there some easy way
    >of setting up the definitions so I don't have to
    >rewrite the code? Any ideas gratefully received.

    Hi Elmer,

    The definition statements should be:

    LATCH var out6 ' as a variable alias
    LATCH_pin con 6 ' as a constant
    ON CON 1
    OFF CON 0


    Then:
    output LATCH_pin ' makes pin an output
    and later:
    LATCH=ON ' assignment of variable
    PULSOUT LATCH_pin,5 ' pin number is a constant

    You have to be careful with the difference between the pin number as a
    constant, or as a variable. I make that mistake all the time!

    regards,
    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2000-11-29 05:10
    You know, it never ceases to amaze me the things I learn by reading
    this board. It's bugged since I started using the Stamp I couldn't
    find a way around the IN / OUT words for control.

    Who woulda thunk it.

    Great newbie question!!
    -Martin
    www.selmaware.com

    --- In basicstamps@egroups.com, Tracy Allen <emesys@c...> wrote:
    > >I wanted to use natural words for the output pins in
    > >my program, so I set up the following:
    > >
    > >OUT6=LATCH
    > >ON CON 1
    > >OFF CON 0
    > >
    > >Later in the program I set:
    > >
    > >LATCH=ON
    > >
    > >and even later in the program did the following:
    > >
    > >PULSOUT LATCH,5
    > >
    > >What I've discovered is that I have to replace LATCH
    > >with OUT6 before the pin works. Is there some easy way
    > >of setting up the definitions so I don't have to
    > >rewrite the code? Any ideas gratefully received.
    >
    > Hi Elmer,
    >
    > The definition statements should be:
    >
    > LATCH var out6 ' as a variable alias
    > LATCH_pin con 6 ' as a constant
    > ON CON 1
    > OFF CON 0
    >
    >
    > Then:
    > output LATCH_pin ' makes pin an output
    > and later:
    > LATCH=ON ' assignment of variable
    > PULSOUT LATCH_pin,5 ' pin number is a constant
    >
    > You have to be careful with the difference between the pin number
    as a
    > constant, or as a variable. I make that mistake all the time!
    >
    > regards,
    > -- Tracy Allen
    > electronically monitored ecosystems
    > http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2001-06-29 07:49
    Could anyone please tell me how I could control the time and duration an
    aquarium air pump stays on. I can build cricuits, but I am not very good at
    designing them.

    Thank you for any assistance...CR West
  • ArchiverArchiver Posts: 46,084
    edited 2001-06-29 13:07
    The aquarium pump is likely to be an AC device you plug into the wall,
    right?

    To keep things simple, select a relay that can handle the voltage/current on
    the CONTACTS and has, say, a 12V coil (or even a 5V coil). Unless the relay
    is a solid state relay specifically meant to be driven by logic circuits,
    you'll need some circuitry to drive the coil.

    Since you are dealing with 120VAC, be careful. I'd use a DPDT relay so I
    could break both the hot and neutral wires to the pump.

    Here's how to wire the coil of the relay:

    +V (5V, 12V, 6V, whatever the relay coil wants) goes to one side of the coil
    (say side A). On side B, you connect the collector of a 2N2222 transistor
    (assuming your relay coil is rated <100mA or so). Ground the emitter. Put a
    1K resistor between the base and a Stamp pin. Take a diode (1N4001 or 1N914
    or 1N4148) and put it with the banded end to side A and the non-banded side
    to side B. Now when you bring the Stamp pin high, the relay will close and
    start the pump. When you bring the pin low, the relay will open.

    Say you power the Stamp with a normally closed momentary action pushbutton.
    When the Stamp comes on, you want it to turn the pump on for 10 minutes and
    then off for 5 minutes. If you push the button, you reset the Stamp so it
    starts over:

    ' Stamp II code
    PUMP con 0
    i var byte
    j var byte
    top:
    HIGH PUMP
    for i=1 to 10
    gosub wait1min
    next
    LOW PUMP
    for i=1 to 5
    gosub wait1min
    next
    goto top

    wait1min:
    for j=1 to 60
    pause 1000
    ' could do extra things every second here
    next
    return

    Not Swiss watch accurate, but probably OK for what you want.

    Good Luck!

    Al Williams
    AWC
    * Prototype with RS232 - http://www.al-williams.com/awce/rs1.htm



    >
    Original Message
    > From: trike62@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=v6txLOU54o_m15kZ-KGGqDeemz91BxlWJTY9JJ4qorW5mw6ItXMQFhdS1_4S6fJUIjeEO86EGQ]trike62@a...[/url
    > Sent: Friday, June 29, 2001 1:50 AM
    > To: basicstamps@yahoogroups.com
    > Cc: TRIKE62@a...
    > Subject: [noparse][[/noparse]basicstamps] Newbie question
    >
    >
    > Could anyone please tell me how I could control the time and duration an
    > aquarium air pump stays on. I can build cricuits, but I am not
    > very good at
    > designing them.
    >
    > Thank you for any assistance...CR West
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed with. 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-21 20:26
    hi all,
    i have a program loaded and running in a basicstamp 2 from a long time
    ago and can't find the source code. was wondering if there is a way to
    upload the code from the bs2 to the pc (or display on the screen) in the
    stamp windows editor.
    thanks in advance,
    mark
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-22 06:15
    Mark,
    As far as I know once the program is on the stamp it is irretrievable.

    Chris Shuster
    http://www.cpuman.f2s.com/

    Original Message
    From: "Mark LoGiudice" <ml@g...>
    To: <basicstamps@yahoogroups.com>
    Sent: Monday, October 22, 2001 3:26 AM
    Subject: [noparse][[/noparse]basicstamps] newbie question


    > hi all,
    > i have a program loaded and running in a basicstamp 2 from a long time
    > ago and can't find the source code. was wondering if there is a way to
    > upload the code from the bs2 to the pc (or display on the screen) in the
    > stamp windows editor.
    > thanks in advance,
    > mark
    >
    > 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 2002-04-02 02:29
    i am such a newbie that i don't even have a microcontroller. i am
    just making sure that what i buy will do what i need it to do. i am
    not making a robot or anything like that. i just need to create a
    program that for every pulse of a switch the ouput can produce a led
    display to show an indicated display and control a set of solenoids.
    i plan on creating a semi-sequential shifter for my car. my car is
    currently a 5 speed standard. i want to have a switch at the front
    and back of my shifter (the shifter will be disconnected from the
    linkages) so that when i push the shifter forward it would hit a
    switch and show on a led display what gear i am in. and also to
    have a proper output to control solenoids to change the gears. all
    this is possible with the basic stamp 2? how about the basicx-24? i
    also need this to work in -30 degree celcius weather too (it gets
    pretty cold in canada during the winters). i know the basic stamp
    has an industrial version but how about the basicx-24? i need all
    the help i can get! thank you!

    conrad andres
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-02 06:40
    Hello all

    Can I program "Basic Stamps" in "C/C++" or I must
    use only PBASIC?

    thanks
    /kmk
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-02 08:24
    Hello

    The Basic Stamp is an interpreter chip and can only be programed in pbasic.
    If you want to use a chip that
    can be programed in any other language, you will have to find one the uses
    complied code. Compiled code is code
    written in an other language and compiled to Assemble Code. These types of
    chips are cheap, but the compiler
    usually cost several hundred dollars. I am not sure if C/C++ is an interpreter
    or a compiler if it is a compiler
    look for a PIC chip that can be programed with C/C++. I am learning about the
    Basic X-24 chip and the Atom chip,
    I am not sure which one I read about but it uses compiled code. It is also
    compatible to the Basic Stamp

    Have Fun !!
    Dale Fleischmann

    kmk wrote:

    > Hello all
    >
    > Can I program "Basic Stamps" in "C/C++" or I must
    > use only PBASIC?
    >
    > thanks
    > /kmk
    >
    > 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 2002-11-12 17:31
    Ok, this is probably simple to the veterans here, but I'll ask anyway.

    What is the theory of operation with the parallel interface to the Stamp I
    board for programming it? This looks to be one of the wierdest connect
    schemes I've seen. No doubt a clever trick of some kind.
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-12 20:16
    Hi

    i have just bought a Basic 2 stamp and need some advice when it comes to serial
    comms.
    On the web site WWW.MILINST.COM there is a 'On screen Display' unit or video
    overlay circuit that you can drive with serial commands from a stamp.
    I want to purchase this but are unsure what commands i would need to send it to
    make it work. There is a data sheet but i am new to this and do not want to
    waste my money purchasing it if it is to difficlt

    So if someone can help can they give me a few examples of code that would put
    the words 'How are you' on the screen for an example

    Thanks for any help you give

    Wayne

    PS if you dont want to help please dont flame me!
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-12 21:06
    You must be talking about the "BOB". Yes, you can use the stamp to
    drive this. It's serial. 2 pin; Txd/Rxd; 2400, 4800, 9600, 19200, and
    38400 baud, 8N1. All the commands you send serially to the BOB are
    documented in the application guide available on
    http://www.decadenet.com/ BS2 specific code is show in this example;
    http://www.decadenet.com/pub/awbob.pdf

    By the way, XBOB is now shipping and superceeds the BOB3.

    --- In basicstamps@yahoogroups.com, WLMOATE@A... wrote:
    > Hi
    >
    > i have just bought a Basic 2 stamp and need some advice when it
    comes to serial comms.
    > On the web site WWW.MILINST.COM there is a 'On screen Display' unit
    or video overlay circuit that you can drive with serial commands from
    a stamp.
    > I want to purchase this but are unsure what commands i would need
    to send it to make it work. There is a data sheet but i am new to
    this and do not want to waste my money purchasing it if it is to
    difficlt
    >
    > So if someone can help can they give me a few examples of code that
    would put the words 'How are you' on the screen for an example
    >
    > Thanks for any help you give
    >
    > Wayne
    >
    > PS if you dont want to help please dont flame me!
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-12 21:43
    I had a quick look at it and the pdf.

    It should be fairly easy to talk to it. You'd just use the Stamps "Serin" and
    "Serout"
    commands

    Infact, I might go and buy one. Although, at $210 NZ + postage, it may be a
    while...

    Cheers,

    Ben.


    Quoting WLMOATE@A...:

    > Hi
    >
    > i have just bought a Basic 2 stamp and need some advice when it comes
    > to serial comms.
    > On the web site WWW.MILINST.COM there is a 'On screen Display' unit or
    > video overlay circuit that you can drive with serial commands from a
    > stamp.
    > I want to purchase this but are unsure what commands i would need to
    > send it to make it work. There is a data sheet but i am new to this and
    > do not want to waste my money purchasing it if it is to difficlt
    >
    > So if someone can help can they give me a few examples of code that
    > would put the words 'How are you' on the screen for an example
    >
    > Thanks for any help you give
    >
    > Wayne
    >
    > PS if you dont want to help please dont flame me!
    >
    > 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 the optimist, the glass is half full. To the pessimist, the glass is
    half empty. To the engineer, the glass is twice as big as it needs to be."

    No animals were harmed in the transmission of this email, although the
    Dog next door is living on borrowed time, let me tell you! Those of you
    with an overwhelming fear of the unknown will be gratified to learn that
    there is no hidden message revealed by reading this warning backwards.
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-13 18:33
    Hi

    i have just bought a Basic 2 stamp and need some advice when it comes to
    serial comms.
    On the web site WWW.MILINST.COM there is a 'On screen Display' unit or video
    overlay circuit that you can drive with serial commands from a stamp.
    I want to purchase this but are unsure what commands i would need to send it
    to make it work. There is a data sheet but i am new to this and do not want
    to waste my money purchasing it if it is to difficlt

    So if someone can help can they give me a few examples of code that would put
    the words 'How are you' on the screen for an example

    Thanks for any help you give

    Wayne

    PS if you dont want to help please dont flame me!
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-13 23:58
    I don't know how to say this without sounding like I'm flaming but:

    http://www.milinst.com/gemodules/6_940.pdf

    There is a 12 page datasheet on the milinst site that explains all of
    the commands that can be sent to the device. It's a neat little
    device, I wish I had some use for one.

    -selket


    --- In basicstamps@yahoogroups.com, WLMOATE@A... wrote:
    > Hi
    >
    > i have just bought a Basic 2 stamp and need some advice when it
    comes to
    > serial comms.
    > On the web site WWW.MILINST.COM there is a 'On screen Display' unit
    or video
    > overlay circuit that you can drive with serial commands from a
    stamp.
    > I want to purchase this but are unsure what commands i would need
    to send it
    > to make it work. There is a data sheet but i am new to this and do
    not want
    > to waste my money purchasing it if it is to difficlt
    >
    > So if someone can help can they give me a few examples of code that
    would put
    > the words 'How are you' on the screen for an example
    >
    > Thanks for any help you give
    >
    > Wayne
    >
    > PS if you dont want to help please dont flame me!
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-10 02:36
    In our church productions we use manual controls(push buttons) for
    our air cannons and strobe flashes on the tomb scene. I was wanting
    to automate this to just being able to press one button and the
    sequence would time each step.Could I use a programed stamp plus
    relays?
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-10 04:31
    Yep. Check out this article; it shows how to build a programmable
    sequencer using a BASIC Stamp. Connect the outputs to proper drivers
    and relays, and you're in business.

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/90.pdf

    -- Jon Williams
    -- Parallax


    Original Message
    From: bbobbya10 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=-491rwgQFE4cMrW9jbRS5zI0mIVR711A9H7gpw3T8DO2uZd2nwhjycpy9G_2NDbk1bLGc1TnF5TyS70]bbobbya10@y...[/url
    Sent: Tuesday, March 09, 2004 8:36 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] newbie question


    In our church productions we use manual controls(push buttons) for
    our air cannons and strobe flashes on the tomb scene. I was wanting
    to automate this to just being able to press one button and the
    sequence would time each step.Could I use a programed stamp plus
    relays?
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-10 16:02
    Yes. The stamp has 16 digital outputs you
    can control through PBasic. You may have
    to experiment a little to find the EXACT
    timing you want, though.

    --- In basicstamps@yahoogroups.com, "bbobbya10" <bbobbya10@y...>
    wrote:
    > In our church productions we use manual controls(push buttons) for
    > our air cannons and strobe flashes on the tomb scene. I was wanting
    > to automate this to just being able to press one button and the
    > sequence would time each step.Could I use a programed stamp plus
    > relays?
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-10 19:39
    check out this web site for methods to control relays, valves, etc.
    http://www.geocities.com/jimforkin2003/
    jim


    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=we117yDuJThbjFfYRD61tDprC5ZWPq-hqv3bNd0uZXLXoOg2mzcR4f6kzwTvFYDQhLkZz-8ltfK7FeZsLXua8tdMNQ]allan.lane@h...[/url
    Sent: Wednesday, March 10, 2004 11:02 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: newbie question


    Yes. The stamp has 16 digital outputs you
    can control through PBasic. You may have
    to experiment a little to find the EXACT
    timing you want, though.

    --- In basicstamps@yahoogroups.com, "bbobbya10" <bbobbya10@y...>
    wrote:
    > In our church productions we use manual controls(push buttons) for
    > our air cannons and strobe flashes on the tomb scene. I was wanting
    > to automate this to just being able to press one button and the
    > sequence would time each step.Could I use a programed stamp plus
    > relays?



    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.

    Yahoo! Groups Links
Sign In or Register to comment.