BS2 Basic serial output code works fine all pins but NOT Pin 1 Sout - Page 1
Forum section: electronics / general

author: K1JOS
author_rank: Regular Contributor
timestamp: February 04, 2017, 11:31:35 pm
content: I need to send a basic stamp data stream (one direction) to a PIC device (fixed at 2400, 8N1, true polarity). I need all BS2 digital pins P0-P15 for my project so would like to use physical pin1 (Sout). I am using the following basic code to send a test stream. The PIC expects True polarity not inverted:' {$STAMP BS2}' {$PBASIC 2.5}' {$PORT COM12}Main:DOSEROUT 16, 396, ["Hello!", CR] ' send the greetingPAUSE 100 ' wait 0.1 secondsLOOP ' repeat foreverENDIt doesn't work on Pin 1 however the code works fine if I change SEROUT to any other pin P0-P15.Just to be sure I looked at the Pin output on my scope which has a UART logic decoder and its all gibberish regardless of settings I try. With the BS2 set for any pin 0-15, the code works perfectly and my scope easily decodes.Would the line driver on Pin Sout be affecting this? The only wires I have from BS2 to PIC (or scope) are the Sout and Ground.Any advice appreciated.Jerry NY2KW

author: rstofer
author_rank: Super Contributor
timestamp: February 04, 2017, 11:36:43 pm
content: Sin and Sout have a form of level shifting for connection to actual RS232 levels, not TTL levels. Not only are the voltages different, the signals are inverted.https://www.parallax.com/sites/default/files/downloads/BS2-IC-Schematic-Rev-J_0.pdf

author: cv007
author_rank: Frequent Contributor
timestamp: February 05, 2017, 12:35:25 am
content: Try setting SEROUT to inverted (for normal output), depending on how smart the firmware is.Looks like possibly very weak pulldown through the Sin npn pack, but maybe tie Sin to ground so it is used as a stronger pulldown for Sout through the 4.7k.Just a thought.

author: K1JOS
author_rank: Regular Contributor
timestamp: February 05, 2017, 12:40:34 am
content: Thanks all for taking time to reply. Can you clarify a bit more? If just higher voltage and inverted why can't I decode it on my scope? Also the TX (pin8) on the BS2 is only going to a single 2N3906 before terminating at Sout so other than inverting no much change on the voltage I guess.The device I am trying to modify has a BS2 sending a data stream to a PIC16F54 directly from Sout to a small voltage divider (220K/(220k+22K)) to the PIC16F54 RA0 pin. If the only difference between using a BS2 pin or using Sout is signal inversion then I should be able to just direct the BS2 to use inverted polarity but that didnt work either.Any other advice ... I hope :-)Jerry

author: K1JOS
author_rank: Regular Contributor
timestamp: February 05, 2017, 12:51:04 am
content: OK I am an old idiot... I am learning to use my new digital scope and I fofgot to readjust my trigger, now decoding fine.So now I think I need to go back over my steps and see if just inverting the serial port will do the trickthanks again.Jerry

author: cv007
author_rank: Frequent Contributor
timestamp: February 05, 2017, 12:56:25 am
content: There is no level shifting as Sin is not used, you are transmitting using the stamp power.Check the tx pin directly first (with the scope), so you know whether normal or inverted is needed (maybe firmware is smart, or maybe not). If normal looks correct, you need inverted, if inverted looks correct, you need normal. If you can't decode output from tx, then anything else further down the circuit will not matter.It looks like Sout will be pulled down to Vss through a pair of 10k's in the npn pack, then 4.7k to the Sout pin- to make it stronger tie Sin to Vss.QuoteYou are using a Basic Stamp, you may be old. You can't be an idiot if you found this forum.