Run/kill switch operated power supply.
Dependencies: BridgeDriver MCP23017 TextLCD mbed
Revision 0:8c0abf52e7c0, committed 2015-10-23
- Comitter:
- ggudgel
- Date:
- Fri Oct 23 01:18:13 2015 +0000
- Commit message:
- Kill Switch operated power supply.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BridgeDriver.lib Fri Oct 23 01:18:13 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/jason701802/code/BridgeDriver/#4db83c772b51
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LocalPinNames.h Fri Oct 23 01:18:13 2015 +0000 @@ -0,0 +1,36 @@ +#ifndef LOCALPINNAMES_H + +#define LOCALPINNAMES_H + + /* local name, resouce name */ +#define DIO0 P2_2 +#define DIO1 P2_3 +#define DIO2 P2_4 +#define DIO3 P2_5 +#define DIO4 P2_6 +#define DIO5 P2_7 +#define DIO6 P2_8 +#define DIO7 P2_9 +#define DIO8 P1_1 +#define DIO9 P1_4 +#define DIO10 P1_8 +#define DIO11 P1_9 +#define SS1 P0_19 +#define SS2 P0_20 +#define SS3 P0_21 +#define SS4 P0_22 +#define SS_ADC P1_0 +#define AI0 P0_23 +#define AI1 P0_24 +#define AI2 P0_25 +#define AI3 P0_26 +#define AI4 P1_30 +#define AI5 P1_31 +#define KILL P2_11 +#define CAN1_RX P0_0 +#define CAN1_TX P0_1 +#define CAN2_RX P0_4 +#define CAN2_TX P0_5 + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MCP23017.lib Fri Oct 23 01:18:13 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/wim/code/MCP23017/#5696b886a895
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Fri Oct 23 01:18:13 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/jason701802/code/TextLCD/#1c0232c55749
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Oct 23 01:18:13 2015 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "LocalPinNames.h"
+#include "BridgeDriver.h"
+#include "TextLCD.h"
+
+I2C i2c(P0_10,P0_11); // I2C bus (SDA, SCL)
+BridgeDriver bridges(&i2c); // bridge
+TextLCD_I2C lcd(&i2c, MCP23008_SA0, TextLCD::LCD20x4); // LCD
+DigitalIn killSw(KILL);
+
+void setDrives(int NEWSTATE) {
+ lcd.setAddress(0,3); //set cursor to 0,0
+ if (NEWSTATE)
+ lcd.printf("Power On ");
+ else
+ lcd.printf("Power Off ");
+ bridges.drive(1,NEWSTATE);
+ bridges.drive(2,NEWSTATE);
+ bridges.drive(3,NEWSTATE);
+ bridges.drive(4,NEWSTATE);
+ bridges.drive(5,NEWSTATE);
+ bridges.drive(6,NEWSTATE);
+ bridges.drive(7,NEWSTATE);
+ bridges.drive(8,NEWSTATE);
+}
+
+int main() {
+ killSw.mode(PullUp);
+ i2c.frequency(1000000);
+ lcd.setBacklight(TextLCD::LightOn);
+ lcd.cls(); //clear the display
+ lcd.setAddress(0,0); //set cursor to 0,0
+ lcd.printf("Simple Power Supply");
+ lcd.setAddress(0,1);
+ lcd.printf("Operate with run sw.");
+
+ int currentKillState = killSw;
+ setDrives(!currentKillState);
+
+ while(1) {
+ if (currentKillState != killSw) {
+ currentKillState = killSw;
+ setDrives(!currentKillState);
+ }
+ wait(0.1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 23 01:18:13 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file