Issue with 25V voltage sensors

Hi all,

Forgive a newbie question but I am having a problem. I want to measure the voltage on a Scalextric track (slot racing). Maximum voltage is 19V.

I have spliced into the controller handset lead so I have two additional leads coming off it to feed into the sensor such in the attached diagram (red to VCC, green to GND). The arduino connections are to A1 (analog input 1) and GND. It works fine, though the readings gathered are noisy.

Of course there are two tracks (cars) on a scalextric set! However, when I connect the second controller to the second voltage sensor (same schematic, but to analog input 2 and to the other GND on the Arduino) the car in the first track suddenly takes off without any pressure on the controller. There is obviously a short in my circuit, there is suddenly a path created for the return current for the first car, but a continuity test shows no obvious issue. Does anyone have any idea where I should start looking for the issue?

Many thanks,

Stephen

schemeit-project.png

I'd love to help, but I need a few things first:

  1. Post your code in </> tags (read the "how to use this forum" post)!!!!!!
  2. What exactly is this 25V sensor?
  3. What is this M device in the picture you provided?
  4. What is the purpose of the Arduino?
  5. Can you provide pics on the splicing you did on the hand controllers?
  6. What does the track voltage represent?

Power_broker,

I dont think the issue is with the code but my wiring! However

/*
DC Voltmeter Using a Voltage Divider
Based on Code Created By
T.K.Hareendran

Amended by SMDE 10 August 2016
Added in two sensors, etc.
*/

int analogInput = A1;
int analogInput2=A2;
float vout = 0.0;
float vin = 0.0;
float vmotor;
float R1 = 30000.0; //  
float R2 = 7500.0; // 
int value = 0;
int value2=0;
float vout2;
float vin2;
float vmotor2;
float R3=30100.0;
float R4=7400.0;

void setup(){
   pinMode(analogInput, INPUT);
   pinMode(analogInput2,INPUT);
   Serial.begin(9600);
   Serial.print("DC VOLTMETER");
}

void loop(){
   // read the value at analog input
   value = analogRead(analogInput);
   value2=analogRead(analogInput2);
   vout = (value * 5.0) / 1024.0; // see text
   vout2 = (value2 * 5.0)/1024.0;
   vin = vout / (R2/(R1+R2));
   vin2 = vout2 / (R4/(R3+R4));
   vmotor = 19-vin; 
   vmotor2 = 19-vin2;
   
Serial.print("INPUT V1= ");
Serial.println(vin,2);
Serial.println(vmotor,2);
Serial.println("Sensor 2= ");
Serial.println(vin2,2);
Serial.println(vmotor2,2);
delay(2000);
}

The sensor is one of these http://www.ebay.co.uk/itm/25v-Voltage-Sensor-Module-Hobby-Electronics-Arduino-Raspberry-Pi-Robot-UK-/181884273832?hash=item2a5925c4a8:g:CwMAAOSwWnFWBxCt - there is no identifying number etc.

The M is the motor in the scalextric car as the potentiometer is the variable resistor in the handcontroller!

Track voltage is 19v of which < 1V goes to the car when the handcontroller is not "squeezed". As the trigger on the controller is squeezed the variable resistance changes and the voltage across the car motor rises and the car moves until at full "squeeze" the voltage across the car motor is 18 odd volts.

As regards the splicing, it is sheathed in insulating tape which is difficult to remove, but it is just a controller wire (red for +ve, green for GND) cut, stripped, rejoined with an additional piece added in for the connection to the voltage sensor. All the connections are soldered.

I can provide a picture if it will help.

Have you you put the "sensor" across the handset potentiometer instead instead of across the motor? Also can you measure the resistance across sensor pins 1 & 3?

setheridge:
Power_broker,

I dont think the issue is with the code but my wiring! However

/*

DC Voltmeter Using a Voltage Divider
Based on Code Created By
T.K.Hareendran

Amended by SMDE 10 August 2016
Added in two sensors, etc.
*/

int analogInput = A1;
int analogInput2=A2;
float vout = 0.0;
float vin = 0.0;
float vmotor;
float R1 = 30000.0; //  
float R2 = 7500.0; //
int value = 0;
int value2=0;
float vout2;
float vin2;
float vmotor2;
float R3=30100.0;
float R4=7400.0;

void setup(){
  pinMode(analogInput, INPUT);
  pinMode(analogInput2,INPUT);
  Serial.begin(9600);
  Serial.print("DC VOLTMETER");
}

void loop(){
  // read the value at analog input
  value = analogRead(analogInput);
  value2=analogRead(analogInput2);
  vout = (value * 5.0) / 1024.0; // see text
  vout2 = (value2 * 5.0)/1024.0;
  vin = vout / (R2/(R1+R2));
  vin2 = vout2 / (R4/(R3+R4));
  vmotor = 19-vin;
  vmotor2 = 19-vin2;
 
Serial.print("INPUT V1= ");
Serial.println(vin,2);
Serial.println(vmotor,2);
Serial.println("Sensor 2= ");
Serial.println(vin2,2);
Serial.println(vmotor2,2);
delay(2000);
}




The sensor is one of these http://www.ebay.co.uk/itm/25v-Voltage-Sensor-Module-Hobby-Electronics-Arduino-Raspberry-Pi-Robot-UK-/181884273832?hash=item2a5925c4a8:g:CwMAAOSwWnFWBxCt - there is no identifying number etc.


The M is the motor in the scalextric car as the potentiometer is the variable resistor in the handcontroller!

Track voltage is 19v of which < 1V goes to the car when the handcontroller is not "squeezed". As the trigger on the controller is squeezed the variable resistance changes and the voltage across the car motor rises and the car moves until at full "squeeze" the voltage across the car motor is 18 odd volts. 

As regards the splicing, it is sheathed in insulating tape which is difficult to remove, but it is just a controller wire (red for +ve, green for GND) cut, stripped, rejoined with an additional piece added in for the connection to the voltage sensor. All the connections are soldered.

Ahhhh, I see. Your code is correct except that the voltage across the motor IS Vout (NOT 19-Vout as you have in your code). As for the electrical short you mention in your original post, bad wiring is most likely to blame (it happens to the best of us).

As a side note: stay as far away from voltage dividers as you can. If you need to measure voltages above 5V, use zener diodes to knock down the voltage. For instance: in my experimental Arduino RC airplane, I have to measure my batteries voltage (which is max 12.6V each). At first, I tried using a voltage divider, but due to ground currents and inaccurate resistor values, it didn't work. Instead, I now use 10V zener diodes in series and they work like a charm. They are MUCH simpler, much less fickle, and are guaranteed to work within the limits specified in their datasheets.