|
@@ -5,22 +5,27 @@
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
+
|
|
|
#include <Automaton.h>
|
|
|
-#include "Atm_lien/Atm_stepper.h"
|
|
|
+
|
|
|
#include "Atm_lien/Atm_TeensyStep.h"
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#include <SPI.h>
|
|
|
#include <Ethernet.h>
|
|
|
#include <EthernetUdp.h>
|
|
|
#include <TeensyMAC.h>
|
|
|
-#include <OSCMessage.h>
|
|
|
+#include <OSCBundle.h>
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
|
|
|
-IPAddress ip(192, 168, 1, 204);
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
IPAddress ipMulti(239, 200, 200, 200);
|
|
|
unsigned int portMulti = 9977;
|
|
|
|
|
@@ -30,6 +35,8 @@ byte sendBuffer2[] = {0x80, 0x14, 0x00};
|
|
|
|
|
|
EthernetUDP Udp;
|
|
|
|
|
|
+
|
|
|
+OSCBundle bndl;
|
|
|
|
|
|
|
|
|
const int HIGH_SPEED = 800 ;
|
|
@@ -41,50 +48,98 @@ Atm_TeensyStep X_top_step;
|
|
|
Stepper X_top_stepper(20 , 19);
|
|
|
StepControl X_top_controller ;
|
|
|
|
|
|
+Atm_TeensyStep Y_top_step;
|
|
|
+Stepper Y_top_stepper(22 , 21);
|
|
|
+StepControl Y_top_controller ;
|
|
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
Ethernet.init(15);
|
|
|
teensyMAC(mac);
|
|
|
- Ethernet.begin(mac, ip);
|
|
|
+ Ethernet.begin(mac);
|
|
|
|
|
|
Udp.beginMulticast(ipMulti, portMulti);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
Serial.begin(115200);
|
|
|
delay(2000);
|
|
|
Serial.println("Started");
|
|
|
- pinMode(13, OUTPUT);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
X_top_step.trace( Serial );
|
|
|
- X_top_step.begin(X_top_stepper, X_top_controller)
|
|
|
- .setEnablePin(18).enable(1)
|
|
|
- .setLimitType(1).setLimitPins(A3).limitReversed(true).limitThresholds(600, 800, 900, 1200);
|
|
|
+ X_top_step.begin(X_top_stepper, X_top_controller, Udp, bndl, "/X_top")
|
|
|
+ .setEnablePin(18).enable(1);
|
|
|
+
|
|
|
X_top_stepper.setMaxSpeed(HIGH_SPEED);
|
|
|
X_top_stepper.setAcceleration(HIGH_ACC);
|
|
|
X_top_stepper.setInverseRotation(true);
|
|
|
|
|
|
+ Y_top_step.trace( Serial );
|
|
|
+ Y_top_step.begin(Y_top_stepper, Y_top_controller, Udp, bndl, "/Y_top")
|
|
|
+ .setEnablePin(23).enableReversed(1)
|
|
|
+
|
|
|
+ .setLimitType(1).setLimitPins(16).limitReversed(true);
|
|
|
+ Y_top_stepper.setMaxSpeed(800);
|
|
|
+ Y_top_stepper.setAcceleration(2500);
|
|
|
+ Y_top_stepper.setInverseRotation(false);
|
|
|
|
|
|
|
|
|
- X_top_step.move(100000);
|
|
|
+ X_top_step.move(-10000);
|
|
|
+ Y_top_step.move(10000);
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop() {
|
|
|
+
|
|
|
automaton.run();
|
|
|
+ Udp.beginPacket(ipMulti, portMulti);
|
|
|
+ bndl.send(Udp);
|
|
|
+ Udp.endPacket();
|
|
|
+ bndl.empty();
|
|
|
+
|
|
|
+ OSCMessage msgIn;
|
|
|
+ int size;
|
|
|
+ if( (size = Udp.parsePacket())>0)
|
|
|
+ {
|
|
|
+ while(size--)
|
|
|
+ msgIn.fill(Udp.read());
|
|
|
+
|
|
|
+ if(!msgIn.hasError()){
|
|
|
+ Serial.println("got OSC");
|
|
|
+
|
|
|
+ X_top_step.onOSC(msgIn);
|
|
|
+ Y_top_step.onOSC(msgIn);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
Serial.print(analogRead(A3));
|
|
|
Serial.print(" ");
|
|
|
- Serial.print(X_top_step.limitState[0]);
|
|
|
+ Serial.print(Y_top_step.limitState[0]);
|
|
|
Serial.print(" ");
|
|
|
Serial.println(X_top_step.limitState[1]);
|
|
|
- delay(10);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ delay(1);
|
|
|
|
|
|
}
|