Last edited · 34 revisions  

 


The WeMos R32 with CNC V3 Shield

NOTE: THIS IS AN EXPERIMENTAL DESIGN AND MAY CHANGE OR HAVE UNFORESEEN PROBLEMS THAT CAUSE IT TO BE ABANDONED (THOUGH THAT ISN'T LIKELY!)

The image below shows a CNC V3 Shield, readily available from many sources including aliexpress (be sure to select CNC Shield V3) and eBay, plugged into an Arduino UNO.  We don't use the UNO, since it's too limiting, but rather the much more powerful but still widely available/inexpensive WeMos (D1 or D2) R32 board with the same exact foot-print.

The only electrical difference being that the UNO is a 5V device where the WeMos R32 is 3.3V, for this reason a single 10K resistor (which pulls stepper driver EN pins HIGH) should be cut off or un-soldered and removed.

You can see a comparison of micro-controller features here (again, this is an ESP32.) 

Whatever you build use an appropriate DC rated fuse (current rating depends on stepper drivers/motors/etc.)

staticboards Arduino CNC shield

License

The SCL and SDA pins on the schematic below are not active for I2C (due to the design.)  The actual I2C pins are on the WeMos R32 and not brought through to this shield but are still accessable though.  The yellow highlights below show where shunts must be inserted it properly activate the 4th stepper driver (labeled AMOT.)

License

License

This CNC V3 shield board is a staticboards.com device, which should work for our purposes (once the 10K resistor R5 is removed,) as far as I know.  Again, similar boards are available from many sources including aliexpress and eBay.


WeMos R32 with CNC V3 Shield:

*** It's up to you to understand the design, connection, limitations, and use of this device and its components, I accept no responsibility. ***

OnStep version 4.4a or later is required for this device.

Please refer to the documentation for the WeMos (D1 or D2) R32 and CNC V3 Shield you choose to understand their use and limitations.


CNC V3 Shield note:

There is a single 10K resistor (R5 in the schematic above) which must be removed by heating with an solder iron etc.  On generic boards this same resistor is often referred to as R1 and is a traditional axial lead resistor which can easily be cut away with small diagonal cutters.

This resistor serves to pull the stepper driver EN pins high (to 5V in this case) which disables all stepper drivers when the MCU isn't in control.  Since the ESP32 is a 3.3v device this can damage its associated pin that is used to control this signal.  Simply removing the device and having the stepper driver default (active low and pulled low by default in most cases) is acceptable for our application.


Power:

The CNC V3 should be powered from the motor supply, possibly another power supply will be need to run the WeMos R32.  Be sure to stay within the voltage and current limits for each device.

There are 3 ways power can be applied to this combination of boards and one must take care if TMC stepper drivers are used (TMC2130, 5160, 2208, etc.) since they can NOT have logic/signal power present before the motor power supply comes up:

  • The power connector on the WeMos R32.
  • The USB connector on the WeMos R32 (see below.)
  • The power connector on the CNC V3 Shield.

Solutions:

  • You can skip the TMC drivers and use LV8729's (or S109, A4988, etc.) and not worry about this.
  • There are TMC driver protection devices (that use Vio to power Vmot) which should avoid issues with this; available on aliexpress, eBay, etc.
  • You can make, and always use, a micro-usb cable with the +5V wire disconnected (cut) and also use a single supply (with voltages within ratings for all devices and also sufficient for the stepper motors) for both the CNC Shield and WeMos R32.  This might sound complicated but when building the controller inside a small enclosure it's all perfectly possible to do in such a way that there will never be an issue.

USB:

The WeMos R32 has a micro-usb port that will be used to upload OnStep firmware to the device and often to allow control of the telescope mount once finished (provides a virtual serial port for control.)


Choice of Stepper driver:

  • Axis1/2 (RA/Dec or Azm/Alt):
    • The LV8729 is the recommend driver due to its low cost and easy setup.
      • These stepper drivers operate in a fixed micro-step mode selected on the 3x 2 pin headers under to each stepper driver.
    • The FYSETC TMC2130 v1.1 is also a good choice but requires more effort.  These are available on ebay (read about the TMC2130 before buying!)  Just remove all shunts under the stepper socket and plug them in. 
      • Once the following is done you'll be able to configure a variety of settings for these stepper drivers in OnStep's Config.h file including the micro-step mode, stealthChop or spreadCycle, lower the power for tracking, etc.
      • Jumper each (Axis1 and Axis2) modules' SPI pins.
        • Axis1 SDI to Axis2 SDI to the WeMos R32 IO32 (SPI MOSI, not present on the CNC V3.)
        • Axis1 SCK to Axis2 SCK to the WeMos R32 IO33 (SPI SCK, not present on the CNC V3.)
        • Axis1 CS to the WeMos R32 IO15 (not present on the CNC V3.)
        • Axis2 CS to the WeMos R32 IO0 (not present on the CNC V3.)
        • Axis1 and Axis2 SDO are NOT supported and don't get connected. 
      • For these drivers you must not power the driver logic section without the motor power present.  See the Power: section above for solutions to this.
    • Many other drivers can work too there's a summary here.
    • Tip:
      • The SSS TMC2130/TMC5160 status and error detection feature is not supported with this device since there is no provision for SPI MISO.
      • The Axis1 and Axis2 ENable control line is shared between the drivers.  For this reason you can't use the AXIS2_AUTO_POWER_DOWN_ON option (to save power.).  You can use the power saving options available on the SSS TMC2130/TMC5160 to achieve a similar effect though.
  • Axis3/4 (Focusers and/or Rotator):
    • The LV8729 is the preferred driver for these sockets due to its low cost and availability.
    • The SilentStepStick TMC2208 is a better choice if TMC drivers are also used in Axis1/2.  They default to using stealthChop for silent operation with 256x interpolation for smooth motion.
      • Supports automatic stand-still power reduction (their ENable pin will need to be cut off for this.)
      • For these drivers you must not power the driver logic section without the motor power present.  See the Power: section above for solutions to this.
    • The A4988 is a good option as well due to its very low cost.
    • Tip:
      • These stepper drivers all operate in a fixed micro-step mode selected on the 3x 2 pin headers under to each stepper driver.
      • Normally these drivers use lower power levels and so no heat-sink is required.

*** warning: never plug in or remove the stepper motor cables while powered up ***


ST4 interface:This is enabled by setting ST4_INTERFACE  ON in the configuration file.  If the ST4_HAND_CONTROL ON option is used additional capabilities become available, read the configuration file for more information.  The order of most pins match those of the RJ12 jack they should be connected to (search eBay for "RJ12 breakout"):

Pin 1: +5v or NC
Pin 2: Gnd
Pin 3: RA- (I34)
Pin 4: Dec- (IO18)
Pin 5: Dec+ (IO4)
Pin 6: RA+ (I35)

Note: you MUST add 2k pull-up (to 3.3V) resistors to each ST4 line (RA-, Dec-, Dec+, RA+.)  You can how one user added the pull-up resistors here.


Hardware SPI interface:
Not supported.  Note: This is separate from the SPI interface used for the TMC2130/TMC5160 stepper drivers.


Bluetooth:
There is built-in Bluetooth on the ESP32 micro-controller.  This interface can be configured using the settings for SerialC in OnStep's Config.h file.


Serial2 (WiFi, or Ethernet):

OnStep on the WeMos R32 has two serial ports always active.  One is attached to the WeMos R32 USB port and the other (Serial2) is available for other purposes. 

  • The Serial2 port pins are designated (TX2, IO5) and (RX2, IO13.)

The Wifi add-on or Ethernet add-on can plug into this port.  For all options jumper wires will be needed to connect things but this is easily done.  RX on the module goes to TX2 on the CNC V3 shield (shown above.)  TX on the module goes to RX2 on the CNC V3 shield.  You also need +5V and Gnd connected to power the device.

  • For Wifi, the "WeMos D1 Mini" ESP8266 WiFi module can be jumper-ed right in.  Setting up WiFi is covered in its own section of the Wiki.
  • For Ethernet, the Teensy3.2/W5500 module can be jumper-ed right in.  Setting up Ethernet is covered in its own section of the Wiki.

DS3231 RTC, BME280 (I2C):

This optional module provides the date/time and a PPS signal (using Aux7) if desired.  Enabling the DS3231 RTC also enables the ESP32 I2C bus and overrides Home SW support since I2C is on the same Aux3/4 pins.  The BME280 temperature/humitidy/pressure sensor is also supported.

  • The pins for Aux3 (SDA) and Aux4 (SCL) are located on the WeMos R32 board only (like named pins on the CNC V3 shield are NOT I2C.)

Misc. I/O:

There are pins designated Aux7 and Aux8 which can be used to support a single feature on each.  I normally bring these out on the 3.5mm mini stereo jack for external access to them.  The jack's collar is Gnd, its ring (middle) is the Limit Sense, and its tip is the Illuminated reticle. 

Aux3 typically used for a Home SW on RA or Azm but can be used any purpose (dew heater for instance, on/off switch, etc.)  If I2C is used this is SDA instead.

Aux4 typically used for a Home SW on Dec or Alt but can be used any purpose (dew heater for instance, on/off switch, etc.)  If I2C is used this is SCL instead.

Aux7 is an input only pin and can be used for the following (selected by positioning a shunt on the appropriate labeled pins under the DS3231 RTC module:)

  • Limit Sense - A switch (or series of switches wired in parallel) can close pulling the limit sense LOW to stop any slew and tracking.  I normally protect the Limit Sense input against ESD with a 0.1uF capacitor and a reasonably strong 2K pull-up resistor.  This can be physical limit switches and/or an emergency stop button.
  • PPS - from the DS3231 RTC.  Pulse per second provides OnStep with an more accurate clock source for precision timing of steps.

Aux8 is an input or output pin and can be used for one of the following:

  • Status LED - not an recommended option.
  • Status LED2 - not an recommended option.
  • Reticle - typically this would be attached by plugging into the mini stereo jack.  If using this to directly drive an LED be sure to add a resistor in series to limit the current.
  • OneWire - supports DS2413 (dual GPIO) and DS18B20 (temperature sensors.)  Allows for temperature compensated focusing, dew heater control, intervalometer, etc. Typically this would be attached by plugging into the mini stereo jack.

BUZZER, the CNC V3 is equipped with a Tone pin (GPIO2) for audible alerts.  Review my MaxPCB3 schematic (on EasyEDA) to see what components to use if you want this.

PEC, the periodic error correction input.  Often the critical RA axis of the mount uses a worm-wheel gear.  The worm has machining errors that repeat once per cycle and a physical sensor makes sure OnStep always knows where the worm is in that cycle.  See PEC_SENSE in the configuration file to set this up, there are several options to suit different sensors.

  • Perhaps use a mini (1/8") stereo jack with its collar as Gnd, ring (middle) as the PEC sense, and the tip as a 3.3V source.  Some ESD protection on the sense pin with a 0.1uF capacitor doesn't hurt.  This arrangement can be used with an optical encoder or hall-effect (magnetic) sensor with minimal or no additional circuitry.  This is on the ESP32 input only pin I36 which can be operated in digital or analog mode.