Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize Motor Controller #51

Draft
wants to merge 47 commits into
base: fprime-fsw/staging
Choose a base branch
from

Conversation

justinnuwin
Copy link

@justinnuwin justinnuwin commented Apr 10, 2021

Drafting PR from MSP430+HerculesFSW motor controller code review with @SchwartzCode.

Terminology

Motor Controller: MSP430
MotorControllerComponent: Hercules FSW

Important Notes

  • Hercules handles orientation of motors — Justin
  • No method to steer in FSW — Justin
  • Should definitely have a way to bypass P-I controller with open-loop control of motors — Jonathan
  • Figure out how telemetry is going to be updated in the Motor Controller-MotorControllerComponent state machine — Ground, FSW, Motor Controller
  • C&TL MotorControllerComponent Telemetry Units+Type don’t match the commanded — Ground, FSW, Motor Controller
  • C&TL MotorControllerComponent Telemetry Speed doesn’t include angular movement — Ground, FSW, Motor Controller

Questions

  • Are all motors always going to be driven abs value of expected # tick? (i.e. support differential steering) — Connor/Jonathan
  • What is the CURRENT_POSITION and CURRENT_SPEED RO registers used for (Motor Controller executes immediately so there is no time to read these registers)? — Justin/Jonathan
  • Goes back to what we want the telemetry to represent: snapshot in time, or state of Motor Controller over time? — Connor/Justin/Jonathan
  • Do we want additional telemetry for internal state of PI controller (potentially over time)? — Connor/Jonathan
  • Do we need a flag for convergence (to let operator know when movement is complete/are we going to poll CURRENT_SPEED and CURRENT_POSITION? — Jonathan/Justin
  • Can the Motor Controller detect that its latched in a continuous driving when we don’t want to (due to SEU or sensor failure)? No, but it will be soon. — Jonathan

@SchwartzCode to PR motor control branches into this branch for staging & testing to merge with fprime-fsw/staging.

@justinnuwin justinnuwin self-assigned this Apr 10, 2021
…so included in this commit (sorry it's messy)
…lation unit.

Remove repeated i2c memory mapped address arguments. Set once as a member attribute
@justinnuwin justinnuwin force-pushed the justin/fprime/navigation branch from 91ae8fa to fe7baf6 Compare April 11, 2021 00:42
Iris Watchdog Developers and others added 10 commits April 11, 2021 14:27
…nected it to i2c interface; can be toggled with first bit in controlRegister
… for several time steps then a flag is added to status_register and controller stops trying to drive motor (until it is given a new setpoint)
…work interface to another. Allocate separate downlink buffers for applications and selecting correct downlink buffer when each application needs to send a file. Add flushing telemetry buffer when switching interfaces so we don't overwhel the NIC if switching from a larger to smaller MTU Fix a bug with uplink where the checksum was 'not'-ed twice making correct commands fail
…nlinkBuffer. Reorder when some tlm variables are updated to be more useful. Add command to set telemetry level of the GroundInterface component
@justinnuwin
Copy link
Author

Meeting Updates

@justinnuwin @SchwartzCode @zCoCo

  • It could be helpful to be able to downlink I-error to detect integral wind-up (or Jonathan could implement automatic mitigations for this).
  • Drifting on the moon: very unlikely (not flight critical), but @zCoCo could give us a function for radius and arc-length to easily implement differential steering.
  • Acceleration and Deceleration registers may be unused for flight

C&TL Motor Controller Telemetry Units

Speeds: Deprecate because these readings are totally useless since we are downlinking the raw encoder readings already (can likely stream encoder values @ >100Hz with current bandwidth) -> Will perform this calculation on ground
Encoder Displacements: encoder ticks

@SchwartzCode 's Motor Control Updates

Flag For Convergence: Use status register -> Telemetry
Fault registers & Control Registers formalized
Output correct (and more simple units) for telemetry

Plans for Motor Receipt

  • No frying SBCs
  • Individual Motor Tests
  • Command all 4 motors simultaneously (forward & turning)
  • Telemetry from all 4 motors simultaneously
  • Navigation command WITH CAMERAS

alecjprobst and others added 17 commits April 16, 2021 00:35
…eems to have resolved last remaining funkiness
…d .cpp/.hpp to reflect these new variables. Should be no change on how program runs normally since functions only used by Watchdog
- Validated all commands working and can command single motors
…staging/watchdoginterface

Alec/fprime/fprime fsw/staging/watchdoginterface
…E_COMMAND bit of control register, added ability to override default open loop PWM and control it using the desired speed given from Hercules
@justinnuwin
Copy link
Author

justinnuwin commented May 1, 2021

Pre-Code Review Motor Control Test

Motor Control Code 503c121

Updates that have been tested

  • Continuous drive test successful with 4 motors & test pattern going forward, backward, turning left, and turning right at different speeds (SBC H#1)
  • Motors seemed to be moving in the correct direction (forward has 2 motors spinning opposite the other 2, turning has them all spinning the same way)
  • Open Loop Fully Integrated (Hercules can set this with common flag for all motors)
  • Execute Command register implemented - bit needs to be set to start the movement
  • Position converged flag implemented (Hercules will not send another move command until current position converged)
  • Added timeout for position converged (on MSP430): after 2 min the position converged flag will be set in addition to the timeout flag in the fault register (tested with a move command speed 10, 3 EM1 motors & 1 EM4 motor where the EM4 motor stalled and after 2 min the position converged flag was set -> did not check fault)

Outstanding TODOs

  • Hercules should also have a timeout for position converged (slightly longer than MSP430 2min)
  • Resetting MotorControllers via Watchdog
  • General Motor Controller code (MSP430) code cleanup
  • Hercules checking fault registers and resolution
  • Measure the 2min MSP430 timeout for position converged (test distance 100cm in open loop (slow) mode -> time out after 2min 12s)
  • Test setting PID gains
  • Verify angular movement conversion (angular -> linear movement conversion)
  • What to do with Hercules stop command (send immediately or wait for convergence)?
  • Hercules should implement critical section when setting execute command
  • Finalize the remaining Hercules TODOs

@justinnuwin justinnuwin changed the title Finalize fprime Motor Controller Component Finalize MotorController May 1, 2021
@justinnuwin justinnuwin changed the title Finalize MotorController Finalize Motor Controller May 1, 2021
Iris Watchdog Developers and others added 4 commits May 1, 2021 15:08
@justinnuwin justinnuwin requested review from RaewynD and alecjprobst May 1, 2021 22:21
Copy link

@SchwartzCode SchwartzCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, going to sift through code and populate code review google sheets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants