Shop OBEX P1 Docs P2 Docs Learn Events
Output serial commands — Parallax Forums

Output serial commands

dr.videodr.video Posts: 5
edited 2007-11-06 20:51 in Propeller 1
I am new to Propeller, have been BS2SX for many years, still trying to learn Spin. I have a project where need to output a couple char to control another device. (A,F,0,0,1) Been looking through many of the examples and reading everything I can find. But still having trouble wrapping my head around Spin code to program this, I have a Max202 chip between the propeller and the device I want to control.

Thanks from the Newbie- in Canada

Comments

  • RaymanRayman Posts: 14,162
    edited 2007-11-05 22:52
    You might want to try the "BS2 functions" object object exchange...

    http://obex.parallax.com/objects/30/

    I think this makes it work like the stamp.

    Otherwise the Propeller Tool comes with "FullDuplexSerial" that you can use...
  • rjo_rjo_ Posts: 1,825
    edited 2007-11-05 22:54
    Welcome aboard, good to see another video hound join the ranks.

    You have to post some code... it doesn't matter how ugly or non-functional it is. This is not an absolute rule (there are no absolute rules here), but if you post some code everyone will jump in.

    Rich

    Another Doctor... this place is going to the nerds[noparse]:)[/noparse]
  • dr.videodr.video Posts: 5
    edited 2007-11-06 17:34
    Thanks guys for trying to help me, I was trying to use the full duplex serial object code but having trouble running, I know this is going seem like a dumb question, but where do I establish my constants, such as tx pin# or actual information that i want to send out

    Newbie in Canada
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-06 18:33
    I think it is best you post your program that will not work....
  • LeonLeon Posts: 7,620
    edited 2007-11-06 18:39
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000      
    OBJ  ser    :       "FullDuplexSerial"
    VAR
    byte c
      
    PUB Main
      ser.start(31,30,0,9600)       'start the serial driver
      repeat
        c := ser.rx
        ser.tx(c)
     
    



    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • dr.videodr.video Posts: 5
    edited 2007-11-06 19:36
    Leon you gave a short code, thanks, is this all I need to output a single "Char"?

    The ser.start(31,30,0,9600)this defines Tx pin, RX pin mode and Baud?

    repeat
    c := ser.rx I am confused what this lines do
    ser.tx(c)

    Sorry guys for sucking up bandwidth, but I do really appreciate it

    Dr.Video
  • SapiehaSapieha Posts: 2,964
    edited 2007-11-06 19:43
    Hi dr.

    ser = Obj name (OBJ ser : "FullDuplexSerial")

    ser.rx = Call RX in OBJ - ser : "FullDuplexSerial" < Receive from Serial
    c:= ser.rx - Fill variable c with RX bufer
    ser.tx = Call TX in OBJ - ser : "FullDuplexSerial" < Transmit to Serial

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.

    Sapieha
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-06 19:48
    @Dr.:
    It's all in the file! Even if you can't read SPIN, you'll find a lot of useful comments there..
  • dr.videodr.video Posts: 5
    edited 2007-11-06 20:26
    OK does "full duplex serial" use the 31,30 pins for communication. i am using Proto board, with a prop plug. Can i use other pins for outputting RS232 for an other device

    dr.video
  • SapiehaSapieha Posts: 2,964
    edited 2007-11-06 20:34
    Hi dr.

    Yes But You must flow This ser.start(-> 31,->30,0,9600)

    ser.start(->YouPin,->YouPin,0,9600)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.

    Sapieha
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-06 20:51
    The start routine initializes the FullDuplexSerial code, starts up a cog to handle the actual receiving and transmitting and passes the pin numbers, mode, and Baud to the routine running in the cog.

    rx waits for a character to be received, then returns the character.

    tx(c) waits for a free location in the transmit buffer, then stores the character passed as a parameter into the buffer. At some time in the future, the separate cog will get around to transmitting the character.

    There are lots of other variations on these routines in FullDuplexSerial including a routine to receive subject to a timeout, one to flush the receive buffer, and several to do formatted transmission (like convert a number into decimal digits for transmission). Look at the source code comments.
Sign In or Register to comment.