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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:08226e87671c
- Parent:
- 0:24b2f1c78160
- Child:
- 2:d42e168b0fa7
--- a/main.cpp Thu Jun 25 17:25:06 2020 +0000
+++ b/main.cpp Thu Jun 25 17:41:11 2020 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "L6230_BLDC.h"
+#include "reScale.h"
L6230_BLDC motor(PC_10, PC_11, PC_12, PA_8, PA_9, PA_10);
@@ -7,16 +8,23 @@
AnalogIn feedback_phase_B(PC_1);
AnalogIn feedback_phase_C(PC_0);
+AnalogIn pot(PB_1);
+
DigitalOut myled(LED1);
DigitalIn sw(PC_13);
Serial pc(USBTX, USBRX);
+reScale _scale(0, 1, 800, 5000);
+
float read_current(char);
int prevStep;
+float speed;
+float adc;
+
int main()
{
pc.baud(115200);
@@ -25,25 +33,9 @@
while(1)
{
- //motor.one_step(1, 5000, &prevStep);
-
- if(sw == 0)
- {
-
- motor.turn_n_steps(1, 10000 , 100);
- motor.turn_n_steps(1, 9000 , 200);
- motor.turn_n_steps(1, 8000 , 300);
- motor.turn_n_steps(1, 7000 , 400);
- motor.turn_n_steps(1, 6000 , 500);
- motor.turn_n_steps(1, 5000 , 600);
- motor.turn_n_steps(1, 4000 , 700);
- motor.turn_n_steps(1, 3000 , 800);
- motor.turn_n_steps(1, 2000 , 900);
- motor.turn_n_steps(1, 1000 , 2000);
- motor.turn_n_steps(1, 800 , 10000);
-
- motor.stop();
- }
+ adc = pot.read();
+ speed =_scale.from(adc);
+ motor.one_step(1, speed, &prevStep);
}
}