Shop OBEX P1 Docs P2 Docs Learn Events
S2 serial port — Parallax Forums

S2 serial port

I'm looking at using the S2 for teaching using an RPi instead of the Fluke. I'm struggling to understand how to communicate with the S2 via its serial port. I've skimmed a lot of forums and code packages, Myro, Calico etc and I get the impression that the S2 responds to byte codes embedded in 9-byte packets. What I don't know is whether the default inbuilt firmware handles these byte codes or whether I need to load some server code into the S2.

As far as I can tell the S2 is mute in response to any messages I send its way, no string emitted on bootup, etc. Toggling DTR seems to reboot it, I don't know what RTS does.

I'm a little hamstrung by the minimal Mac/Elcapitan support. Calico crashes, SimpleIDE works but I'm struggling to find S2 specific doco to write code in spin, bst works but its a similar struggle to find S2 specific doco for C programming.

Any tips, pointers or corrections to my understanding would be much appreciated. I'm sure this is a common request but I can't find a definitive answer.

Comments

  • Hello pcorke,

    What are you trying to teach because a BOE-Bot or an Activity Bot may be more appropriate?

    The S2 uses a GUI for programming but the GUI generates Spin.
    Like most Spin programs the dirty work is done by the S2 object which is heavily commented.
    The Propeller Education Kit text is the best Spin tutorial that I have seen though it's not S2 specific.

    A USB-to-Serial converter will allow you to program the Propeller on the S2 using a RPi with Simple IDE.
    Most Parallax Propeller boards use an FTDI USB-to-Serial chip since Serial ports aren't common today.

    Are you using USB or the Fluke with your Mac?
    The Fluke uses an Python API over Bluetooth.
    The latest drivers and software might cure some of your problems.

    Spin is native to the Propeller and C is only a recent addition so the bulk of code hasn't been converted.
    The Activity Bot also uses a Propeller and it was designed for C.
  • Thanks for your reply. The class I teach is around mobile robot navigation, localization and vision. We use an RPi+camera with a wheeled base. I am looking at upgrading the wheeled base to the S2. I have an investment in RPi + cameras so I don't plan to use the Fluke which effectively replicates that functionality.

    Spin is not going to cut it for this class, so the plan is to use the S2 simply as a slave: to execute motion commands and return status (obstacles, encoder counts etc) to the host which will be the RPi or a desktop via WiFi from the RPi.

    As per my original question, how do I get the S2 to execute motor commands or return status information via its serial port? I can see two options:

    1. The S2 must already have some builtin capacity to communicate via the serial port, that's clearly how Spin programs get installed. How general is this interface, does it support motor/sensor commands or does it just do program loading?

    2. I write a "server" and load it into the S2. Maybe I write it in Spin or C. It sits in a loop, gets bytes from the serial port, does the appropriate operations on the S2 object, and returns status via the serial port.

    I don't have a communications or driver problem, I can load and execute a helloworld program on the S2 using bst. I simply don't know if there is a serial protocol to do what I want, and if there is a protocol what are the details?

    If I have to write a server then I guess I can choose Spin or C, ideally it would use threads so my language choice would depend on documentation about threading in Spin and C for Propellor. If this has been done, and I'd be really surprised if it hasn't then a pointer would be really handy.



  • pcorke wrote: »
    1. The S2 must already have some builtin capacity to communicate via the serial port, that's clearly how Spin programs get installed. How general is this interface, does it support motor/sensor commands or does it just do program loading?

    The serial port is just used to load the program. I'm not aware of any protocol which would allow you to give commands through the serial port.

    I'd think this wouldn't be too hard to do with the S2 since the movement commands are already so nicely abstracted by the s2.spin object.

    Parallax has a serial protocol they used with the Eddie robot. I modified the Eddie firmware to allow the same protocol to command their Arlo hardware.

    The same sort of protocol could be used with the S2 but it would require a bit of work to convert the commands to work with the S2's main control object.

    Here's a link to the Eddie firmware in my GitHub. The repository is a bit of a mess but the readme file contains information about which archive does what.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2016-01-24 04:52
    The Fluke IPRE setup includes downloading custom firmware into the Propeller on the S2 which provides the communication protocol between the Myro software and the Scribbler. There's a snippet from the Fluke IPRE user manual that mentions entering a command in the Python window as "upgrade(‘scribbler’)" which installs the IPRE firmware onto the S2.

    Here is a link to the IPRE firmware:
    https://bitbucket.org/ipre/ipre-scribbler2/downloads
    S2.SPIN is the Parallax Scribbler Object
    ipre_s2_port.spin is the Fluke IPRE object that houses the communication protocol

    I would recommend reviewing the S2 Object documentation. It is very detailed and very helpful in my opinion.
    http://www.parallax.com/s2help/english/s2_doc.html
  • +pcorke
    I am doing a similar project and was stuck until I saw the post from +WBA Consulting.

    I cloned the IPRE Firmware bitbucket above and used the Propellor Tool to load the ipre_s2_port.spin onto my S2. This is the program that accepts the 9-byte commands you mentioned. I then tested with Bray's terminal set at 38400,N,8,1. I was able to send the commands listed in the Myro/Scribbler documentation and get a proper response.

    Kevin
Sign In or Register to comment.