Apr 18, 2021, 03:06 pm

News:

New, New TardisBuilders!


"Working" meters for Hartnell/Troughton consoles

Started by Other Dave, Apr 10, 2019, 08:54 pm

Previous topic - Next topic

Other Dave

When I made my Hartnell and Baker consoles, I put a lot of effort to add blinking lights, movement, and sound.   One thing that I'm quite proud of is making all the big meters (and radiation meter) on the Hartnell console actually DO something.  On the Baker console there was only one tiny little meter - but I made that move too!

Here's a shot of one of the Hartnell meters.

meter1.jpg


Here it is without the plastic circular lens.  As mentioned in another post, I used a clock hand (from Hobby Lobby) for the needle.  It is attached to a small servo motor behind the meter face, (which is made out of foamcore - with a printout of Tony Farrell's meter face glued on)

meter2.jpg


Here it is with the needle(hand) removed and laying upside down.  The servo comes with different attachments.  I simply glued the clock hand to it.  More on that later.


meter3.jpg

So what we will do is use an Arduino Uno, a little servo motor, and some programming code to make it all work.  If you never used an Arduino or programmed anything, no worries!  I will show you step by step.


I'll provide a shopping list of what you'll need.  And its not very expensive.  The Arduino is about US$25, and the motor about US$5.  You can use one Arduino to run several motors/meters.  (But you will need one motor for each meter)

That's all for now!  Gotta busy weekend ahead of me.  I will get back to this on Monday.



karsthotep

This is perfect thank you for doing this tutorial
I want notes, lists and answers by the time I finish this here Juicy-a-Box! WARNING: I am Thirst-ay! And it is Fruit Punch! And it is Delicious!"

davidnagel

Nice. And there's me going to connect the meter to a power source and a flickering tea light circuit (see thread: https://www.therpf.com/forums/threads/fake-meter-dial-gauge-pin-needle-activity.256974 ) to give this effect.

Only thing is, aren't those servo motors the tiniest bit noisy? I'm not imagining a big whirr or does the sound disappear somewhat?
Kind Regards,

David

www.spiffinglyniceguy.co.uk

elkad

You have any YouTube video of the diles in action?  8)

Other Dave

David Nagel: Yes they are a bit noisy.  Especially when there are 5 of them zipping around.  They actually have a sort of "zip" sound to them when they suddenly move from one extreme to the other.  Slow moves don't have much sound.  I put foam around a couple of them to try to quiet them down a little.  But on the other hand the more sound the better!

Elkad: See my console project for a video at the very end of the last page.  It is called Other Dave's Hartnell/Troughton Console

Other Dave

So here are the things you will need:

I found these at www.jameco.com, but there are other sites such as SparkFun and mouser.com that probably have these too.  Or you may already have a favorite site.
I'm not going to use links here, because they often go bad.  So just search for the item, or if on jameco, search for the part number.


2151486.jpg
Arduino Uno R3
jameco part number: 2151486
$21.95 (US)


2234100.jpg
9vDC 1 amp power supply for the Arduino
jameco part number: 2234100 (US adapter. They have others.)
$10.95


229711.jpg
USB A male to USB B male cable (this is used to set up the programming from your computer to the Arduino)
jameco part number: 229711
$1.95


2214601-1.jpg
9g 2 kg.cm Micro Servo Motor (size is: 23mm x 12.3mm x 25.6mm)
jameco part number: 2214601
$4.95



2260738.jpg
ZipWire 40-piece 20cm male to male
jameco part number: 2260738
$4.95


Okay, so gather up these items and I will wait for you!

Next time we will connect them up and start to make it work!

- Other Dave






thewhovian228

Apr 17, 2019, 10:40 am #6 Last Edit: Apr 17, 2019, 10:40 am by thewhovian228
this is starting to sound like a blue peter episode... all we need is a dog and 'one you made earlier'   ;D

karsthotep

On it thank you for the parts list.  We need more of these. 
I want notes, lists and answers by the time I finish this here Juicy-a-Box! WARNING: I am Thirst-ay! And it is Fruit Punch! And it is Delicious!"

Volpone

I need Karshotep to say he can't get it to work and Other Dave to say "REVERSE THE POLARITY!" 
"My dear Litefoot, I've got a lantern and a pair of waders, and possibly the most fearsome piece of hand artillery in all England. What could possibly go wrong?"
-The Doctor.

karsthotep

Apr 17, 2019, 04:58 pm #9 Last Edit: Apr 17, 2019, 05:16 pm by karsthotep
Quote from: Volpone on Apr 17, 2019, 04:03 pm
"REVERSE THE POLARITY!"


I pretty much do that with everything now :)...

Oh...and all parts have been put on order,  I am very excited about getting theses gauges working. 

I want notes, lists and answers by the time I finish this here Juicy-a-Box! WARNING: I am Thirst-ay! And it is Fruit Punch! And it is Delicious!"

elkad

Quote from: Other Dave on Apr 16, 2019, 09:13 pm

Elkad: See my console project for a video at the very end of the last page.  It is called Other Dave's Hartnell/Troughton Console


If anyone else is curious, a quick link to the page with the video. http://tardisbuilders.com/index.php?topic=7028.15  8)

karsthotep

They ship fast already received all the parts.    The Servos are small as is the arduino,  I don't know why I would have thought they would be bigger
I want notes, lists and answers by the time I finish this here Juicy-a-Box! WARNING: I am Thirst-ay! And it is Fruit Punch! And it is Delicious!"

Other Dave

Got all the parts?  Okay next up:

First you need to download the Arduino software to your computer.  Or use their new web interface.  You can find them here: https://www.arduino.cc/en/Main/Software

Either way, run the Arduino program, connect the USB cable from the Arduino to your computer.  Then select which serial port to communicate with.

UNO_Port.jpg

Also make sure the correct Arduino board is selected.

UNO_BoardType.jpg

So basically 4 things:
1: Get the software
2: Connect the USB cable:
3: Select the port for the USB cable:
4: Select the board you have

You're ready to go, but to be sure it's hooked up correctly, find the Blink program.  It is in File -> Examples -> 01.Basics -> Blink

UNO_Load_Blink.jpg

Select that and it will load the code into the editor. 

This is the Run button.  When you click this it sends the code to the board and the board runs it forever - until you send it something else. (Or unplug it)

UNO_Upload.png

Strangely, there is no Stop button.  In order to stop the Arduino, pull out the USB cord.

Run it and you will see a small LED light on the Arduino board start to blink.

If it does, Hooray!  If not, make sure everything is connected as above. 


Note: The USB cable servers two purposes:  It sends the program code to the board, and it also powers the board.  Once you are happy with the program, you can disconnect the USB cable from your computer.  Now, to power it use the AC adapter.  The Arduino will run whatever program you gave it last over and over.

The programming language that runs the Arduino is called a "Sketch".  Why? I don't know.  But it is very similar to C or Java or several other programming languages. 

The Sketch code is written in plain English.  But before it gets sent to the Arduino board it takes that code and translates it into the "ones and zeros" that the board understands. This is called compiling the code.


The basic structure of an Arduino Sketch is just a couple of items. 

void setup()
{

}

and

void loop()
{

}

All the things that need to be initialized go in the setup() part and happens just once.
All the things in the loop() part get repeated over and over

For instance, in the Blink code it selects the place where the LED is on the board in the setup() part
Then in the loop(), it turns on the LED, waits for a second, turns off the LED, and waits for another second

If you haven't done any programming at all, take a look at some of the other examples to get a feel for how the code looks.  There is also a lot of support and examples to be found on the Internet.


I think we better stop here and let this soak in.  Next we'll connect up the servo and make it move!

- Other Dave  (and NO!  Do not reverse the polarity!)



karsthotep

Done and done, connected, and ran blink..and well..its blinking at me right now.  I am ready for the next phase.   

Karst
I want notes, lists and answers by the time I finish this here Juicy-a-Box! WARNING: I am Thirst-ay! And it is Fruit Punch! And it is Delicious!"

Other Dave

Okay here we go!  Take your wire and peal off the three brown, orange, red ones from the rest.  Keep them together and plug them in from your Arduino to the servo like this:

IMG_3325.JPG

Attach the brown wire to one of the GND spots.   Put the red wire in the spot marked 5V.  Put the orange wire to number 3 connection.  

Now we're connected!

Open up a new "Sketch" in the Arduino program and copy and paste the following into it:


/*
METER TUTORIAL 1

this will make the needle go back and forth, back and forth, like a pendulum...
*/


#include <Servo.h>

Servo myservo;

int leftmax = 2000;
int rightmin = 1000;
int position = 2000;
int direction = 1;  // direction will be either 0 or 1  ( going left / going right)
int speed = 10;


void setup()
{
 myservo.attach(3);  // pin #3
 myservo.writeMicroseconds(1500);   // cannot use pin 0 or pin 1
 
   // 2000 left
   // 1500 center
   // 1000 right
}




void loop()
{
   if (direction == 1) // moving to the right
   {
       position = position - speed;

       if (position < rightmin) // at the min?
       {
           position = rightmin;
           direction = 0;  // go to the left
       }
    }
   else // moving to the left
   {
       position = position + speed;
      
       if (position > leftmax)  // at the max?
       {
           position = leftmax;
           direction = 1; // go to the right
       }
   }
   myservo.writeMicroseconds(position);
   delay(20);
}


Then hit the "Upload" button on the Arduino menu.

As the comment in the code mentions, this will make the servo go back and forth like a slow pendulum.

Do yourself a favor and mark on the servo shaft a mark to let you remember about where the center position is.  


IMG_3321.JPG


So if you're happy with it so far, great!  But we can make some improvements to it.  Below is code that gives some randomness to the speed and how far it will stop before going back the other way.


Replace your previous code with this:

/*
 
METER TUTORIAL 2
 
*/

#include <Servo.h>




Servo servo1;
int pos1=1500;
int newpos1 = 1970;
int dir1=1;
int speed1=1;
unsigned long previousMillis1;



void setup()
{
 Serial.begin(9600);
 randomSeed(analogRead(0));

 // CANT USE PIN 0 or PIN 1!!
 

 // servo1 attached to pin 3
 servo1.attach(3, 1000, 2000);
 servo1.writeMicroseconds(1500);
 previousMillis1 = 0;
 

}


int updateServo(Servo which, int p, int *d, int *s, int *n, unsigned long *m)
{
 unsigned long currentMillis = millis();
 
 if (currentMillis - *m >= 15)
 {
   *m = currentMillis;
   
   if (*d == 1)
   {
     p+= *s;
   
     if (p >= *n)
     {
       *s = random(1,10);
       *n = random(10,15) * 100; //1030;
       if (*n > p) *d = 1;
       else *d = 0;
     }
   }
   else
   {
     p-= *s;
   
     if (p < *n)
     {
       *s = random(1,10);
       *n = random(15, 20) * 100; //1970;
       if (*n > p) *d = 1;
       else *d = 0;
     }
   }

   which.writeMicroseconds(p);
 }
   
 return p;
}


void loop()
{  
 pos1 = updateServo(servo1, pos1, &dir1, &speed1, &newpos1, &previousMillis1);
 
}




And then finally here is code that will run 2 servos independent of each other.  Replace your previous code with this:

-------- FINAL CODE --------

/*
 
METER TUTORIAL
 
*/

#include <Servo.h>




Servo servo1;
int pos1=1500;
int newpos1 = 1970;
int dir1=1;
int speed1=1;
unsigned long previousMillis1;

Servo servo2;
int pos2=1500;
int newpos2 = 1970;
int dir2=1;
int speed2=1;
unsigned long previousMillis2;



void setup()
{
 Serial.begin(9600);
 randomSeed(analogRead(0));

 // CANT USE PIN 0 or PIN 1!!
 

 
 // servo1 attached to pin 3
 servo1.attach(3, 1000, 2000);
 servo1.writeMicroseconds(1500);
 previousMillis1 = 0;
 
// second one attached to pin 4
 servo2.attach(4, 1000, 2000);
 servo2.writeMicroseconds(1500);
 previousMillis2 = 0;

}


int updateServo(Servo which, int p, int *d, int *s, int *n, unsigned long *m)
{
 unsigned long currentMillis = millis();
 
 if (currentMillis - *m >= 15)
 {
   *m = currentMillis;
   
   if (*d == 1)
   {
     p+= *s;
   
     if (p >= *n)
     {
       *s = random(1,10);
       *n = random(10,15) * 100; //1030;
       if (*n > p) *d = 1;
       else *d = 0;
     }
   }
   else
   {
     p-= *s;
   
     if (p < *n)
     {
       *s = random(1,10);
       *n = random(15, 20) * 100; //1970;
       if (*n > p) *d = 1;
       else *d = 0;
     }
   }

   which.writeMicroseconds(p);
 }
   
 return p;
}


void loop()
{  
 pos1 = updateServo(servo1, pos1, &dir1, &speed1, &newpos1, &previousMillis1);
 pos2 = updateServo(servo2, pos2, &dir2, &speed2, &newpos2, &previousMillis2);
 
}


Happy Programming!

- Other Dave