Single and Two-motor driver objects P2 Spin2/Pasm2 for our 6.5" Hub Motors with Universal Motor Driver Board
Provide ready-to-use objects easily incorporated into your own code which control Brushless DC (BLDC) motors via the Parallax 64010 Universal Motor Driver P2 Add-on Boards These boards can be used with either the:
- Parallax 64020 P2 Edge Module Breadboard - larger, extra unused pins
- or Parallax 64019 P2 Edge Mini Breakout Board - smaller, fewer unused pins
NOTE: If you wish to add more than a couple of sensors to your platform then you'll want to use the larger of the two as it provides more unused pins.
Parallax offers a pair of the 6.5" Hoverboard wheels along with mounting hardware which is perfect for use with the drivers from this project.
This post Build a Heavy-Duty Robot Using 6.5″ Hub Motors and Propeller 2 Control System describes our two-wheel system. The objects provided by this project are all you need to get your platform moving!
NEW! If you are looking for Serial control of our BLDC Motor platform then head over to: Serial Control Page
Latest Changes:
04 May 2022 v2.0.0
- Add new Serial Top-Level object as interface to 2-wheel steering object.
-- Drive your platform from RPi or Arduino (RPi example provided)
- Fixed issues with position tracking and reporting within isp_steering_2wheel.spin2
27 Apr 2022 v1.1.0
- Add emergency stop methods to isp_bldc_motor.spin2, and isp_steering_2wheel.spin2
- Adjust spin-up ramp to start slower then speed up (better traction on loose surfaces but faster speed-up as well.)
- Add FlySky control mapping info to this README
- Map FlySky SwD to emergency stop!
02 Apr 2022 v1.0.1
- Initial Public Release
Things we know about that still need attention:
v2.0.0
- Drive status reporting is not working in base objects so is also reported badly over serial I/F
v1.1.0
- Issues with position tracking not working in isp_steering_2wheel.spin2
- Drive status reporting is not working in base objects (motor and steering)
On this Page:
- Motor Object Introduction - An overview of the objects provided by this project
- System Diagram - A quick visual overview of the motor and steering runtime structure
- Future Directions - Notes about areas we can improve over time if you have experience and want to help us with these, please contact us in Forums (in this thread)
- DEMOs - Example files that show how to interact with the motor control and steering objects provided by this project
- FlySky Controls for DEMO - How our Switches and Joysticks are tasked
- Reference - We looked at a number of control systems before deciding on the public interfaces for our steering and motor control objects
- How to Contribute - We welcome contributions back to this project for all of us to use. Learn how, here!
Additional pages:
- Steering and Motor control - The object public interfaces
- Start your drive project using these objects - Walks thru configuration and setup of your own project using these objects
- Use RPi or Arduino to control your platform - Walks thru configuration and setup of RPi control system (extrapolate to Arduino)
- Drawings - Files (.dwg) that you can use to order your own platform inexpensively
- To-scale drawings of possible rectangular and round robotic drive platforms for Edge Mini Break and JonnyMac P2 Development boards
- The author's development platform - Overview of the robot platform used when developing and testing the code for this project
There are two objects in our motor control system. There is a lower-level object (isp_bldc_motor.spin2) that controls a single motor and there's an upper-level object (isp_steering_2wheel.spin2) which coordinates a pair of motors as a drive subsystem.
If you are working with a dual motor device then you'll be coding to the interface of this upper-level steering object as you develop your drive algorithms. If you were to work with say a three-wheeled device then you may want to create a steering object that can better coordinate all three motors at the same time. Actually this is true for any other number of motors you decide to control. Create your own better-suited steering object, base it on this project's 2-wheel version. (And, if you do, please consider contributing your work to this project so it can be available to us all! See: How to Contribute below.)
The drive subsystem currently uses two cogs, one for each motor and a third cog for active tracking of wheel position. Conceptually, the drive system is always running. It is influenced by updating control variable values. When the values change the drive subsystem responds accordingly. The public methods of both the steering object and the motor object simply write to these control variables and/or read from associated status variables returning their current value or an interpretation thereof.
The interfaces for these two objects are described in BLDC Motor Drive Objects
The following diagram shows the nested motor control and sense subsystem comprised of the two objects: steering and motor control.
In this diagram there are three rectangular objects depicting files (yellow background) of code. There are three methods within the files (white and green backgrounds) that are run in separate cogs. The arrows attempt to show which objects interact with each other and also show with which object the user application can interact. The gear icon indicates which are running in their own Cog. You can see that the users' top-level control application runs in its own Cog as well.
We now have a working motor drive system that is fun to use. While this was being developed we kept track of further improvements that can be made in the future. Here's our list of the most notable:
- Add acceleration control
- Replace simple built-in spin-up, spin-down ramps with better
A small number of demos are provided with this project:
Spin2 File Name(s) | Demonstration |
---|---|
demo_single_motor.spin2 | Provides example code for controlling a single motor and position sensing of the single motor. (Uses HDMI (DVI) as display of live motor details. |
demo_dual_motor.spin2 | Provides example code for controlling a pair of motors and using the 2-wheel steering object. |
demo_dual_motor_rc.spin2 | Provides example code for using our FlySky Remote Controller and the SBUS receiver to control the pair of motors via the 2-wheel steering object |
NOTE: we built these demos over time as we developed the driver. There can be better examples but in the interest of time, so that we can get more of us using this driver as soon as possible, we are releasing these in their current state and will improve them over time.
The R/C demo uses the following controls:
Control | Purpose |
---|---|
SWITCHES | |
SwA | Motor Control Toggle: Up - disabled, Down - Enabled |
SwB | not used |
SwC | Stop Demo - Up - running, Down - exit demo |
SwD | Emergency Cutoff: Up - disabled, Down - Immediatly stop motors! |
JOYSTICKS | |
Left Joystick | Steering: Left - turn to left (slow right motor), Right - turn to right (slow down left motor) |
Right Joystick | Acceleration: Up - go foward, Down - go backward (speed controlled by joystick center is stopped, at extremes is fastest) |
- A study of Motor Control and Drive Techniques found in LEGO Mindstorms and in Parallax BlocklyProp is presented in: Movement API Study
This is a project supporting our P2 Development Community. Please feel free to contribute to this project. You can contribute in the following ways:
- File Feature Requests or Issues (describing things you are seeing while using our code) at the Project Issue Tracking Page
- Fork this repo and then add your code to it. Finally, create a Pull Request to contribute your code back to this repository for inclusion with the projects code. See CONTRIBUTING
If you like my work and/or this has helped you in some way then feel free to help me out for a couple of ☕'s or 🍕 slices!
This work is entirely based upon Chip Gracey's excellent BLDC Motor Driver written in Pasm2 which he demonstrated to us in many of our live forums. This project allows us all to use this driver. Thank you Chip!
Parallax, Propeller Spin, and the Parallax and Propeller Hat logos are trademarks of Parallax Inc., dba Parallax Semiconductor
Copyright © 2022 Iron Sheep Productions, LLC. All rights reserved.
Licensed under the MIT License.
Follow these links for more information: