Pi-lomar - TMC2209 & Pico2 Motor Controller Upgrade

by MattHh in Circuits > Raspberry Pi

181 Views, 2 Favorites, 0 Comments

Pi-lomar - TMC2209 & Pico2 Motor Controller Upgrade

IMG_1896.JPG
PCB 2025-12-15.jpg

If you have made the Pi-lomar 3D printed telescope project, this is an improved motor controller for the system.

The original controller used a Pimoroni Tiny 2040 microcontroller together with DRV8825 stepper motor drivers.

This new controller design improves on the performance and smoothness of the original. You should update to the latest pi-lomar software from GitHub on both the RPi and the microcontroller. The board itself should be a straight swap for the earlier design within the telescope itself.

The main changes are :

  1. The microcontroller is now the Raspberry Pi Pico 2
  2. The stepper drivers are now the TMC2209
  3. I2C channels are now available from the Raspberry Pi Pico2
  4. Power control to the microcontroller is improved
  5. The circuit can monitor the power to the motors
  6. USB cable usage is safer

Why the Pico2?

Originally the Raspberry Pi Pico (1) was not reliable enough for the project, there were reset problems that could not be resolved. The project used the Pimoroni Tiny2040 or Tiny2350 instead. These work really well, but have limited GPIO pins exposed and lacked a reset pin. The original circuit had minimal power available to the Tiny. The Pico2 now receives a better power supply from the Raspberry Pi with this design. This means the Pico2 can overclock the processor a little to further improve performance.

Why the TMC2209?

The original DRV8825 chips worked well with the project, but they were quite noisy in operation. If you have good hearing (young!) there was even some background buzzing which could be irritating. The TMC2209 chips use smoother signals to the motor and offer other configuration possibilities. They result in smoother and quieter operation. You can also adjust motor power from the software instead of using a screwdriver and multimeter.

Why the I2C channels?

Many add on sensors (temperature, humidity, position) can communicate with I2C. If you want to expand the capabilities of your project it makes some sense to have I2C communication with the microcontroller available.

Why improve motorcontroller power?

The Tiny does not have a 'reset' pin, so the original circuit used a transistor to control the power pin instead. This reduced the voltage available to microcontroller. It worked well, but was running on the absolute minimum power possible. Switching to the Pico2 gives us a reset pin, so we can have a simpler power solution with higher voltage to the Pico2. That in turn allows us to overclock the Pico2 slightly for even smoother performance.

Why monitor the motor power?

The TMC2209 will not work without motor power, you cannot even configure it, so the system will generate an error. It is possible to forget to turn on the motor power and then wonder why the telescope is not moving. If you are running the project from batteries out under dark skies it is useful to be able to monitor the voltage from the batteries to the motors. The new circuit uses one of the ADC ports on the microcontroller to monitor the voltage and display it on the dashboard.

Why is USB cable usage safer?

When you are developing or debugging on the microcontroller you need to have the USB cable connected to the Raspberry Pi. This provides power to the microcontroller. This can compete with the microcontroller's power via the GPIO header. There is software in pi-lomar to reduce the risk of conflicting power causing damage, but it is not perfect, you have to be very careful when and how you connect a USB cable. The new circuit design eliminates the risk, the circuit can now support two power sources at the same time, it uses a protective diode to keep them separate.

Supplies

IMG_1903.JPG
IMG_1901.JPG
IMG_1902.JPG
IMG_1899.JPG
IMG_1904.JPG
IMG_1900.JPG
IMG_1907.JPG
IMG_1906.JPG
IMG_1898.JPG
  1. PCB (Either protoboard or a produced PCB)
  2. Raspberry Pi Pico 2 with header pins (NOT PICO 1)
  3. 2 x TMC2209 stepper drivers (Recommend Big Tree Tech V1.3)
  4. 3 x 100uF capacitors
  5. 1 x 10k Ohm resistor (0.5W is good)
  6. 2 x 4.7K Ohm resistors
  7. 2 x 1K Ohm resistors
  8. 1 x 1N5817 Schottky Diode
  9. 1 x 40 pin socket for Raspberry Pi GPIO cable
  10. 2 x 20 pin header for Raspberry Pi Pico 2
  11. 4 x 8 pin header for TMC2209 drivers
  12. 2 x 2 pin header for TMC2209 drivers
  13. 5 x 2 pole PCB connection blocks for motor and power connections (pitch 5.08mm / 0.2 Inches)

PCB Choice

PCB schematic small 2025-12-15.jpg
PCB GUIDE 2025-12-15.jpg

There are two choices for producing the PCB

  1. Build your own using protoboard. See the attached pdf schematic.
  2. Having a bare PCB manufactured for you. See links.

I always prototype using 'Breadboard' and jumper cables first, then move on to a self wired protoboard for reliability testing. For the final circuit I generate a design in KiCAD and have a manufacturer produce the circuitboard for me. It is more reliable, neater and it removes the complexity of reading the schematic and producing your own matching wiring.

You must then fit the same components both cases.

The schematic is attached here as a .pdf document.

If you want to have a board produced there are several online manufacturers who can produce small batches and ship them to you in just a few days. JLCPCB and PCBWay are commonly used. I use PCBWay and this project is already available on their website to download the Gerber files or order directly from them.

pilomar steppermotor controller (Pico2 & TMC2209) - Share Project - PCBWay

Use the above link to download the 'Gerber file' which tells the manufacturers what do produce, or you can place and order directly with PCBWay from the same page. You can also access the Gerber file contents from the GitHub repository for the project.

pilomar/gerber/PCB-2025-12-15 at main · Short-bus/pilomar

You will need to 'zip' all the files in the PCB-2025-12-15 folder and submit the zipped file to the manufacturer.

Ordering the PCB

If you place an order for the PCB to be manufactured I suggest these options (usually the default options for new PCBs)

  1. Board type : Single pieces
  2. Different design in panel: 1
  3. Size : 111.9 x 72.5 mm
  4. Quantity :5
  5. Layer : 2 Layers
  6. Material :FR-4: TG130
  7. Thickness : 1.6 mm
  8. Min track/spacing : 8/8mil
  9. Min hole size : 0.3mm ↑
  10. Solder mask : Purple
  11. Silkscreen : White
  12. Edge connector : No
  13. Surface finish : HASL with lead (*)
  14. "HASL" to "ENIG" : No (*)
  15. Via process : Tenting vias
  16. Finished copper : 1 oz Cu
  17. Remove product No. : No
  18. Customized Services and Advanced Options : UL marking:None,

(*) HASL or ENIG: This refers to the soldering surface for the components you will add to the PCB. HASL seems to be cheaper, I use this - however you should make sure that the PCB surface is clean and there is no oxidisation before soldering your components. ENIG will produce 'gold' contacts which will be easier to solder but a little more expensive.

Preparing a Manufactured PCB

It is important to clean the PCB when you receive it. The HASL finish on the contact points can oxidise or have other surface contaminants which can make soldering tricky occasionally. For safety I make sure that the solder points are cleaned with a light abrasive such as a 'fibre pen', 'scribe' or fine 'pin' then the whole board is washed down with isopropyl alcohol to remove grease. Wear gloves to keep the board clean while you are assembling it.

If solder does not adhere to a pad, try scraping the surface with something sharp to clean it of any contaminants. If you are worried by this you can order the board with ENIG finishing, which is a little more expensive but generally easier to solder.

Adding the Components

FZLBITYMNDMK4OG.jpg
IMG_1915.JPG
IMG_1917.JPG
IMG_1918.JPG
IMG_1920.JPG
IMG_1921.JPG

I start by adding the headers to the board. See the images above for the placement of the components on a manufactured board.

2 x 20 pin headers for the Raspberry Pi Pico 2.

4 x 8 pin headers + 2 x 2 pin headers for the TMC2209 drivers.

1 x 40 pin GPIO header.

Add the connection blocks for the 12V power and the motor connections to the drivers.

3 x 100uF capacitors (Get the orientation right!)

1 x 1N5817 Schottky Diode (Get the orientation right!)

2 x 4.7K resistors

2 x 1K resistors

1 x 10K resistor

If you are using 'flux' or 'flux core solder' wash the board again with Isopropyl Alcohol to remove any residual flux once all the components are added. Flux can degrade the board over time.

Installing the PCB in the Telescope

IMG_1956.JPEG
IMG_1957.JPEG

Mount the PCB in the telescope, it is the same form factor as the earlier version.

Connect 40pin ribbon cable from the PCB to the Raspberry Pi GPIO header.

Connect the altitude and azimuth motors (4 wires each) to the PCB. The PCB has the A/B terminals for the stepper motor cables marked.

Manufacturers may not use the same color coding for the motor coil wires, so please check the specification sheet of your motor to get the wiring correct.

A coil is connected to A1 & A2.

B coil is connected to B1 & B2.

If your motor wires are marked A+/A-, B+/B- the connections map as:

  1. A+ = A2
  2. A- = A1
  3. B+ = B2
  4. B- = B1

Connect the 12V power to the PCB. The TMC2209s will not work or even initialize without power.

Upgrading the Pilomar Software

Download project.jpg

If this is your first installation of the telescope then the software will automatically recognise the new board and you will just follow the standard startup instructions from the main project. Refer also to the original pilomar project page for more installation instructions.

If you are upgrading an existing build there may be some extra steps to follow. This is all most easily done via the DESKTOP rather than the command line.

You must have the latest Pilomar software installed from GitHub on the Raspberry Pi (See image above in this section).

Save the pilomar-main.zip file on your Raspberry Pi in /home/pi

Extract everything in the zip file, it will create a folder /home/pi/pilomar-main

To have a clean install of the project: Rename this to /home/pi/pilomar (move any previous /home/pi/pilomar folder somewhere else for safety).

To update an existing installation: Copy the entire contents of /home/pi/pilomar-main into /home/pi/pilomar, overwrite any existing files as it copies.

You must install CircuitPython 9.x or later on the Raspberry Pi Pico 2. (See instructions in the main Pilomar project page for installation guide)

You can then copy ALL the files and folders from /home/pi/pilomar/circuitpython/pico2_tmc2209 onto the Pico 2.

code.py
tmc2209.py
README.txt
erase.py
as5600.py
pilomar/
pilomar/devices.py
pilomar/enum.py
pilomar/helpers.py
pilomar/steppermotor.py
pilomar/trajectory.py
pilomar/uarthost.py
lib/
lib/adafruit_bus_device/
lib/adafruit_bus_device/__init__.py
lib/adafruit_bus_device/i2c_device.mpy
lib/adafruit_bus_device/spi_device.mpy
lib/adafruit_register/
lib/adafruit_register/__init__.py
lib/adafruit_register/i2c_bcd_alarm.mpy
lib/adafruit_register/i2c_bcd_datetime.mpy
lib/adafruit_register/i2c_bit.mpy
lib/adafruit_register/i2c_bits.mpy
lib/adafruit_register/i2c_struct.mpy
lib/adafruit_register/i2c_struct_array.mpy
lib/adafruit_lis3dh.mpy


Finally insert the Pico2 into the PCB, it should be ready to operate.

When you start the pilomar program on the Raspberry Pi computer it will recognise the new PCB and automatically adjust some parameters.

Exit the program, it will have updated the /data/pilomar_params.json file.

Open the file in an editor and check the following settings.

  1. Azimuth "Orientation" should be : 1
  2. Altitude "Orientation" should be : 1
  3. Azimuth "Driver" should be : "tmc2209"
  4. Altitude "Driver" should be : "tmc2209"

Save the edited file before restarting the main pilomar program.

Tuning the TMC2209 Drivers

You can adjust the power to the TMC2209 drivers via software. The previous DRV8825 chips needed you to measure and adjust potentiometers directly on the driver boards. TMC2209s are simpler because it's now software controlled.

The drivers have a default current limit of 1.0A to the motors. This may be enough for your project. You can change this value from the pilomar menu.

Start with small tests.

Check that the azimuth motor can move a few hundred steps using the Tune Azimuth option on the motor menu.

+1000 steps should move the telescope CLOCKWISE.

-1000 steps should move the telescope ANTI-CLOCKWISE.

Check the altitude motor in the same way.

+1000 steps should RAISE the telescope.

-1000 steps should LOWER it.

If the motors fail to move you can increase the current supplied to them from the motor menu.

If the motors move in the wrong direction you can adjust the 'Orientation' parameter for the motor in the parameter file and restart the program. (This may be because of color coding differences between manufacturers or other reasons)

The pdf manual in the pilomar/docs folder on the Raspberry Pi gives more options and detail.

Debugging a New Board

There are options in the pilomar program to help with debugging a new board. Check the manual in the pilomar/docs folder for more tools and ideas.

If the telescope fails to initialize the motor control board:

  1. Check that the 40 pin ribbon cable is attached correctly.
  2. Check that the motor power is available.
  3. On the 'microcontroller tools' menu use the 'monitor communication' option to see if any errors are appearing.