Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ADS1115 BME280 CronoDot SDFileSystem mbed
Fork of Outdoor_UPAS_v1_2_Tboard by
Revision 23:1ca41779b8ec, committed 2016-03-28
- Comitter:
- caseyquinn
- Date:
- Mon Mar 28 02:54:17 2016 +0000
- Parent:
- 22:baa5a077d908
- Child:
- 24:e274a34492cf
- Commit message:
- Tests Hbridges top two HB2 and HB4 are working. Added in gps heading and also red light for log when no gps connection and RGB light when gps connection.; UPASv1_Tboard_NUCLEO_L152RE_Hbridge_test_RN4677_GPS_pumpson_100digpot_20160327.bin
Changed in this revision
| MAX_M8.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MAX_M8.lib Sat Mar 26 02:51:09 2016 +0000 +++ b/MAX_M8.lib Mon Mar 28 02:54:17 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Vockens-Group-Sensors/code/MAX_M8/#58aed255c80c +http://developer.mbed.org/teams/Vockens-Group-Sensors/code/MAX_M8/#31fed051309c
--- a/main.cpp Sat Mar 26 02:51:09 2016 +0000
+++ b/main.cpp Mon Mar 28 02:54:17 2016 +0000
@@ -71,21 +71,21 @@
//GPS
/////////////////////////////////////////////
DigitalOut gpsEN(PB_15, 0);
-Max_M8 gps(PB_9, PB_8,(66<<1));
+Max_M8 gps(PB_9, PB_8,(0x84));
/////////////////////////////////////////////
//Hbridge Valve Control
/////////////////////////////////////////////
-/*
-DRV8830 motor1(PB_9, PB_8, 0xC4);
-DRV8830 motor2(PB_9, PB_8, 0xCA);
-DRV8830 motor3(PB_9, PB_8, 0xCC);
-DRV8830 motor4(PB_9, PB_8, 0xCE);
+
+DRV8830 motor1(PB_9, PB_8, 0xCA); //Not working with 0xC4 will remove R28 and try 0xCA
+DRV8830 motor2(PB_9, PB_8, 0xC8); //Works with 0xC8, not 0xCA since R8 isn't on the Tboards.
+DRV8830 motor3(PB_9, PB_8, 0xCC); //Not working with 0xCC might try replacing R15 with a 0 ohm resistor and try again.
+DRV8830 motor4(PB_9, PB_8, 0xCE); //Works!
DigitalIn hb_fault1(PA_6);
DigitalIn hb_fault2(PA_7);
DigitalIn hb_fault3(PA_5);
DigitalIn hb_fault4(PA_4);
-*/
+
/////////////////////////////////////////////
//SD Card
/////////////////////////////////////////////
@@ -160,13 +160,14 @@
float flat = 0;
float flon = 0;
+bool gpsFix;
uint8_t gpssatellites = 0;
-double gpsspeed = 0.0;
-double gpslatitude = 0.0;
-double gpslongitude = 0.0;
-float gpsaltitude = 0.0;
-char gpslat = 'W';
-char gpslon = 'N';
+double gpsspeed = 0.0;
+double gpslatitude = 0.0;
+double gpslongitude = 0.0;
+float gpsaltitude = 0.0;
+char gpslat = 'W';
+char gpslon = 'N';
float home_lat = 40.580508;
@@ -404,8 +405,7 @@
void log_data()
{
- RGB_LED.set_led(1,1,1);
-
+
time_t seconds = time(NULL);
strftime(timestr, 32, "%y%m%d%H%M%S", localtime(&seconds));
@@ -447,8 +447,14 @@
vBlowerReading = ads.readADC_SingleEnded(2, 0xE783); // read channel 0
omronDiff = ads.readADC_Differential(0x8583); // differential channel 2-3
- if(gpsEN ==1){
- gps.read(1);
+ //if(gpsEN ==1){
+
+ if(gpsFix){
+ RGB_LED.set_led(1,1,1);
+ }else{
+ RGB_LED.set_led(1,0,0);
+ }
+ gpsFix = gps.read(1);
//RGB_LED.set_led(1,1,0);
gpsspeed = gps.speed;
gpssatellites = gps.satellites;
@@ -511,9 +517,9 @@
location = 3;
}
-*/
+
}
-
+*/
FILE *fp = fopen(filename, "a");
fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC_UPAS.year, RTC_UPAS.month,RTC_UPAS.date,RTC_UPAS.hour,RTC_UPAS.minutes,RTC_UPAS.seconds);
@@ -523,8 +529,7 @@
fprintf(fp, "%.1f,%.1f,%.1f,%.3f,%.3f,%.3f,%.1f,", angle_x,angle_y,angle_z,mag_x, mag_y, mag_z,compass);
fprintf(fp, "%d,%d,%d,%d,%d,%d," ,uv,omronReading, vInReading, vBlowerReading, omronDiff,gasG.getAmps());
fprintf(fp, "%d,%d,%d,%1.3f,%1.3f,", gasG.getVolts(), gasG.getCharge(),digital_pot_set, deltaMflow, deltaVflow);
- //fprintf(fp, "%f,%f,%06d,%06d\r\n", gps.lat, gps.lon, (long)gps.date, (long)gps.utc); // test and add in speed, etc that Josh added in to match the adafruit GPS
- fprintf(fp, "%f,%f,%06d,%06d,%f,%d,%f\r\n", gps.lat, gps.lon, (long)gps.date, (long)gps.utc, gpsspeed, gpssatellites, gpsaltitude); // test and add in speed, etc that Josh added in to match the adafruit GPS
+ fprintf(fp, "%f,%f,%06d,%06d,%f,%d,%f,%d,%f\r\n", gps.lat, gps.lon, (long)gps.date, (long)gps.utc, gpsspeed, gpssatellites, gpsaltitude, gpsFix, gps.hdop); // test and add in speed, etc that Josh added in to match the adafruit GPS
fclose(fp);
free(fp);
RGB_LED.set_led(0,1,0);
@@ -592,15 +597,10 @@
//Main Function
//////////////////////////////////////////////////////////////
int main(){
+
+ RGB_LED.set_led(0,0,1);
- gpsEN = 1;
- wait(1);
- BT_SW = 1;
- wait(1);
- BT_IRST = 1;
- wait(1);
-
- /*
+ /*
//CODE ADDED TO TEST EEPROM
//////////////////////////////////////////
uint8_t serialNumWriter [2] = {0x00,0x12};
@@ -611,8 +611,7 @@
if(putDataInMe[0] == 0x02)pumps=1;
//////////////////////////////////////////
//END CODE ADDED TO TEST EEPROM
-
-
+
RGB_LED.set_led(0,0,1);
STtime.tm_sec = 10; // 0-59
STtime.tm_min = 30; // 0-59
@@ -624,22 +623,24 @@
set_time(seconds); // Set RTC time to 16 December 2013 10:05:23 UTC
wait(5);
+*/
motor1.getFault();
- //wait(5);
+ wait(1);
RGB_LED.set_led(0,0,0);
motor2.getFault();
- //wait(5);
- RGB_LED.set_led(1,0,0);
+ wait(1);
+ RGB_LED.set_led(0,1,0);
motor3.getFault();
- wait(5);
+ wait(1);
RGB_LED.set_led(0,0,0);
motor4.getFault();
- //wait(5);
- RGB_LED.set_led(1,0,0);
+ wait(1);
+ RGB_LED.set_led(0,1,0);
+/*
RGB_LED.set_led(1,0,0);
motor1.drive(254); //closed = 253, open = 254
wait(10);
@@ -665,6 +666,26 @@
*/
+ motor1.drive(254); //closed = 253, open = 254
+ motor2.drive(254); //closed = 253, open = 254
+ motor3.drive(254); //closed = 253, open = 254
+ motor4.drive(254); //closed = 253, open = 254
+
+
+ wait(10);
+ motor1.stop();
+ motor2.stop();
+ motor3.stop();
+ motor4.stop();
+
+
+ gpsEN = 1;
+ wait(1);
+ BT_SW = 1;
+ wait(1);
+ BT_IRST = 1;
+ wait(1);
+
pc.baud(115200); // set what you want here depending on your terminal program speed
pc.printf("\f\n\r-------------Startup-------------\n\r");
@@ -765,7 +786,7 @@
DigPot.writeRegister(digital_pot_setpoint);
wait(1);
- pumps = 1;
+ //pumps = 1;
uint8_t subjectLabelOriginal[8] = {0,};
E2PROM.read(0x00001, subjectLabelOriginal,8);
