Arduino Forum

Using Arduino => Sensors => Topic started by: andhavarapulokesh on Aug 16, 2017, 01:44 pm

Title: Distance measurement
Post by: andhavarapulokesh on Aug 16, 2017, 01:44 pm
i am trying to find the distance using arduino and TDC GP22 modules . i want to find the difference between  transmitted and  recieved signals  can any one tell how to do that
Title: Re: Distance measurement
Post by: TomGeorge on Aug 16, 2017, 02:29 pm
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html (http://forum.arduino.cc/index.php/topic,148850.0.html) 

What is a TDC GP22?
Can you post a link to specs/data of this unit please?

What model Arduino are you using?

Can you tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom.. :)
Title: Re: Distance measurement
Post by: johnwasser on Aug 17, 2017, 01:32 am
Datasheet: https://www.digikey.com/product-detail/en/ams/TDC-GP22-T-R/TDC-GP22CT-ND/5970104 (https://www.digikey.com/product-detail/en/ams/TDC-GP22-T-R/TDC-GP22CT-ND/5970104)
Title: laser range finder sssihl
Post by: andhavarapulokesh on Aug 18, 2017, 12:59 pm
Hi every one

I am new to this arduino . As a part of my M.Tech i am trying to build a Laser range finder using Arduino uno and TDC converter GP22 laser and photo detector

can any one tell or give me any links  how to set the connections between arduino and tdc ,laser, pd.

please help me how to trigger laser diode using firepulse

 
Title: regarding LRF
Post by: andhavarapulokesh on Sep 08, 2017, 09:01 am
i am trying to build a laser range finder using GP22 TDC. Can any one help me in configuring the TDC  using arduino uno  and acquiring the data from the TDC to  arduino.


Title: regarding Laser range finder
Post by: andhavarapulokesh on Sep 19, 2017, 11:59 am
Hi everyone i am trying to use the arduino uno and TDC GP22  for the laser range finder application . I configured the register settings to single measurement mode1 with auto calibration enable of TDC gp22.

1.Can any one help me how to send a signal from aurdino uno to the TDC a start signal and also a PWM signal to laser driver for laser pulses to on

2.How to read the results of the read registers and find the time of flight


Please help me


Title: Re: Distance measurement
Post by: Coding Badly on Sep 19, 2017, 07:17 pm

Threads merged.

Title: Re: Distance measurement
Post by: johnwasser on Sep 19, 2017, 09:31 pm
Everything you need to know can be found in this Application Note:
http://www.acam.de/fileadmin/Download/pdf/TDC/English/AN034_en.pdf (http://www.acam.de/fileadmin/Download/pdf/TDC/English/AN034_en.pdf)

They even include source code in C.  It's written for an STM32 microprocessor but much of it should be applicable to the Arduino:
http://www.acam.de/fileadmin/Download/_software/TDC/GP22_main_AN034.c (http://www.acam.de/fileadmin/Download/_software/TDC/GP22_main_AN034.c)
Title: how to write the register configuration of TDC GP22 using Arduino uno
Post by: andhavarapulokesh on Sep 26, 2017, 12:51 pm
I am new to the programming can any one help me how to write the register configurations and read the register configuration of TDC using GP22

I actually setup the hardware with SPI interface but can any one give me sample code for testing communication  in writing and reading

Title: Re: how to write the register configuration of TDC GP22 using Arduino uno
Post by: MarkT on Sep 26, 2017, 12:59 pm
TDC?
GP22?

No idea what they are, but you clearly do - tell us please (links to datasheets, product page, etc etc).
Title: Re: how to write the register configuration of TDC GP22 using Arduino uno
Post by: johnwasser on Sep 26, 2017, 03:49 pm
http://ams.com/eng/Products/Precision-Time-Measurement/Time-to-Digital-Converters/TDC-GP22 (http://ams.com/eng/Products/Precision-Time-Measurement/Time-to-Digital-Converters/TDC-GP22)

General Purpose "Time to Digital Converter" model GP22.

For example Arduino code, try using Google.  Put in: TDC GP22 Arduino
Title: Re: Distance measurement
Post by: andhavarapulokesh on Sep 27, 2017, 08:09 am
The code what is there for STM32 micro controller how can we use it to arduino uno
Title: how to write and read a register
Post by: andhavarapulokesh on Sep 27, 2017, 09:14 am
i am trying to write a configuration and read the register value using a arduino uno and TDC GP22  for intial testing communication between arduino uno and GP22

Please help me
Title: Re: how to write and read a register
Post by: Whandall on Sep 27, 2017, 09:27 am
https://github.com/leokoppel/GP22 (https://github.com/leokoppel/GP22)
Title: Re: Distance measurement
Post by: Coding Badly on Sep 27, 2017, 09:29 am

@andhavarapulokesh,

STOP CROSS-POSTING

Title: Re: Distance measurement
Post by: TomGeorge on Sep 27, 2017, 01:10 pm
Hi,
I am new to this arduino . As a part of my M.Tech i am trying to build a Laser range finder using Arduino uno and TDC converter GP22 laser and photo detector

can any one tell or give me any links  how to set the connections between arduino and tdc ,laser, pd.

please help me how to trigger laser diode using firepulse

 
What resources do you have at your college/university.
You must have departments on campus, or at least had subjects concerned with programming, typically C++.
Here in this forum you have been given references to code.
Read Post #7, #10 and #13
Please read them?
Can you tell us your electronics, programming, Arduino, hardware experience?
Thanks.. Tom... :)
Title: Re: Distance measurement
Post by: johnwasser on Sep 27, 2017, 06:35 pm
Have you tried this library?
https://github.com/leokoppel/GP22 (https://github.com/leokoppel/GP22)

I found that with Google in under a minute.
Title: Re: Distance measurement
Post by: andhavarapulokesh on Sep 28, 2017, 12:40 pm
https://translate.google.com/translate?hl=en&sl=auto&tl=en&u=http%3A%2F%2Frefleader.ru%2Fjgebewrnarnajge.html

This link is arduino uno  and TDC GP 22 for  lidar imaging application .  I want to use the code for finding the distance up to 5mts what should i modify in  order to write  and read the register configuration and calibration measurements
Title: Re: Distance measurement
Post by: johnwasser on Sep 28, 2017, 06:54 pm
Good luck using the Russian example.  Even after reducing the 'data' array to 4x500 instead of 4x5000 the RAM usage is still 1380%  (uses almost 14 times the RAM that an Arduino UNO has).

The good news is that the writing of registers is pretty straightforward.  Look at the writeReg0(), writeReg1(),...writeReg6() functions.

I fixed some of the coding errors that might have been caused by translation software:
Code: [Select]
#include <SPI.h>
const int slaveSelectPin = 8;
const int resetPin = 4;
const int START = 7;
byte res [2];
byte test;
float r [2];
float ToF;
float Result;
int n = 0;
int s [4];
int i = 0;
int j = 0;
int m = 0;
int k = 0;
int l = 0;
// int n = 0;  //??? Double definition might be a a translation artifact?
float sred = 0;
unsigned int shagtime = 50;
int pos = 0;
int flag = 0;
unsigned long time1 = 0;
unsigned long time1_p = 0;
unsigned long time2 = 0;
unsigned long time2_p = 0;
boolean pulse = LOW;
int iteration = 0;
float data [4][500]; //??? was [5000];  // 40,000 bytes is WAY too large for an Arduino UNO
float scan [5000];

void RESET () {
  digitalWrite (resetPin, LOW);
  delay (0.001);
  digitalWrite (resetPin, HIGH);
}
void INIT () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x70);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg0 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x80);
  SPI.transfer (0x00);
  SPI.transfer (0x24);
  SPI.transfer (0x10);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg1 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x81);
  SPI.transfer (0x19);
  SPI.transfer (0x49);
  SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg2 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x82);
  SPI.transfer (0xE0);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg3 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x83);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg4 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x84);
  SPI.transfer (0x20);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg5 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x85);
  SPI.transfer (0x10);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
}
void writeReg6 () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0x86);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
}
void ReadDATA () {
  digitalWrite (slaveSelectPin, LOW);
  SPI.transfer (0xB0);
  res [1] = SPI.transfer (0x00);
  res [0] = SPI.transfer (0x00);
  digitalWrite (slaveSelectPin, HIGH);
  r [0] = float (res [0]);
  r [1] = float (res [1]);
  ToF = (r [0] + 256 * r [1]) * 0.09;
  Result = ToF * 0.299792458 / 2;
  data [iteration] [k] = Result;
  k ++;
}
void setup () {
  pinMode (slaveSelectPin, OUTPUT);
  pinMode (resetPin, OUTPUT);
  pinMode (START, OUTPUT);
  digitalWrite (slaveSelectPin, HIGH);
  digitalWrite (START, LOW);
  RESET ();
  SPI.begin ();
  SPI.setDataMode (SPI_MODE1);
  SPI.setClockDivider (SPI_CLOCK_DIV8);
  SPI.setBitOrder (MSBFIRST);
  writeReg0 ();
  writeReg1 ();
  writeReg2 ();
  writeReg3 ();
  writeReg4 ();
  writeReg5 ();
  writeReg6 ();
  attachInterrupt (0, ReadDATA, LOW);
  Serial.begin (9600);
  s [0] = 10;
  s [1] = 9;
  s [2] = 6;
  s [3] = 5;
  pinMode (s [0], OUTPUT);
  pinMode (s [1], OUTPUT);
  pinMode (s [2], OUTPUT);
  pinMode (s [3], OUTPUT);
  pinMode (3, INPUT);
  digitalWrite (s [0], LOW);
  digitalWrite (s [1], LOW);
  digitalWrite (s [2], LOW);
  digitalWrite (s [3], LOW);
  delay (1000);
  attachInterrupt (1, STARTSHAG, FALLING);
}
void STARTSHAG () {
  s [0] = 5;
  s [1] = 6;
  s [2] = 9;
  s [3] = 10;
  flag = 1;
  pos = 0;
}
void ROTATE1 () {
  time1 = millis ();
  if (time1 - time1_p >= shagtime) {
    time1_p = time1;
    digitalWrite (s [i], HIGH);
    digitalWrite (s [j], HIGH);
    for (m = 0;
         m < 4;
         m ++) {
      if (m != i && m != j) {
        digitalWrite (s [m], LOW);
      }
    }
    if (j == i) {
      j = (i + 1) % 4;
    }
    else {
      i = (i + 1) % 4;
    }
    if (flag == 1) {
      pos ++;
    }
  }
}

void LaserPulse () {
  time2 = micros ();
  if (time2 - time2_p >= 125) {
    time2_p = time2;
    pulse = ~pulse;
    digitalWrite(START, pulse);
  }
}

void loop() {
  if (iteration < 4) {
    ROTATE1();
    if (pos == 156) {
      s[0] = 10;
      s[1] = 9;
      s[2] = 6;
      s[3] = 5;
      flag = 0;
      iteration++;
    }
    if (pos >= 28 && pos <= 128) {
      LaserPulse();
    }
  }
  else {
    for (l = 0; l < 5000; l++) {
      for (n = 0; n < 4; n++) {
        sred += (data[n][l]) / 4;
      }
      scan[l] = sred;
      sred = 0;
    }
    for (l = 0; l < 5000; l++) {
      Serial.println(scan[l]);
    }
  }
}
Title: Re: Distance measurement
Post by: Tedmong on Mar 19, 2019, 08:40 pm
Hello johnwasser,

 I tried to compile your given code using Arduino.ino, but memory issue popped up. I also carefully saw your found Github code, but laser and photodiode pin are not defined. Have you solved this problem? Thanks!

Ted
Title: Re: Distance measurement
Post by: johnwasser on Mar 20, 2019, 10:11 pm
Hello johnwasser,

 I tried to compile your given code using Arduino.ino, but memory issue popped up. I also carefully saw your found Github code, but laser and photodiode pin are not defined. Have you solved this problem?
As I noted, the code that the OP found did not translate well from Russian and had a problem with using way too much memory.  You should probably start by finding a copy of Application Note AN034 (apparently now called Application Note AN000249) for the GP22 and working from there.

https://ams.com/documents/20143/36005/TDC-GP22_AN000249_1-00.pdf (https://ams.com/documents/20143/36005/TDC-GP22_AN000249_1-00.pdf)
Title: Re: Distance measurement
Post by: Tedmong on Mar 21, 2019, 03:57 am
Hello johnwasser,

 Thank you for your fast reply. I have already saw the datasheet of AN034 you posted with its application notes by several universities. Some universities had same purpose with mine, but they did not post any source code; I am contacting with them.

 I may try to refer code in the .pdf file you posted, but not sure whether I can translate this code to Arduino.ino software, and actual pinouts are not shown.

 Since I am a newbie at hardware, I hope that there are some open codes with wirings, but could not find so far.

 
Title: Re: Distance measurement
Post by: johnwasser on Mar 21, 2019, 01:50 pm
Read about the SPI library:
https://www.arduino.cc/en/Reference/SPI (https://www.arduino.cc/en/Reference/SPI)
Title: Re: Distance measurement
Post by: Tedmong on May 03, 2019, 04:11 am
Thank you for your advice! I have studied SPI for this project with this stage:

1. Aruidno UNO - UNO : SPI worked & SCK, MOSI, MISO, SSN waveform checked as well
2. UNO - GP22 : not worked
3. UNO - GP22 physical connection & using UNO-UNO SPI code : not worked
4. UNO - UNO physical connection & using UNO-GP22 SPI code : worked

The problem is that even the inner function, SPI.transfer does not work for UNO-GP22. The connection is right, and I used the same code as you uploaded(https://github.com/leokoppel/GP22 (https://github.com/leokoppel/GP22)).


And I just found that for the case of the 3 above, SSN, SCK, MOSI waveform works well, but there is no signal from MISO pin. I have already checked the soldered status. Do you guys have any idea?