..

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
brianconnett
Date:
Mon Aug 18 18:05:21 2014 +0000
Commit message:
ES305 Lab2 Exercise 5; Control of Servo with Potentiometer

Changed in this revision

Servo.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 a294a5353234 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Mon Aug 18 18:05:21 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r a294a5353234 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Aug 18 18:05:21 2014 +0000
@@ -0,0 +1,50 @@
+//****************************************
+//  ES305 Linear Control Systems
+//  Lab 2 - Introduction to mbed microcontroller
+//  Exercise 5 - Controlling servo position with PWM and variable potentiometer
+//
+//  Brian Connett, LCDR, USN
+//  exercise and code derived from mbed.org
+//  exercise and code derived from Curtis Shorr, Capt, USAF
+//****************************************
+
+/*********************************************************************************/
+//SCY202 LAB 2 - Introduction to Cyber Attack
+//Program Name: Motor Control
+//Program Description: This program uses the mbed application board to control
+// an RC motor, DC motor and peltier device.  With user interface via 2
+// potentiometers and lcd screen.
+// Created by Capt Curtis Shorr, USAF, Instructor USNA
+// Libraries and Code derived from mbed.org online community
+/*********************************************************************************/
+
+
+#include "mbed.h"                  //include mbed library
+#include "Servo.h"                 //include Servo library
+
+AnalogIn pot1(p15);                //declare pot1
+Serial pc(USBTX,USBRX);            //declare serial comms over USB;
+Servo rc_motor(p21);               //delcare Servo Motor
+
+int main()
+{
+
+    
+    rc_motor.calibrate(0.0009, 90.0); /********************** Servo Motor Calibration **************************/
+    
+    
+    float motpos;                 //declare servo position variable
+    float rc_control;
+    while(1) {
+
+        /********************* Servo Motor Control ***********************/
+        rc_control = pot1.read();//reads pot1 input
+        rc_motor = rc_control;   //send actuation command to servo
+
+        motpos = pot1.read();     //read pot2 input & set as servo position
+        motpos *= 1800;           //180 degrees with three sig figs
+        motpos = (float)((int)motpos);
+        motpos /= 10;
+        pc.printf("RC Position:%9.6f\r",rc_control*180);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a294a5353234 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Aug 18 18:05:21 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804
\ No newline at end of file