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: Break Motor Communication Steering mbed Controller
Revision 1:2538cbbea1f8, committed 2017-07-13
- Comitter:
- skrickl
- Date:
- Thu Jul 13 13:45:55 2017 +0000
- Parent:
- 0:226470cfa428
- Commit message:
- bla
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Brake.lib Thu Jul 13 13:45:55 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/skrickl/code/Break/#4e486eec2359
--- a/Break.lib Mon Jun 12 20:04:26 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/skrickl/code/Break/#375efcba6fef
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Communication.lib Thu Jul 13 13:45:55 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/skrickl/code/Communication/#524a21a2ee25
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Controller.lib Thu Jul 13 13:45:55 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/skrickl/code/Controller/#7ab090cd6520
--- a/Motor.lib Mon Jun 12 20:04:26 2017 +0000 +++ b/Motor.lib Thu Jul 13 13:45:55 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/skrickl/code/Motor/#5eb2bad9ea40 +https://developer.mbed.org/users/skrickl/code/Motor/#39b173360768
--- a/SerialCom.lib Mon Jun 12 20:04:26 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/skrickl/code/SerialCom/#542aea49add2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialCommunication/MbedToPC.h Thu Jul 13 13:45:55 2017 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+
+#ifndef MOTOR_CONTROLLER_H
+#define MOTOR_CONTROLLER_H
+
+#define BAUD_RATE 115200
+#define PIN_TX p9
+#define PIN_RX p10
+#define ENTER 0x0D
+
+Serial mPC(PIN_TX, PIN_RX); // tx, rx
+
+void Rx_interrupt();
+char temp_rx[80];
+
+int initMotorController()
+{
+ mPC.baud(BAUD_RATE);
+
+ // Setup a serial interrupt function to receive data
+ mPC.attach(&Rx_interrupt, Serial::RxIrq);
+
+ return 0;
+}
+
+void Rx_interruptMPC()
+{
+ // led2 = 1;
+ bool lineEnd = true;
+ char raw_rx[80];
+ int i = 0;
+
+ while (lineEnd)
+ {
+ raw_rx[i] = mc.getc();
+ if ((int)raw_rx[i] == 13)
+ {
+ lineEnd = false;
+ }
+ i++;
+ led3 = lineEnd;
+ }
+
+ //Here now the Values of the MC in the current Value
+ //sprintf(temp_rx,raw_rx);
+ //led2 = 0;
+}
+void writeLine(char *line)
+{
+ mc.printf("%s\r\n",line);
+}
+
+void writeWord(char *word)
+{
+ mc.printf("%s",word);
+}
+
+void startStatusWriting()
+{
+ writeLine("status_start");
+}
+
+void endStatusWriting()
+{
+ writeLine("status_end");
+}
+
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialCommunication/MotorController.h Thu Jul 13 13:45:55 2017 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+
+#ifndef MOTOR_CONTROLLER_H
+#define MOTOR_CONTROLLER_H
+
+#define BAUD_RATE 115200
+#define PIN_TX p9
+#define PIN_RX p10
+#define ENTER 0x0D
+
+Serial mc(PIN_TX, PIN_RX); // tx, rx
+
+void Rx_interruptMC();
+char temp_rx[80];
+
+int initMotorController()
+{
+ mc.baud(BAUD_RATE);
+
+ // Setup a serial interrupt function to receive data
+ mc.attach(&Rx_interruptMC, Serial::RxIrq);
+
+ return 0;
+}
+
+void Rx_interruptMC()
+{
+ //led2 = 1;
+ bool lineEnd = true;
+ char raw_rx[80];
+ int i = 0;
+
+ while (lineEnd)
+ {
+ raw_rx[i] = mc.getc();
+ if ((int)raw_rx[i] == ENTER)
+ {
+ lineEnd = false;
+ }
+ i++;
+ led3 = lineEnd;
+ }
+
+ //Here now the Values of the MC in the current Value
+ sprintf(temp_rx,raw_rx);
+ //led2 = 0;
+}
+void writeLine(char *line)
+{
+ mc.printf("%s\r\n",line);
+}
+
+void writeWord(char *word)
+{
+ mc.printf("%s",word);
+}
+
+void startStatusWriting()
+{
+ writeLine("status_start");
+}
+
+void endStatusWriting()
+{
+ writeLine("status_end");
+}
+
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialCommunication/SerialCommunication.h Thu Jul 13 13:45:55 2017 +0000
@@ -0,0 +1,14 @@
+#include "mbed.h"
+#include "MotorController.h"
+#include "MbedToPC.h"
+
+#ifndef SERIAL_COM_H
+#define SERIAL_COM_H
+
+int initSerialCom()
+{
+
+}
+
+
+#endif
\ No newline at end of file
--- a/Steering.lib Mon Jun 12 20:04:26 2017 +0000 +++ b/Steering.lib Thu Jul 13 13:45:55 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/skrickl/code/Steering/#21d9efc7ecb6 +https://developer.mbed.org/users/skrickl/code/Steering/#787f4284d968
--- a/main.cpp Mon Jun 12 20:04:26 2017 +0000
+++ b/main.cpp Thu Jul 13 13:45:55 2017 +0000
@@ -1,11 +1,84 @@
#include "mbed.h"
+#include "SerialController.h"
+#include "MbedToPC.h"
+#include "MotorController.h"
+#include <string>
-DigitalOut myled(LED1);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+//DigitalOut led3(LED3);
+//DigitalOut led4(LED4);
+
+DigitalOut pin1(p21);
+DigitalOut pin2(p22);
+
+
+DigitalOut pin_forward(p29);
+DigitalOut pin_backward(p30);
+AnalogOut pin_analog_out_throttle(p18);
+
+Serial pc(USBTX, USBRX, 115200);
int main()
-{
- while(1)
+{
+ pin1 = 0;
+ pin2 = 0;
+
+ SerialController controller(p9, p10, p28, p27, 115200);
+
+ float speed = 0.0;
+ int status = 0;
+ int uno = 1;
+ int zero = 0;
+
+ led1 = uno;
+ wait(1);
+ led1 = zero;
+
+ while (1)
{
-
+ /*led1 = !led1;
+ wait(0.5);*/
+
+ status = controller.getStatus();
+
+ led1 = status;
+ led2 = status;
+
+ pc.printf("Status: %i \r\n",status);
+
+ /*if (status == MbedToPC::STATUS_START)
+ {
+ speed = controller.getVelTarget();
+ led1 = 0;
+ }
+ else
+ {
+ speed = 0;
+ led1 = 1;
+ }
+
+ if (speed == 0)
+ {
+ pin_analog_out_throttle = 0;
+ pin_forward = 0;
+ pin_backward = 0;
+ }
+ else if (speed < 0)
+ {
+ pin_analog_out_throttle = 0;
+ pin_forward = 0;
+ pin_backward = 1;
+ wait_ms(100);
+ pin_analog_out_throttle = 0.6;
+ }
+ else if (speed > 0)
+ {
+ pin_analog_out_throttle = 0;
+ pin_backward = 0;
+ pin_forward = 1;
+ wait_ms(100);
+ pin_analog_out_throttle = 0.6;
+ }*/
}
-}
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/save.h Thu Jul 13 13:45:55 2017 +0000
@@ -0,0 +1,76 @@
+/create instances
+ //Controller controller;
+ //controller_timer.attach(&timer_interrupt_controller, 0.1);
+ //MbedToPC test(p9, p10, 115200);
+ //MotorController test1(p28, p27, 115200);
+ //test.enableInterrupt();
+ //test.writeLine("Hello World");
+
+ //test1.writeLine("help");
+ //initMotorController();
+
+ //test.writeLine("hallo welt");
+ //test1.writeWord("status_start\r\n");
+
+ /*SerialController com(p9, p10, p28, p27, 115200);
+
+
+ led3 = 1;
+ com.getMotorControllerReady();
+ led3 = 0;
+
+ com.enableInterrupt();
+ com.startStatus();
+
+ //com.init();
+
+ string line;
+
+
+ led1 = 1;
+ led2 = 1;
+
+ wait(1);
+ //led2 = 0;
+
+ while (1)
+ {
+
+
+ /*led3 = 1;
+ line = test1.readLine();
+
+ wait(0.5);
+ led3 = 0;
+ led2 = 1;
+ test.writeLine(line);*/
+
+
+
+
+ //string line = test1.readLine();
+
+ //test.writeLine(line);
+ /*Test.writeLine("Test read char");
+ char word[1];
+ word[0] = Test.readChar();
+ Test.writeLine(word);*/
+ /*Test.writeLine("Test read line");
+ string line = Test.readLine();*/
+ /*std::size_t found = myLine.find("stop");
+ if (found!=std::string::npos)
+ {
+ Test.disableInterrupt();
+ myLine = "ended!!";
+ }
+ Test.writeLine(myLine);*/
+
+
+ //led1 = !led1;
+ //led2 = !led2;
+
+
+ /* wait(1);
+ led1 = !led1;
+ led2 = !led2;
+ }*/
\ No newline at end of file