leokoppel / GP22

An Arduino library for the Acam GP22 Time-to-Digital Converter
MIT License
35 stars 23 forks source link

Questions about time measurement with Arduino Mega #3

Open slangshot opened 7 years ago

slangshot commented 7 years ago

Hi Leo First - thanks for making the GP22 arduino code available. I would like to do something fairly simple : send a short 400 ns pulse to the START pin then some brief time later (eg 300ns (seen on the O-scope) send a similar pulse to STOP1 and measure the time difference. I am running the GP22 in Mode 1. I have the following set up

  1. GP22 https://www.digikey.it/catalog/en/partgroup/gp22-demo-kits/55298
  2. Arduino Mega 2560
  3. TIVA TMC1294 (supplies the START and STOP impulses for testing) On the positive side the SPI works (can save and retrieve register data) I got the code working up until the Resonator calibration with values for the theoretical (1953.13) and measured (1939.65), but then has trouble with getting the TOF to work in the getCalCycles function - it times out - and it seems does not see the STOP1 impulse. Id like to first make sure I have the correct set up
  4. It is not clear how to use the enable pins EN_START and EN_STOP1 pg 2-10 of the datasheet says to connect STOP1 to VIO IF UNUSED (it seems the START and STOP enabled by default), right? I have just left them unconnected.
  5. INT0 on the 2560 is pin2 so connected the INT pin on the GP22 to this and the scope shows this pin toggleing as the code executes
  6. Since the problem seems to point to not processing the STOP1 (although the scope shows it on the STOP 1 pin) what things should be checked? Could I have a faulty board?
  7. just using the register values provided and put my own _serial.print statements in to trace the code with debug = 0 since it seems some of the code executes differently when debug = 1. look forward to hearing comments ;)

Tim

leokoppel commented 7 years ago

Hi Tim,

  1. It is not clear how to use the enable pins EN_START and EN_STOP1 pg 2-10 of the datasheet says to connect STOP1 to VIO IF UNUSED

That doesn't seem right; do you mean "connect EN_STOP1 to VIO"?

(it seems the START and STOP enabled by default), right? I have just left them unconnected.

Not sure, but I don't think EN_START is enabled if left unconnected. (Unless you change the setting SEL_TSTO2 - see SEL_TSTO2 in the datasheet). Have you tried setting the Enable pins high?

slangshot commented 7 years ago

Hi Leo Please delete the new issue I put up - I didnt realize the first attempt was fixed.

  1. Yes I meant the EN_STOP1 to VIO if unused - for my power input I use a 3.3V from the Arduino for both VIO and VCC since when I checked their impedance I see they are connected. Hence connecting a pin to VIO seems odd to disable it ... Yes I have tried connecting EN_START to VIO to see if it would enable START but getCalCycles ... waitForInterrupt waits forever (having commented out the time-out lines. ) I had SEL_TST_02 = 0 but tried 1 after your suggestion - to no apparent effect. So the main problem seems to be activating the START pin. Does your code set up to trigger off rising edge? My impulse arrives at the STOP pin with min about 3V - see image. impulses2 Do you think I need to condition these signals? They arrive in pairs like this continuously every 25 uS My background is CompSci not ElectricalEng so your insights are most welcome. I have read the vols 1,2 on embedded micro-controllers by Valvano which was quite interesting. Tim
leokoppel commented 7 years ago

The signals look fine to me. Any number of issues may not be visible from the picture. For example, are the grounds on the Arduino, TMC1294, and GP22 shared?

Hence connecting a pin to VIO seems odd to disable it ...

I'm not sure I understand. To clarify, this row in the datasheet:

EN_STOP1 ... if not used VIO

says "If you don't actively use the pin EN_STOP1, connect it to VIO". When you connect EN_STOP1 to VIO, STOP1 is always enabled.

Does your code set up to trigger off rising edge?

I don't know what code you are running. The example code in the example TDCtalk.ino initially sets NEG_STOP1 to 1, which is falling edge. It shouldn't matter here, since your stop pulse has both a rising and falling edge.

Since the problem seems to be with registering any input at all, I would debug by trying the simplest possible program first (e.g, no calibration step).

slangshot commented 7 years ago

Hi Leo Yes I have been running the example code TDCtalk.ino. It looks like I need to set bit 31 in Reg 6 - EN_ANALOG as soon as I did this I got responses on INT0 and what looks like sensible data from the output registers corresponding to the inter-pulse interval I can see on the scope. I didn't see enabling analog front end in your code nor the START_TOF opcode. How did you use the GP22 to measure TCSPC? In any event I am hopeful that Im on the right track now. I want to run the chip continuously at 40 kHz to process dynamic frequency modulation in air (what might normally be thought of nuisance noise) of an ultrasonic carrier. The specs say it can be run at up to 500 kHz in mode 1. Tim

leokoppel commented 7 years ago

It is odd that you would need to use Analog mode for a digital input, but I'm glad you have something working.

For TCSPC I had a digital pulse from a photon counting module (details).

Best of luck with the application.

kgschaedler commented 5 years ago

Hi Leo and Tim, First of all thanks to Leo for this code. I am having similar issues to Tim with a GP-22 hooked up to an Arduino Nano. I also manage to see the measured resonator value in debug mode, so SPI is working. Testing with TTL pulses shifted to 3.3 V, I haven't been able to measure time delays between pulses (timeout error). I'm pretty sure that I'm missing the correct combination of settings of the EN_START and FIRE_IN settings and levels which match the TDCtalk example.

Could you provide the details of how you connected the non-SPI pins of the GP-22 evaluation board? Ideally for both Tim's inter-pulse delay scheme as well as Leo's TCSPC scheme? My aim is to measure delay times between two APDs, somewhat a mix of the two.

Thanks very much! Kevin

leokoppel commented 5 years ago

Hi Kevin, I probably can't be much help because it's been so long since I had the equipment and notes, but I will answer what I can.

Could you provide the details of how you connected the non-SPI pins of the GP-22 evaluation board?

The non-SPI pins on the eval board are

That you "see the measured resonator value in debug mode" suggests these are connected properly.

I'm pretty sure that I'm missing the correct combination of settings of the EN_START and FIRE_IN settings and levels which match the TDCtalk example.

I didn't use the FIRE_IN connection at all; not sure what you mean.

kgschaedler commented 5 years ago

Hi Leo,

thanks for the quick response. I realise that in fact I am using the GP-22 demo board (https://www.digikey.es/product-detail/en/ams/GP22-DEMO-MODULE/GP22-DEMOMODULE-ND/5405930), which has less easy access to the "Start" input, for example, therefore I suppose that your code may not readily run on that board. For that reason I was wondering how you had set up the FIRE_IN channel to externally start the TDC signal. I checked and saw that on this board, START is grounded permanently so it may not be suitable for my application in the end - it seems specific to ultrasonic flow measurement. I will see if I can adapt the code to trigger externally somehow or use two stop inputs + the internal start to measure.

Thanks again, Kevin