Alternative for using relay switch ?

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
My project aims at finding the x and y coordinates of the point where the jockey (connected to A4 pin) touches a resistive square plate (100k measured between opposite sides). For this , an x-axis pair of electrodes applies a 5V drop for 1ms, during which the y-axis electrode pair is broken off from the Arduino circuit by 2 relay switches(for each one of the pair), so that the current flows in a straight path between the x-axis electrode pair and does not enter the y-axis electrodes. The A4 pin reads the input voltage and calculates x-coordinate. Then in the next 1ms , the x-axis electrode pair is broken from the Arduino circuit by 2 relay switches(for each one of the pair) and the y-axis pair applies 5V drop. A4 reads and calculates the y-coordinate. But since, relay has a switching speed of 10-20ms, and a limited switching life, I cannot use relays. And I cannot decrease my sampling frequency , since, I need very accurate and real-time location of the jockey. Is there any alternative to using relays? Can I use the L293D IC for this purpose?
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
If you set the Arduino pins as inputs then they are high impedance and effectively disconnected - no need for switches.
No , the x and y-axis pair of electrodes are connected to Arduino digital output pin, not as input.The current in the resistive plate must flow in a straight path, not bending towards y-electrodes , when the 5V drops along the x-direction. This is necessary for the square resistive plate to work as an alternating x and y-axis potentiometer.
 

AlbertHall

Joined Jun 4, 2014
12,346
But if you set the the pair you want to disconnect as inputs then they will be effectively disconnected. Set Y-axis pins as inputs while you measure the X-axis. Then set the X-axis pins as inputs and the Y-axis pins as outputs and measure the Y-axis. No current will flow into or out of the pins while they are set as inputs.
 

AnalogKid

Joined Aug 1, 2013
11,044
TS - If you convert to reed relays, the operating time is much faster and the lifetime is many years. What is the current through the relay contacts?

Albert - It sounds like what is being switched is not signals into the Arduino, but power to the sensor, maybe under Arduino control.

TS - please post a schematic of your setup. You description is not clear and is missing important details.

ak
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
But if you set the the pair you want to disconnect as inputs then they will be effectively disconnected. Set Y-axis pins as inputs while you measure the X-axis. Then set the X-axis pins as inputs and the Y-axis pins as outputs and measure the Y-axis. No current will flow into or out of the pins while they are set as inputs.
Yeah, thanks for the help.
Also I was wondering how do I detect whether the jockey is even touching the resistive plate or held away from the plate and just detecting noise signals ?
 

AlbertHall

Joined Jun 4, 2014
12,346
Connect the jockey pin via a 100k resistor to another Arduino pin. For measuring the jockey voltage set this pin as an input so it won't affect the voltage reading. To check whether the jockey is connected at all set the extra pin as an output. If the jockey is not touching then the voltage readings will follow the setting of this extra pin however if it is touching then then the voltage will change but not to full supply and ground.
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
Connect the jockey pin via a 100k resistor to another Arduino pin. For measuring the jockey voltage set this pin as an input so it won't affect the voltage reading. To check whether the jockey is connected at all set the extra pin as an output. If the jockey is not touching then the voltage readings will follow the setting of this extra pin however if it is touching then then the voltage will change but not to full supply and ground.
Can I use a 1nF capacitor between the ADC (jockey) pin and GND. So that the ADC reads 0 when jockey is not touching the resistive plate
 

AlbertHall

Joined Jun 4, 2014
12,346
The capacitor will not guarantee 0V. Suppose the jockey had been touching. The capacitor will be charged to some voltage depending where it was touching. Now, if the jockey is lifted, the capacitor will store that voltage. There will be some leakage at the ADC pin so that will very gradually change the stored voltage but there is no guarantee that the voltage will fall. the leakage may also cause the voltage to rise.
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
Connect the jockey pin via a 100k resistor to another Arduino pin. For measuring the jockey voltage set this pin as an input so it won't affect the voltage reading. To check whether the jockey is connected at all set the extra pin as an output. If the jockey is not touching then the voltage readings will follow the setting of this extra pin however if it is touching then then the voltage will change but not to full supply and ground.
I connected the 100k resistor between ADC(jockey) pin and +5V and ran this code--
Code:
void setup() {
  Serial.begin(115200);
analogReference(DEFAULT);
}

void loop() {
  delay(100);
Serial.println(analogRead(4));

}
But I got these readings, when the jockey was not touching the resistive plate
Code:
1023
1023
1022
1023
1023
1023
1023
1021
1022
1023
1023
So, I replaced the 100k resistor with a 820ohm resistor (between the ADC input and +5V) and it always read a 1023, when the jockey was not touching the resistive plate and always read a less-than 1023 when the jockey was touching the resistive plate.
 
Last edited:

AlbertHall

Joined Jun 4, 2014
12,346
In setup, set the pin connected to the resistor to an output.
In the loop, set the pin to logic '1' then read the jockey voltage.
Set the pin to logic '0' and read the jockey voltage again.
Compare the readings you get from this with the jockey touching and not touching.
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
In setup, set the pin connected to the resistor to an output.
In the loop, set the pin to logic '1' then read the jockey voltage.
Set the pin to logic '0' and read the jockey voltage again.
Compare the readings you get from this with the jockey touching and not touching.
OK, wait 2 minutes. Let me try this quick.
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
In setup, set the pin connected to the resistor to an output.
In the loop, set the pin to logic '1' then read the jockey voltage.
Set the pin to logic '0' and read the jockey voltage again.
Compare the readings you get from this with the jockey touching and not touching.
So, I ran this code.
Code:
void setup() {
  Serial.begin(115200);
  analogReference(DEFAULT);
  pinMode (12, OUTPUT);
}

void loop() {
  delay(100);
  digitalWrite(12, 0);
  Serial.println(analogRead(4));
  delay(100);
  digitalWrite(12, 1);
  Serial.println(analogRead(4));

}
First I used the 100k resistor ,between the ADC pin and pin 12, and got these readings. The first half of the readings are for when the jockey is not touching the resistive plate and the latter part is for when the jockey is touching the resistive plate.
Code:
0
1023
0
1023
2
1021
1
1021
410
921
411
921
410
920
Now, I replaced the 100k resistor with an 820ohm between the ADC pin and pin 12, ran the same code. The jockey was at the same location on the resistive plate as it was earlier.The first half of the readings are for when the jockey is not touching the resistive plate and the latter part is for when the jockey is touching the resistive plate.
Code:
0
1023
0
1023
0
1023
0
1023
7
1021
7
1020
7
1020
6
1020
 

Thread Starter

Sumit Aich

Joined Dec 3, 2016
100
So, I ran this code.
Code:
void setup() {
  Serial.begin(115200);
  analogReference(DEFAULT);
  pinMode (12, OUTPUT);
}

void loop() {
  delay(100);
  digitalWrite(12, 0);
  Serial.println(analogRead(4));
  delay(100);
  digitalWrite(12, 1);
  Serial.println(analogRead(4));

}
First I used the 100k resistor ,between the ADC pin and pin 12, and got these readings. The first half of the readings are for when the jockey is not touching the resistive plate and the latter part is for when the jockey is touching the resistive plate.
Code:
0
1023
0
1023
2
1021
1
1021
410
921
411
921
410
920
Now, I replaced the 100k resistor with an 820ohm between the ADC pin and pin 12, ran the same code. The jockey was at the same location on the resistive plate as it was earlier.The first half of the readings are for when the jockey is not touching the resistive plate and the latter part is for when the jockey is touching the resistive plate.
Code:
0
1023
0
1023
0
1023
0
1023
7
1021
7
1020
7
1020
6
1020
Connect the jockey pin via a 100k resistor to another Arduino pin. For measuring the jockey voltage set this pin as an input so it won't affect the voltage reading. To check whether the jockey is connected at all set the extra pin as an output. If the jockey is not touching then the voltage readings will follow the setting of this extra pin however if it is touching then then the voltage will change but not to full supply and ground.
Yeah, I have decided to use your method, but replacing the 100k with an 820ohm resistor. If the ADC input reads 1023 or 0, when set to a '1' or '0' respectively, the jockey is not touching the resistive plate.If the ADC input reads even slight less than 1023 or slight more than 0, then the jockey is touching the resistive plate.
 

AlbertHall

Joined Jun 4, 2014
12,346
Using 100k, difference between pin 12 logic '1' and logic '0' when not touching is about 1020, when touching is about 500.
Using 820Ω, difference when not touching is 1023, when touching is about 1013.
 
Top