Shop Learn
Creating a multi port serial object - Page 3 — Parallax Forums

Creating a multi port serial object



  • I put test code into the spin object so I didn’t have to bounce between different files.

  • @DiverBob said:
    A lot of this is an exercise to help me learn pasm (plus I need something along thes line for my robot communications!).

    Bob, if your object is to learn PASM better than more power to you. If you just want a multi port serial driver with uses your "AddPort" method to start, then I'd be glad to help you out. I think my multi port driver could be easily modified to use your version of the AddPort method.

    It's great if you want to keep work on this but if you want to get back to your amazing robot, I'd be glad to modify my code to match your requirements.

    I feel reasonably competent in PASM on the Propeller 1 myself. PASM in the Propeller 2 is a whole other animal. While I modified a lot of Spin code in Clusso99's and JonnyMac's driver, I only changed variable names in the PASM section. PASM2 is to PASM1 what a full grown tiger is to domestic kitten. It might just be some growing pains, but I find PASM2 very intimidating.

    Good luck either way. If you want me to modify my code to use your AddPort method, just let me know. I'd be glad to make those changes.

  • I started this project when I determined that the P1 didn’t have enough horsepower and speed to be effective as the master computer for my hexapod robot. However at the time the P2 didn’t have all the objects created that I needed. Those objects have been slowly becoming available. First, I learned enough C to use FlexProp to recreate the Inverse Kinematics equations (I’d like to do the Inverse Kinematics in Spin/PASM instead of C, those calculations were the stumbling block on the P1). JonnyMac was very helpful and created the object for the RGB display setup. The master to leg controllers communications needed 8 serial ports, as there wasn’t anything like that around I decided it would be ‘fun’ to learn P2 PASM and see if I could create it myself. Fortunately now there are 2 different versions of a multi-port serial object by you and Ray. The last item on the object todo list is XBee communications and JonnyMac is having a very timely discussion on that in a couple of weeks!
    At this point I’ve put so much time and effort into learning and getting this version to work I hate to just drop it! Besides I like the idea of the simplicity of the original P1 object and I’ve learned a lot about pasm since I started. JonnyMac’s instructional series has been great for learning new ways of doing things. My problem is that there are still large holes in my knowledge of pasm and I haven’t found or recognized examples that help me as much as I hoped. At this point I don’t think I’m too far off from having this work, I just can’t figure out where I’m going wrong at this point. I appreciate your offer to help out!

  • I got my version of a multiple port serial to work! Attached is a Pulseview snapshot with 2 ports enabled at 115200 baud with the TX of port0 feeding RX of port1, TX of port1 feeding RX of port0.
    Having the debug capability in Spin and PASM really made the difference for figuring out what was going on and how to fix it.
    This isn't set up as a proper stand alone code item yet as my SPIN testing code is embedded in the object, so no other files are needed to run. I will split the serial object out and make a proper demo of it.

  • Cluso99Cluso99 Posts: 17,474

    Congratulations Bob. As NASA says, Perseverance pays off ;)

  • I second Clusso99's congratulations.

    @DiverBob said:
    Fortunately now there are 2 different versions of a multi-port serial object by you and Ray.

    I want to make sure it's clear, I just modified Clusso99's code to move the parameter arrays into the serial object. My modifications were very superficial.

    @DiverBob said:
    I determined that the P1 didn’t have enough horsepower and speed to be effective as the master computer for my hexapod robot.

    I ran into trouble using the P1 with my hexapod project. I look forward to updating my hexapod with a new Propeller 2 brain. I think some of the Propeller 2's rotation commands will make the inverse kinematics much faster than my earlier version. I look forward to following the progress of your large hexapod.

  • Thanks Duane, I’m looking forward to working directly on the robot again soon. I really think the P2 has plenty of horsepower to make the hexapod move much more smoothly. Plus it will be neat having a P2 controlling 6 P1’s! I’m thinking of mounting the P2 Edge mini breakout board on the robot, it will be easy to run wires between it and the 6 P1 RoboPi boards.

    Tomorrow I will set the serial object up as a stand alone object with separate code for demo and further testing. I want to see how well it runs with 8 ports running at the same time at clock speeds less than 300Mhz and baud rates over 115200.

    I took a quick look today at the built-in Spin methods and ran a quick test. I got results but didn’t understand the outputs I was getting yet. Hoping I can find some good examples as I need sin, cos, tan, and arccos methods to recreate the Inverse Kinematics equations. This will be the next programming adventure once this serial object gets finished.

  • Here is the demo file and multiport serial spin code. To use this version just add the object to your code. Then run AddPort(rx, tx, mode, baud) to your code before you run the Start() method. By default it is set for 8 ports. I tested it with 4 ports at 128_000 baud. Have fun!

Sign In or Register to comment.