Drive a coil (valve, solenoid, contactor, etc)

Dependents:   TestBenchSerenity-proto_F429ZI TestBenchFlow HSPFLOW1 TestBenchFlow1 ... more

coil-driver.h

Committer:
dmwahl
Date:
2017-07-20
Revision:
6:e8395448fc8b
Parent:
5:3dab9e2441e3
Child:
7:3f1d2cdcf49b

File content as of revision 6:e8395448fc8b:

#ifndef COIL_DRIVER_H
#define COIL_DRIVER_H

#include "mbed.h"
#include "rtos.h"

// Coil driver class. Applies full power for given "spike" time
// and then applies a PWM signal to keep the coil energized at a lower power.
class Coil
{
public:
    Coil(PinName _controlPin, uint16_t _spikeus, uint16_t _holdperiod_us, uint16_t _holdpulse_us);

    //InterruptIn controlIn; // Input for external coil "ON" signal
    PwmOut controlOut; // PWM output pin driving coil
    uint16_t spikeus, holdperiod_us, holdpulse_us, pwmFrequency;
    
    char status(); // Return 1 if coil is energized, 0 if not
    void on();
    void off();
};

#endif