Akifumi Takahashi / PulseGenerator
Embed: (wiki syntax)

« Back to documentation index

PulseGenerator Class Reference

PulseGenerator Class Reference

A class which generate us-order Pulse wave. More...

#include <PulseGenerator.h>

Public Member Functions

 PulseGenerator ()
 Default constructor.
int8_t setWaveform (const uint16_t arg_pulseWidth, const uint16_t arg_pulseFreq)
 Function to set pulse width and culc period from given frequency.
void startPulseWave ()
 Function to start/resume generating Pulse wave.
void stopPulseWave ()
 Function to stop/pose generating pulse wave.
bool getState ()
 Function to refer whther the pulse wave is H xor L.

Detailed Description

A class which generate us-order Pulse wave.

This generates continual pulses which can be used for such as clock for another continual pulses having same pulse width and frequency and another pulse hight.

start________|--|________|--|________|--|________|--|_____...stop

Definition at line 23 of file PulseGenerator.h.


Constructor & Destructor Documentation

Default constructor.

As default, the parameters of pulse form are set as followng.

  • pulse width = 200 [us]
  • pulse period = 5000 [us] (refering to freq = 200 [Hz])

Definition at line 9 of file PulseGenerator.cpp.


Member Function Documentation

bool getState (  )

Function to refer whther the pulse wave is H xor L.

Return values:
(bool)H between pulse rising and then falling
(bool)L between pulse falling and then rising

Definition at line 82 of file PulseGenerator.h.

int8_t setWaveform ( const uint16_t  arg_pulseWidth,
const uint16_t  arg_pulseFreq 
)

Function to set pulse width and culc period from given frequency.

This function set a value m_clockduration, m_rt, and m_ft. The clock is culcurated from pulse width and period (= 1/frequency) using Eucledean Algorithm.

Parameters:
arg_pulseWidthrequired in [us]
arg_pulseFreqrequired in [Hz] bigger than 15 Hz

Definition at line 19 of file PulseGenerator.cpp.

void startPulseWave (  )

Function to start/resume generating Pulse wave.

This function culculates a base clock freq (e.g. pulse periodand) and a pulse rising/falling timing in the clock with which to generate pulse wave. And then exe TICKER.attach().

Definition at line 55 of file PulseGenerator.cpp.

void stopPulseWave (  )

Function to stop/pose generating pulse wave.

This function exe TICKER.detach().

Definition at line 63 of file PulseGenerator.cpp.