Serial communications using a single wire
DiverBob
Posts: 1,108
I've been doing a lot of testing using FullDuplexSerial but have been unable to get it to successfully transmit and recieve over a single wire between the propellor serial terminal program and a propellor chip.
I have searched but haven't been able to locate any discussions in the forum where anyone else has done this so I want to see if anyone has or knows of any serial code (or can point me to some code) that I can examine to see where I'm having my problems. I just need something simple to start testing...
Thanks in advance
Bob Sweeney
I have searched but haven't been able to locate any discussions in the forum where anyone else has done this so I want to see if anyone has or knows of any serial code (or can point me to some code) that I can examine to see where I'm having my problems. I just need something simple to start testing...
Thanks in advance
Bob Sweeney
Comments
Erik: I will take a look at the GPS code tomorrow - time to get some sleep, too much time spent playing with the prop!
Bob Sweeney
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
What I am ultimately trying to accomplish is using a PIC to read 4 channels of input and then serially send the results to a propellor in a half-duplex mode. The 6 conductor cable connecting the prop and PIC has one wire left that isn't already dedicated to some other purpose (such as V+, GND and some switch inputs for the prop). The process is for the prop to request a specific ADC channel over the line. The PIC wakes from sleep mode, processes the request, serially sends the data back down the line and goes back to sleep until the next request. This setup is being used because the entire setup is battery powered and there is no on/off switch - in sleep mode the PIC draws nano watts and I have been able to programatically shutdown the prop and display to around 0.06 mA. So I need to keep the PIC in sleep mode as much as possible but the prop has to 'wake' it up when data is required.
I have·made this all work using two wires in test but I have been unable to get it to work at all once I point the rx and tx pins to the same pin#. So I was hoping that someone with more experience in serial communications might know of some example code that could be used as a guide. All the serial code I have reviewed on the forum so far is set for 2 wire comms.
Thanks for any help, suggestions or advice!
Bob
Post Edited (DiverBob) : 1/8/2009 2:41:35 AM GMT
obex.parallax.com/objects/217/
Technically you could do anything like this
Post Edited (grasshopper) : 1/7/2009 10:45:12 PM GMT
the propeller serial terminal program (PST.EXE) will ONLY communicate on two seprate wires tx/rx.
There is no option in PST.EXE to setup tx and rx on the same pin. PST.EXE can't be used to test this
Anyway: there are modes for the FullDuplexSerial-driver to set tx and rx on the same IO-pin
I'm sure you have to set bit 3 = %1000
I'm not sure about using bit 2 = %0100
and what this means for the hardware
In the file simple_serial.spin (found in the propeller library is a description how this can be done with the simple serial object using a pull-up-resistor
best regards
Stefan
I will try SimpleSerial again, reprogram the PIC and prop. I should at least be able to monitor the serial line using PST just by dumping whatever is being passed on the comm line.
I'll give it a go right after supper! I'll let you know how it turns out!
Thanks
Bob Sweeney
A€AP ,
A€AP ,
It seems to cycle through the strings but I didn't catch any pattern. So until I figure out why this is happening I'm stuck. I have attached the archive of the test code I am using. Hopefully someone here understands what's going on.
Bob Sweeney
as you use a single wire for Tx and Rx this might be simple the answer of the PIC
You made modifications in the file simple_serial.spin.
I would test them right before doing something else with a demo-prg
that is known as working with the original simple_serial.spin
than test your added methods and test them too.
old programmers wisdom:
a program does ALWAYS what is coded. Sometimes what is coded differs from what you intended to do.
To narrow down the problem I would "narrow down" the code.
Code a NEW and very simple test-prg that does NOTHING ELSE like send and receive serial data.
To be REALLY 101% sure there's no error in the other code or interference with the other code
you have to REMOVE the other code which is not related to the serial transmisssion.
best regards
Stefan
I did the followong tests:
I stripped down your code to just test serial datatransfer
with no delay the receiving is fine just "A"s
If I add the delay around 272 I get "A"s combinded with rubish
if I do NOT use a Pull-UP-resistor
Pull-up means one end connected to the Rx/Tx-pin and the other end to +3.3V
I started my testing with normal-mode (baud +2400)
reverse-mode does not work with PST.EXE
and there is another trap in PST.EXE for long delays just a zero is added to the "A" always A<0>A<0>A<0>
The default preferences of PST.EXE does a clearscreen if a zero is received
so the screen stood empty only the Rx-indicator was flashing (fist thought of me strange thing what is wrong?)
The rubbish after the "A" is added because of the IO-pin beeing set as input after finishing the transmission of the "A"
see commet '<=== HERE in PUB Tx
This is done because the Rx-pin is the same as the Tx-pin !
This let's the Pin flow around at high impedance WITHOUT a Pull-UP-resistor and that causes the received rubbish
if it's commented out it works fine again
But you need to set it to an input as the same pin is used for receiving
So you really HAVE to use a Pull-UP-resistor combined with normalmode
Why are you using inverted mode baud-parameter -2400 (MINUS 2400) ???
is there a special reason for this ?
best regards
Stefan
Post Edited (StefanL38) : 1/8/2009 2:23:14 PM GMT
I took my PPDB and connected pin 21 with the onboard MAX2323
I connected Rx AND Tx of the max2323 with pin 21 and used a pull-up on pin 21
then i tested the following code with success
as the terminal does not ignore the tx on rx the terminal connected to pin 21 received both characters
the final test would be to use two propellerchips both in mode ignore tx echo on rx
But on pin 21 I received what was sendet from the terminal software
and then the terminal software received correctly char+1 which was sended back from the propeller
this worked with initialisation of Fulldoplexseialplus like this
Serial.start(21, 21, %1100,2400)
best regards
Stefan
Thanks again, I'll post my testing results but first it's time to go play some raquetball and relieve some of this tension!
Bob
Now I have to put the PIC to sleep in-between data requests but that's a problem for another day (that and getting all the registers set correctly!).
Thanks to everyone for their help and examples.
Bob Sweeney