RS-232 Problems
spaine
Posts: 51
I understand that I can connect some device such as the Accelerometer and/or UltraSonic Sensor to a Microcontroller such as the Basic Stamp or Javelin. I understand that the stamp has a RS-232 (or TTL out) so that I can connect it to my Laptop.
Am I wrong so far?
If I'm not wrong, and that is how it works... then I only have one true problem. That is, I hope to have a OEM GPS sensor board that has a RS-232 output that will be attached to my robot. I expected the robot to transmit the GPS data over the RS-232 line. How do I get the Accelerometer, UltraSonic Sensor, and GPS signal all to go over the same RS-232 link that will connect to my Laptop?
I was thinking that the OEM GPS will connect directly to the Basic Stamp (or Javelin) Microcontroller... like the other devices, and then all three data signals will come out of the RS-232 output of the Microcontroller that will then be connected to my Laptop. Also, I want my computer to send control data back to the robot (via an RS-232 line, possibly RF). Again, I assume the Microcontroller receives the data from the RS-232 and knows (or can be programmed to know) what to do, such as turn, increase speed, and so on.
Any help is welcome... I have been going crazy over this problem. I have litterally spent weeks reading about serial bus lines, and I am only getting more confused. There has got to be an easy solution to this multiple in, one serial line out problem.
Please save me from certain insanity.
Am I wrong so far?
If I'm not wrong, and that is how it works... then I only have one true problem. That is, I hope to have a OEM GPS sensor board that has a RS-232 output that will be attached to my robot. I expected the robot to transmit the GPS data over the RS-232 line. How do I get the Accelerometer, UltraSonic Sensor, and GPS signal all to go over the same RS-232 link that will connect to my Laptop?
I was thinking that the OEM GPS will connect directly to the Basic Stamp (or Javelin) Microcontroller... like the other devices, and then all three data signals will come out of the RS-232 output of the Microcontroller that will then be connected to my Laptop. Also, I want my computer to send control data back to the robot (via an RS-232 line, possibly RF). Again, I assume the Microcontroller receives the data from the RS-232 and knows (or can be programmed to know) what to do, such as turn, increase speed, and so on.
Any help is welcome... I have been going crazy over this problem. I have litterally spent weeks reading about serial bus lines, and I am only getting more confused. There has got to be an easy solution to this multiple in, one serial line out problem.
Please save me from certain insanity.
Comments
However if you want to connect these 4 devices directly to your robot - you'll need to come up with a different solution.
I dropped you some info in the other forum wrt to the GPS.
But I'll cover some of your other questions here!
Yes indeed the stamp (we'll exclude the Javelin for the moment) is a great rs232/serial tool.
You have a programming port that will 'steal power' from the PCs port in order to give it proper rs232 levels.· Try to only use this port for programming....it's just easier (as I've found out later).
The stamp will output rs232 data in TTL levels (so 0 and 5volts).·
The stamp can use each of it's I/O pins as a separate serial line (coming in or going out).· Just to note that you do need to protect yourself from the +/-12V levels of RS232 ports....in the manual it says to use a 22kohm resistor inline with data coming in to the stamp.· This limits the current to the stamp pin and the stamps' onboard diodes will clip the 12V's down to 5V's for the uP to work with.
Take note in the help file (and manual) that you have different baudmode values that represent different baud rates.
For instance, 9600 baud coming from a laptop/PC would have a baudmode value of 16468...which represents 9600 8bit No stop bit and INVERTED.
RS232 is the opposite of TTL logic.
In TTL logic you deal with 1's and 0's.· A 1 is represented by a +5Vdc and a 0 is represented by a 0V (really a 1 is anything about 2.5v and a 0 is anything below that....).· Now in RS232, they use a +12V to represent a 0 (or a space) and -12V to represent a 1 (or a mark).· (hope I didn't get those backwards)....so, if you look at what makes up a 1 in either case...they are opposite.· So the RS232 data stream must be read in an INVERTED mode so that the stamp can convert it to TRUE logic values.
Also note that when you send rs232 data from the stamp that you have the same options to send it as inverted or true.· You will almost always sent it as inverted (and this is at TTL levels not RS232 levels but the 5V will be a logic 0 and a 0V will be a logic 1 -- so they are inverted) and most rs232 devices will read this no problem...MOST!
There are things out there called Level converters or drivers.· A popular one is the MAX232 chip.· These chips will take TTL levels and bump them up to proper rs232 levels (so 0/5volt levels to -12/+12volt levels).· So in this case you would send data in the TRUE format (for 9600 that baudmode value becomes 84--this is all in the online help file under serin/serout)....the max232 chip will then take this TRUE TTL levels and invert it and pump it up.· Very nice and depending which chip you get, only requires 5 capacitors OR none at all!
SORRY if I'm rambling...just got off the golf course and have too much energy (eg. chocolate bar).
No as far as ingesting your different sensors....you can use the serin command on a different pin that each sensors' connected to.· Now, the way the stamp works is, it only does one thing at a time.· So while you are doing a SERIN on pin 0, you will be missing data that might be coming in on other devices.· So, if you don't need the data all the time, then you might be alright...just switch to each serin line and grab the data when you can.
I know my message is wordy and LOONNGGG!! lol (not as long as my drive though)...but take it in steps.
Baby steps work well!· First talk to your sensors individually....then couple them together.
You'll find that programming efficiency will help keep things streamlines....and documenting your code will help you troubleshoot it later!
Best of luck!!
and welcome!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://ca.geocities.com/steve.brady@rogers.com/index.html
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Each received input byte could be split into two 4-bit nybbles. Two new outgoing bytes would be formed with data in the low 4 bits, and a coded nybble in the high bits showing which input port the nybble came from and whether this is the high nybble or low. The new byte would be sent out an RS232 port to your PC.
A program in the PC would read the code in each byte, reassemble nybbles into bytes and dispose of each byte according to which channel it came from.
You'd need to design the output baud rate to be fast enough to pass the combined input data streams, but both the Sx and any PC should easily be able to manage high enough speeds (although if you use RF to link to the PC you'll also need to take its baud rate limits into account).
This should work!
Thanks for all of the replies. I'm thinking about first sitting down and writing up what it is I ultimately want to do, and then passing it on to the forums to see if someone can give me some insight.
However, I'm not sure what Stamp I should go with. I saw the Nuts & Volts articles that you referenced, and I saw how those projects made use of the Scratch Pad RAM. Ultimately, I would like to have the processing performed onboard the vehicle. However, for my first pass, I think I just want to take the GPS data in on one pin, and send it (as well as any other data) out on another pin to my computer. I'm not sure if I truly need Scratch Pad for that. Also, since I currently work with Java, I was thinking about the Javelin Stamp... However, it's not the fastest, it looks like it draws the most current, and it has no Scratch Pad.
Perhaps you could recommend a Stamp. Money isn't the issue, I just want to make sure that it is easily programmable, and it's fast enough to control a vehicle moving at a good rate of speed.
The BS2. It's general enough...the base model if you will!
If you don't intend to do much compiling of data on the stamp...then it'll be fine for reading your GPS and then firing it off to your PC.
You could then do the crunching on your PC then send it back to the stamp to display on an LCD if you wanted.
The BS2px is the new model out and you might want to plan ahead and get this guy, as you may outgrow your stamp once you realize what you want to do.
There are 'command' differences between the models. the BS2pe has extra memory if you need....go to parallax's comparison chart and you can see quickly what the differences are.
I'd lean towards the new BS2px if $$ isn't an issue!
For the most part, if your stamp doesn't have enough of what you need, external ICs can be added to make up for it (external serial Eproms; I/O expanders...etc..)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://ca.geocities.com/steve.brady@rogers.com/index.html
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
I finally did it. I went ahead and went with the BS2p24, and then Motor Mind C to control 1-2 motors. I would have liked to purchase the BS2px, but I'm one of those guys that need instant gratification, and the BS2px keeps going on backorder. That's ok, I can prototype with the BS2p24, and then upgrade if I want. Besides, I'm having way to many ideas going through my head of things that a Microcontroller can be used for. This is fun...I think it's better than software programming. Speaking of, I still am interested in maybe trying the Javeline (as I'm a java programmer).
In any case, am I safe in assuming that people are helpful with pBasic programming questions?
Thanks for my help earlier on.
Stephen
You may get some "beginners grace" on your first few questions, but etiquette would be to do as much of your own homework as possible before posting (we do see a lot of repeat questions on here).
Also, if you want a specific answer, you need to ask the appropriate question! And post code that you have!
There are a lot of example programs on the net and specifically in this forum and on Parallax's site (nutz and voltz ariticles). Check them out and they'll give you some ideas!
I'm not terribly strong with the programming, but do work on electronics and I speak up where I can!
I'm scared to say this, but you can almost expect a daily reply to your post!
welcome to Stamp-land!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://ca.geocities.com/steve.brady@rogers.com/index.html
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."