Ansteuerung_motor_2509

Dependencies:   Serial_HL mbed

Files at this revision

API Documentation at this revision

Comitter:
andreashatzl
Date:
Thu Oct 01 18:22:03 2015 +0000
Commit message:
ansteuerung motor seriel

Changed in this revision

Serial_HL.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 433a8e843e38 Serial_HL.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Serial_HL.lib	Thu Oct 01 18:22:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hollegha2/code/Serial_HL/#b958bdf108cf
diff -r 000000000000 -r 433a8e843e38 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 01 18:22:03 2015 +0000
@@ -0,0 +1,73 @@
+
+#include "mbed.h"
+#include "Serial_HL.h"
+
+// Testprogramm um zu sehen ob die RGB-Led richtig verlötet
+// ist und ob sie sich auch dimmen lässt
+
+SerialBLK pc(USBTX, USBRX);
+SvProtocol ua0(&pc);
+
+PwmOut servo1(p21),servo2(p22),servo3(p23);
+int16_t stickVal1,stickVal2,stickVal3;
+
+void CommandHandler();
+
+int main()
+{
+    servo1.period_ms(20);
+    servo2.period_ms(20);
+    servo3.period_ms(20);
+    
+    pc.format(8,SerialBLK::None,1);pc.baud(500000);
+    ua0.SvMessage("ServoTest");
+    
+    Timer stw; stw.start();
+    while(1)
+    {
+        CommandHandler();
+        if((stw.read_ms()>100))
+        {
+            stw.reset();
+            if(ua0.acqON)
+            {
+             ua0.WriteSvI16(1, stickVal1);
+             ua0.WriteSvI16(2, stickVal2);
+             ua0.WriteSvI16(3, stickVal3);   
+                }
+            }
+        }
+    
+    return 1;
+}
+
+
+void CommandHandler()
+{
+    uint8_t cmd;
+   
+
+    // Fragen ob überhaupt etwas im RX-Reg steht
+    if( !pc.IsDataAvail() )
+        return;
+
+    // wenn etwas im RX-Reg steht
+    // Kommando lesen
+    cmd = ua0.GetCommand();
+
+    if( cmd==2 ) {
+        // cmd2 hat 2 int16 Parameter
+        stickVal1 = ua0.ReadI16();
+        servo1.pulsewidth_us(1000+stickVal1);
+    }
+    if( cmd==3 ) {
+        // cmd2 hat 2 int16 Parameter
+        stickVal2 = ua0.ReadI16();
+        servo2.pulsewidth_us(1000+stickVal2);
+    }
+    if( cmd==4 ) {
+        // cmd2 hat 2 int16 Parameter
+        stickVal3 = ua0.ReadI16();
+        servo3.pulsewidth_us(1000+stickVal3);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 433a8e843e38 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 01 18:22:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file