Go Down

Topic: Common Ground problem. (Read 276 times) previous topic - next topic

jppoeck

Jun 15, 2019, 11:56 pm Last Edit: Jun 16, 2019, 12:23 am by CrossRoads
Hi, I'm doing a project for myself and my fencing group, the project is a wireless fencing scoring machine, the "fencing scoring machine"is done, my problem is the wireless part, not quite the communication, but the analogRead.

So, my project works detecting changes in analog pins
(https://www.instructables.com/id/Arduino-Fencing-Scoring-Apparatus/) it's based in this project, in step 5 has a image that show how the analog pins are connected with resistors. Btw, my problem is, I have 2 arduinos nano, each one have 3 pins ( two with resistor to gnd and 1 to 5v), the code is basic an analogRead, but it's not detecting when i touch the other arduino, I know that's the ground issue, it's a way to solve that? code or even harware? Thanks!
Picture of the project attached.


larryd

You should show us 'your' work.

Show us a good schematic of your circuit. Show us a good image of your wiring.  Give links to components. Posting images:  https://forum.arduino.cc/index.php?topic=519037.0

Use CTRL T to format your code. Attach your 'complete' sketch between code tags, use the </> icon in the posting menu. [code]Paste your sketch here[/code]



No technical PMs.
The last thing you did is where you should start looking.

jppoeck

#2
Jun 16, 2019, 12:18 am Last Edit: Jun 16, 2019, 12:27 am by jppoeck
Thanks for answer!
The code is:

Code: [Select]
#include <SPI.h>
#include <NRFLite.h>

#define TEST_ADC_SPEED

const static uint8_t RADIO_ID = 1;             // Our radio's id.
const static uint8_t DESTINATION_RADIO_ID = 0; // Id of the radio we will transmit to.
const static uint8_t PIN_RADIO_CE = 7;
const static uint8_t PIN_RADIO_CSN = 10;

NRFLite _radio;


const uint8_t groundPinA = A1;    // Ground A pin - Analog
const uint8_t weaponPinA = A2;    // Weapon A pin - Analog
const uint8_t lamePinA   = A3;    // Lame   A pin - Analog (Epee return path)


//              ID - weapon - lame - CHANGE ID FOR EACH BOX
int enviar[3] = { 2 , 0  , 0};


#ifdef TEST_ADC_SPEED
long now;
long loopCount = 0;
bool done = false;
#endif

int i = 0;
void setup() {
  //adcOpt();
  Serial.begin(115200);
  _radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN);




}



void loop() {
  // put your main code here, to run repeatedly:
  while (1) {

    read();
#ifdef TEST_ADC_SPEED
    if (loopCount == 0) {
      now = micros();
    }
    loopCount++;
    if ((micros() - now >= 1000000) && done == false) {
      Serial.print(loopCount);
      Serial.println(" readings in 1 sec");
      done = true;
    }
#endif
    analogWrite(

    if (enviar[1] < 1000 || enviar[2] > 100) {


    _radio.send(DESTINATION_RADIO_ID, &enviar, sizeof(enviar));
      i = 0;

    } else if (i == 1) {
    _radio.send(DESTINATION_RADIO_ID, &enviar, sizeof(enviar));
      i++;
    }


  }
}

void read() {
  enviar[1] = analogRead(weaponPinA);
  enviar[2]   = analogRead(lamePinA);

}


This image is a eagle project.


Here is the pcb.
1k resistors.


the pins 1 - 2 - 3 are Guard (sword guard) - Weapon - Lamé (clothes)

in Epee the tip close the pins 2 and 3 to make a "touch" (epee works fine, it's not reading anything from other arduino)

in sabre we use 2 pins, one for clothes, and one for weapon, the weapon touch the clothes from the opponent, the weapon drops from 1023 to around 512 anaog read. the clothes raise from 0 to 510

in foil is the complex that i dont want to do it now.

the problem is, when powered with the same psu, all runs fine. But when powered with bat, it's not reading.

CrossRoads

Systems like the Hitmate for epee used the capacitance of the body cord and a person to make the Gnd.

http://www.hitmate.co.uk/epee_hitmate.php
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

#4
Jun 16, 2019, 12:25 am Last Edit: Jun 16, 2019, 12:30 am by CrossRoads
How does yours detect & allow/blockout double touches within the timeframes allowed?

Epee doesn't use a lame, button on the end of the weapon is normally open, may be closed against Gnd for no touch, may be closed against not-Gnd for a touch. May bounce off a bellguard for a not-touch and then close agianst body for a touch.  Must be closed for 2mS for a touch, opponent may score within 40mA of the start your touch for a double touch.

Foil & sabre have similar timing requirements. Foil button Opens on a touch, sabre is touch against lame only.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jppoeck

Hi thanks for answer, the main code is based in the aireal from instructables, i changed the input and output a lot, but the fencing logic it's the same.

CrossRoads

Code looks too simple to me to account for timing needs.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jppoeck

How does yours detect & allow/blockout double touches within the timeframes allowed?

Epee doesn't use a lame, button on the end of the weapon is normally open, may be closed against Gnd for no touch, may be closed against not-Gnd for a touch. May bounce off a bellguard for a not-touch and then close agianst body for a touch.  Must be closed for 2mS for a touch, opponent may score within 40mA of the start your touch for a double touch.

Foil & sabre have similar timing requirements. Foil button Opens on a touch, sabre is touch against lame only.
.
for epee i disabled the guard touch, so it's think as valid, because i have the same problem with sabre, it's not reading anything from the another board.

in wired mode, it's works normal, with the guard touch not valid.


I have a main board and another 2, the data transfer is with NRF24L01, it's works fine, I dont want FIE times for wireless righ know.

jppoeck

Code looks too simple to me to account for timing needs.
This code is for the wireless boards, the main code is another one.

the issue i think is the common ground. I don't know how to solve it.

MarkT

#9
Jun 16, 2019, 07:58 pm Last Edit: Jun 16, 2019, 07:59 pm by MarkT
You don't have a circuit, so no current will flow.

The players need to be wired up to the scoring system, or else you'll need some sort of capacitance/RF
sensing method using adapted weapons.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up