Shop OBEX P1 Docs P2 Docs Learn Events
I have some questions: — Parallax Forums

I have some questions:

James HarrisonJames Harrison Posts: 4
edited 2009-03-02 13:05 in BASIC Stamp
Hello all,

I am new to the Parallax products and this forum, but so far have really enjoyed the controller I purchased. I have a Revision D Basic Stamp 2, which was purchased from Radio Shack.

I have some questions:

1.
I saw on the main Parallax web site that there are LCD displays available to connect to the Basic Stamp controllers. Can I connect an LCD display to my controller and if yes, which one will work? I saw some of the LCD monitors use serial or I2C communications and strangely enough there are Basic commands for these. Some kind of Accessory computability matrix would be useful.

2.
Am I limited to Basic? Is there an assembly language IDE and compiler. I am sure the basic is compiled into machine code somewhere along the way.

3.
Am I limited to the 2K EEPROM? Has anyone tried to compile Linux on this? Would it even work?

4.
From the examples in the manual, I am only able to make the stepper motor rotate a fraction of the way around. How would you make the stepper motor rotate 360 deg?

5.
I know on most CPUs there is the idea of an interrupt that runs runs some code along side of the main program. My only experience of such a thing was with the Commodore 64 and its IRQ interrupt. Its function was to run periodically and maintain the up keep of the machine, read the keyboard etc. Is there anything line this with Basic Stamp systems?

Thanks for any help.

Regards,

James Harrison

Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:13:47 AM GMT

Comments

  • UghaUgha Posts: 543
    edited 2009-02-28 12:24
    First... Welcome to the forum!

    Parallax's basic stamp forum is one of the best sources for information on getting started with microcontrollers there are. In addition, the people are friendly and helpful.

    Now... your questions:
    1: All the displays on the Parallax site except "Mini LCD A/V Color Display" are usable by a BS2.
    2: Yes, your limited to Basic due to the way Stamps are designed (see below)
    3: Your stuck with the 2k EEPROM limit unless you upgrade to a better stamp. You also can't use most of the EEPROM due to the program space taking up a great deal (see below)
    It would be impossible to put Linux on a Stamp.
    4: I've never used steppers, someone else will have to help you.
    5: Basic stamps don't have interrupts at all. They are "single task" microprocessors.


    Here's a quick breakdown of how a BS2 works:
    You write your code in a custom Basic Parallax created called PBASIC. This has all the features of normal Basic plus a lot of others (the I2C stuff and the like). Please note that not all commands
    work on all stamps. You most likely have the "normal BS2" like me. I don't believe I2C works with these, but I could be wrong.

    After you write your code, the compiler translates the Basic into "Tokens". These Tokens can be thought of as lower level than assembly, but not quite binary. They are not english-readable and
    aren't meant to be so.

    The Token language is then uploaded to the stamp's EEPROM. There it resides until called for.

    The Basic stamp then has an Interpreter chip that reads the code off the EEPROM and then executes it. This interpreter chip has onboard RAM and like to be able to actually run your program.

    Because the BS2 has to access EEPROM with every task it performs, it is slower than most microprocessors... but the upside is that it is FAR easier to learn than pretty much everything out there.

    Most of the time, the Interpreter chip is a SX microcontroller (another Parallax product), although the normal BS2 has a PIC instead. These are preprogrammed and you cannot replace or
    directly program them.

    Think of a BS2 as a "front end" for a more advanced chip.

    If you are comfortable with the BS2, I'd suggest sticking with it. If you want more power, I'd suggest either getting a more advanced BS2 or going for SX. The SX can also be programmed in
    Basic (SX/B) but it can also be programmed in assembly or C. There is far less support for an SX, but there's still enough to get you started. Especially if you want to learn assembly.

    If your budget allows and you feel up to the challenge, the Propeller is also an option... it has audio-video capabilities and can be programmed in a couple different langauges as well (not Basic
    I believe). Personally, I always recommend going to the SX next (especially since each SX chip is less than $4 USD so you can have many projects with them)
    The SX also has interrupts.

    Please note that I am, myself, a newbie to a lot of this stuff. I just read a lot and thought I'd pass on the information. Some of it may not be correct.
  • $WMc%$WMc% Posts: 1,884
    edited 2009-03-01 01:24
    James Harrison

    Like Ugha stated This is the best forum going that I now of.And I have tried a lot

    Did You Say You got Your BS2 At Radio Shack?

    If so this is great news

    James: If You have some problems, just send a Post Reply to this thread and We will help You get started.

    ______________$WMc%________________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • James HarrisonJames Harrison Posts: 4
    edited 2009-03-01 13:42
    Hi.
    Thanks Ugha and $WMc% for your help.

    I am still unsure how to get the stepper motor to rotate 360 deg. Is it possible?

    Thanks
    James
  • James HarrisonJames Harrison Posts: 4
    edited 2009-03-01 13:47
    All,

    I have been using stepper motor instead of servo. Can I make the supplied servo rotate 360 deg?

    Thanks
    James Harrison
  • rixterrixter Posts: 95
    edited 2009-03-01 15:36
    Often stepper motors as used in servos have a limiting tab to keep them rotating 360 degrees. Servos are probably used most often for radio controlled cars and planes where full rotation is not required to activate steering and control surfaces. There is enough documentation out there on the internet showing how to modify a servo for full rotation as this is how the servos in the BoeBot projects work to provide locomotion.

    Here is one:

    http://www.sharemation.com/Jrobota/Robot vehicle with Elektor Electronics version of BoE installed on top..pdf?uniq=-m2xnax

    Here is another link to some info on stepper motors:

    http://www.maelabs.ucsd.edu/mae_ds/stamp/how/hardware/motor_stepper/stepper-workshop.pdf

    Rick
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-01 15:39
    Depends on what you have. Servos come in two varieties: standard and continuous motion. Standard servos usually rotate around 240 - 270 degrees. Some servos are manufactured for 360 degrees or even 720 degrees of rotation, but these are special purpose. The width of the control pulse (roughly 1ms to 2ms) specifies the position of the servo. Continuous motion servos are modified or manufactured to move at variable speed in either direction with no mechanical stops to their motion. The control pulse specifies the direction and approximate speed of the motion, not the final position.
  • rixterrixter Posts: 95
    edited 2009-03-01 16:00
    While the BASIC Stamps do not implement true interrupts, you have to decide if a true interrupt is essential for what you are trying to accomplish. Interrupts are a "tap on the shoulder" or "whack up side the head" to the processor telling it that something else is going on over here that you need to know about. Generally these would have a priority assignment to them. Using a human analogy, you're there painting your living room and the phone rings and the timer for the oven goes off. So you put down the paint brush, take the pie out of the oven then answer the phone. Then you resume painting.

    For your BASIC Stamp projects where the processor doesn't implement a way to inform you of these events happening while your program is running, you must go and check them on your own. So your PBASIC code comprises of a loop that works like this:

    1) do some painting
    2) go see if the oven timer has gone off
    3) check to see if the phone is ringing
    4) go back to step one and repeat.

    When the loop is small and the processes within each step are fast, this can work depending on your application. Faster processors naturally do this better. Where you get in trouble is if you flat out miss an event by taking too long to get back to check for that event or the event was so critical that missing it is failure. Let's say for example that some attached circuit activates a pulse and you are looping around checking for that. A true interrupt could see this event and immediately get the attention of the processor. But if your code got bogged down by the time it cycled around to check for this event, it may miss it. Now let's say your attached circuit activates a switch. When your code loops around to check for this, it will successfully see this event and can deal with it, and perhaps turn the switch back off. So it all depends on what you are trying to achieve with the interrupt concept.

    Rick
  • James HarrisonJames Harrison Posts: 4
    edited 2009-03-02 11:43
    Mike and rixter, thanks for you replies.

    rixter,
    imagine this scenario. I have a button and an LED. The button and LED are connected to the IO ports of the Stamp. If my main program is to turn the LED on and off continuously, I have to pause (at least for 500) so it can be accurately interpreted by a human (pressing a button does only last about a half to a second long); so during the sleep I press the button, I cannot interrupt the pause or set a program flag to indicate the button press. I need a way to tell my program the button was pressed during the pause.

    I see the POLL commands could do something like what I want to do, but how do you put programs into specific slots.

    James Harrison
  • rixterrixter Posts: 95
    edited 2009-03-02 13:03
    James,

    You are dealing with a few issues there.

    The part about accurately interpreting the human action of pressing a button and typical durations of how long this is are what the BUTTON command attempts to handle. Again though, you still have to monitor the button by having the BUTTON command in your programming loop.

    The Poll commands are only available in the BS2P series of BASIC Stamps. You will note though when studying this command that it polls inputs between instructions. While this polling will occur faster and more often than you would be able to do with a PBASIC programming loop, it still isn't a true interrupt.

    Having programs run in a different program slot is a feature available in the BS2e BASIC Stamp and higher. With these Stamps you can utilize multiple 2K memory slots for programs and data. Check out the RUN and STORE commands to see how this works. While a bit unnatural to grasp at first, I've found this feature very useful. You won't be able to have one giant continuous program across these slots, but you can break your program up into segments with some craftiness.

    Rick
  • UghaUgha Posts: 543
    edited 2009-03-02 13:05
    What you can do instead of pausing, is setup a loop to execute 500 times that has a 1 pause in it along with a poll to detect user input.
    You'd actually need a bit less than 500 loops due to the fact that checking the user input and executing the loop eats up some processor time.

    You can do this with a normal BS2
Sign In or Register to comment.