Skip to content

Commit

Permalink
Move to single mech for motor geom request
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsheep committed Aug 17, 2022
1 parent 1db33f2 commit eac9d03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
23 changes: 14 additions & 9 deletions src/isp_bldc_motor.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,7 @@ PUB start(eMotorBasePin, eMotorVoltage) : ok | legalBase, fwdDegrees, revDegrees

targetAngle := $FFFFFFFF ' set to not used! (other values only used during testing)

case user.MOTOR_TYPE
MOTR_DOCO_4KRPM:
' 15 degrees per tic
degrPerTic := 15
hallTicsPerRotation := 24
other:
' 4 degrees per tic
degrPerTic := 4
hallTicsPerRotation := 90
degrPerTic, hallTicsPerRotation := hallTicInfoForMotor()

fwdDegrees, revDegrees := offsetsForMotor(user.MOTOR_TYPE)
offset_fwd := fwdDegrees frac 360
Expand Down Expand Up @@ -618,6 +610,19 @@ PUB validMotorForChoice(userMotor) : legalMotor
legalMotor := INVALID_MOTOR
debug("*VAL* ", sdec_long(legalMotor))

PUB hallTicInfoForMotor() : degreesPerTic, ticsPerRotation
'' Return numbers for user selected motor (for use by two-wheel-steering object!)
if user.MOTOR_TYPE == user.MOTR_DOCO_4KRPM
' degrees = ticks * 15
degreesPerTic := 15
' rotations = ticks / 24
ticsPerRotation := 24
else
' degrees = ticks * 4
degreesPerTic := 4
' rotations = ticks / 90
ticsPerRotation := 90

CON { --- TEST-USE ONLY Methods --- }

PUB testSetLimit(newMaxLimit)
Expand Down
18 changes: 2 additions & 16 deletions src/isp_steering_2wheel.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ PUB stopAfterRotation(nRotationCount, eRotationUnits) | degreesPerTic, ticsPerRo
' FIXME: UNDONE should be more than ticks needed for spin-up/down ramps!!!
abort

degreesPerTic, ticsPerRotation := hallTicInfoForMotor()
degreesPerTic, ticsPerRotation := ltWheel.hallTicInfoForMotor()

' convert rotation info to ticks (will stop at ticks limit)
motorStopHallTicks := 0
Expand Down Expand Up @@ -352,7 +352,7 @@ PRI convertRotationCount(nValue, eRotationUnits) : rotationCount | degreesPerTic
' Returns accumulated {rotationCount} in {rotationUnits} [DRU_DEGREES, DRU_ROTATIONS, or DRU_HALL_TICKS], since last reset, for this motor.
rotationCount := -1

degreesPerTic, ticsPerRotation := hallTicInfoForMotor()
degreesPerTic, ticsPerRotation := ltWheel.hallTicInfoForMotor()

case eRotationUnits
DRU_HALL_TICKS:
Expand Down Expand Up @@ -426,20 +426,6 @@ PRI calcPowerForDirection(power, direction) : ltPower, rtPower | bIsLeft, absPow

debug("* calcPowerForDirection(", sdec_long(power), ", ", sdec_long(direction), ") -> ", sdec_long(ltPower), sdec_long(rtPower))

PRI hallTicInfoForMotor() : degreesPerTic, ticsPerRotation
' return numbers for user selected motor
if user.MOTOR_TYPE == user.MOTR_DOCO_4KRPM
' degrees = ticks * 15
degreesPerTic := 15
' rotations = ticks / 24
ticsPerRotation := 24
else
' degrees = ticks * 4
degreesPerTic := 4
' rotations = ticks / 90
ticsPerRotation := 90


PUB isReady() : bState
'' Return T/F where T means the both motor cogs are running
bState := ltWheel.isReady() and rtWheel.isReady()
Expand Down

0 comments on commit eac9d03

Please sign in to comment.