upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions

API for the CJQ4435 MOSFET. More...

Detailed Description

UPM module for the CJQ4435 MOSFET. It was developed using the Grove MOSFET module. 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 device.

cjq4435.jpg
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
upm::CJQ4435* mosfet = new upm::CJQ4435(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);
usleep(100000);
}
sleep(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);
usleep(100000);
}
sleep(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 ()
 

Constructor & Destructor Documentation

CJQ4435 ( int  pin)

CJQ4435 constructor

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

CJQ4435 destructor

Member Function Documentation

void setPeriodUS ( int  us)

Sets a period in microseconds

Parameters
usPeriod in microseconds
void setPeriodMS ( int  ms)

Sets a period in milliseconds

Parameters
msPeriod in milliseconds
void setPeriodSeconds ( float  seconds)

Sets a period in seconds

Parameters
secondsPeriod in seconds
void enable ( bool  enable)

Enables output

Parameters
enableEnables PWM output if true, disables otherwise
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
void on ( )

Shortcut to turn the output to continuous on (high)

void off ( )

Shortcut to turn the output to continuous off (low)


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