Skip to content
Browse files

don't know what I changed.

  • Loading branch information...
1 parent 6337c0b commit 3ce53c41e134e4f7600c7a2dd500203d70204c50 @mrbichel mrbichel committed Oct 19, 2012
Showing with 72 additions and 49 deletions.
  1. +61 −38 arduino/chaos_flowcontrol/chaos_flowcontrol.ino
  2. +9 −9 src/flowControl.cpp
  3. +2 −2 src/simulator.cpp
View
99 arduino/chaos_flowcontrol/chaos_flowcontrol.ino
@@ -12,6 +12,8 @@ int state = 2; //0 = auto 1 = pending 2 = controlled
long autoDelay = 400;
long lastContact = 0;
+bool testing = false;
+
int channels [CHANNEL_NUM];
float waterPressure [CHANNEL_NUM];
@@ -60,16 +62,16 @@ void setup() {
airRegulatorPins[1] = 10;
airRegulatorPins[2] = 11;
- setAirPressure(0, 5);
- setAirPressure(1, 40);
- setAirPressure(2, 40);
-
-
for(int i=0; i< CHANNEL_NUM; i++) {
- setAirPressure(i, 80);
+ setAirPressure(i, 90);
closeAir(i);
- closeWater(i);
+ openWater(i);
+
}
+
+ setAirPressure(1, 120);
+
+
}
@@ -84,32 +86,36 @@ void loop() {
// 5 - 2
// 6 - 0
// 7 - 1
- /*
- int tc = 1;
- closeWater(tc);
- openAir(tc);
- delay(200 + random(200));
- closeAir(tc);
- openWater(tc);
- delay(200 + random(200));
+ // arduino 1
+ // 0: virker ikke
+ // 1: success
+ // 2: success
+
+ // arduino 2
+ // 3: - pumpe trækker kun 0.2 ampere ved 12v
+ // 4: success
+ // 5: - pumpe kortsluttet
+
+ // arduino 3
+ // 6: success
+ // 7: success
+
+ int tc = 0;
+
+
+
+ //setAirPressure(tc, 120);
+ //openAir(tc);
+
+
- tc = 2;
- closeWater(tc);
- openAir(tc);
- delay(300 + random(200));
- closeAir(tc);
- openWater(tc);
- delay(200 + random(200));
- tc = 0;
- closeWater(tc);
- openAir(tc);
- delay(100 + random(200));
- closeAir(tc);
- openWater(tc);
- delay(400 + random(200));*/
-
+
+
+
+ if (!testing) {
+
// send data only when yoSu receive data:
if (!Serial.available()) {
// no data
@@ -128,16 +134,32 @@ void loop() {
}
if (state==0) {
- //auto control here
+
+ for(int i=0; i< CHANNEL_NUM; i++) {
+
+ tc = i;
+
+ //setAirPressure(i, 100);
+ closeWater(tc);
+ openAir(tc);
+ delay(400 + random(2000));
+ closeAir(tc);
+ openWater(tc);
+ delay(400 + random(2000));
+
+
+ }
+
+
} else if (state == 2) {
- int c;
- //while(!Serial.available());
- c = Serial.read();
+ int c;
+ //while(!Serial.available());
+ c = Serial.read();
- if (c!='c' && c!='p' && c!='s' && c!='a' && c!='w') {
- value = c;
- } else {
+ if (c!='c' && c!='p' && c!='s' && c!='a' && c!='w') {
+ value = c;
+ } else {
if (c=='c') {
channel = value;
//Serial.println("Set channel to " + String(value));
@@ -168,5 +190,6 @@ void loop() {
value = 0;
}
- }
+ }
+ }
}
View
18 src/flowControl.cpp
@@ -8,21 +8,21 @@ void flowControl::setup(){
arduino[0].enumerateDevices();
- arduino[0].setup("/dev/tty.usbmodemfd1221", 9600);
- arduino[1].setup("/dev/tty.usbmodemfd1211", 9600);
- arduino[2].setup("/dev/tty.usbmodemfd1241", 9600);
+ arduino[0].setup("/dev/tty.usbmodemfa1311", 9600);
+ arduino[1].setup("/dev/tty.usbmodemfa1321", 9600);
+ arduino[2].setup("/dev/tty.usbmodemfa1341", 9600);
//arduino[2].setup(2, 9600);
//arduino[0].setVerbose(true);
for (int i = 0; i < NUM_CHANNELS; i++) {
channels[i].i = i;
- channels[i].airCal = 0.8;
+ channels[i].airCal = 1;
channels[i].waterOpen = true;
updateChannel(&channels[i]);
}
- channels[0].airCal = 0.2;
+ channels[0].airCal = 1;
}
@@ -102,19 +102,19 @@ void flowControl::updateChannel(Channel * c) {
int ci;
int ard = 0;
- if (c->i > 2) {
+ if (c->i > 2 && c->i < 4) {
ci = c->i - 3;
ard = 1;
- } else if (c->i ) {
+ } else if (c->i > 4) {
ci = c->i - 6;
ard = 2;
}
sendValue('c', ci, &arduino[ard]);
- sendValue('p', ofMap(c->airPressure, 0, 1, 0, 160) * c->airCal, &arduino[ard]);
+ sendValue('p', 100, &arduino[ard]);
//sendValue('s', ofMap(c->waterPressure, 0, 1, 0, 255), &arduino[ard]);
sendValue('a', c->airOpen, &arduino[ard]);
- sendValue('w', true, &arduino[ard]); // hard coded ex
+ sendValue('w', c->waterOpen, &arduino[ard]); // hard coded ex
}
View
4 src/simulator.cpp
@@ -82,8 +82,8 @@ void Simulator::simulatePath(Channel * c) {
//hasBike;
if (ofGetFrameNum() % 8 == 0) {
- c->path->timeToNextBike = ofMap(c->path->trafficf, 0, 1, 6000, 100) + ofMap(ofNoise(elapsedFloat), -1, 1, 2000, 0);
- c->path->singleBikeDuration = ofMap(c->path->trafficf, 0, 1, 1000, 20) + ofMap(ofNoise(elapsedFloat), -1, 1, 200, 0);
+ c->path->timeToNextBike = ofMap(c->path->trafficf, 0, 1, 20000, 13000) + ofMap(ofNoise(elapsedFloat), -1, 1, 4000, 0);
+ c->path->singleBikeDuration = ofMap(c->path->trafficf, 0, 1, 10000, 4000) + ofMap(ofNoise(elapsedFloat), -1, 1, 3000, 0);
}
if(c->path->hasBike) {

0 comments on commit 3ce53c4

Please sign in to comment.
Something went wrong with that request. Please try again.