00 scale turntable project

The input impedance of the Arduino inputs with INPUT_PULLUP enabled may be as high as 50kΩ, Those inputs will therefore be highly susceptible to interference. In my view the first thing to do now is to add pull-up resistors of value roughly 1kΩ to all button inputs. As mentioned, adding a pull-up resistor to the input from the hall-effect sensor may also be beneficial.

Have you added any capacitor decoupling to your 5V supply near your Arduino?

Archibald, I assume you mean changing the input_pullup to input and adding an external pullup of 1k to each pin instead. I've bought some Cat5e cable today and have sourced a RJ45 socket from a redundant router. I'll probably give this a go first but I think I understand your point about too high a pullup resistor, making the high logic state vulnerable. Do you think it's possible that when I had this working properly , I had the 5v instead of GRD connected to the button return. The code simply requires the button state to change. Is it possible that a weak High using internal pull up could leak (since leakage is clearly happening) leaving the pin low until the button gives it a shot of 5v ? I imagine that this could burn out the pin if sustained or is this line of thought nonsensical? The only capacitor employed is as recommended, between the poles of the motor supply voltage. The Arduino is powered from a USB lead, currently plugged into a local wall socket with USB ports. I'm definitely not using the Amazon Firestick adaptor again, because I think its output is too high. Plenty to keep me busy over the weekend.

No reason at all to change it. Just try adding the pullups.

That would certainly qualify as keeping all the wires together.

1 Like

Yes I was going into town and since there's no electronic shops here I, I found a 5 meter length of CAT5e in a shop that sells all sorts. Beats waiting over a week for stuff in the post.

When you have added pull-up resistors of about 1kΩ, they will be in parallel with the INPUT_PULLUP resistance of about 40kΩ, giving about 0.97kΩ. So, as Paul has written, there is no need to change pinMode to INPUT.

The choice of value of resistor is very far from critical. With 1kΩ you will get 5mA drawn from the power supply when a single button is pressed. You could choose a lower value of resistor to give even less sensitivity to interference but ultimately you don't want to draw too much supply current if someone tries pressing all the buttons at once!

It would not work at all if you had 5V on the button return. The INPUT_PULLUP resistances will pull the inputs up close to 5V and the buttons need to connect ground to each input when depressed.

The internal pull-up resistance cannot leak anywhere. Leakage is not happening anywhere else: that would require very damp conditions for example.

From what we can tell, your button wires are picking up interference from the track signal due to the INPUT_PULLUP resistances being rather high. Are your button wires running fairly close to the track anywhere?

That would not burn out the pin. You would damage the Arduino if you apply a voltage to an input pin a little outside the range 0V to 5V.

Your USB lead is probably OK for powering the Arduino. I was concerned you may have a long pair of wires from your power supply unit (plugged into a wall socket): and that those wires may be near some track.

I understand you have, or at least will have four buttons. The Cat5e cable has four pairs of wire so use a pair for each button. This means 4 of the 8 wires will be connected to ground. I would have recommended use of screened cable but Cat5e may well be sufficient to resolve your issue.

I'll bet that was expensive! :astonished:

Nope, they have a hot line to China, only 3.25 quid. But blow me it's working! The Cat5e has done the trick!

Thanks guys for all your help.

That's good news. Is it video time?

Ha ha no, not yet wildbill. Probably up and running tomorrow with Cat5e cable and buttons in place. Then I need an assistant to film whilst I operate it. But I promise I'll get that done in the not too distant future, together with the wiring diagram.

1 Like

New problem. Can anyone suggest any errors in this code which could cause button presses 3 and 4 to have zero effect. I've tried running a simple button test sketch and all buttons report on serial monitor. I've tried switching button wires to further test continuity, button wires 3 and 4 to 1 and 2 positions on arduino (pins D2 and D3). I can only conclude that it's a sketch problem, not a wiring problem. Buttons 1 and 2 working as required when back in correct position but buttons 3 and 4 not working on their respective pins D4 and D5. Pins showing even though these pins are giving a reading of 4.6 V with respect to ground.`[code]

#define HALL_SENSORPin 9
#define DIRPin 10
#define STEPPin 11

#define key1Pin 2 //connect wire 1 to pin 2
#define key2Pin 3 //connect wire 2 to pin 3
#define key3Pin 4 //connect wire 3 to pin 4
#define key4Pin 5 //connect wire 4 to pin 5

// Direction Variable
boolean setdir = LOW;

void setup() {

pinMode(key1Pin, INPUT_PULLUP);// set pin as input
pinMode(key2Pin, INPUT_PULLUP);// set pin as input
pinMode(key3Pin, INPUT_PULLUP);// set pin as input
pinMode(key4Pin, INPUT_PULLUP);// set pin as input

// Setup the stepper controller pins as Outputs
pinMode(DIRPin, OUTPUT);
pinMode(STEPPin, OUTPUT);

// Setup the Hall Effect switch as an Input
pinMode(HALL_SENSORPin, INPUT );
}

void loop() {

int key1 = digitalRead(key1Pin);// read if key1 is pressed
int key2 = digitalRead(key2Pin);// read if key2 is pressed
int key3 = digitalRead(key3Pin);// read if key3 is pressed
int key4 = digitalRead(key4Pin);// read if key4 is pressed

if (!key1) { // Set motor speed pulse duration
int pd = 12000;

// Move motor until home position reached

while  (digitalRead(HALL_SENSORPin) == 1)
{

  digitalWrite(DIRPin, setdir);
  digitalWrite(STEPPin, HIGH);
  delayMicroseconds(pd);
  digitalWrite(STEPPin, LOW);
  delayMicroseconds(pd);

}

}

if (!key2) { // Makes 400 pulses for making half cycle rotation
for (int x = 0; x < 400; x++) {

  digitalWrite(DIRPin, setdir);

  digitalWrite(STEPPin, HIGH);
  delayMicroseconds(12000);
  digitalWrite(STEPPin, LOW);

  delayMicroseconds(12000);

if (!key3) { // Makes 732 pulses for making 30 degree reverse rotation
for (int x = 0; x < 732; x++) {

      digitalWrite(DIRPin, setdir);

                   digitalWrite(STEPPin, HIGH);
                   delayMicroseconds(12000);
                   digitalWrite(STEPPin, LOW);
                   delayMicroseconds(12000);
                   
    }

if (!key4) { // Makes 732 pulses for making 30 degree reverse rotation
for (int x = 0; x < 732; x++) {

      digitalWrite(DIRPin, setdir);

                   digitalWrite(STEPPin, HIGH);
                   delayMicroseconds(12000);
                   digitalWrite(STEPPin, LOW);
                   delayMicroseconds(12000);
    }

  }

}


} 

}

[/code]Preformatted text`

Code tags would be nice.

I've solved it wildbill. It was those evil curly brackets. All good now. Piled them up at the end again which is incorrect!

Just a note for when you are chasing driver problems with whatever Arduino, it is usually best to upload the blink sketch but modify the flash rate each time so you can see if the thing is working or not.
Plenty of youtube videos on how to do it out there.
As far as FTDI not supplying drivers for the clone chips, that was jumped on and rectified years ago.

Hi there bluejets, the driver problem was resolved months go. It turned out to be an Arduino which looked like a CH340 but actually used FTDI drivers. The reason why it wasn't working at first was that the old bootloader setting was required. Today I've been adding 2 more functions but didn't get the { } brackets right. All good now!