Shop OBEX P1 Docs P2 Docs Learn Events
Need more help on programming — Parallax Forums

Need more help on programming

ArchiverArchiver Posts: 46,084
edited 2000-07-23 18:52 in General Discussion
Hi!

I am suppose to come up with a program for this robot using a basic
stamp. The problem is that time is rather short(like within this week
or else.....*sigh*) and i haven't got the time to really understand
the full usage and language used by the basic stamps.


Details of the robot:

The function of this robot is to only move in the presence of light
(hence there is a light sensor) and this will cause the 2 stepper
motors (it should be the unipolar kind, has 4 outputs to each motor
directly) to start moving.

There are 3 IR sensors (the front, left and right)and they are to
prevent the robot from hitting any obstacles.

I don't know how should i loop the program so as to make sure that
the controller will keep checking for the presence of light.
Actually, i am hoping someone will be able to give me a clearer
picture of how the program should be written for the robot with the
above function. The controller seems to be able only to do one thing
at a time.By the way, the controller i am using is Basic Stamp I.

Thanks for reading this!
hope to hear from all of you soon [noparse]:)[/noparse]


Joanna

Al Williams and Andrew Tucker: Thanks for replying to my previous
postings....wonder if you two will read this as well......

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-07-23 18:52
    Rough outline:

    ' do one-time init code here
    top:
    gosub checklight ' set light on variable to 1 if light present
    if lighton=1 then goto top
    gosub findobstacles ' set left, fwd, right to 0 if blocked
    if fwd=1 then gofwd
    if left=1 then goleft
    if right=1 then goright
    gosub goreverse
    ' fall into goright
    goright:
    ' make steppers move right
    goto top

    gofwd:
    ' make steppers move forward
    goto top

    goleft:
    ' make steppers move left
    goto top

    goreverse:
    ' make steppers back up
    goto top


    checklight:
    ' set lighton
    return

    findobstacles:
    ' set variables
    return


    Something like that. The Stamp I doesn't have much memory compared to the
    Stamp II, so I hope it will all fit.

    If the light sensor is a CdS cell (like a circle with a snake running
    through it) you'll use the POT command to read it (and you'll need a
    capacitor). If it is a photodiode (like a little transparent transistor)
    you'll just read it as a digital input (pinX where X is the pin number).
    Most likely you have one of these two.

    The IR sensors are trickier. You'll need to excite an IR source at the
    proper frequency that the detectors use. This is often done with a 555 timer
    or similar oscillator and is often at about 38kHz (for historical reasons).
    The sensors then usually have all the filtering etc, so you can just read a
    digital output.

    You might find the BOEBOT documentation on the Parallax Web site useful.

    Regards,

    Al Williams
    AWC
    * Microcontroller Projects with Basic Stamps:
    http://www.al-williams.com/awce/sbook.htm




    >
    Original Message
    > From: Joanna [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=0Yo6f2c0dWnR13V3HPlOefKjk8dBX-NAbfuKONEh-3b5uE7beywAHgw2ODR7uW6gAkQlWSZw-VE8aSj4]qiuyi18@h...[/url
    > Sent: Sunday, July 23, 2000 12:33 PM
    > To: basicstamps@egroups.com
    > Subject: [noparse][[/noparse]basicstamps] Need more help on programming
    >
    >
    >
    >
    > Hi!
    >
    > I am suppose to come up with a program for this robot using a basic
    > stamp. The problem is that time is rather short(like within this week
    > or else.....*sigh*) and i haven't got the time to really understand
    > the full usage and language used by the basic stamps.
    >
    >
    > Details of the robot:
    >
    > The function of this robot is to only move in the presence of light
    > (hence there is a light sensor) and this will cause the 2 stepper
    > motors (it should be the unipolar kind, has 4 outputs to each motor
    > directly) to start moving.
    >
    > There are 3 IR sensors (the front, left and right)and they are to
    > prevent the robot from hitting any obstacles.
    >
    > I don't know how should i loop the program so as to make sure that
    > the controller will keep checking for the presence of light.
    > Actually, i am hoping someone will be able to give me a clearer
    > picture of how the program should be written for the robot with the
    > above function. The controller seems to be able only to do one thing
    > at a time.By the way, the controller i am using is Basic Stamp I.
    >
    > Thanks for reading this!
    > hope to hear from all of you soon [noparse]:)[/noparse]
    >
    >
    > Joanna
    >
    > Al Williams and Andrew Tucker: Thanks for replying to my previous
    > postings....wonder if you two will read this as well......
    >
    >
    >
    >
    >
    >
    >
    >
Sign In or Register to comment.