-
Notifications
You must be signed in to change notification settings - Fork 0
/
thrustnew.ino
100 lines (80 loc) · 1.85 KB
/
thrustnew.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "HX711.h"
#include <LiquidCrystal.h>
//lcd pins
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = A0;
const int LOADCELL_SCK_PIN = A1;
HX711 scale;
double mtime;
double force;
double dt;
double dp;
double impulse;
double last;
double ig;
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("Take off Calibration Weight!");
//not my code
int done = 0; // Declared as a global
Serial.println("Take off calibration weightttt!");
delay(500);
Serial.println("First column - time elasped.");
delay(1000);
Serial.println("Second column - thrust measured in N");
delay(1000);
Serial.println("Third Column - Total Impulse");
delay(500);
Serial.println("Press G and Enter to continue");
while(done == 0)
{
done = 1;
while (Serial.available() > 0)
{
if (Serial.read() == 'G')
{
done = 1;
}
}
}
// now we clear the serial buffer.
while(Serial.available() > 0)
{
byte dummyread = Serial.read();
}
//back to me
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
double taret = 80;
scale.tare(taret);
scale.set_scale(-413.53); // paste cal val here
mtime = micros()/1000000.f;
force = scale.get_units()*0.009806f;
dt = 1/80.f;
dp = force*dt;
impulse = impulse + dp;
last = mtime;
ig = mtime + 10.f;
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
}
void loop() {
mtime = micros()/1000000.2f;
force = scale.get_units()*0.009806f;
dt = mtime-last;
dp = force*dt;
impulse = impulse + dp;
last = mtime;
Serial.print(mtime,10);
Serial.print("\t ");
Serial.print(force,10);
Serial.println("");
if (ig <= mtime && ig + 2 >= mtime){
digitalWrite(10, HIGH);
}
else{
digitalWrite(10, LOW);
}
}