ROBOTIZED MAG LOOP

GOAL

Using a stepper motor to remotely control the variable capacitor from the shack while watching the SWR-meter and avoid tuning mess because of skin effect.

HARDWARE

STEPPER MOTOR

The famous 28BYJ-48.

DATASHEET

28byj48-stepper-motor-datasheet.pdf

CHARACTERISTICS

NOTES

Manufacturers usually specify that the motors have a 64:1 gear reduction. Some members of the Arduino Forums noticed that this wasn’t correct and so they took some motors apart to check the actual gear ratio. They determined that the exact gear ratio is in fact 63.68395:1, which results in approximately 4076 steps per full revolution (in half step mode). I am not sure if all manufacturers use the exact same gearbox, but you can just adjust the steps per revolution in the code, to match your model.

The Adafruit Industries Small Reduction Stepper Motor uses the same form factor as the 28BYJ-48, but does have a different gear ratio. It has a roughly 1/16 reduction gear set, which results in 513 steps per revolution (in full-step mode). You can download the datasheet for it here.

DRIVER BOARD

The famous ULN2003 driver board.

ULN2003 DATASHEET

uln2003-datasheet.pdf

ULN2003 DRIVER BOARD DATASHEET

uln2003-stepper-motor-driver-pcb.pdf

STEPPER CONTROL SCHEMATICS

POSITION READING

We are using a 250k potentiometer to read the position of the stepper-motor / variable capacitor. We must avoid to go below the 0 position of the variable capacitor (fully open, minimum capacitance) and avoid to go over the 100% position of the variable capacitor (fully closed, maximum capacitance).

/* Analog Read to LED
 * ------------------ 
 *
 * turns on and off a light emitting diode(LED) connected to digital  
 * pin 13. The amount of time the LED will be on and off depends on
 * the value obtained by analogRead(). In the easiest case we connect
 * a potentiometer to analog pin 2.
 *
 * Created 1 December 2005
 * copyleft 2005 DojoDave <http://www.0j0.org>
 * http://arduino.berlios.de
 *
 */
 
int potPin = 2;    // select the input pin for the potentiometer
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor
 
void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}
 
void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(val);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(val);                  // stop the program for some time
}

CODE

LIBS

ARDUINO STEPPER EXAMPLES

/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board and Arduino UNO. More info: https://www.makerguides.com */
 
// Include the Arduino Stepper.h library:
#include <Stepper.h>
 
// Define number of steps per rotation:
const int stepsPerRevolution = 2048;
 
// Wiring:
// Pin 8 to IN1 on the ULN2003 driver
// Pin 9 to IN2 on the ULN2003 driver
// Pin 10 to IN3 on the ULN2003 driver
// Pin 11 to IN4 on the ULN2003 driver
 
// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
 
void setup() {
  // Set the speed to 5 rpm:
  myStepper.setSpeed(5);
 
  // Begin Serial communication at a baud rate of 9600:
  Serial.begin(9600);
}
 
void loop() {
  // Step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
 
  // Step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

//Includes the Arduino Stepper Library
#include <Stepper.h>
 
// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;
 
// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
 
void setup() {
	// Nothing to do (Stepper Library sets pins as outputs)
}
 
void loop() {
	// Rotate CW slowly
	myStepper.setSpeed(100);
	myStepper.step(stepsPerRevolution);
	delay(1000);
 
	// Rotate CCW quickly
	myStepper.setSpeed(700);
	myStepper.step(-stepsPerRevolution);
	delay(1000);
}