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

Limit switches in series ? #12

Closed savehanges closed 3 years ago

savehanges commented 3 years ago

I am little bit confuse on using limit switches in series. when i chose different switch types in "Add a new limit switch configuration" the result in json file is different then definition in the header file: https://github.com/pkerspe/ESP-StepperMotor-Server/blob/0e3fc4373f508f7373167f8720a6d9433bcbb71a/src/ESPStepperMotorServer_PositionSwitch.h#L15 image (9)

one other thing i want to know. Is the internalSwitchISR() hard-coded in staticLimitSwitchISR() with SWITCHTYPE_LIMITSWITCH_POS_BEGIN_BIT ? if yes then its mean i can change it to SWITCHTYPE_LIMITSWITCH_COMBINED_BEGIN_END_BIT and use limit switches in series ? https://github.com/pkerspe/ESP-StepperMotor-Server/blob/0e3fc4373f508f7373167f8720a6d9433bcbb71a/src/ESPStepperMotorServer.cpp#L1196

pkerspe commented 3 years ago

What exactly is your question?

The variable "switchType" is decimal representation of a bit mask.

The bit mask also integrates the information if it is an active high or active low configuration of the switch (SWITCHTYPE_STATE_ACTIVE_HIGH_BIT or SWITCHTYPE_STATE_ACTIVE_LOW_BIT).

So the value decimal 17 is in 10001 in binary, which means the first (decimal 1) and the fifth (decimal 16) bit are set in your configuration: first bit indicates SWITCHTYPE_STATE_ACTIVE_HIGH_BIT, so the switch is in active high configuration the fifth bit indicates SWITCHTYPE_POSITION_SWITCH_BIT, so the switch is a position switch

So by sending the decimal value you configure a position switch in active high configuration.

pkerspe commented 3 years ago

as for the second part of your post: yes, it is hardcoded, and yes you can change it to SWITCHTYPE_LIMITSWITCH_COMBINED_BEGIN_END_BIT I did not test this at the moment, but in the internalSwitchISR the switch type is evaluated and the proper value should be handed to the ESP_FlexyStepper Library for a combined Start/End switch connected in series.

pkerspe commented 3 years ago

I pushed a "fix" in version 0.4.1 that actually differentiates between the different limit switch types and thus removed the hardcoded SWITCHTYPE_LIMITSWITCH_POS_BEGIN_BIT

pkerspe commented 3 years ago

in version 0.4.1 I also included the latest UI version now (also 0.4.1) which support selecting the combined (Serial wired) limit switch