A demonstration of the telemetry library (https://github.com/Overdrivr/Telemetry) to transfert to the desktop various data from the FRDM-TFC shield

Dependencies:   BufferedSerial FRDM-TFC-HBRIDGE mbed telemetry

Example of the 'Telemetry' library, a portable communication library for embedded devices.

This code fetches all the data from the Freescale Cup RC-car. It relies on a more advanced shield library that is able to read current feedback from HBridges.

The available data is the following :

  • Potentiometer 0
  • Potentiometer 1
  • 4-bit DIP switch
  • Battery level
  • current inside HBridge A
  • current inside HBridge B

You can use the Pytelemetry Command Line Interface to open plots, visualize the received data, and communicate with the car.

See https://github.com/Overdrivr/pytelemetrycli

Files at this revision

API Documentation at this revision

Comitter:
Overdrivr
Date:
Wed Feb 17 20:43:59 2016 +0000
Child:
1:eeaf7cbb5582
Commit message:
Initial commit with telemetry set-up

Changed in this revision

BufferedSerial.lib Show annotated file Show diff for this revision Revisions of this file
FRDM-TFC.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
telemetry.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BufferedSerial.lib	Wed Feb 17 20:43:59 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/sam_grove/code/BufferedSerial/#779304f9c5d2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FRDM-TFC.lib	Wed Feb 17 20:43:59 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Overdrivr/code/FRDM-TFC-HBRIDGE/#86c5fc9a53d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 17 20:43:59 2016 +0000
@@ -0,0 +1,49 @@
+#include "telemetry/driver.hpp"
+#include "FRDM-TFC/TFC.h"
+
+struct TM_state
+{
+    float throttle;
+};
+
+void process(TM_state * state, TM_msg * msg);
+
+int main()
+{
+    TFC_Init();
+    TM_state state;
+    
+    Telemetry tm(&state,115200);
+    tm.sub(process);
+    
+    Timer refresh_timer;
+    refresh_timer.start();
+    TFC_HBRIDGE_ENABLE;
+    for( ; ; )
+    {
+        if(refresh_timer.read_ms() > 100)
+        {
+            tm.pub_f32("left",TFC_ReadMotorCurrent(0));
+            tm.pub_f32("right",TFC_ReadMotorCurrent(1));
+            tm.pub_f32("pot0",TFC_ReadPot(0));
+            tm.pub_f32("pot1",TFC_ReadPot(1));
+            tm.pub_f32("throttle",state.throttle);
+            tm.pub_f32("bat",TFC_ReadBatteryVoltage());
+            
+            TFC_SetMotorPWM(state.throttle ,state.throttle);
+            tm.update();
+        }    
+    }   
+}
+
+void process(TM_state * state, TM_msg * msg)
+{
+    if(msg->type == TM_float32)
+    {
+        float th = 0;
+        if(emplace_f32(msg,&th))
+        {
+            state->throttle = th;   
+        }
+    }   
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 17 20:43:59 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/telemetry.lib	Wed Feb 17 20:43:59 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Overdrivr/code/telemetry/#b7a3ac7bcec8