Distance measurement

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

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

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.. :slight_smile:

Datasheet: https://www.digikey.com/product-detail/en/ams/TDC-GP22-T-R/TDC-GP22CT-ND/5970104

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

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.

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

LRF.txt (2.99 KB)

Threads merged.

Everything you need to know can be found in this Application Note:
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

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

TDC?
GP22?

No idea what they are, but you clearly do - tell us please (links to datasheets, product page, etc etc).

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

The code what is there for STM32 micro controller how can we use it to arduino uno

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

@andhavarapulokesh,

STOP CROSS-POSTING

Hi,

andhavarapulokesh:
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... :slight_smile:

Have you tried this library?

I found that with Google in under a minute.

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

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:

#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]);
    }
  }
}

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