Raspberry Pi Pico controlled coil winder

John, VK3JCB, showed his home-brew coil winder at the last show and tell meeting and we asked him for some more details on the project.

Earlier this year I was given a cardboard box containing several hundred reed switches of varying sizes. Included in collection were a number of Comus GC-1513 switches.

Just after receiving these switches, the February 2024 edition of Practical Wireless included an article detailing the construction of an antenna switching unit based around the use of reed switches and, fortuitously, the switches used were Comus GC-1513. Having a need for another antenna switch, construction of this unit commenced.

Activating coils for reed switches seemed to be difficult to procure and hence these were to be made as part of the project. The coils consist of 1800 turns of 0.2 mm diameter enamelled wire wound on formers made from a piece of plastic drinking straw with glued on acrylic ends. The winding length is 30 mm implying 150 turns per layer with 12 layers required. To wind 4 coils of 1800 turns each by hand with wire that could barely be seen was considered a step too far and so some means of mechanical assistance was sought.

A fellow club member offered the use of a home made, hand cranked coil winder with the thought this could be fitted with a universal motor since a speed control for such a motor could be easily put together. However a suitable motor wasn’t able to be found in the junk box and so the idea was then conceived of using a stepper motor.

A KP4M4-001 stepper motor was available. These used to be quite common as they were widely used in 5¼” floppy disk drives. They are a 5 wire unipolar motor and some limited testing indicated that this could be made to work.

Power, Pico and stepper

A controller was developed using Micropython running on a RaspberryPi Pico (using such a device for this application is gross overkill in terms of processing power but a) they are cheap and b) several were on hand). A rotary encoder was added to give some speed control. The Pi Pico drives the stepper motor via a ULN2003 7-channel darlington array. For a source of the +5V and +12V power needed a repurposed computer psu was used.

PC Power supply

The stepper motor shaft was fitted an extension machined from a piece of mild steel onto which the coil formers could be mounted. Tension and position control of the windings were done by hand as the speed was manually adjusted.

It all worked quite well with each coil taking about 12 minutes to complete.

If more coils were to be made and the precise number of turns important, it would be a relatively trivial job to add a turn counter.

from machine import Pin
from time import sleep_us
from time import sleep_ms
from rotary_irq_rp2 import RotaryIRQ


# Enter the two GPIO pins you connected to data pins A and B
# Note the order of the pins isn't strict, swapping the pins
# will swap the direction of change.
rotary = RotaryIRQ(18, 19)
btn = Pin(16, Pin.IN, Pin.PULL_UP)

current_val = 0  # Track the last known value of the encoder

IN1 = Pin(2,Pin.OUT)
IN2 = Pin(3,Pin.OUT)
IN3 = Pin(4,Pin.OUT)
IN4 = Pin(5,Pin.OUT)

pins = [IN1, IN2, IN3, IN4]

sequence = [[1,0,0,0],[1,1,0,0],[0,1,0,0],[0,1,1,0],[0,0,1,0],[0,0,1,1],[0,0,0,1],[1,0,0,1]]

while True:
    for step in sequence:
        if btn.value() == 0:  # Has the button been pressed?
#            print("Reset encoder to:", 0)
            rotary.reset() # Resets the rotary library's internal counter back to zero
            sleep_ms(250) # A small delay to wait for the button to stop being pressed
        
        new_val = rotary.value()  # What is the encoder value right now?
    
        if current_val != new_val:  # The encoder value has changed!
#           print("Encoder value:", new_val)
            current_val = new_val  # Track this change as the last know value
#            print("Sleep_us", 2500-current_val*50)
        else:
            while current_val == 0:
                IN1 = 0
                IN2 = 0
                IN3 = 0
                IN4 = 0
                break
               
        for i in range(len(pins)):
            pins[i].value(step[i])
            sleep_us(2500-current_val*50)
#        sleep_us(500)

John, VK3JCB