DawnGuardian / PGA460-ESP32_Library

Library for controlling PGA460 series of chips using ESP32 (or any Arduino framework board)
MIT License
2 stars 1 forks source link

Is this code tested? #2

Open rajdeep-engineer opened 6 days ago

rajdeep-engineer commented 6 days ago

I have tried to run this code using ESP32 and Ultrasonic 2 click from Mikroe. But the code doesn't work, even basic temperature reading also doesn't seem to work.

DawnGuardian commented 5 days ago

Yes, the code has been tested.

Please upload the wiring details between the modules, the relevant parts of the sketch, and the outputs/errors.

Also please specify the module of ESP32 used.

rajdeep-engineer commented 4 days ago

I used the Mikroe Ultrasonic 2 Click board https://www.mikroe.com/ultrasonic-2-click with an ESP32 (DOIT ESP32 DEVKIT 1). In the Ultrasonic 2 Click, I replaced the default transducer with "PUI Audio UTR-1440K-TT-R".

The hardware connections are as follows:-

  1. 3V3 of Ultrasonic 2 Click -> 3.3V of ESP32
  2. GND of Ultrasonic 2 Click -> GND of ESP32
  3. RX of Ultrasonic 2 Click -> TX2 of ESP32 (GPIO17)
  4. TX of Ultrasonic 2 Click -> RX2 of ESP32 (GPIO16)

I ran the "GetDistance" example from your repository. This is what I get in the terminal. Screenshot 2024-10-22 102722

DawnGuardian commented 4 days ago

There is a mistake in the readme where I have not mentioned the proper UART port to use. This not not the issue here because the port used in your setup is the correct one.

I'll probably write a change later on where you can pass a UART port when initialising the PGA460 object later.

On to the main issue, I've just tested the same example with a DOIT ESP32 DEVKIT 1 and a module that I've created using the ESP32-S3. The PGA460 module I used is the Texas Instruments PGA460PSM-EVM. Both setups worked fine for me.

The thing to note is that the PGA460PSM-EVM requires a 5V input to power, not 3.3V. Seeing that the module you are using is also transformer based, I would suggest that the MikroE module also requires a 5V input.

DawnGuardian commented 4 days ago

Alright, so I just went through the documentation for the MikroE module. There is a minor mistake in the silkscreen labeling for the pins (TST has a 16 above it when it should be 1), but otherwise the pin descriptions seem fine.

There is an EN pin connected to the TLV61046A that should be driven high to enable the board. Please check if you have tied that pin to the 3V3 pin.

rajdeep-engineer commented 4 days ago

I test with a PGA460PSM-EVM.

Here are the hardware connections:-

  1. PWR of PGA460PSM-EVM -> Vin of ESP32 (5V)
  2. GND of PGA460PSM-EVM -> GND of ESP32
  3. Rx of PGA460PSM-EVM -> Tx of ESP32 (GPIO17)
  4. Tx of PGA460PSM-EVM -> Rx of ESP32 (GPIO16)

I am still not getting anything. Can you confirm if the hardware connection mappings are ok?

DawnGuardian commented 3 days ago

Yes, those hardware connections are correct. I do have additional pull ups for the UART lines (1k5 resistors).

If you are still only getting the output that had been posted previously, then the ESP32 has not connected to the PGA460 at all. My library does not currently check for a positive connection.

This lack of connection is usually because the PGA460 has not been powered properly, or a fault in the UART lines.

Normal output

Working output

Notice the timestamps show immediate return of data after the separation line.

Output with PGA460 power removed

Output with PGA460 power removed

Notice the timestamps now show a ~2 second delay after the separation line - this is due to the UART timing out.

rajdeep-engineer commented 2 days ago

ok thanks for the screenshots.

I have checked the power pins of PGA460 and it seems fine. So, I am clueless why it's not working on both PGA460PSM-EVM and Mikroe Ultrasonic Click 2.

I am purchasing a BOOSTXL-PGA460 evaluation kit to study this further.

I had earlier written code for STM32 microcontroller to interface with PGA460. The strange thing I found is that PGA460 generated checksum is wrong (the checksum returned by PGA460 for against commands from MCU/controller). So, there is no way to tell if the data returned by PGA460 is correct or not.

The Energia code written by "Whitehead" also doesn't validate the checksum returned by PGA460.

DawnGuardian commented 1 day ago

Good luck, and please do get back if you figure out the issue. I'll also try to improve the library in the mean time to allow configuration of serial ports and connection detection.

And yes, the main motivation I had behind writing this library was how obfuscated the Energia library was. You'll see that I've actually separated the checksum process - not too great for speed, but then again, this is an Arduino library.

rajdeep-engineer commented 1 day ago

Sure, I will keep you posted.