Shop OBEX P1 Docs P2 Docs Learn Events
Member Supported FAQ — Parallax Forums

Member Supported FAQ

MrBi11MrBi11 Posts: 117
edited 2013-01-14 11:01 in BASIC Stamp
#1.. Use the forum's search feature [noparse][[/noparse]button on top right of page]

Or and select advanced search

add "inurl:f=5" without quotes to the words to search for to limit to BASIC STAMP forum

Chances are you're not the first to experience the same issues.

Computer Doesn't recognize Basic Stamp:

Low battery level.

Not all USB to RS232 adapters work with the basic stamp.

Are the correct drivers installed for your USB/232 device?

what ones work thread

Controlling a Relay:

The stamp will not drive a relay directly.

You'll need a transistor driver AND a diode to prevent cooking the output.

Sample of 5V Relay circuit.

Need more I/O:

Start by re thinking, multiplexed I/O can save many pins.

Shift registers like the 74LS165 or 74LS595.

I2C Chips like The PCF8574 or PCF8575.

Why do my robot's wheels turn in opposite directions when I send them both the same command

Giving the same command to both wheel motors will turn them both in the same direction.

When they face in opposing directions and both rotate CW [noparse][[/noparse]or CCW] your robot will spin in circles.

They need to rotate in opposite directions for forward [noparse][[/noparse]or backward] movement.

This must be taken into consideration when turning also.

Making a wide arcing turn you may just slow one motor down [noparse][[/noparse]relative to the other side] causing the robot to turn,

or you can force it to 'turn on a dime' by reversing one motor, but physics comes into play when you try to

take a forward moving mass and reverse it's direction in fractions of a second.

How do I get the Stamp to run two programs at once?

Simple, you can't. Your PC doesn't run two programs at once, it just switches between different programs

at a very fast pace making it seem to be running them both [noparse][[/noparse]newer multi processor systems excluded]

on your PC this is handled by the operating system.

To do the same thing with PBASIC you would need to program the entire function yourself

Without hardware interrupts to work with causing the processors state

to be saved swapping would require a large amount of overhead.

That said, you can load more than one program into the Stamp and switch between them using different 'program slots'

and switching between then as needed.

How to Control a DC motor

The stamp can not power a DC motor directly, you need to utilize some sort of driver.

This can be as simple as controlling a relay to start/stop you motor or a high power transistor circuit.

If you require variable speed you'll also need some form of DAC [noparse][[/noparse]digital to analog converter] or PWM [noparse][[/noparse]pulse width modulation]

There are many variables that are involved to select the proper method for a given application.

Controlling a stepper motor

First Step Would be to understand how a stepper motor works.

You can control the phases A+ A- B+ B- using 4 different pins [noparse][[/noparse]with driver transistors]

for slow movements using the following pattern:

0 0 0 1

0 0 1 0

0 1 0 0

1 0 0 0

My choice would be to use a 'driver' board that accepts signals of step & direction from the Stamp

and does all the timing and supplies the power required for the motor I'm trying to control.

This can be done using the PULSOUT command. but I've found that due to the overhead of PBASIC

the signals can be intermittent [noparse][[/noparse]causing the motor to surge].

I've used a 555 Timer circuit to control my steps with the Stamp controlling the 'reset' pin on the timer chip.

A I2C digital resistor connected to the 555 could control speed to some extent.

Maximum control would be with an external driver board that accepts serial commands from the stamp

How can I program the PIC**** to be like a BS2?

Start a company, hire a bunch of people to develop & prototype the assemble language and upload it to your selected

PIC's processor. Being very careful not to violate any copyrighted material. [noparse][[/noparse]/sarcasm]

I have a BS2px, and It says I've ran out of memory. What's up?

Even though the BS2px has 16K of memory it's sectioned off into 8- 2K blocks called Program Slots

Each slot shares the same I/O but can have a different 'program' in each, you can only run 1 at any time

but they can share data between each other and one program can turn control over to another.

With some pre-planning you can break up your project into sections and use the slots together to control everything

Example: one slot could be a routine to configure variable values need to operate your project and another

slot contains the operating 'running?' routine and a 3rd slot for a 'reporting' section.

Recovering Program from stamp to make copies/back ups

The question comes up about loosing source code or wanting to copy a chip someone else has made

This question raises an eyebrow about the persons legal rights/morals as to making illegal copies

regardless of the reasoning, recovering source code from a chip is not something that is practical.

An advanced programmer may be able to write a program to dump the EEPROM and get the PBASIC tokens

from the chip [noparse][[/noparse]other than the area they overwrote with there program], and reverse engineer it.

but the effort would be more work than re-writing from scratch [noparse][[/noparse]not to mention incomplete]

So, in response to that question, My reply is "You Can't", So making backups of your development is highly advised.

Serial Data transfer:

Serial communications is the process of transferring more than one piece [noparse][[/noparse]bit] of information over a single path. This path can be in many forms as described later, but first let's look at exactly what serial transfer is.

If I tell you I'm going to tell you the ages of every one in Mrs. Smith's 3rd Grade class in Alphabetically order [noparse][[/noparse]and you know who is in her class]. I can read off the ages [noparse][[/noparse]transmit] and you could re-assemble them to the proper person [noparse][[/noparse]receive]. Now let look at this differently, the phone line only works intermittently, so to make sure you hear I’ll repeat each age for an entire minute.. the first minute I repeat Johnny’s age over and over ”8”,”8”,”8”….

the second minute I repeat Jane’s age… “7”,”7”,”7” etc…, now with this pattern you know you only have to hear [noparse][[/noparse]sample] what I’m saying once each minute….. [noparse][[/noparse]data rate]

Okay, now lets look at digital data... lets transmit the number 167 [noparse][[/noparse]hopefully you understand different number bases: $A7 or %10100111]. we can start by sending it LSB [noparse][[/noparse]least significant bit] first, at a speed of one bit per second.

Second Data---Pin Level









But what if You started listening at a different time than when I started sending?

Timing is everything, somehow we need to make sure were both looking at the same time slot, this can be done a couple different ways. Synchronous would be if when I’m telling you the ages on Mrs. Smith students, the first ten seconds a light turns on the phone, now you know when to listen [noparse][[/noparse]Clock signal].
Note: we ‘sample the data at the rising edge of the clock cycle, this ensures that the data line has stabilized.

Asynchronous, we would just time the signals so we are the same. First off, Asynchronous isn’t, it still needs to be synchronized somehow. Adding a start bit! … If you simply know the rate that the information arrives but not when, you could sit and listen for a que as when to start the timing. but if we do this we need to make sure there is an area between when I don’t talk.. hence the stop bit(s)
With this method, the receiver waits for the beginning of the start signal then 1.5 time frames later it starts getting the data, This picks up the signal level in the center of the frame, again giving the data line time to stabilize.

The time frame needs to be known for asynchronous transfer, It is measured in ’frames per second' or BAUD.. So if we’re set up to ’talk’ as 9600 baud, each frame would be 1/9600 seconds or about 104mS wide, assuming the above format at 9600 Baud, we can transmit 960 eight bit words a second.

9600 bit per second / (1 Start + 8 Data + 1 stop bit)

Error checking, Parity… we Can have a simple error checking method by adding Parity, this would be an added bit that is calculated on each end based on the total number of high level bits in the data word being transferred. With Even Parity the level of the parity bit will make the data word [noparse][[/noparse]including the parity bit] have an even number of high bit’s. In the example number of $A7 there are 5 high level bits, so the parity bit would also be high making it even [noparse][[/noparse]5+1=6 an even number], if we had set odd parity the parity bit would be low [noparse][[/noparse]5+0=5 an odd number]

But since we just added parity our data stream per word got larger by one bit per word. so now we can only get 9600/11 or 872 words per second. And [noparse][[/noparse]with other overhead] when we get a parity error [noparse][[/noparse]i.e. receiver doesn’t calculate the same level as it received] typically there is a request send back to the sending unit to re send the data. although this slows down the transfer there is a better chance of it being accurate.

Okay kids, if you're not confused yet, let me make sure you are soon!

Add to the above the way the data is transferred! The samples above were TTL level [noparse][[/noparse]+5V/Ground] while this works fine for very short distances [noparse][[/noparse]from one chip to another] , it won’t work very well across the room. There is to much of a chance of electrical ‘noise’ to be introduced in the signal. The Electronic Industries Alliance has made some Recommended standards these include:

RS232 where the signals are anywhere between +3 and +12 volts for a low logic level and -3 to -12 for a high logic level. Note that the voltage level is inverse of the logic level [noparse][[/noparse]This is why there is an inverted TTL level defined with the Basic Stamp] . This is a single ended signal, meaning the voltage levels are measured from a ground level. this signal is only recommended for about 50 feet [noparse][[/noparse]I’ve ran it between building overhead across the road, without issues before] due to the possibility of interference introduced into the signal. Another downfall is what is known as ground loop interference, where there is a difference between the ground levels of the units.

RS422 - this standard is defined to be +/-2 to +/-6 volt differential driven, this signal is a pair of wires and the signal is measured between then [noparse][[/noparse]not between the signal and ground]. This signal is capable of faster speeds over 4000’, much improved over the RS232. Also with RS422 you can have more that just one device on each end of the connection, you may have one master device talking to as many as 10 slave devices. the trouble is talking back could cause collisions, where to many devices are talking at the same time.

Both of the above are half duplex signals [noparse][[/noparse]one side talks, the other side listens] to make then full duplex [noparse][[/noparse]both side and talk and listen] you need to add another signal path for the opposite direction [noparse][[/noparse]i.e. transmit & receive]

So now we introduce DTE and DCE.. being Data Terminal Equipment [noparse][[/noparse]Computers, terminals etc] and Data Commutations Equipment [noparse][[/noparse]Modems, Printers etc] the difference between these two devices is what data path they talk/listen on. A null modem cable is a connection that is used to connect two like items together [noparse][[/noparse]as in computer to computer]


RS485 These signal levels are close to the RS422 and the same distances, but you can transmit and receive over the same data path, and connect as many as 32 devices on the bus. There sill is typically a master device on the bus overseeing that there are no data collisions.

Is RS232 Dead yet?

Even though the RS232 standard has been around since the 60’s [noparse][[/noparse]a heck of a long time in the computer industry]. I don’t think we’ll see the end of it any time soon, it’s still the most used short distance standard there is, common to many devices both new and old. Developing your widgets using this standard will be a safe bet to be compatible with another manufactures device for a long time. this is not based on any fact, just my editorial 2¢

If you're using anything other than TTL

You’ll need to add external hardware to convert the signal levels to the desired standard.
There are different ways to do this, via simple transistor drivers or dedicated IC’s designed for the task. Example the MAX232 chip is a great way to connect your Stamp the real World.
Setting up Serial commutations on your BASIC STAMP

Add the following compiler directives to the top of your program:

    T1200       CON     813
    T2400       CON     396
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
    T1200       CON     2063
    T2400       CON     1021
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
    T1200       CON     3313
    T2400       CON     1646
    T9600       CON     396
    T19K2       CON     188
    T38K4       CON     84

Inverted       CON     $4000
Open            CON     $8000

Baud            CON     T9600  + Inverted ‘ NOTE: Select the Settings you need here

Then use the commands

SEROUT PinNumber, Baud, data2Send


SERIN PinNumber, Baud, [noparse][[/noparse]format] Var2ReceiveIn

SOON TO COME: I2C and SPI defined...


Any other things people can think of I'll add to this post.
Thanks everyone for your support

Smile ... It increases your face value!

Post Edited (MrBi11) : 2/23/2009 11:44:29 AM GMT


  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-08 15:35
    I strongly recommend using a different schematic for the relay driver that puts the relay (and diode) in the collector lead of the transistor rather than the emitter. There's a diagram in Nuts and Volts Column #6 that shows this.

    The problem with your circuit is that the base current (that switches the transistor) has to flow through the relay coil which has resistance and also opposes the change in the flow of current when the Stamp pin turns on. This will reduce the gain of the transistor and slow down the turning on of the transistor.
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-08 16:32
    change made, and new image added

    Smile ... It increases your face value!

    Post Edited (MrBi11) : 2/11/2009 7:55:12 PM GMT
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-02-08 19:15
    How do I use the Basic Stamp to process audio/video?
    How do I get the Stamp to run two programs at once?
    How do I get a cheaper widget than the one that Parallax sells to work properly?
    Why do my robot's wheels turn in opposite directions when I send them both the same command?

    Edit: Er, I hope it's clear I meant these to be part of the FAQs, not actual questions that I have. I see good answers below: mostly "you can't". I'd add "go to the support forum for the manufacturer of the cheaper widget and ask there" as part of the answer to my third question.

    Post Edited (sylvie369) : 2/9/2009 12:34:33 AM GMT
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-08 20:03
    I'm new to the Basic Stamp and PBASIC, first time I saw one was less than a month ago. I don't know how to processes audio/video [noparse][[/noparse]without a lot of external circuitry]. It seems to me that none of the Basic Stamps have the required processing power [noparse][[/noparse]speed] to handle that task.....

    teach me.....

    I'd also need to know what 'widgets'...

    Smile ... It increases your face value!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-08 20:04
    1) You can't really. The Basic Stamp is too slow to process video although it can control a video device (like pushing buttons to play or record). It's mostly too slow to process audio although some commands like FREQOUT can produce audio.

    2) It can't really. There's only one processor in the Stamp, so it can only do one thing at a time. You can attach additional processors to a Stamp and you can network several Stamps together, but, if you want to do two things at the same time, you need something like the Propeller that can really do several things at the same time. It's possible to combine two programs together so two functions are interleaved and the Stamp appears to be doing several things at the same time. The BoeBot works somewhat that way in that servos require control pulses about 50 times a second. The Stamp in the BoeBot can read sensors and do some decision making in between the servo pulses since there's about 17ms left in the 20ms interval before another servo control pulse has to be generated.

    3) That depends on the widget. Maybe you can't. Part of what you pay for when you buy from Parallax is the attention to detail in making sure their products work and work properly. They also provide first rate service and support when, for some reason, things don't work as expected.

    4) The servos that drive the wheels are mounted opposite to each other. One of them moves clockwise and the other moves counter-clockwise for the robot to move forward. They need different commands for the robot to move forward. If you send them the same command, the robot just spins.
  • SRLMSRLM Posts: 5,045
    edited 2009-02-08 20:24
    How do I get the datalogger to work with the stamp?
    How can I control a DC Motor?
    How can I control a stepper motor?
    I have a BS2px, and It says I've ran out of memory. What's up?
    I hooked up my LCD, and tried a DEBUG command. Nothing shows up. How do I fix it?
    How can I program the PIC**** to be like a BS2?
    How do I connect two BS2s together?
    How do I make a computer control a BS2 wirelessly?
    I want to make a weather station. How do I store the data?
    How do I make my BOE-BOT solve a maze?
    How do I time an event with my BS2?

    If you get a big list, you should convert it into a nice PDF format, and just update that. Maybe have a list in your post of all Qs, and then the attached file. Just a thought.
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-08 21:17
    like a stated in the above post, I'm new to the Basic Stamp.
    The way I'd make things work and the way it should be done using items from Parallax's inventory may not be the same.
    I could use some help from the people who have been around for awhile in answering [noparse][[/noparse]BTW, thanx Mike, even though I was editing the OP when you answered]
    just posting up the questions is making me think more than my tiny little mind can handle.

    it's just in the month that I've been here, Ive seen numerous posts dealing with the same topic [noparse][[/noparse]i.e. USB2Serial]

    I don't want to step on any toes with my answers to the questions.


    Smile ... It increases your face value!
  • Desy2820Desy2820 Posts: 138
    edited 2009-02-08 21:21
    As you continue to develop the FAQ document, it would be really nice to make it a "sticky" at the top of this forum.... (hint, hint)
  • SRLMSRLM Posts: 5,045
    edited 2009-02-08 21:22
    Go ahead! Make a really nice document, and include it in your signature. Then, when you see a post that deals with one of the Qs, just say: "follow the link in the sig." No toes or feelings crushed over here.
  • MSDTechMSDTech Posts: 342
    edited 2009-02-08 23:33
    Actually, what would be nice is a reference post like the one in the SX Forum. Capt. Quirk did an excellent job of creating an index to the posts and other reference matrials. See:
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-09 00:10
    That is great, he did a good job...

    Smile ... It increases your face value!
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-02-09 03:46
    Oh, a new post reminds me of another one (again, whose answer is "You can't):

    "I didn't save my program on my computer, but it's loaded onto my Stamp. How can I download it from my Stamp so I can program it into another Stamp?"

    Maybe there should just be a section for frequently asked questions whose answer is "You can't".
  • Craig EidCraig Eid Posts: 106
    edited 2009-02-09 23:49
    Add some notes regarding baud rates, baumode and communicating between two Stamps - we've had a few postings on these items in the last few days.

    Craig Eid
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-02-10 04:15

    You've taken on a big task. I hope you stick with it. You will learn a lot and I will too.


    You are what you write.
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-11 16:32
    Images for Serial information added to first post.. so this is just blank other than attachments

    .. See first post for Serial Transfer

    Smile ... It increases your face value!

    Post Edited (MrBi11) : 2/12/2009 12:48:00 PM GMT
    564 x 86 - 2K
    590 x 172 - 3K
    744 x 472 - 7K
    475 x 125 - 6K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-11 17:05
    If you're going to keep updating the page it will remain a sticky. Sorry I missed the original messages hinting about this. You can always ask a moderator for something like this. Good luck on this project. Take care.

    Chris Savage
    Parallax Engineering
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-02-11 18:49
    A couple of edit suggestions:

    The "Recovering Program from stamp to make copies/back ups" section seems to me to be conflating two very different things (of course the answer to both is "you can't").

    Asking about cloning a Stamp chip in order to somehow make Stamps cheaper is one thing, while asking about recovering a PBasic program from a Stamp chip is a completely different thing. When I suggested this topic, I meant the latter. I think that the section needs to be divided into two parts, or perhaps two entirely different sections. Otherwise someone who wants to recover a PBasic program he has written from a Stamp chip will look at that section and fail to realize it's telling him that he can't.

    The line "Okay kid’s, if your not confused yet, let me make sure you are soon!" should say

    "Okay, kids, if you're not confused yet, let me make sure you are soon!".

    There's another errant "your" in the heading for the section after that. The rule for "your" versus "you're" is very simple.

    "You're" = "You are". (Just like "I'm" = "I am", and "He's" = "He is")

    If you mean "You are", then use the apostrophe ("You're"). If you mean "something belongs to you", then use "your".

    Post Edited (sylvie369) : 2/11/2009 6:55:02 PM GMT
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-11 19:03
    yes, that is one of my common mistakes [noparse][[/noparse]your vs you're]

    Smile ... It increases your face value!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-11 21:47
    Hopefully forum members will continue to help keep this FAQ up to date and error free so everyone can benefit from it. Take care.

    Chris Savage
    Parallax Engineering
  • SRLMSRLM Posts: 5,045
    edited 2009-02-11 22:00
    Some suggestions:

    If it's a FAQ, then each heading should be a question, right?
    I think you should be careful about letting it diverge into a 'how-to' guide. Often, a short explanation and a link would work as well and keep it concise.
    How about numbering each question, and having a list at the top of the post that has each question?

    Congratulations on making the sticky!
  • Craig EidCraig Eid Posts: 106
    edited 2009-02-12 07:09
    Congrats on the sticky!

    Craig Eid
  • SRLMSRLM Posts: 5,045
    edited 2009-02-12 08:48
    For searching the forum tips, take a look at this thread:

    -controlling a motor, "give" should be "given"

    -Supported USB to serial: the one parallax sells and most FTDI chip based converters
    --Other solutions might be incorrectly installed drivers: try downloading the prop-tool (it installs them automatically).

    Some part numbers on your diagrams would be, or perhaps the question: "[noparse][[/noparse]something] says to use a general purpose transistor(PNP/NPN)/relay/diode/current limiting resistor/etc." Answer to question would be something like:
    -General Purpose NPN Transistor: PN2222 Link / Link / Link

    Under the wheels in opposite directions, "causing it to turn" should be "causing the robot to turn"
    -Some capitalization at beginning of sentences would be good.

    The line " It is measured in ’frames per second or BAUD. " needs another " ' ".

    Another question: I don't understand anything! Where do I start? [noparse][[/noparse]Link to parallax stamps in class books]

    Keep up the good work.
  • UghaUgha Posts: 543
    edited 2009-02-13 21:52
    I just realized the info I'm currently looking for would most likely be a FAQ.

    How fast does a BS2 do X? (in my case, transmit a serial byte).

    There's a webpage out there SOMEWHERE that lists average speed rate for the various commands but I can't find it anywhere.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2009-02-17 16:33
    Ugha, maybe you were looking for this page on Stamp instruction timing.

    Tracy Allen
  • UghaUgha Posts: 543
    edited 2009-02-17 17:27
    Yep... that's it!
    Its a great site with a lot of info... I assume its yours? If so, great job [noparse]:)[/noparse]

    Its a shame it isn't complete though... and its a shame Steve Parkis' website doesn't feature that code/information anymore.
  • NR1XNR1X Posts: 111
    edited 2009-03-20 00:19
    I found what i needed in the Basic Stamp Manual, but I'm sure it is also asked over ,and over!!! "I have just purchased the BS2px and when i plug it into my BOE it does not work the same??" might consider adding
  • MrBi11MrBi11 Posts: 117
    edited 2009-03-21 17:28
    Does not work the same? I assume you mean that it's faster [noparse][[/noparse]and things like serial I/O change]?

    Smile ... It increases your face value!
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-05-08 01:54
    Please add a link to “Pull-up resistors” ·and / or appropriate comment as "frequently omitted hardware" causing programmers grieve
    Cheers Vaclav
  • davejamesdavejames Posts: 4,046
    edited 2009-06-06 21:11
    SEROUT/SERIN with HyperTerm...

    If SEROUT/SERIN are used in their simple form , IE no "flow control", make sure HyperTerm flow control is set to "none".

    HyperTerm's flow control setting can be found:

    File -> Properties -> Connect To -> Configure -> Port Settings -> Flow Control (Hardware, Xon/Xoff, None)



    Instead of:

    "Those who can, do.· Those who can't, teach." (Shaw)
    I prefer:
    "Those who know, do.· Those who understand, teach." (Aristotle)
  • Lab RatLab Rat Posts: 289
    edited 2009-07-12 14:28
    what happens if my stamp dies or seems to be dead how do i know whether it is truely dead how can i test this theory and if it is does parallax repair them and what is the going price for such a repair

    (if i remember correctly somewhere one of the moderators posted a topic on how to test your stamp and i think parallax does repair them for a fraction of the cost of new but i forget all the details)

    Parallax posesses power beyond belief.

    Believe in it.
Sign In or Register to comment.