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.
Revision 1:d43df9a7cef2, committed 2020-10-31
- Comitter:
- yeongsookim
- Date:
- Sat Oct 31 07:12:28 2020 +0000
- Parent:
- 0:3ead6014ad51
- Commit message:
- 2020 Hall Sensor
Changed in this revision
--- a/Actuator/Motor.cpp Sun Nov 03 23:28:27 2019 +0000 +++ b/Actuator/Motor.cpp Sat Oct 31 07:12:28 2020 +0000 @@ -6,8 +6,8 @@ { INH1_=1; INH2_=1; - IN1_.period_us(50); - IN2_.period_us(50); + IN1_.period_us(100); + IN2_.period_us(100); } void Motor::setSpeed_percent(float percent, char direction) @@ -28,7 +28,7 @@ IN1_=duty; IN2_=0; } - else if (direction == BREAK) + else if (direction == BRAKE) { IN1_=1; IN2_=1;
--- a/Actuator/Motor.h Sun Nov 03 23:28:27 2019 +0000 +++ b/Actuator/Motor.h Sat Oct 31 07:12:28 2020 +0000 @@ -5,7 +5,7 @@ #define FORWARD 'f' #define BACKWARD 'b' -#define BREAK 's' +#define BRAKE 's' class Motor {
--- a/Sensor/HallSensor.cpp Sun Nov 03 23:28:27 2019 +0000 +++ b/Sensor/HallSensor.cpp Sat Oct 31 07:12:28 2020 +0000 @@ -1,7 +1,7 @@ #include "HallSensor.h" #define REF 23400.0 #define MIN 60.0 -#define SEC_PERIOD (1.0 / (REF / MIN )) +#define SEC_PERIOD (1.0 / (2.0 * REF / MIN )) HallSensor::HallSensor (PinName a) : m_hallSensor (a,PullUp) { @@ -34,4 +34,4 @@ int HallSensor::getPinState () { return m_hallSensor; -} \ No newline at end of file +}
--- a/main.cpp Sun Nov 03 23:28:27 2019 +0000 +++ b/main.cpp Sat Oct 31 07:12:28 2020 +0000 @@ -28,18 +28,19 @@ { wait(1); - //Set the 1ms thicker. + + ////Set the 1ms thicker. Ticker ticker_1ms; - ticker_1ms.attach (&counter_1ms, 0.001); + ticker_1ms.attach(&counter_1ms, 0.001); + + //Set the motor to 10%. + motor.setSpeed_percent(10.0, FORWARD); while(1) { // Every 1 ms, if(uiFlag_1ms >= 1) { uiFlag_1ms = 0; - //Set the motor to 10%. - motor.setSpeed_percent(10.0, FORWARD); - //If A is 0, turn on the LED. myled1 = hall.getPinState(); } @@ -52,10 +53,10 @@ plot.reset (); // put data to buffer - plot.put (hall.getSpeed_rps(), 0); + plot.put(hall.getSpeed_rps(), 0); // send buffer - plot.send (&pc); + plot.send(&pc); } } } \ No newline at end of file