Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Tourobo2022_TBCMotorDriver
motorDrive_SMB.cpp
- Committer:
- YutaTogashi
- Date:
- 2020-03-25
- Revision:
- 0:db4f58345725
- Child:
- 1:30665f088188
File content as of revision 0:db4f58345725:
#include "motorDrive_SMB.h" motorDriveSMB::motorDriveSMB (PinName PwmH,PinName Phase) : pwmh(PwmH),phase(Phase) { lowerLimitDuty = -1.0f; upperLimitDuty = 1.0f; } void motorDriveSMB::setupFrequency(float frequency) { pwmh.period(1.0f / frequency); } void motorDriveSMB::setupLimitDuty(float lowerLimit,float upperLimit) { lowerLimitDuty = lowerLimit; upperLimitDuty = upperLimit; } void motorDriveSMB::output(float duty) { if(duty > 0.0f) { if(duty > upperLimitDuty) duty = upperLimitDuty; pwmh.write(fabs(duty)); phase.write(false); } else if(duty < 0.0f){ if(duty < lowerLimitDuty) duty = lowerLimitDuty; pwmh.write(fabs(duty)); phase.write(true); } else { pwmh.write(0.0f); phase.write(false); } }