Novice having problems with Serout
SSchaffer
Posts: 12
Hello,
···· I'm currently working on a program in C# communicating back and forth with my Basic Stamp controller (Homework Board). I have a serial cable coming out of Com 3 leading to my Microcontroller, with the Red wire (Receive) connected to Pin 0, the·Purple wire (Transmit) connected to Pin 1, and the Brown wire connected to Vss. All 3 wires have 22 kOhm Resistors soldered to the ends before going into the Pins.
···· I have no problem transmitting from my computer to the Basic Stamp. On the Stamp, I am using the commands:
LOOP1:
· DO
··· SERIN 0, 19697, 60000, LOOP1, [noparse][[/noparse]reader]
··· SERIN 0, 19697, [noparse][[/noparse]facility1]
··· SERIN 0, 19697, [noparse][[/noparse]facility2]
··· SERIN 0, 19697, [noparse][[/noparse]badge1]
··· SERIN 0, 19697, [noparse][[/noparse]badge2]
··· SERIN 0, 19697, [noparse][[/noparse]issue]
··· SERIN 0, 19697, [noparse][[/noparse]dooro]
··· <Other Code>
· LOOP
···· I am using the utility Portmon to confirm that the data I'm sending is travelling at 300 Baud and is correct. However, when I try to transmit from the Basic Stamp to my computer, it's not working:
SEROUT 1, 19697, [noparse][[/noparse]1]
···· Portmon is telling me that the the information is being sent at 9600 Baud, even though I specified 300 Baud, and what is being sent is a 42 hex instead of a 1.
···· Anyone happen to have seen this before or have an idea of how I could proceed?
···· Thanks,
········· Scott
···· I'm currently working on a program in C# communicating back and forth with my Basic Stamp controller (Homework Board). I have a serial cable coming out of Com 3 leading to my Microcontroller, with the Red wire (Receive) connected to Pin 0, the·Purple wire (Transmit) connected to Pin 1, and the Brown wire connected to Vss. All 3 wires have 22 kOhm Resistors soldered to the ends before going into the Pins.
···· I have no problem transmitting from my computer to the Basic Stamp. On the Stamp, I am using the commands:
LOOP1:
· DO
··· SERIN 0, 19697, 60000, LOOP1, [noparse][[/noparse]reader]
··· SERIN 0, 19697, [noparse][[/noparse]facility1]
··· SERIN 0, 19697, [noparse][[/noparse]facility2]
··· SERIN 0, 19697, [noparse][[/noparse]badge1]
··· SERIN 0, 19697, [noparse][[/noparse]badge2]
··· SERIN 0, 19697, [noparse][[/noparse]issue]
··· SERIN 0, 19697, [noparse][[/noparse]dooro]
··· <Other Code>
· LOOP
···· I am using the utility Portmon to confirm that the data I'm sending is travelling at 300 Baud and is correct. However, when I try to transmit from the Basic Stamp to my computer, it's not working:
SEROUT 1, 19697, [noparse][[/noparse]1]
···· Portmon is telling me that the the information is being sent at 9600 Baud, even though I specified 300 Baud, and what is being sent is a 42 hex instead of a 1.
···· Anyone happen to have seen this before or have an idea of how I could proceed?
···· Thanks,
········· Scott
Comments
I've seen some serial ports not be able to properly establish a zero crossing when the incomming signal has only a 5v swing. I'd try pulling the 22K resistor off of the output line from the stamp to the computer. It's unlikely the stamp is going to produce enough current to damage anything on the CPU. Where is the ground on the serial line tied?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A wise man told me; "All electronics are made to work by magic smoke.
Don't ever let it out as it's·very difficult·to get it back in."
http://weimenglee.blogspot.com/2006/09/build-low-cost-ttl-to-rs232-level.html
And you can read the first 6 chapters online of this book
http://www.smileymicros.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=50
And the prebuilt ones
http://www.sparkfun.com/commerce/product_info.php?products_id=449
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Post Edited (metron9) : 8/23/2008 1:21:44 AM GMT
Thanks for the reply. I hadn't considered that possibility. All the wires, including the Ground wire, all have 22 KOhm resistors. The Ground wire on the Basic Stamp side is tied to Vss. I'll try removing the resistor on the Transmit wire. I suppose that I can take it off the Ground wire as well, correct?
Thanks again,
Scott
Thank you very much for the links. It looks very helpful. I've downloaded the book chapters and will look them over.
Scott
You need to use a level shifter. The higher voltage signals get converted to lower 0 and +5 and your 0 and +5 get converted to -12 and +12 so the computer com port can read the signals. Some laptops now can read 0 and +5 but just use a level shifter so it works on any computer.
Another cute little device , I just got one is from smileymicros.com called the usb thingee check that out as it allows USB connection and your C programs can talk to the virtual COM port through the USB and it has the proper level shifters built in.
And for those who may want to try C but not get into the C# or c++ giant bemoths the lcc-win32 compiler is great. Google it and give it a try. I just found this code on one of their forums. Pretty raw but I tested it with the usbthinge from smileymicros and output the letter "U" and captured it on my scope with this code. I will have to rewrite the code so it is easier to use but for now I know it works.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Post Edited (metron9) : 8/23/2008 3:46:04 AM GMT