Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Stabilize Sensor Output and Achieve Target Frequency for asm330lhhxg1 and lsm6dsox? #17

Open
AlysonQ opened this issue May 5, 2024 · 1 comment

Comments

@AlysonQ
Copy link

AlysonQ commented May 5, 2024

Hi ,

I am currently working on porting two sensors, the asm330lhhxg1 and lsm6dsox, to my platform.
However, I have no idea how to stabilize the sensor data and achieve the frequency in Hz as specified in the hardware specifications. Despite searching and trying various tutorials, using the iio_generic_buffer tools yields no results.

# Enable Y-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_y_en

# Enable X-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_x_en

# Enable timestamp
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_timestamp_en

# Enable Z-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_z_en

# Attempt to enable buffer
echo 1 > /sys/bus/iio/devices/iio:device2/buffer/enable

# Run generic buffer utility
./iio_generic_buffer -a -g -n asm330lhhxg1_accel
# Output from incomplete command
  iio device number being used is 2
  trigger-less mode selected
  Auto-channels selected but some channels are already activated in sysfs
  Proceeding without activating any channels
##stuck here

#Here is my device tree configuration under `i2c0`:

&i2c0 {
   asm330lhhx-imu@0x6b {
        compatible = "st,asm330lhhxg1";
        reg = <0x6b>;
        interrupt-parent = <&gpio0>;
        interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
        /*vddio-supply = <&sensors_vddio>;*/
        /*vdd-supply = <&sensors_vdd>;*/
	    drive-open-drain;
        st,int-pin = <1>;
        st,mlc-int-pin = <2>;
        mount-matrix = "1", "0", "0",
                   "0", "1", "0",
                   "0", "0", "1";
        };
    }
#  ./iio_generic_buffer -a -n asm330lhhxg1_gyro -e -g
iio device number being used is 1
trigger-less mode selected
No channels are enabled, enabling all channels
Enabling: in_anglvel_z_en
Enabling: in_timestamp_en
Enabling: in_raw_en
Enabling: in_anglvel_y_en
Enabling: in_anglvel_x_en
nothing available
nothing available
Disabling: in_anglvel_z_en
Disabling: in_timestamp_en
Disabling: in_raw_en
Disabling: in_anglvel_y_en

Could you please provide any suggestions?

Thanks,
AlysonQ

@mariotesi
Copy link
Contributor

mariotesi commented Jun 6, 2024

Hi,

all the work of enabling the axes and the buffer is already done by the iio_generic_buffer tool so you can directly run the command (for 100 samples):

$ iio_generic_buffer -n asm330lhhxg1_accel -ga -c 100

If this is not working you can check if interrupt are properly configured in /proc/interrupts:

$ cat /proc/interrupts | grep asm330

If the irq line is correctly configured you should see something different from zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants