Serial Out & Serial In Commands With Flow Control
Inquiry: In review of the Basic Stamp commands Serin & Serout in the Syntax Reference Manual an example of the use of these commands are given. In this example two BS2s are serial linked together. Two leads are shown which connect the respective ICs. One lead with a 1k series current limiting resistor is connected directly to what I assume is the line used to actually transfer the serial data. In the schematic given this connects pin P1 to each BS2 The second lead connects the P0 pins of each chip at a common nodal point with a 10k pull down resistor. This latter line, I believe anyway, is used for the Flow Control signal. However, in review of the Pbasic code it appears that the Pins used for the Flow Control Signal and that of the Data Stream are Flipped Flopped. In the Sender code the serial output is located on Pin 1 while the Flow Control signal is generated on Pin 0 of that chip. Whilst the converse is indicated on the Receiver BS2. The serial input is incoming on Pin 0 and the Flow Control pin is indicated as Pin 1. My question is, as indicated in this example are both the schematic and programming codes correct ? If true, my original assumption of separate dedicated lines was not correct. In the not to distant further I will be using such a circuit to link BS2 & BS2P in a solar thermal control application.
Comments
Could you post links to the data you are referencing and ask a question (preferably on a line by itself)?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
In the little sketch in the help file, p1 on the sender is connected to p1 on the receiver via a series resistor; that is, p1 is the communication connection while the p0's are the flow control.
Once sorted out, the process works well.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
but it should be
to match the circuit diagram and the sender program.
About the 10kOhm pull down resistor. The SERIN command is set up in those two programs to use inverted baud mode, so the pulldown resistor assures that the flow control pin is in the low (not ready) state at initialization. Once the program hits a LOW FP or the SERIN SI\FP,... commands, the 10kOhm resistor becomes superfluous.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thank you, thank you, I'm here all week!
THANK YOU for your collective input.
My next issue that I have discovered this afternoon that my instock brand new BS2P appears to be non-functional at this time. The module is Plugged into a standard Carrier 2 24 pin board. The applied voltage is 7.5vdc with no other circuitry connected to it at this time. Does the BS2P have an on-board LED "ON" lamp ?? If so, then I do have a problem. However, the test program that I down loaded to the BS2P showed No errors However, No echo signals were received back to the Debug Terminal from it.
I did run a system test of an associated BS2 circuit which is also currently located on the same breadboard with no problems. (This circuit is isolated from the BS2P Chip at this time.)
Thanks again for the input,
7.5 VDC is a good voltage for Vin -- assuming you're supplying it to Vin.
Oh, if you were able to download a program with no errors, you're talking to it fine.
Try a very simple program:
MAIN:
SEROUT 16, 16864, [noparse][[/noparse]"Hi!", CR]
PAUSE 1000 ' Very important to prevent output flying up the screen
GOTO MAIN
That should put a bunch of "Hi!" strings on your debug output.
The Serial Input / Output commands using the BS2 as the Sender and the BS2P as the Receiver worked just fine. In my initial test of the connections I had forgot to reconnect the serial line at the BS2P terminal when I discovered that the Reference text had a probable error in the software code. (The reason for my original Inquiry on this forum). Hence, the reason why I did not get a response signal back to the Debug terminal from the BS2P on the first run.
Which brings to mind two follow up questions.
1. In light of the fact that an error is in the Syntax Reference information
does Parallax monitor the activity on these forums and make the necessary
corrections or does someone need to point this out to them formally ??
2. My second questions is about usable voltage levels, but maybe I should start a
new thread on that subject later.
Virgil
In my current application I needed a way to have Three BS2 chips to communicate with each other while at the same time perform specific tasks.
1. One BS2 collects temperature data from mutli-channel AD/Converters and displays this
information on a rotating basis to three 7-segment LEDs.
2. A second BS2 is dedicated to operating the Domestic Hot Water Solar System. This involves turning pump(s) on and off and monitoring various immediate system protection circuits.
3. The third PIC is a BS2P. It's use will be to receive information from the other two BS2s and based on that input information make logic decision such as to heat the house with the solar system or with the conventional furnace. In future plans this chip will store and out put Serial system information to the PC.
4. Without dedicated interrupt signals each BS2s must be able to operate in their individual continuous Loops to perform these tasks.
It should be pointed out that in this particular application the reaction time of the system to conditional changes is much slower than that of the microprocessors. Therefore, this particular method may not be readily adaptable to other higher speed applications. In other words the BS2s have lots of time to collect data, pass information to each other, and change the system operating status based on the relatively slow varying temperatures.
Therefore, the optional syntax functions, Flow Control (Fpin), and Timeout, Tlabel, Wait, and data stream character identifier embedded in the Serin and Serout commands work well in this application. All of this information and method of use was directly obtained from the Parallax Syntax Reference information.
For the Serout portion of the current program:
'Serial Out Waits 2 seconds to send data. If NO response is received
'back from BS2P Stamp the program Defaults to the No_Permission Subroutine.
'From there the program Reloops And Collects Updated Information and than
'Reattempts to establish communication with the BS2P again. FLOW CONTROL
'ensures that all Data Transmitted is Received by the BS2P Receiver Stamp.
SEROUT SerialOut\FlowCont, Baud, 2000, No_Permission, [noparse][[/noparse]"ABC", ADCBits(0), ADCBits(1), ADCBits(2), etc...., ]
RETURN 'Additional Channels are added to the Data Stream as needed.
No_Permission: 'Example from Syntax Reference.
DEBUG CLS, "TIMED OUT",CR
DEBUG "Serial Data Transmission Not Successful", CR
PAUSE 3000 'Hold it for 3 seconds
GOTO Reset 'Continue Looping For Updated Information
For the Receiver code once the BS2P as performed it's immediate tasks it arrives at the following code line(s) and Waits for the return of either of the BS2s. Note that only one SERIN line is shown with the "ABC" Wait function. The other SERIN line would have a different Wait identifier.
'Will Stop and Wait For That Specific Character Sequence Before Accepting Input Data.
SERIN SerialIn\FlowCont, Baud, [noparse][[/noparse]WAIT ("ABC", TempIn(0), TempIn(1), etc....]
'Add more variables as needed....
The Syntax Functions (Timeout, Tlabel) I believe could also be used in the latter code line, though thus far, as shown it has worked well.
Any Comments ???
Virgil