pkerspe / ESP-StepperMotor-Server

Turn your ESP32 into a complete stepper motor control server with web UI, REST API and serial control interface
MIT License
225 stars 39 forks source link

5th motor setting is not visible #11

Closed savehanges closed 3 years ago

savehanges commented 3 years ago

Describe the bug in the setup page 4 motors are showing properly but when i add 5th motor( even with uploading config.json) setup page only show index id and other variables name but not values. in Control page there are only 4 motor showing but when i download the config file 5th motor is there with all values.

Environment IDE: Arduino 1.8.13 ESP_StepperMotor_Server = 0.3.3 ESP-FlexyStepper = 1.4.3 AsyncWebserver = 1.2.3 ArduinoJSON = 6.16.1

To Reproduce Config.json is attached

Screenshots image (6) image (7)

savehanges commented 3 years ago
{
  "serverConfiguration": {
    "port": 80,
    "wififMode": 1,
    "wifiSsid": "",
    "wifiPassword": "*****",
    "apName": "StepperMotor-Server",
    "apPassword": "*****"
  },
  "stepperConfigurations": [
    {
      "id": 0,
      "name": "X-Axis",
      "stepPin": 13,
      "directionPin": 12,
      "stepsPerRev": 1000,
      "stepsPerMM": 100,
      "microsteppingDivisor": 1,
      "rpmLimit": 2000
    },
    {
      "id": 1,
      "name": "Y-Axis",
      "stepPin": 14,
      "directionPin": 27,
      "stepsPerRev": 1000,
      "stepsPerMM": 100,
      "microsteppingDivisor": 1,
      "rpmLimit": 2000
    },
    {
      "id": 2,
      "name": "Z-Axis",
      "stepPin": 26,
      "directionPin": 25,
      "stepsPerRev": 1000,
      "stepsPerMM": 66,
      "microsteppingDivisor": 1,
      "rpmLimit": 2000
    },
    {
      "id": 3,
      "name": "A-Axis",
      "stepPin": 33,
      "directionPin": 32,
      "stepsPerRev": 1000,
      "stepsPerMM": 66,
      "microsteppingDivisor": 1,
      "rpmLimit": 2000
    },
    {
      "id": 4,
      "name": "B-Axis",
      "stepPin": 15,
      "directionPin": 2,
      "stepsPerRev": 200,
      "stepsPerMM": 100,
      "microsteppingDivisor": 1,
      "rpmLimit": 1200
    }
  ],
  "switchConfigurations": [],
  "rotaryEncoderConfigurations": []
}
pkerspe commented 3 years ago

this might not be a bug per-se. To limit the amount of ram used, the number of stepper configurations is limited by a macro in ESPStepperMotorServer.h: https://github.com/pkerspe/ESP-StepperMotor-Server/blob/586816abc478db28f1900c9ad8234562d2be830e/src/ESPStepperMotorServer.h#L51

You need to define a value here that is number-of-stepper-configs +1

So you need to put this line at the top of your main.cpp script (hope that works, otherwise need to change ESPStepperMotorServer.h directly): #define ESPServerMaxSteppers 10 (to allow up to 9 stepper motors to be configured)

I have to say I did not test this, but I assume it is the cause of the issue :-) please give it a try

savehanges commented 3 years ago

Thank you for your quick response .. i already defined 6 .. but now again i defined 10 but nothing changed even in control 5th motor is not showing up. if i remove any motor other then 5th then suddenly its there showing all values in "setup" and "control". one more thing i notice. only 5th motor showed up with the "brake settings" with 4 motors brake settings are not showing.

pkerspe commented 3 years ago

Thanks for the feedback. I will investigate it as soon as I find the time to do so

pkerspe commented 3 years ago

the issue should be fixed now, was caused by insufficient memory assigned in the arduino json document (StaticJsonDocument) instance creation. Fixed in Version 0.4.1 please re-test and confirm fix

pkerspe commented 3 years ago

I also increased the stepper config count to 10 (I doubt anyone will ever need more, since the the ESP32 does not even have enough IO Pins to connect more steppers). I did NOT test if the movement is still smooth with so many steppers configured