Potentiometer problems in project

I have built the circuit i have pictured below but i seem to be having trouble with the resistance readings from some of the pots . The all the pots are 10k. The top right section with to pots is a seperate module and that’s where my problem seems to be. they are in parallel so a get a base reading of 5k across the red and wiper and ramps smoothly down to 0 only if the 5V (red wire) is disconnected from the rest of the circuit. If i have the red wire is the ramps from zero up to about 3 and then starts ramping down again and end up at about 2.5 at what would be 5k. I have tried disconnecting each device that is connected to the 5v line to help find the problem but nothing stands out, the arduino moves it a few ohms but I’m kinda stuck, any insight would be greatly appreciated. I have a modified version of my main program i have been using for the Pot test but the problems are still there even if the arduino is powered down.

#include <Adafruit_DS3502.h>                  
Adafruit_DS3502 ds3502 = Adafruit_DS3502();   

byte directionPin = 2;      //New Stepper control
byte stepPin = 3;
byte stepstop  = 4;


unsigned long curMillis;
unsigned long prevStepMillis = 0;
unsigned long millisBetweenStepsup = 1; // milliseconds
unsigned long millisBetweenStepsdown = 2; // milliseconds
int stepdelay              =10; //testing
int clutchadvance          =10; //testing
int brakespeed             =5; //testing



#include "MultiMap.h"           //Multimap
int mappedValue;                //
int in[] = {0 , 31, 63, 95, 127};   //
int out[] = {0, 95, 115, 125, 127};  //



#define magnetDetected       HIGH
#define noMagnet             LOW

#define weAreTiming          true
#define weAreNotTiming       false

#define notfull              false
#define full                 true

#define resetting           true
#define tensioning          false

#define brakeon             true
#define brakeoff            false

#define clutchon            true
#define clutchoff           false

const byte BRAKE_IN_PIN    = A0;
const byte CLUTCH_IN_PIN    =A3; 
const byte PRESSURE        = A1;  // Pot on Analog Pin 1
const byte POTH            = A2;  // Pot on Analog Pin 2

bool timerRunningFlag      = weAreNotTiming;
bool fullthrottle          = notfull;
bool resetflag             = tensioning;
bool brakeflag             = brakeoff;
bool clutchflag            = clutchoff;

const byte sensor          = 6;
const byte heartbeatLED    = 13;
int reset                  = 12;

byte lastWheelState        = noMagnet;

int digitalPot                ;
int brake_value           = 0;
int clutch_value          = 0;
int clutch_temp           = 0;
int lowspeed               = 0;   // Low speed set
int highspeed              = 0;   // High Speed set
int lowrpm                 = 0;   // Low RPM kick in
int highrpm                = 0;   // High RPM kick in
int highValue              = 0;
int stepsLeft              = 0;
int force                  = 0;
int stepmath               = 0;
int tension                = 0;
int stepstaken             = 0;
int fullsqueeze            = 0;


int totaltension           =3000;

int lowValue         = 800; //low speed setting

const int highLow          = 600; //reading 0
const int highHigh         = 200; //reading 1023

//timing stuff
unsigned long startTime;
unsigned long endTime;
unsigned long duration;
unsigned long timerMillis;
unsigned long heartbeatMillis;
unsigned long wheelMillis;

//*********************************************************************
void setup()
{
  analogReference(A0);
  ds3502.setWiper(0);
  pinMode (sensor, INPUT_PULLUP);

  pinMode (heartbeatLED, OUTPUT);

  Serial.begin(115200);

  while (!Serial)
  {
    delay(1);
  }

  Serial.println("Adafruit DS3502 Test");

  if (!ds3502.begin())                             // <-----<<<<<
  { // <-----<<<<<
    Serial.println("Couldn't find DS3502 chip");   // <-----<<<<<
    while (1);                                     // <-----<<<<<
  }                                                // <-----<<<<<

  Serial.println("Found DS3502 chip");
 
  pinMode(reset, INPUT_PULLUP);

  pinMode(directionPin, OUTPUT);      //New stepper
  pinMode(stepPin, OUTPUT);
  pinMode(stepstop, OUTPUT);
fullthrottle = notfull;
} 


//*********************************************************************
void loop()

{
  digitalRead(reset);
  while (digitalRead(reset) == LOW)
    {
      stepstaken = 0;
      tension = 0;
      digitalWrite(stepstop, HIGH);
      digitalWrite(heartbeatLED, LOW);
      if (resetflag == tensioning) { 
        Serial.println("reset");
        resetflag = resetting;
        }
      digitalRead(reset);
      
    }

  brake_value = analogRead(BRAKE_IN_PIN);
    clutch_value = analogRead(CLUTCH_IN_PIN);
    
  highspeed = analogRead(POTH); //0 to 1023
  highValue = map(highspeed, 0, 1000, highLow, highHigh);
  lowValue = (highValue + 400);
  force = analogRead(PRESSURE);
  
 
   
   
  Serial.print("B: ");
  Serial.print(brake_value);
  Serial.print("C: ");
  Serial.print(clutch_value);
  Serial.print("  ");
  Serial.print(lowValue);
  Serial.print("  ");
  Serial.print("Timer spread ");
  Serial.print(highValue);
  Serial.print ("  Time in millis = ");
  Serial.print (duration);
  Serial.print("  ");
  Serial.print("   Digital pot set to: ");
  Serial.print(digitalPot);
  Serial.print("\t");
  Serial.print("Savage level: ");
  Serial.print(force);
  Serial.print("  ");
  Serial.print(stepmath);
  Serial.print(" -Stepmath   Stepstaken- ");
  Serial.print(stepstaken);
  Serial.print("   Needed tension: ");
  Serial.println(tension);
  Serial.println("");
  
delay (1000) ;

} 

Perhaps you can tell us when the problem FIRST appeared. You did test as you went a long, didn't you?

Are you saying that you have measured the resistance using a multimeter with the module disconnected? Please do that and check if the resistance across the red/black is indeed 10k and the the resistance across the wiper and one of the pot pins changes with rotating the pot.

The problem first appeared when i replaced 2 small pots off the breadboard with the pots is a seperate module i built (containing the pushbuttons, led and pots) . That module seems to function correctly when seperate from the rest of the circuit but when connected the reading go astray.

Am i correct in stating that 2 10k pots in parallel will show a 5k across the shared 5v and 0v lines? they are just buried deep and the module and soldered in so its hard to break the bond to confirm. they are labeled as 10k and im pretty sure i tested them before they went but it was a while back so cant be too sure.

When the red wire is broken the pot wiper functions "correctly"? from 5k to 0

The total resistance across the two potentiometers will indeed be 5k. So, the current draw from the Arduino will be double that of a single 10k pot (each is drawing its own current based on V+ and ground). They will draw ~ 0.5 mA each.

But the wiper arm is still measuring the resistance between one end of the pot and the contact point.
Perhaps it is a wiring problem.

This is why we hate Fritzing:

Jeeze! You do NOT convert a 9V battery to 5V with a POT! As the load current varies so will the supply voltage.
Get a REAL +5 power supply and then get back to us.

I thought he made it pretty clear that it was actually a 5 V supply correctly connected to the "5V" pin. :face_with_raised_eyebrow:

The invisible wires in the Futzing diagram are not at all helpful. :roll_eyes:

Yeah, but since we all know what the pins on a UNO actually are, it's not too bad. :grin:

Forget measuring kOhms with your multimeter. You can measure resistances only on passive disconnected components. If everything is connected and you have power on, resistance readings mean nothing. Your multimeter adds its own minimal voltage to be able to measure minimal currents to be able to calculate the resistance. This all mean nothing if the points you want to measure have a voltage coming from the power source of the circuit. Or from a capacitor left with charge.

At the minimum, at least the sweaper must be disconnected from the Arduino port, for you to be able to measure the resistance between the red line and the sweaper. That should give you a ramp from 0 to 10k.

If everything is connected and power is on, switch your multimeter to voltage measuring and measure between the red line and the sweeper. This should give you a ramp from 0 to 5 V. Reading voltages won't mess with the circuit almost all. It just draws a minimal current and calculates a voltage from that.

Hello sugakane
TL;DR
Take some time and describe the desired function of the sketch in simple words and this very simple and a short form.
Have a nice day and enjoy coding in C++ and feel free to reply for any help.
Дайте миру шанс!

Hi, @sugakane
Can you please post some images of your project?

Can you please post a hand drawn schematic of your project?
Please include ALL power supplies, component names and pin labels.

Thanks... Tom... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.