Weston and Ivan / ContinuousServo

Dependencies:   Tach

Dependents:   EW202FP_Stop

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ContinuousServo.cpp Source File

ContinuousServo.cpp

00001 #include "ContinuousServo.h"
00002  
00003  //64 counts per rev
00004  
00005 ContinuousServo::ContinuousServo(PinName output): servo_(output){
00006     servo_.period_ms(50);
00007 }
00008 
00009 void ContinuousServo::speed(float val){
00010     //convert val from -1,1 to 1.3 to 1.7
00011     if(val<-1.0)
00012         val = -1.0;
00013     if(val>1.0)
00014         val = 1.0;
00015     servo_.pulsewidth_us((int)(1500+200*val));
00016 }
00017 
00018 void ContinuousServo::stop(){
00019     servo_.pulsewidth_us(0);
00020 }