tdk-invn-oss / ultrasonic.arduino.ICUX0201

Arduino Driver for TDK InvenSense consumer ultrasonic sensor family ICUX0201
https://invensense.tdk.com/smartsonic
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

ch_set_frequency is inconsistent #5

Open vmanoj1996 opened 2 weeks ago

vmanoj1996 commented 2 weeks ago

ch_set_frequency function sets different frequencies everytime even when its arguments didnot change.

verified the same frequency using ch_get_frequency

mhkline commented 1 week ago

Hi @vmanoj1996. Can you tell us what the variation in the set frequency is?

Some variation is expected. There are a couple reasons for this:

  1. The on-chip digitally controlled oscillator has a finite step size. This is on the order of a few hundred Hz.
  2. When you set the frequency, the ICU chip runs a frequency search routine to find the closest frequency step to the frequency you specified.
  3. The frequency of the on-chip DCO may be re-measured when changing the operating frequency.
vmanoj1996 commented 1 week ago

I was getting really different numbers. The fluctuation was between ~52KHz to ~100kHz. But I also found that some wires are loose. Lemme fix that for good and try again.

mhkline commented 1 week ago

Ah ok. Yes, that's way too much. I would expect no more than a few hundred Hz. Which part are you using? 30201?

vmanoj1996 commented 1 week ago

Yep. I am using 30201.