Dependencies:   PWM-Coil-driver mbed-rtos mbed

Committer:
iwolf32
Date:
Wed Sep 06 21:37:21 2017 +0000
Revision:
1:08a21ae747ff
Parent:
0:a562ecd6baab

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dmwahl 0:a562ecd6baab 1 #include "mbed.h"
dmwahl 0:a562ecd6baab 2 #include "rtos.h"
dmwahl 0:a562ecd6baab 3 #include "coil-driver.h"
iwolf32 1:08a21ae747ff 4
dmwahl 0:a562ecd6baab 5 // Coil parameters [control pin, spike time (us), hold time period (us), hold time pulse width (us)]
iwolf32 1:08a21ae747ff 6 Coil yellow(A0, 300, 40, 4); // Injector
dmwahl 0:a562ecd6baab 7
iwolf32 1:08a21ae747ff 8 Coil orange(A1, 2000, 40, 12); // Shutoff valve
dmwahl 0:a562ecd6baab 9 DigitalOut fb(A2); // Fast shutoff circuit for shutoff valve. High when valve is off, low when valve is on.
dmwahl 0:a562ecd6baab 10
iwolf32 1:08a21ae747ff 11 InterruptIn injectorValveStatus(D7);
iwolf32 1:08a21ae747ff 12 InterruptIn shutoffValveStatus (D8);
iwolf32 1:08a21ae747ff 13
iwolf32 1:08a21ae747ff 14 void injectorValveOn()
iwolf32 1:08a21ae747ff 15 {
iwolf32 1:08a21ae747ff 16 yellow.on();
iwolf32 1:08a21ae747ff 17 }
iwolf32 1:08a21ae747ff 18 void injectorValveOff()
iwolf32 1:08a21ae747ff 19 {
iwolf32 1:08a21ae747ff 20 yellow.off();
iwolf32 1:08a21ae747ff 21 }
iwolf32 1:08a21ae747ff 22 void shutoffValveOn()
iwolf32 1:08a21ae747ff 23 {
iwolf32 1:08a21ae747ff 24 fb=0;
iwolf32 1:08a21ae747ff 25 orange.on();
iwolf32 1:08a21ae747ff 26 }
iwolf32 1:08a21ae747ff 27 void shutoffValveOff()
iwolf32 1:08a21ae747ff 28 {
iwolf32 1:08a21ae747ff 29 orange.off();
iwolf32 1:08a21ae747ff 30 fb=1;
iwolf32 1:08a21ae747ff 31 }
dmwahl 0:a562ecd6baab 32 int main()
dmwahl 0:a562ecd6baab 33 {
iwolf32 1:08a21ae747ff 34 while(1) {
iwolf32 1:08a21ae747ff 35 shutoffValveOff();
iwolf32 1:08a21ae747ff 36 wait(1);
iwolf32 1:08a21ae747ff 37 shutoffValveOn();
iwolf32 1:08a21ae747ff 38 wait(1);
iwolf32 1:08a21ae747ff 39 }
dmwahl 0:a562ecd6baab 40 }