I am new, I am probably out of my depth but I am trying so here goes...
I purchased this as part of a camera slider kit. The board should generate its own wifi network however it only does so for a second and then stops. Upon viewing the serial monitor I can see a few resets and timeouts. Snippet and code below.
I have searched this site for quite a while. I've seen some comments on power supply's and I have tried 12v @ 2amp, 3amp and 5amp and no difference.
Ive also seen a lot of comments about watchdog but I have not idea what this is or how to control it.
The original supplier is insisting the code is fine, they sent me a second board which also does the same so I'm open to help but I am a green newbie!
Camera Slider project
WIFI init
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x40100000, len 1856, room 16
tail 0
chksum 0x63
load 0x3ffe8000, len 776, room 8
tail 0
chksum 0x02
load 0x3ffe8310, len 552, room 8
tail 0
chksum 0x79
csum 0x79
2nd boot vAT
OK
AT+GMR
AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co. Ltd.
Dec 2 2016 14:21:16
OK
AT+CIPSTAMAC?
+CIPSTAMAC:"10:52:1c:e4:1f:85"
OK
MAC:10521CE41F85
AT+CWMODE=2
OK
AT+CWSAP="JJROBOTS_85","87654321",5,3
OK
Start UDP server
!Timeout!
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x40100000, len 1856, room 16
tail 0
chksum 0x63
load 0x3ffe8000, len 776, room 8
tail 0
chksum 0x02
load 0x3ffe8310, len 552, room 8
tail 0
chksum 0x79
csum 0x79
2nd boot version : 1.5
SPI Speed : 40MHz
SPI Mode : DIO
SPI Flash Size & Map: 32Mbit(512KB+512KB)
jump to run user1 @ 1000
Code
// CAMERA SLIDER PROJECT by JJrobots
// STEPPER MOTOR CONTROL WITH JJROBOTS NEW DEVIA M0 BOARD
// Author: Jose Julio & Juan pedro (JJROBOTS)
// Hardware: New JJROBOTS DEVIA M0 Board with Arduino M0 & ESP8266
// Board (arduino IDE): Arduino/Genuine Zero (Native USB Port)
// Date: 08/10/2019
// Version: 1.09
// Project page : http://jjrobots.com/cameraslider
// License: Open Software GPL License v2
// Hardware:
// X Motor (longitudinal move) connected to MOTOR1 output
// Y Motor (camera rotation) connected to MOTOR2 output
#define VERSION "1.10"
// ROBOT configuration parameters
#include "Configuration.h"
// Configuration: Pins, servos, Steppers, Wifi...
void setup()
{
// STEPPER PINS ON JJROBOTS BROBOT BRAIN BOARD
pinMode(11, OUTPUT); // ENABLE MOTORS ATSAMD21:PA16
pinMode(5, OUTPUT); // STEP MOTOR 1 ATSAMD21:PA15
pinMode(6, OUTPUT); // DIR MOTOR 1 ATSAMD21:PA20
pinMode(7, OUTPUT); // STEP MOTOR 2 ATSAMD21:PA21
pinMode(8, OUTPUT); // DIR MOTOR 2 ATSAMD21:PA06
pinMode(9, OUTPUT); // STEP MOTOR 3 ATSAMD21:PA07
pinMode(10, OUTPUT); // DIR MOTOR 3 ATSAMD21:PA18
pinMode(A4, OUTPUT); // Microstepping output
digitalWrite(A4, HIGH); // 1/16
pinMode(3, OUTPUT); // SERVO1 ATSAMD21:PA09 //Servo outputs not used
pinMode(4, OUTPUT); // SERVO2 ATSAMD21:PA08
pinMode(12, OUTPUT); // output (PA19)
digitalWrite(12, LOW); //Disable
digitalWrite(11, HIGH); // Disbale motors
// LEDS
pinMode(RED_LED, OUTPUT); // RED LED
pinMode(GREEN_LED, OUTPUT); // GREEN LED
// RED LED ON STARTUP
digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED, LOW);
delay(100);
SerialUSB.begin(115200); // Serial output to console
//while (!Serial); // Arduino Leonardo wait for Serial port to open...
Serial1.begin(115200); // Wifi initialization
// Button pressed at init?
//if (digitalRead(A0) == LOW)
// SerialUSB.print("Button pressed at init...");
delay(2000);
SerialUSB.println("Camera Slider project");
// WIFI MODULE INITIALIZATION PROCESS
SerialUSB.println("WIFI init");
delay(200);
Serial1.flush();
Serial1.print("+++"); // To ensure we exit the transparent transmision mode
delay(100);
ESPsendCommand(String("AT"), String("OK"), 1);
//ESPsendCommand("AT+RST", "OK", 2); // ESP Wifi module RESET
//ESPwait("ready", 6);
ESPsendCommand(String("AT+GMR"), String("OK"), 5);
// Deafault : we generate a wifi network
Serial1.println("AT+CIPSTAMAC?");
ESPgetMac();
SerialUSB.print("MAC:");
SerialUSB.println(MAC);
delay(100);
//ESPsendCommand("AT+CWQAP", "OK", 3);
ESPsendCommand(String("AT+CWMODE=2"), String("OK"), 3); // Soft AP mode
// Generate Soft AP. SSID=JJROBOTS_XX, PASS=87654321
String cmd = String("AT+CWSAP=\"JJROBOTS_") + MAC.substring(MAC.length() - 2, MAC.length()) + String("\",\"87654321\",5,3");
ESPsendCommand(cmd, String("OK"), 6);
// Start UDP SERVER on port 2222, telemetry port 2223
SerialUSB.println("Start UDP server");
ESPsendCommand(String("AT+CIPMUX=0"), String("OK"), 3); // Single connection mode
ESPsendCommand(String("AT+CIPMODE=1"), String("OK"), 3); // Transparent mode
String Telemetry = String("AT+CIPSTART=\"UDP\",\"") + String(TELEMETRY) + String("\",2223,2222,0");
ESPsendCommand(Telemetry, String("CONNECT"), 3);
SerialUSB.println(Telemetry);
delay(200);
ESPsendCommand(String("AT+CIPSEND"), String('>'), 2); // Start transmission (transparent mode)
delay(250);
SerialUSB.println();
SerialUSB.print("Camera Slider project v");
SerialUSB.println(VERSION);
// Output parameters
SerialUSB.print("Max_acceleration_x: ");
SerialUSB.println(acceleration_M1);
SerialUSB.print("Min speed X: ");
SerialUSB.println(MIN_SPEED_M1);
SerialUSB.print("Max speed X: ");
SerialUSB.println(MAX_SPEED_M1);
// STEPPER MOTORS INITIALIZATION
SerialUSB.println("Steper motors initialization...");
timersConfigure();
SerialUSB.println("Timers initialized");
delay(200);
// Initializing Robot command variables
max_speed_M1 = MAX_SPEED_M1;
max_speed_M2 = MAX_SPEED_M2;
//Initializing init position
position_M1 = ROBOT_INITIAL_POSITION_X * X_AXIS_STEPS_PER_UNIT;
position_M2 = 0;
timersStart(); //starts the timers
SerialUSB.println("Timers started");
digitalWrite(GREEN_LED, HIGH);
delay(50);
digitalWrite(GREEN_LED, LOW);
delay(50);
digitalWrite(GREEN_LED, HIGH);
delay(50);
digitalWrite(GREEN_LED, LOW);
digitalWrite(RED_LED, LOW);
SerialUSB.print("Robot position:");
SerialUSB.println(position_M1/X_AXIS_STEPS_PER_UNIT);
SerialUSB.println(" Ready... waiting...");
CameraSliderDirection=-1;
dt2_period=50000;
timer_old1 = micros();
timer_old2 = timer_old1;
}
void loop()
{
float distance_to_object=0.0;
float distance_to_max;
float newSpeed;
int i;
MsgRead();
if (newMessage)
{
newMessage = 0;
if (CameraSliderState == 5){
newSpeed = (CameraSpeed/1000.0)*(MAX_SPEED_M1-MIN_SPEED_M1)+MIN_SPEED_M1;
setSpeedS(newSpeed);
SerialUSB.print("Speed:");
SerialUSB.print(CameraSpeed);
SerialUSB.print(" (");
SerialUSB.print(newSpeed); // Speed in steps/seg
SerialUSB.println(")");
}
if (CameraSliderState == 4){
if (oldCameraSliderState==0){
SerialUSB.println("CONTINUE WITH DELAY...");
for (i=15;i>=0;i--){
SerialUSB.println(i);
digitalWrite(GREEN_LED, HIGH); //LED ON
delay(500);
digitalWrite(GREEN_LED, LOW); //LED OFF
delay(500);
}
CameraSliderState=2; // Continue normaly...
}
else
SerialUSB.println("We could not resume if we are not stopped!");
}
if (CameraSliderState == 3){
if (oldCameraSliderState==0){
SerialUSB.println("START FROM INIT WITH DELAY...");
for (i=15;i>=0;i--){
SerialUSB.println(i);
digitalWrite(GREEN_LED, HIGH); //LED ON
delay(500);
digitalWrite(GREEN_LED, LOW); //LED OFF
delay(500);
}
CameraSliderState=1; // Start normaly...
}
else
SerialUSB.println("We could not start if we are not stopped!");
}
if ((CameraSliderState == 1)||(CameraSliderState == 2)){
if (oldCameraSliderState==0){
newSpeed = (CameraSpeed/1000.0)*(MAX_SPEED_M1-MIN_SPEED_M1)+MIN_SPEED_M1;
setSpeedS(newSpeed);
digitalWrite(11, LOW); // Enable motors
move_motor=true;
SerialUSB.println("START MOTORS!");
SerialUSB.print("Rail length:");
SerialUSB.println(SliderSize);
if (ObjectDistance==0){
SerialUSB.println("No object tracking...");
}
else{
SerialUSB.println("Object tracking");
SerialUSB.print(" Object-rail distance:");
SerialUSB.println(ObjectDistance);
SerialUSB.print(" Camera-object distance:");
SerialUSB.println(ObjectPosition);
}
SerialUSB.print("Speed:");
SerialUSB.print(CameraSpeed);
SerialUSB.print(" (");
SerialUSB.print(newSpeed); // Speed in steps/seg
SerialUSB.println(")");
if (CameraSliderState == 1){
SerialUSB.println("=>Start from init position...");
// Initial position: 0
setPosition_mm10(SliderSize * 10);
CameraSliderDirection=-1; // Initial going to max...
position_M1 = 0;
}
else{
SerialUSB.println("=>Resume from actual position...");
}
// Initial angle: We suposse that the camera is already pointing to the object
if (ObjectDistance==0){
position_M2=0;
speed_M2=0;
dir_M2=0;
}
else{
distance_to_object = float(ObjectPosition)-(float(position_M1)/float(X_AXIS_STEPS_PER_UNIT));
position_M2 = atan2(distance_to_object,float(ObjectDistance))*RAD2GRAD*Y_AXIS_STEPS_PER_UNIT;
target_angle_M2 = position_M2; // We suppose to start in the right direction
}
SerialUSB.print("Initial camera angle:");
SerialUSB.println(target_angle_M2/Y_AXIS_STEPS_PER_UNIT);
SerialUSB.print("Camera position:");
SerialUSB.println(position_M1/X_AXIS_STEPS_PER_UNIT);
SerialUSB.print("Target:");
SerialUSB.println(target_position_M1);
digitalWrite(GREEN_LED, HIGH); //LED ON
max_speed_M1 = MAX_SPEED_M1;
max_speed_M2 = MAX_SPEED_M2;
}
else
SerialUSB.println("We could not start or continue if we are not stopped!");
}
if (CameraSliderState == 0)
{
SerialUSB.println("STOP MOTORS!");
max_speed_M1 = 0;
max_speed_M2 = 0;
//digitalWrite(11, HIGH); // Disbale motors
//dir_M1=0;
//dir_M2=0;
//digitalWrite(GREEN_LED, LOW); //LED OFF
}
/*
if (newSpeed < 10)
dt2_period = 400000; // 2.5Hz
else if (newSpeed < 100)
dt2_period = 200000; // 5Hz
else if (newSpeed < 500)
dt2_period = 100000; // 10Hz
else
dt2_period = 50000; // 20Hz
*/
dt2_period = 50000; //20hz
} // End new message
// Motor1 control
timer_value = micros();
dt1 = timer_value - timer_old1;
if (dt1 >= 5000) { //40000=> 25hz 20000 => 50hz 10000=>100hz loop 5000=>200hz 4000=>250hz 2000 => 500hz loop
timer_old1 = timer_value;
if (CameraSliderState == 0){
// If we are stopped=>Disable motors
if ((speed_M1==0)&&(speed_M2==0))
{
move_motor=false;
digitalWrite(11, HIGH); // Disbale motors
dir_M1=0;
dir_M2=0;
digitalWrite(GREEN_LED, LOW); //LED OFF
}
}
if (move_motor) {
positionControl(dt1); // position, speed and acceleration control of stepper motors
if (robot_stopped){ // End of movement? == rail end?
if (end_wait_counter==0)
SerialUSB.println("STOP!");
end_wait_counter++;
if (end_wait_counter>ENDWAIT){
end_wait_counter=0;
distance_to_max = abs(position_M1-long(SliderSize)*X_AXIS_STEPS_PER_UNIT);
// Start the reverse movent
if (distance_to_max<500.0){
SerialUSB.println("...GOING TO ROBOT MIN...");
setPosition_mm10(0);
CameraSliderDirection=1;
}
else{
SerialUSB.println("...GOING TO ROBOT MAX...");
setPosition_mm10(SliderSize * 10);
CameraSliderDirection=-1;
}
SerialUSB.print("Target:");
SerialUSB.println(target_position_M1);
}
} // if (robot_stopped)
} // if (move_motor)
} // 100hz Motor1 control loop
// Motor2 control
timer_value = micros();
dt2 = timer_value - timer_old2;
if (dt2 >= dt2_period) {
timer_old2 = timer_value;
loop_counter++;
if (move_motor) {
if (ObjectDistance==0){
target_angle_M2=0;
speed_M2=0;
dir_M2=0;
}
else{
distance_to_object = float(ObjectPosition)-(float(position_M1)/float(X_AXIS_STEPS_PER_UNIT));
target_angle_M2_old = target_angle_M2;
target_angle_M2 = atan2(distance_to_object,float(ObjectDistance))*RAD2GRAD*Y_AXIS_STEPS_PER_UNIT;
//angleControl(target_angle_M2,dt2);
angleControl(dt2);
}
// DEBUG TO CONSOLE: position and angle
if(1==1){
SerialUSB.print("P:");
SerialUSB.print(float(position_M1)/X_AXIS_STEPS_PER_UNIT);
SerialUSB.print(" ");
SerialUSB.print(target_angle_M2/Y_AXIS_STEPS_PER_UNIT);
SerialUSB.print(" A:");
SerialUSB.print(position_M2/Y_AXIS_STEPS_PER_UNIT);
//SerialUSB.print((target_angle_y-position_y)/Y_AXIS_STEPS_PER_UNIT);
SerialUSB.print(" ");
SerialUSB.print(speed_M1);
SerialUSB.print(" ");
SerialUSB.println(speed_M2);
}
}
} // Motor2 control
}