|
|
|
@@ -41,7 +41,6 @@ const int PWR_CAM_PIN = 6; |
|
|
|
|
|
|
|
JsonDocument msg; |
|
|
|
String stepperVelocity; |
|
|
|
int actAzi = 0; |
|
|
|
|
|
|
|
// Define motor interface type |
|
|
|
#define motorInterfaceType AccelStepper::MotorInterfaceType::HALF4WIRE |
|
|
|
@@ -55,11 +54,11 @@ void setup() { |
|
|
|
pinMode(PWR_RELAY_PIN, OUTPUT); |
|
|
|
pinMode(PWR_CAM_PIN, OUTPUT); |
|
|
|
|
|
|
|
digitalWrite(PWR_RELAY_PIN, HIGH); |
|
|
|
digitalWrite(PWR_CAM_PIN, HIGH); |
|
|
|
|
|
|
|
setSlowStepperVelocity(); // Slow: Acc: 500 / Fast: MaxSpeed: 1000 |
|
|
|
// Slow: Acc: 200 / Fast: MaxSpeed: 500 |
|
|
|
|
|
|
|
digitalWrite(PWR_RELAY_PIN, HIGH); |
|
|
|
digitalWrite(PWR_CAM_PIN, HIGH); |
|
|
|
} |
|
|
|
|
|
|
|
/* The loop function runs over and and checks the serial port for receiving a Json of following format: |
|
|
|
@@ -155,7 +154,6 @@ void loop() { |
|
|
|
|
|
|
|
} else if (sdr == CMD_SENDER_PC && cmd == CMD_ZERO_CAM) { |
|
|
|
stepper.setCurrentPosition(0); |
|
|
|
actAzi = 0; |
|
|
|
sendZeroCamStatus(String(stepper.currentPosition())); |
|
|
|
|
|
|
|
} else if (sdr == CMD_SENDER_PC && cmd == CMD_VELOCITY_CAM) { |
|
|
|
@@ -170,12 +168,11 @@ void loop() { |
|
|
|
sendCamVelocityStatus(); |
|
|
|
|
|
|
|
} else if (sdr == CMD_SENDER_PC && cmd == CMD_ACT_AZIMUT_CAM) { |
|
|
|
actAzi = round(stepper.currentPosition() / (4076.0 / 360.0) * -1); |
|
|
|
int actAzi = round(stepper.currentPosition() / (4076.0 / 360.0) * -1); |
|
|
|
sendCamActAzimut(String(actAzi)); |
|
|
|
|
|
|
|
} else if (sdr == CMD_SENDER_PC && cmd == CMD_AZIMUT_CAM) { |
|
|
|
if (digitalRead(PWR_CAM_PIN) == LOW) { |
|
|
|
actAzi = val.toInt(); |
|
|
|
long target = round((4076.0 / 360.0) * val.toDouble() * -1); |
|
|
|
stepper.moveTo(target); |
|
|
|
stepper.run(); |