Public Member Functions | Private Member Functions | Private Attributes | List of all members
SoftwarePWM Class Reference

#include <SoftwarePWM.h>

Public Member Functions

void Disable ()
 
void Enable (int StartPos, int Period)
 
void SetPosition (int NewPos)
 
 SoftwarePWM (PinName Pin)
 

Private Member Functions

void EndPulse ()
 
void StartPulse ()
 

Private Attributes

int Position
 
Ticker Pulse
 
Timeout PulseStop
 
DigitalOut SoftwarePWMPin
 

Detailed Description

Class to control a servo on any pin, without using pwm

Example:

// Keep sweeping servo from left to right
#include "mbed.h"
#include "Servo.h"
Servo Servo1(p20);
Servo1.Enable(1500,20000);
while(1) {
for (int pos = 1000; pos < 2000; pos += 25) {
Servo1.SetPosition(pos);
wait_ms(20);
}
for (int pos = 2000; pos > 1000; pos -= 25) {
Servo1.SetPosition(pos);
wait_ms(20);
}
}

Definition at line 55 of file SoftwarePWM.h.

Constructor & Destructor Documentation

SoftwarePWM::SoftwarePWM ( PinName  Pin)

Create a new SoftwarePWM object on any mbed pin

Parameters
PinPin on mbed to connect PWM device to

Definition at line 4 of file SoftwarePWM.cpp.

Member Function Documentation

void SoftwarePWM::Disable ( )

Disable the PWM. After disabling the PWM won't get any signal anymore

Definition at line 35 of file SoftwarePWM.cpp.

void SoftwarePWM::Enable ( int  StartPos,
int  Period 
)

Enable the PWM. Without enabling the PWM won't be running. Startposition and period both in us.

Parameters
StartPosThe position of the PWM to start (us)
PeriodThe time between every pulse. 20000 us = 50 Hz(standard) (us)

Definition at line 29 of file SoftwarePWM.cpp.

void SoftwarePWM::EndPulse ( )
private

Definition at line 24 of file SoftwarePWM.cpp.

void SoftwarePWM::SetPosition ( int  NewPos)

Change the position of the PWM. Position in us

Parameters
NewPosThe new value of the PWM position (us)

Definition at line 6 of file SoftwarePWM.cpp.

void SoftwarePWM::StartPulse ( )
private

Definition at line 11 of file SoftwarePWM.cpp.

Member Data Documentation

int SoftwarePWM::Position
private

Definition at line 87 of file SoftwarePWM.h.

Ticker SoftwarePWM::Pulse
private

Definition at line 89 of file SoftwarePWM.h.

Timeout SoftwarePWM::PulseStop
private

Definition at line 90 of file SoftwarePWM.h.

DigitalOut SoftwarePWM::SoftwarePWMPin
private

Definition at line 88 of file SoftwarePWM.h.


The documentation for this class was generated from the following files:


rosserial_mbed
Author(s): Gary Servin
autogenerated on Mon Jun 10 2019 14:53:26