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: Regrind RioRandHBridge SDFileSystem Solenoid mbed
Fork of ECE4012-PHD_data_out_and_1pps by
Diff: main.cpp
- Revision:
- 5:893aa74ff5aa
- Parent:
- 3:597f8492fee2
- Child:
- 6:ad8a8c14b1f0
--- a/main.cpp Thu Dec 03 06:37:32 2015 +0000
+++ b/main.cpp Sun Dec 06 18:53:38 2015 +0000
@@ -5,15 +5,15 @@
#define OG1_TO_OG2_DIST 1
#define OG1_TO_OG3_DIST 2
-#define SOLENOID_ON_DELAY 0.5
+#define SOLENOID_ON_DELAY 0.25
#define SOLENOID_OFF_DELAY 0.0
#define LED_ON_DELAY 0.5
#define LED_OFF_DELAY 0.0
#define REGRIND_ARRAY_SIZE 1
-#define THRESHOLD 0.015
+#define THRESHOLD 0.02
#define RETURN_THRESHOLD 0.01
-DigitalOut led1(LED1,0); //Used as 1pps out indicator
+Solenoid led1(LED1, LED_ON_DELAY, LED_OFF_DELAY); //Used as 1pps out indicator
Solenoid led2(LED2, LED_ON_DELAY, LED_OFF_DELAY);
Solenoid led3(LED3, LED_ON_DELAY, LED_OFF_DELAY);
Solenoid led4(LED4, LED_ON_DELAY, LED_OFF_DELAY);
@@ -25,7 +25,7 @@
AnalogIn topMotorAdjuster(p19);
DigitalOut bottomMotorAdjuster(p16,0);
DigitalOut unused1(p17,0);
-AnalogIn og1(p15);
+AnalogIn og1(p16);
AnalogIn og2(p20);
DigitalOut og3(p18,0);
InterruptIn divertParticle(p5);
@@ -69,6 +69,7 @@
*/
void divert(){
regrindArray[og2Ndx].divert = 1;
+ led3 = 1;
}
void reverseMotor1(){
augerMotors.Dir1 = !augerMotors.Dir1;
@@ -129,13 +130,13 @@
og2_adc = og2.read()*3.3;
//og3_adc = og3.read()*3.3;
//wait(0.01);
- //pc.printf("og1: %f og2: %f og3: %f\n\r",og1_adc, og2_adc, og3_adc);
-
+ //pc.printf("og1: %f og2: %f \n\r",og1_adc, og2_adc);
+
if((og1_calibration - og1_adc > THRESHOLD) && (og1Oneshot != 1)){ //Something passed through og1
og1Oneshot = 1;
divertParticle.rise(&divert);
//pc.printf("Regrind seen at OG 1 : %fV\n\r", og1_adc);
- led2 = 1;
+ led1 = 1;
//Create Regrind
regrindArray[og1Ndx%REGRIND_ARRAY_SIZE] = Regrind(totalT.read_us(), 1, 0, 0, 0, 0);
@@ -151,13 +152,18 @@
og2Oneshot = 1;
divertParticle.rise(NULL);
regrindArray[og2Ndx%REGRIND_ARRAY_SIZE].setVelocity(OG1_TO_OG2_DIST);
- led3 = 1;
+ led2 = 1;
if(regrindArray[og2Ndx].divert == 1){
+ wait_ms(90);
solenoid = 1; //actuate solenoid if red
+ led4 = 1;
}
else {
+ //wait_ms(90);
solenoid = 0; //Dont actuate if not red.
+ led4 = 0;
}
+ regrindArray[og2Ndx].divert = 0; //reset divert flag
}//if(og2..)
else if(og2_calibration - og2_adc < RETURN_THRESHOLD){ //Regrind has passed ok to reset og
og2Oneshot = 0;
@@ -177,6 +183,7 @@
}//else if(og3 ...)
*/
+ /*
//Check on 1pps clock
if((totalT.read_us() % 2000000) < 1000000){
led1 = 1;
@@ -185,7 +192,7 @@
else {//timer is in off cycle
led1 = 0;
onePPS_out = 0;
- }
+ }*/
//Check if data writing flag is set - if so, write to SD card
