Shop OBEX P1 Docs P2 Docs Learn Events
Parallax Serial Controller and SX/B — Parallax Forums

Parallax Serial Controller and SX/B

Rob v.d. bergRob v.d. berg Posts: 89
edited 2005-09-06 21:01 in General Discussion
Hello,

I want to control the Parallax Servo Controller (#28023) with·the SX28 in basic.
With a BS2, it is like this, to send·the baudrate command:

SEROUT PIN, baudrate, "!SCSBR", 1, CR
to change from 2400 to 38400 baud.

Does someone has experience with this ?

The SX/B send only bytes one byte at a time. Like this
SEROUT PIN_PSC, TO38400, "!"
SEROUT PIN_PSC, TO38400, "S"
SEROUT PIN_PSC, TO38400, "C"
SEROUT PIN_PSC, TO38400, "S"
SEROUT PIN_PSC, TO38400, "B"
SEROUT PIN_PSC, TO38400, "R"
SEROUT PIN_PSC, TO38400, 1
SEROUT PIN_PSC, TO38400,·CR
SEROUT PIN_PSC, TO38400, low_byte
SEROUT PIN_PSC, TO38400,·CR
SEROUT PIN_PSC, TO38400, hi_byte
SEROUT PIN_PSC, TO38400, CR

or do I mis somethink ?
thanks in advance

Rob


·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-26 14:01
    It's true the SEROUT only sends one byte at a time, but with SX/B 1.4 you can nearly duplicate what the BS2 does.· If you look at the examples for READ you'll see how string pointers can be sent to a subroutine; that subroutine will send each of the characters.· I've attached a modified version of that program for you to work with.

    Note that "high level" things like SEROUT should be embedded in subroutines so they just get compiled (expanded to assembly instructions) once, otherwise you will burn through your code space pretty quickly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rob v.d. bergRob v.d. berg Posts: 89
    edited 2005-08-26 14:24
    Jon,

    Thanks for the sample,· i'ts very helpfull.· I must think in an other way

    Regards Rob.··tongue.gif
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-26 14:28
    SX/B "borrows" heavily from PBASIC, but it is indeed different. If you look at the examples in the help file you will quickly adapt to the Tao of SX/B.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rob v.d. bergRob v.d. berg Posts: 89
    edited 2005-09-05 19:47
    Jon and ?

    I have "played' with your code and add some·to set a position for controlling the Parallax Servo Controller. It is working well, but when I add a interrupt (2usec) with the OPTION command, it is complete dead.· The interrupt i can see, with the Testpin output. I know that the timing for the SEROUT command is possible corrupt.

    but there is nothing happen in de main loop.

    2e question: what is the best way to disable the interrups for a moment ? (SEROUT)

    can someone give me·an idea ?,

    Regards Rob.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-06 00:10
    Yes, of course, if you turn of the interrupts you will trash the timing of other commands -- SX/B is good, but not that good. What Bean did in a project was pretty clever: He changed the baud rate of SERIN and SEROUT to account for additional time being used by the interrupt routine. Now, this only works if your interrupt always uses the same number of cycles. Why not use PULSIN?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rob v.d. bergRob v.d. berg Posts: 89
    edited 2005-09-06 18:25
    Jon,

    I·know Pulsin is simple en works.·I have tested a simple loop with pulsin and pulsout with the same·puls variable. When the·input puls was not change the servo·gives a restless movement. Probably the·10usec (resolution) step is too·big.

    Rob
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-06 21:01
    No problem -- look at the compiled output of PULSIN and modify it to work with 16-bit values and at the resolution you require. That's part of the fun of SX/B: taking what the compiler does and extending it to do what you want and need.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.