diff options
| author | Donald Delmar Davis <don@suspectdevices.com> | 2013-05-24 19:26:25 -0700 |
|---|---|---|
| committer | Donald Delmar Davis <don@suspectdevices.com> | 2013-05-24 19:26:25 -0700 |
| commit | 522c47fbbb9d2d3d39e9a8a76fa59a45630b3e4e (patch) | |
| tree | 793d150732adaddc96cc89eae6add1cbb4c2966f /RetoolingForOpenSprints | |
| parent | dced1ddb7316c5b5911f6f78d9f434a739a7d01f (diff) | |
Its alive. There are some minor issues.
Diffstat (limited to 'RetoolingForOpenSprints')
| -rw-r--r-- | RetoolingForOpenSprints/NewClock/NewClock.ino (renamed from RetoolingForOpenSprints/NewClock/NewClock/NewClock.ino) | 57 | ||||
| -rw-r--r-- | RetoolingForOpenSprints/RaceInABox2/RaceInABox2.ino (renamed from RetoolingForOpenSprints/RaceInABox2/RaceInABox2/RaceInABox2.ino) | 0 | ||||
| -rw-r--r-- | RetoolingForOpenSprints/basic_msg/basic_msg.ino (renamed from RetoolingForOpenSprints/basic_msg/basic_msg/basic_msg.ino) | 2 | ||||
| -rw-r--r-- | RetoolingForOpenSprints/raceinabox/bikewedge.py (renamed from RetoolingForOpenSprints/raceinabox/netsuck.py) | 32 |
4 files changed, 57 insertions, 34 deletions
diff --git a/RetoolingForOpenSprints/NewClock/NewClock/NewClock.ino b/RetoolingForOpenSprints/NewClock/NewClock.ino index bb44efe..22194c3 100644 --- a/RetoolingForOpenSprints/NewClock/NewClock/NewClock.ino +++ b/RetoolingForOpenSprints/NewClock/NewClock.ino @@ -1,16 +1,17 @@ - -/* - * ##### requires modified +/*------------------------------------------------------------------------------------ + * rough in of new clock. + * bikewedge proxy provides the number of steps wanted from goldsprints data. + * this should do some pid ling around so that it will be less jerkey. + * requires the modified stepper motors to do half stepping. * - * 5.9222222 steps per degree. - * too much error. + * (c) 2013 Donald Delmar Davis, Suspect Devices * */ #include <Stepper.h> -#define MIN_MILLIS_PER_STEP 3 +#define MIN_MILLIS_PER_STEP 8 #define STEPPER_STEPS 200 -#define STEPS_PER_REVOLUTION 2132 // for your motor +#define STEPS_PER_REVOLUTION 2132 #define INBUFFERLENGTH 100 char inbuffer[INBUFFERLENGTH]; int bufferIndex; @@ -18,7 +19,7 @@ int yellowGoal=0; int blueGoal=0; int yellowPosition=0; int bluePosition=0; -int stepCount = 0; // number of steps the motor has taken +int stepCount = 0; long int lastStepMillis; Stepper blue(STEPPER_STEPS, 8,9,10,11,1); @@ -41,20 +42,20 @@ void loop() { inbuffer[bufferIndex]=0; if ((inbuffer[0]=='d') && bufferIndex>3) { target=atoi(inbuffer+3); - if (target>STEPS_PER_REVOLUTION)target=STEPS_PER_REVOLUTION; + if (target>STEPS_PER_REVOLUTION) target=STEPS_PER_REVOLUTION; if (inbuffer[1]=='1') { - blueGoal=target;//analogWrite(MOTOR1PWM,bike1speed); + blueGoal=target; Serial.println(inbuffer+3); - Serial.print("blueGoal="); Serial.println(blueGoal); - Serial.print("bluePosition="); Serial.println(bluePosition); } else { - yellowGoal=target;//analogWrite(MOTOR2PWM,bike1speed); + yellowGoal=target; } } else if (inbuffer[0]=='v') { Serial.println("RaceClock 0.1"); Serial.flush(); } else if (inbuffer[0]=='s') { - blueGoal=yellowGoal=STEPS_PER_REVOLUTION; + if (blueGoal||yellowGoal) { + blueGoal=yellowGoal=STEPS_PER_REVOLUTION; + } } bufferIndex=0; //reset input @@ -62,23 +63,25 @@ void loop() { } } if ((millis()-lastStepMillis)>MIN_MILLIS_PER_STEP){ - if ((blueGoal>bluePosition) && (bluePosition<=STEPS_PER_REVOLUTION)){ + if ((blueGoal==STEPS_PER_REVOLUTION)&&((bluePosition==0)||(blueGoal==bluePosition))){ + blueGoal=bluePosition=0; + } + if ((yellowGoal==STEPS_PER_REVOLUTION)&&((yellowPosition==0)||(yellowGoal==yellowPosition))){ + yellowGoal=yellowPosition=0; + } + + if ((blueGoal>bluePosition) && (bluePosition<STEPS_PER_REVOLUTION)){ blue.step(-1); - bluePosition++; - } - - if ((yellowGoal>yellowPosition) && (yellowPosition<=STEPS_PER_REVOLUTION)) { + bluePosition++; + } + if ((yellowGoal>yellowPosition) && (yellowPosition<STEPS_PER_REVOLUTION)) { yellow.step(-1); yellowPosition++; - } - lastStepMillis=millis(); + } - if ((bluePosition==STEPS_PER_REVOLUTION)&&(blueGoal==bluePosition)){ - blueGoal=bluePosition=0; - } - if ((yellowPosition==STEPS_PER_REVOLUTION)&&(yellowGoal==yellowPosition)){ - yellowGoal=yellowPosition=0; - } + lastStepMillis=millis(); + } + } diff --git a/RetoolingForOpenSprints/RaceInABox2/RaceInABox2/RaceInABox2.ino b/RetoolingForOpenSprints/RaceInABox2/RaceInABox2.ino index 06a3251..06a3251 100644 --- a/RetoolingForOpenSprints/RaceInABox2/RaceInABox2/RaceInABox2.ino +++ b/RetoolingForOpenSprints/RaceInABox2/RaceInABox2.ino diff --git a/RetoolingForOpenSprints/basic_msg/basic_msg/basic_msg.ino b/RetoolingForOpenSprints/basic_msg/basic_msg.ino index 55d52c3..21a94c7 100644 --- a/RetoolingForOpenSprints/basic_msg/basic_msg/basic_msg.ino +++ b/RetoolingForOpenSprints/basic_msg/basic_msg.ino @@ -49,7 +49,7 @@ boolean isReceivingRaceLength = false; int raceLengthTicks = 20; int previousFakeTickMillis = 0; -int updateInterval = 250; +int updateInterval = 50; unsigned long lastUpdateMillis = 0; void setup() { diff --git a/RetoolingForOpenSprints/raceinabox/netsuck.py b/RetoolingForOpenSprints/raceinabox/bikewedge.py index 98af13b..f47a854 100644 --- a/RetoolingForOpenSprints/raceinabox/netsuck.py +++ b/RetoolingForOpenSprints/raceinabox/bikewedge.py @@ -1,4 +1,5 @@ -"""-------------------------------------------------------------------------netsuck.py +"""------------------------------------------------------------------------bikewedge.py + DESCRIPTION: This code intercepts both sides of opensprints/goldsprintsfx "conversation" to control a visual indication of progress using something like a phsical clock or a race tree. @@ -13,16 +14,25 @@ job of recovering when the pile of flash or the serial proxy crashes (which happens). It creates a server on 5331 (the only port gold sprints checks) and expects - to listen to serproxy on 5330 + to listen to serproxy on 5330 it talks to the clock on 5332 + it should eventually check and start serproxy and the goldsprints programs. + it should also do a better job of recovering from issues created by externals. + + It has a lot of number foo (hard coding) in it that should be cleaned up + """ import socket import re isocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) osocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) +csocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) isocket.connect(('localhost',5330)) #isocket.setblocking(0) isocket.settimeout(0.2) print "Connected to serproxy" +csocket.connect(('localhost',5332)) +csocket.settimeout(0.2) +print "Connected to clock" osocket.bind(('',5331)) osocket.listen(1) @@ -44,6 +54,7 @@ try: for chunk in receivedData.split('\x00'): if len(chunk)>0 and chunk[0] == 's': print "(RE)SET RACE !!!" + csocket.sendall("s\n"); if len(receivedData)==0: print "ISSUE WITH CLIENT" @@ -58,11 +69,18 @@ try: #if len(chunk.rstrip('\r')): # print "<",re.escape(chunk),len(chunk) if len(chunk) > 4 and chunk[0]=='0' : - done1=int((float(chunk[3:])/1566.0) * 100.00) - print "Bike # 1 is ", str(done1), "percent done" + done1=(float(chunk[3:])/1566.0) * 100.00 + if done1>100.00 : + done1=100.00 + print "Bike # 1 is ", str(int(done1)), "percent done" + csocket.sendall("d1:"+str(int(21.32*(done1)))+"\n") if len(chunk) > 4 and chunk[0]=='1' : - done1=int((float(chunk[3:])/1566.0) * 100.00) - print "Bike # 2 is ", str(done1), "percent done" + done2=(float(chunk[3:])/1566.0) * 100.00 + if done2>100.00 : + done2=100.00 + print "Bike # 2 is ", str(int(done2)), "percent done" + csocket.sendall("d2:"+str(int(21.32*(done2)))+"\n") + if len(sentData)==0: print "ISSUE WITH SERPROXY" try: @@ -72,6 +90,8 @@ try: isocket.connect(('localhost',5330)) break finally: + #need to see if connections is defined.... connection.close() + csocket.close() osocket.close() isocket.close() |
