Shop OBEX P1 Docs P2 Docs Learn Events
Serial Comms with SX48 1 wire or two — Parallax Forums

Serial Comms with SX48 1 wire or two

SailerManSailerMan Posts: 337
edited 2008-12-26 10:57 in Propeller 1
I have serial comms between a prop and an SX48 so I'm not sure which forum to post this in.

Basically, I have a 2 wire communication working perfectly... I'm using FullDuplexSerial on the prop and standard Serin/Serout on the sx48 using sx/b.

Any how I wanted to convert this to a single wire. So I just chose the same pin for Serial Input and Output on both Micros... Now I can send from the Prop and it recieves well on the sx48, but I send from the SX to the prop... Any Ideas?

Eric

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-04 15:37
    FullDuplexSerial is just that ... It's a full duplex routine. The output pin is always enabled for transmitting and the input pin is always enabled for receiving. During initialization, the way the Propeller works, if you use the same pin number, the output mode will take precedence.

    The FullDuplexSerial routines have a mode parameter. If you set the mode to be %1100, this will set open-drain mode and the transmit routine will throw away a received character for each one transmitted (since the receiver is always active it will receive all transmitted characters). Open drain mode will set the I/O to input instead of driving the I/O pin high. It will drive the I/O pin low, but you'll need a pull-up resistor to provide the high logic level. The receive routine will be able to receive between transmitted characters which is what you want.

    Try just changing the mode parameter and adding the pull-up if you don't already have it.
  • SailerManSailerMan Posts: 337
    edited 2007-10-04 16:25
    OK thanks Mike I will try this when I get home later... One question... Is there anything I need to change on the SX Side?

    I'm hoping not as I want the SX (Slave) side to be independant of the (Master).

    Eric
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-04 16:37
    I'm not sure what you're doing on the SX side. The main issue is: How do the Propeller and SX agree about who transmits and who receives? There are all kinds of ways to do this ... anything from a strict master/slave relationship to an Ethernet-like protocol where there are no masters, but there are rules about what to do when two or more devices attempt to transmit at a time.
  • SailerManSailerMan Posts: 337
    edited 2007-10-04 18:19
    In Simple terms how do you determine who is attemping to transmit? So rules can be made.

    In any event the SX is controlling a motor driver board that I am also designing (Yeah I know there are a ton of them out there) but none that I made... It's a total learning experience for me. [noparse]:)[/noparse] Thanks for you insight.

    Regards,
    Eric

    Post Edited (SailerMan) : 10/4/2007 6:26:12 PM GMT
    778 x 293 - 128K
    MC.jpg 128.2K
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-04 18:24
    You make up your own rules and your programs implement the rules ... That's it.

    The simplest set of rules is that one side of the conversation always initiates:

    SX: Talk to me (are you still there?)
    Prop: What do you want to know?
    SX: Send me a packet
    Prop: Here it is
    SX: OK, I got it
    ....
    SX: Talk to me (are you still there?)
    Prop: What do you want to know?
    SX: Nothing really, just checking
    ...
  • SailerManSailerMan Posts: 337
    edited 2007-10-05 16:55
    I finally got this to work.. Thanks.. I actually had to put a 75 uSec delay on the sx48 side between receiving a command and sending the reply.

    I was getting unusual numbers on the propeller... I looked at the scope and the bit pattern looked a little poor and it was being sent a little too early it seems that this small delay has got it working.. I don't know why. Hmm.

    The SX was sending %1101_0000 but the Prop was receiving %0110_1000. I'll have to look at this in more detail.


    Eric
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-05 17:04
    Most likely the SX was not waiting until the stop bit time slot was over. No one does - why should one? But of course you must not start transmitting on the the same line before it's over smile.gif

    Post Edited (deSilva) : 10/5/2007 6:13:03 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-12-26 10:57
    this is just an additional post for easier finding this thread by special keywords


    V24 RS232 bidirectional bi-directional oneline onewire FullDuplexSerialbidirectional bidirectionalfullduplexserial oneiopin for bothdirections
    V24bidrectional serialbidirectional FDSbidirectional singlewire singleline V24singlewire V24onewire RS232singlewire RS232onewire

    Stefan
Sign In or Register to comment.