Skip to content

Commit

Permalink
Merge pull request #5 from ironsheep/develop
Browse files Browse the repository at this point in the history
Changes to support Motor RevB board with both motors
  • Loading branch information
ironsheep authored Apr 14, 2023
2 parents 6c78a10 + f687314 commit 8081f9a
Show file tree
Hide file tree
Showing 34 changed files with 3,439 additions and 556 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ BLDC_Motor_Driver_ChipNew.spin2
demo_single_motor (DESKTOP-QL1K6HH's conflicted copy 2022-02-21).spin2
isp_bldc_motor-OLD.spin2
isp_bldc_motor-REF.spin2
angleTest.spin2
test_angle.spin2
REF/


# VSCode objects to ignore
Expand Down Expand Up @@ -65,3 +66,6 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf
src/chip_recipr_ctr.spin2
src/test_bldc_id_recipr.spin2
src/*REF.spin2
Binary file added DOCs/DesignFiles/EdgeMiniRoundV3b.dwg
Binary file not shown.
Binary file modified DOCs/sources/DriverFlowCharts.graffle
Binary file not shown.
Binary file modified DOCs/sources/driverPlanning.graffle
Binary file not shown.
Binary file modified DOCs/sources/motor-study.graffle
Binary file not shown.
Binary file modified DOCs/sources/objects.graffle
Binary file not shown.
39 changes: 27 additions & 12 deletions DRAWINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@ Single and Two-motor driver objects P2 Spin2/Pasm2 for our 6.5" Hub Motors with

### Drawing Files

These are the various design files I sent off to be make by [SendCutSend.com](https://sendcutsend.com/) - their prices are quite good!:
These are the two design files I sent off to be make by [SendCutSend.com](https://sendcutsend.com/) - their prices are quite good!:

1. [Drawing File - outboard wheels (.dwg)](DOCs/DesignFiles/EdgeMiniRoundV1.dwg) - I spec'd 0.250" MDF as the material at ~$29 USD.
![File w/Outboard Wheels](images/EdgeMiniRoundV1-dwg.png)
1. [Drawing File - enclosed wheels (.dwg)](DOCs/DesignFiles/EdgeMiniRoundV2_encl.dwg) - I spec'd 0.250" MDF as the material at ~$29 USD.
![File w/Enclosed Wheels](images/EdgeMiniRoundV2_encl-dwg.png)
1. [Drawing File - spacer to drop motors below castors (.dwg)](DOCs/DesignFiles/SpacerV1.dwg) - I spec'd 0.025" MDF as the material w/Ten of these for ~$14.20 USD.</br>
![Spacer](images/SpacerV1.png)
#### 1. Platform Board

[Drawing File - outboard wheels (.dwg)](DOCs/DesignFiles/EdgeMiniRoundV3b.dwg) - I spec'd 0.250" MDF as the material at ~$29 USD.
![File w/Outboard Wheels](images/EdgeMiniRoundV3b-ss-anno.png)

NOTE: the 4 center small holes (for M3 screws) are for mounting the twin motors boards connected to the Mini Edge Breakout Board.
NOTE: the 8 center small holes (for M3 screws) are for mounting the twin motor boards connected to the **Mini Edge Breakout Board** (#64019) or the newer **Edge Breakout Board** (#64029). The inner-most 4 holes are for the new, smaller RevB boards, while the outer four are for the larger RevA motor boards.

There are 2 ea. holes for each motor (for 1/4" - 20 Screws.)

There are 4 ea. holes for each castor - (for 1/4" - 20 Screws.)
There are 4 ea. holes for each castor - (for 1/4" - 20 Screws.). One of the castor holes is longer to provide access to the hex nut.


#### 2. Spacer Board

[Drawing File - spacer to drop motors below castors (.dwg)](DOCs/DesignFiles/SpacerV1.dwg) - I spec'd 0.025" MDF as the material w/Ten of these for ~$14.20 USD.</br>
![Spacer](images/SpacerV1.png)


There are 2 ea. holes for each spacer board (shim) (for 1/4" - 20 Screws.)

### Packaging (order arrives)

This is what I found when I opened my first order:
This is what I found when I opened my order:

![Opened Package](images/EdgeMiniRoundV1.jpg)
**The Package arrived with these contents..** This was quite well packaged. The MDF part was shrink-wrapped to the backing cardboard. The laser cuts were all clean with a little bit of scorch mark on one side of the MDF as you might expect. *And yes, the Skittles package made me smile!*
![Opened Package](images/unboxing-platform.jpg)
**The Package arrived with these contents..** This was quite well packaged. The MDF part was shrink-wrapped to the backing cardboard. The laser cuts were all clean with a little bit of scorch mark on one side of the MDF as you might expect.


---
Expand All @@ -41,6 +46,16 @@ This is what I found when I opened my first order:
---

## Older Drawing Files

These are my earlier designs including the version you see in the pictures above.

1. **OLD:** [Drawing File - outboard wheels (.dwg)](DOCs/DesignFiles/EdgeMiniRoundV1.dwg) - I spec'd 0.250" MDF as the material at ~$29 USD.
![File w/Outboard Wheels](images/EdgeMiniRoundV1-dwg.png)
1. **OLD:** [Drawing File - enclosed wheels (.dwg)](DOCs/DesignFiles/EdgeMiniRoundV2_encl.dwg) - I spec'd 0.250" MDF as the material at ~$29 USD.
![File w/Enclosed Wheels](images/EdgeMiniRoundV2_encl-dwg.png)


## Disclaimer and Legal

> *Parallax, Propeller Spin, and the Parallax and Propeller Hat logos* are trademarks of Parallax Inc., dba Parallax Semiconductor
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ See also:
Latest Changes:

```
10 April 2023
- Completing RevB board support for both motors
12 March 2023
- Add new demo Dual-motor w/FlySky and HDMI debug out - used when upgrading dual wheel behavior
10 March 2023
- Add FlySky Receiver wiring descriptions
16 August 2022 v3.0.0
Expand Down Expand Up @@ -149,9 +153,10 @@ A small number of demos are provided with this project:

| Spin2 File Name(s) | Demonstration
| --- | --- |
| [demo\_single_motor.spin2](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](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](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
| [demo\_single_motor.spin2](src/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](src/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](src/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
| [demo\_dual\_motor\_rc_hdmi.spin2](src/demo_dual_motor_rc_hdmi.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 - adds HDMI providing visibility of both motor's internal variables

*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.*

Expand Down
Binary file added images/EdgeMiniRoundV3b-ss-anno.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/EdgeMiniRoundV3b-ss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scripts/get
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

SRC_PYTHON_DIR=/home/pi/Projects/P2-BLDC-Control
DST_PYTHON_DIR="/Users/stephen/Projects/Projects-ExtGit/IronSheepProductionsLLC/Projects Propeller/P2-BLDC-Motor-Control/P2-BLDC-Motor-Control/pythonSrc"
DST_PYTHON_DIR="/Users/stephen/Projects/Projects-ExtGit/IronSheepProductionsLLC/Projects P2/P2-BLDC-Motor-Control/P2-BLDC-Motor-Control/pythonSrc"

SRC_SPIN_DIR=/Users/stephen/Dropbox/PropV2-Shared/Projects/P2-BLDC-Motor-ControlSW
DST_SPIN_DIR="/Users/stephen/Projects/Projects-ExtGit/IronSheepProductionsLLC/Propeller2/P2-BLDC-MotorControl/P2-BLDC-Motor-Control/src"

DST_SPIN_DIR2="/Users/stephen/Projects/Projects-ExtGit/IronSheepProductionsLLC/Projects Propeller/P2-BLDC-Motor-Control/P2-BLDC-Motor-Control/src"
DST_SPIN_DIR2="/Users/stephen/Projects/Projects-ExtGit/IronSheepProductionsLLC/Projects P2/P2-BLDC-Motor-Control/P2-BLDC-Motor-Control/src"

if [ ! -d "${DST_SPIN_DIR}" ]; then
DST_SPIN_DIR="${DST_SPIN_DIR2}"
Expand Down
8 changes: 5 additions & 3 deletions src/demo_dual_motor.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OBJ { our Drive Subsystem }
user : "isp_bldc_motor_userconfig" ' driver configuration
wheels : "isp_steering_2wheel" ' the dual-drive BLDC motors

PUB main() | basePinLt, basePinRt, voltage, motor
PUB main() | basePinLt, basePinRt, voltage, motor, detectModeLt, detectModeRt
'' DEMO Driving a two wheeled platform

debug("* dual motor demo")
Expand All @@ -40,14 +40,16 @@ PUB main() | basePinLt, basePinRt, voltage, motor
' do NOT start motor unless all are legit!
basePinLt := wheels.validBasePinForChoice(user.LEFT_MOTOR_BASE)
basePinRt := wheels.validBasePinForChoice(user.RIGHT_MOTOR_BASE)
detectModeLt := wheels.validDetectModeForChoice(user.LEFT_BOARD_TYPE)
detectModeRt := wheels.validDetectModeForChoice(user.RIGHT_BOARD_TYPE)
voltage := wheels.validVoltageForChoice(user.DRIVE_VOLTAGE)
motor := wheels.validMotorForChoice(user.MOTOR_TYPE)

if basePinLt <> wheels.INVALID_PIN_BASE and basePinRt <> wheels.INVALID_PIN_BASE and voltage <> wheels.INVALID_VOLTAGE and motor <> wheels.INVALID_MOTOR
if basePinLt <> wheels.INVALID_PIN_BASE and basePinRt <> wheels.INVALID_PIN_BASE and voltage <> wheels.INVALID_VOLTAGE and motor <> wheels.INVALID_MOTOR and detectModeLt <> wheels.INVALID_DET_MODE and detectModeRt <> wheels.INVALID_DET_MODE
' start our dual motor driver

' start our motor drivers (left and right)
wheels.start(basePinLt, basePinRt, voltage)
wheels.start(basePinLt, basePinRt, voltage, detectModeLt, detectModeRt)

' just don't draw current at stop
wheels.holdAtStop(false)
Expand Down
190 changes: 190 additions & 0 deletions src/demo_dual_motor_hdmi.spin2
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
'' =================================================================================================
''
'' File....... demo_dual_motor_hdmi.spin2
'' Purpose.... Demonstrate driving a two-wheeled platform
'' Authors.... Stephen M Moraco
'' -- Copyright (c) 2022 Iron Sheep Productions, LLC
'' -- see below for terms of use
'' E-mail..... stephen@ironsheep.biz
'' Started.... Mar 2023
'' Updated.... 21 Mar 2023
''
'' =================================================================================================

CON { timing }

CLK_FREQ = 270_000_000 ' system freq as a constant
_clkfreq = CLK_FREQ ' set system clock

CON { fixed io pins }

RX1 = 63 { I } ' programming / debug
TX1 = 62 { O }

SF_CS = 61 { O } ' serial flash
SF_SCK = 60 { O }
SF_SDO = 59 { O }
SF_SDI = 58 { I }

HDMI_BASE_PIN = tvDebug.PINS_P0_P7

OBJ { our Drive Subsystem }

user : "isp_bldc_motor_userconfig" ' driver configuration
wheels : "isp_steering_2wheel" ' the dual-drive BLDC motors
tvDebug : "isp_hdmi_debug" ' HDMI debug object

DAT { run-time condition vars }

bUseHDMI LONG TRUE ' set to TRUE to enable HDMI use/output

PUB main() | basePinLt, basePinRt, voltage, motor, basePin, detectModeLt, detectModeRt
'' DEMO Driving a two wheeled platform

debug("* dual motor demo w/HDMI")

if bUseHDMI
basePin := tvDebug.validBasePinForChoice(HDMI_BASE_PIN)
if basePin <> tvDebug.INVALID_PIN_BASE
tvDebug.start(basePin)
debug("* HDMI started")
else
debug("* ERROR bad pin #")

' validate user settings/choicess
' do NOT start motor unless all are legit!
basePinLt := wheels.validBasePinForChoice(user.LEFT_MOTOR_BASE)
basePinRt := wheels.validBasePinForChoice(user.RIGHT_MOTOR_BASE)
detectModeLt := wheels.validDetectModeForChoice(user.LEFT_BOARD_TYPE)
detectModeRt := wheels.validDetectModeForChoice(user.RIGHT_BOARD_TYPE)
voltage := wheels.validVoltageForChoice(user.DRIVE_VOLTAGE)
motor := wheels.validMotorForChoice(user.MOTOR_TYPE)

if basePinLt <> wheels.INVALID_PIN_BASE and basePinRt <> wheels.INVALID_PIN_BASE and voltage <> wheels.INVALID_VOLTAGE and motor <> wheels.INVALID_MOTOR and detectModeLt <> wheels.INVALID_DET_MODE and detectModeRt <> wheels.INVALID_DET_MODE
' start our dual motor driver

' start our motor drivers (left and right)
wheels.start(basePinLt, basePinRt, voltage, detectModeLt, detectModeRt)

' just don't draw current at stop
wheels.holdAtStop(false)
'wheels.setMaxSpeed(100) ' override 75% with 100%


if bUseHDMI
connectMotorToHDMI()

' now drive!
'waitUntilMotorReady()

{
debug("* BOTH Wheels")
wheels.driveDirection(80, -25)
wheels.stopAfterTime(15, wheels.DTU_SEC) ' hold at speed for 15 Sec

waitUntilMotorDone()

wheels.driveDirection(80, 25)
wheels.stopAfterTime(15, wheels.DTU_SEC) ' hold at speed for 15 Sec

waitUntilMotorDone()
'}
'{
debug("* LT Wheel")
wheels.driveAtPower(40, 50)
wheels.stopAfterTime(10, wheels.DTU_SEC) ' hold at speed for 15 Sec

waitUntilMotorDone()
'}
{
debug("* RT Wheel")
wheels.driveAtPower(0, 100)
wheels.stopAfterTime(15, wheels.DTU_SEC) ' hold at speed for 15 Sec

waitUntilMotorDone()
'}
' turn off our motor drivers
wheels.stop()
else
debug("* ERROR user configuration NOT valid!")

debug("* DONE")


PRI connectMotorToHDMI() | nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars
' connect our two motors to the HDMI display mech
if bUseHDMI
nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars := wheels.getLeftDebugData()
debug("* Received Lt: ", udec(nGroups), uhex_long(pGroupTitles), uhex_long(pGroupNames), uhex_long(pGroupVarCts), uhex_long(pGroupVars))
tvDebug.registerDisplay(nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars)

'{ -- in-active until this can work! --
nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars := wheels.getRightDebugData()
debug("* Received Rt: ", udec(nGroups), uhex_long(pGroupTitles), uhex_long(pGroupNames), uhex_long(pGroupVarCts), uhex_long(pGroupVars))
tvDebug.registerDisplay(nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars)
'}

'{ -- in-active until this can work! --
nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars := wheels.getDebugData()
debug("* Received Steer: ", udec(nGroups), uhex_long(pGroupTitles), uhex_long(pGroupNames), uhex_long(pGroupVarCts), uhex_long(pGroupVars))
tvDebug.registerDisplay(nGroups, pGroupTitles, pGroupNames, pGroupVarCts, pGroupVars)
'}


PRI waitUntilMotorReady()
if wheels.isReady() == false
debug("* wait motors ready...")
repeat
if wheels.isReady()
quit
else
waitms(2)
debug("* Motors ready, let's drive!")


PRI waitUntilMotorDone()
if wheels.isStarting() == false
debug("* wait until motors start...")
repeat
if wheels.isStarting()
quit
else
waitms(2)

if wheels.isStopped() == false
debug("* wait until motors finish...")
repeat
if wheels.isStopped()
quit
else
waitms(2)
debug("* Motors stopped!")


CON { license }
{{

-------------------------------------------------------------------------------------------------
MIT License

Copyright (c) 2022 Iron Sheep Productions, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=================================================================================================
}}
8 changes: 5 additions & 3 deletions src/demo_dual_motor_rc.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ VAR
long remoteCog


PUB main() | statusOK, basePinLt, basePinRt, voltage, motor
PUB main() | statusOK, basePinLt, basePinRt, voltage, motor, detectModeLt, detectModeRt
'' DEMO Driving a two wheeled platform

debug("* demo dual motor control via R/C")
Expand All @@ -53,14 +53,16 @@ PUB main() | statusOK, basePinLt, basePinRt, voltage, motor
' do NOT start motor unless all are legit!
basePinLt := wheels.validBasePinForChoice(user.LEFT_MOTOR_BASE)
basePinRt := wheels.validBasePinForChoice(user.RIGHT_MOTOR_BASE)
detectModeLt := wheels.validDetectModeForChoice(user.LEFT_BOARD_TYPE)
detectModeRt := wheels.validDetectModeForChoice(user.RIGHT_BOARD_TYPE)
voltage := wheels.validVoltageForChoice(user.DRIVE_VOLTAGE)
motor := wheels.validMotorForChoice(user.MOTOR_TYPE)

if basePinLt <> wheels.INVALID_PIN_BASE and basePinRt <> wheels.INVALID_PIN_BASE and voltage <> wheels.INVALID_VOLTAGE and motor <> wheels.INVALID_MOTOR
if basePinLt <> wheels.INVALID_PIN_BASE and basePinRt <> wheels.INVALID_PIN_BASE and voltage <> wheels.INVALID_VOLTAGE and motor <> wheels.INVALID_MOTOR and detectModeLt <> wheels.INVALID_DET_MODE and detectModeRt <> wheels.INVALID_DET_MODE
' start our dual motor driver

' start our motor drivers (left and right)
wheels.start(basePinLt, basePinRt, voltage)
wheels.start(basePinLt, basePinRt, voltage, detectModeLt, detectModeRt)

' override defaults, use 100 %
wheels.setMaxSpeed(100)
Expand Down
Loading

0 comments on commit 8081f9a

Please sign in to comment.