Data Conversion

Enter Your Electronics & Design Project for a chance to win a $200 shopping cart!

Submit an EntrySubmit an Entry  Back to homepage
Project14 Home
Monthly Themes
Monthly Theme Poll

 

For the Data Conversion Project14 challenge I decided that I wanted to use a multi-turn potentiometer so I have started to make a micro servo motor tester. I have wanted a  servo motor tester for some time but didn't want to spend any money, plus I could always knock together a Nano project that did the job. So combining a multi-turn pot with a Nano to make a proper piece of test equipment seemed a good idea. I also wanted to try and make a good looking 3D printed casing to go with this - which is not going quite so well.

 

Multi-Turn Potentiometers

 

I original wanted to use digital potentiometers but after looking around I realised that what I thought a digital potentiometer was not what most digital potentiometers were. I wanted a digital potentiometer that provided many steps per revolution, something like 100 but nothing like that seems to exist at a sensible price. Instead I have used 10 turn wire wound potentiometers instead which should provide me with the resolution I wanted (100 steps per revolution) and multi-turn capability (well - 10 turns anyway). I found some reasonably low cost potentiometers so purchased a pack of five (ZHITING 5pcs WXD3-13-2W 10K Ohm Multi-Turn Wirewound: AmazonSmile: Electronics). I was expecting these to be relatively small but they are quite big which makes the 3D printed casing a bit more of a challenge. However, that is for the future.

 

Circuit Diagram

 

The complete circuit is fairly simple, consisting of two potentiometers (I wanted to control the frequency and pulse width eventually) so two analogue inputs, a Nano and three LEDs, just for some user interfacing, (three digital outputs), plus the digital output for the micro servo motor. The prototype circuit is illustrated below. For the future I will also add some buttons to select various functionality, plus some sort of battery power supply to make it completely independent.

 

Micro Servo Motor Tester Cicruit Diagram

 

I wired this all together using a small protoboard and 3D printed a rectangular front plate just to keep it all tidy. The potentiometers didn't come with any knobs so I 3D printed some. They do not look brilliant but they do the job. For the final version I might (maybe) create a more attractive 3D printed knob.

 

Programme

 

The programme is correspondingly simple, at this point. All it does is flash the blue LED for 500 ms at the beginning of the programme, just to show to the user that everything is working. Then it enters an infinite loop where it reads the ADC (from the right hand 10 turn potentiometer) and uses that to create a microsecond delay between 200 and 2000 us, followed by the required 18 ms space delayed needed for the micro servo motor. The Nano uses 10 bit ADCs so for a 10 turn potand to use the whole range each turn is dividied into 100 increments. The default reference voltage is 5V so with 1000 increments this provides a quantisation step of 0.005 V or 5 mV. The conversion from the ADC value to microseconds was achieved empirically. For a more robust future version some sort of proper calibration will be needed. I'm not sure at this stage how stable this conversion process is and to be honest, I'm sure how I might find out, but it is good enough for my testing purposes.

 

There is a serial text output sequence but I am only using it for testing and it should not affect the timings as most of the text is sent during the 18 ms space delay of each pulse. The Arduino programme is listed below. It works so is satisfactory at present.

 

/*  Dubbie Dubbie

*  Servo Tester and Pulse Generator

*  5th Feb'21

*  Just for Fun

*/

 

#define ledblue  2

#define ledwhite 4

#define ledred   6

#define adcwidth A0

#define adcfreq  A1

#define testservo 8

 

void setup(void)

{

  pinMode(ledblue, OUTPUT);

  pinMode(ledwhite, OUTPUT);

  pinMode(ledred, OUTPUT);

  pinMode(testservo, OUTPUT);

  digitalWrite(ledblue, LOW);  

  digitalWrite(ledwhite, LOW);  

  digitalWrite(ledred, LOW);

  digitalWrite(testservo, LOW); 

  delay(100);        

  Serial.begin(19200);

} /* setup */

 

void loop(void)

{

 

int width;

int freq;

 

width = 0;

freq = 0;

 

Serial.println("Servo Motor Tester " );

Serial.println("Dubbie Dubbie : Just for Fun " );

Serial.println(" 5th Feb'21 ");

Serial.println();

delay(500);

 

  digitalWrite(ledblue, HIGH);   // Shows it's working

  delay(500);

  digitalWrite(ledblue, LOW);  

 

while(1)

  {

    digitalWrite(testservo, HIGH);

    delayMicroseconds(200);       // Start of the 1 ms pulse

    delayMicroseconds(width);     // Makes up the rest of the pulse

    digitalWrite(testservo, LOW);

    Serial.println(width);

    width = analogRead(adcwidth); //Assumes 100 us conversion time

    width = width * 2;

 

    delay(18);                    // The rest of the pulse

  } /* while */ 

} /* loop */

 

The Working System

 

Power is currently supplied from a USB connection used for programming and debugging which should be enough for a single micro servo motor. A video showing the operation of the system is shown below.

 

 

(Note : In the video I do say it provides 10 steps per revolution, it is actually 100 steps per revolution.)

 

It seems to work quite well and I can now test out micro servo motors, including the continuous rotation ones and I have already tested two servo motors. Even in this prototyping stage the indicators are that this will be a good project.

 

Future Options

 

When designing this system I thought it would be a useful additional function to be able to act as a pulse generator (variable frequency as well as variable pulse width), which is why there are two 10 turn potentiometers. This will be a future step as it gets a little bit more complicated on determining the required pulse widths when frequency is also being varied. I will need to add some user input, probably at least one push button, to be able to select between the two different modes: servo tester or pulse generator. When in pulse generator mode it would be good to have some feedback to the user as to the actual frequency and pulse width being output and some sort of graphic display seems a good idea, so I might do the display part first.

 

Dubbie