#1.. Use the forum's search feature
[noparse][[/noparse]button on top right of page]
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.
C 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
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.
C 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.
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
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.
- 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]
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:
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
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