upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Attributes

API for the CJQ4435 MOSFET. More...

Detailed Description

UPM module for the CJQ4435 MOSFET. It was developed using the Grove MOSFET module, but could be used with any MOSFET. A MOSFET is like a switch, but it can switch much faster than a mechanical relay. Here, we implement support via MRAA pulse width modulation (PWM) functions. Note: available periods vary depending on the capabilities of your platform.

cjq4435.jpg
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
upm::CJQ4435 mosfet(3);
mosfet.setPeriodMS(10);
mosfet.enable(true);
while (shouldRun) {
// start with a duty cycle of 0.0 (off) and increment to 1.0 (on)
for (float i = 0.0; i <= 1.0; i += 0.1) {
mosfet.setDutyCycle(i);
upm_delay_us(100000);
}
upm_delay(1);
// Now take it back down
// start with a duty cycle of 1.0 (on) and decrement to 0.0 (off)
for (float i = 1.0; i >= 0.0; i -= 0.1) {
mosfet.setDutyCycle(i);
upm_delay_us(100000);
}
upm_delay(1);
}

Public Member Functions

 CJQ4435 (int pin)
 
 ~CJQ4435 ()
 
void setPeriodUS (int us)
 
void setPeriodMS (int ms)
 
void setPeriodSeconds (float seconds)
 
void enable (bool enable)
 
void setDutyCycle (float dutyCycle)
 
void on ()
 
void off ()
 

Protected Attributes

cjq4435_context m_cjq4435
 

Constructor & Destructor Documentation

CJQ4435 ( int  pin)

CJQ4435 constructor

Parameters
pinDigital pin to use; this pin must be PWM-capable
~CJQ4435 ( )

CJQ4435 destructor

Here is the call graph for this function:

Member Function Documentation

void setPeriodUS ( int  us)

Sets a period in microseconds

Parameters
usPeriod in microseconds

Here is the call graph for this function:

void setPeriodMS ( int  ms)

Sets a period in milliseconds

Parameters
msPeriod in milliseconds

Here is the call graph for this function:

void setPeriodSeconds ( float  seconds)

Sets a period in seconds

Parameters
secondsPeriod in seconds

Here is the call graph for this function:

void enable ( bool  enable)

Enables output

Parameters
enableEnables PWM output if true, disables otherwise

Here is the call graph for this function:

void setDutyCycle ( float  dutyCycle)

Sets a duty cycle. Duty cycle is a floating-point number between 0.0 (always off) and 1.0 (always on). It represents a proportion of time, per period, during which the output is driven high.

Parameters
dutyCycleDuty cycle to use

Here is the call graph for this function:

void on ( )

Shortcut to turn the output to continuous on (high)

Here is the call graph for this function:

void off ( )

Shortcut to turn the output to continuous off (low)

Here is the call graph for this function:

Collaboration diagram for CJQ4435:
Collaboration graph
[legend]

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