RS 232 Question for a newbe (BS2)
YORKIE
Posts: 6
Hi there,
I'm new to Parallax and the world of Basic Stamp.
I have completed many experiments, and I want to further one particular experiment for a future application.
The experiment was controlling the position of a servo with a potentiometer using an RC time circuit.
What I want to achieve is the same, but over a range of 50 meters/150ft.
I believe this can be achieved using two basic stamps, connected via RS232
One basic stamp being the input - Potentiometer/RC time circuit and the second module being the output - Servo connected.
Can anyone point me in the right direction as to what code I need on each of the modules?
This is my code so far:
Thanks in advance
=]
I'm new to Parallax and the world of Basic Stamp.
I have completed many experiments, and I want to further one particular experiment for a future application.
The experiment was controlling the position of a servo with a potentiometer using an RC time circuit.
What I want to achieve is the same, but over a range of 50 meters/150ft.
I believe this can be achieved using two basic stamps, connected via RS232
One basic stamp being the input - Potentiometer/RC time circuit and the second module being the output - Servo connected.
Can anyone point me in the right direction as to what code I need on each of the modules?
This is my code so far:
' What's a Microcontroller - ControlServoWithPot.bs2
' Read potentiometer in RC-time circuit using RCTIME command.
' Scale time by 0.724 and offset by 500 for the servo.
' {$STAMP BS2}
' {$PBASIC 2.5}
PAUSE 1000
DEBUG "Program Running!"
time VAR Word' Read potentiometer in RC-time circuit using RCTIME command.
' Scale time by 0.724 and offset by 500 for the servo.
' {$STAMP BS2}
' {$PBASIC 2.5}
PAUSE 1000
DEBUG "Program Running!"
DO
HIGH 7
PAUSE 10
RCTIME 7, 1, time
time = time */ 185 ' Scale by 0.724 (X 256 for */).
time = time + 500 ' Offset by 500.
PULSOUT 14, time ' Send pulse to servo.
LOOPHIGH 7
PAUSE 10
RCTIME 7, 1, time
time = time */ 185 ' Scale by 0.724 (X 256 for */).
time = time + 500 ' Offset by 500.
PULSOUT 14, time ' Send pulse to servo.
Thanks in advance
=]
Comments
--Rich
Ok then, same question, but how to I go about using 485 for the comms.
Would I set it up as 232, and use a 485 converter?
Thanks
Yorkie
'485 is a good thing to learn about. Use 75176 chips (or the more modern versions) at each end to create a half-duplex system that can be adapted to a wide range of communication tasks.
Cheers,
True RS232 signal levels (not what's used for the programming / debug port) are used all the time over a 50 meter range. In a high electrical noise environment or where you want speeds greater than say 9600 Baud, you may want to use RS485.
I would like to go ahead and use RS232 over the range, which is actually 40m. I believe I can achieve this with RS232.
Any help on the code would greatly be appreciated.
Best Regards
Yorkie
You'll be able to use SERIAL communication by tieing two stamps together, but unless there's some over-riding technical need, you'll probably do it with the 5 volt levels of the stamp, not the "real" RS-232 levels of +/- 12 volts or +/- 15 volts.
See the Help file under SERIN for a solid example of how to connect 2 stamps together.
Cheers,
If I use the stamps 5v SERIN/SEROUT for communication, what range would I be looking at.
About the code, I can't get my head around the help file.
Please, Please someone give me a wee hint.
Thanks
The example in the SERIN helpfile is quite straight forward and has the connections and sample code. Its near the bottom of the Help article for SERIN.
You've already got the servo code. Just add on the serial communication code.
Cheers,
Sorry to be a pain, but which Help file are you referring to?
Cheers mate
Click on "Help", then "Index". Scroll down to SERIN.
If you're on a Mac, I don't know where the file resides, but you can probably download it as a text file fromthe Parallax web site.
Got it! I am running on a Mac, but recently installed Parallels which lets me run windows as a virtual machine.
Just downloaded the Stamp Editor, and found the help section.
I will read through, and try and grasp it.
Many Thanks for your help.
Nik