Skip to content

ADXL355 OverflowError #688

@SiboVG

Description

@SiboVG

Hello,

I just ran the examples/adxl355_example.py on my Raspberry Pi Model 4B, but got this OverflowError:

uri: ip:localhost

Checking temperature channel...
Temperature raw: 1874
Calculated Temperature: 26.2154697155

Sampling frequencies available:
[4000.0, 2000.0, 1000.0, 500.0, 250.0, 125.0, 62.5, 31.25, 15.625, 7.813, 3.906]

Initial sample frequency:
X Sample frequency: 4000.0
Y Sample frequency: 4000.0
Z Sample frequency: 4000.0
Single calculated acceleration values:

X acceleration: 0.752623355 m/s^2
Y acceleration: -0.30312986999999997 m/s^2
Z acceleration: 9.965996834999999 m/s^2

Setting sample frequencies to 1000 sps...
Verifying new sample rate: 1000.0
Setting back to 4000 sps...

Data using buffered rx(), SI (m/s^2):
[array([0.77694717, 0.78998872, 0.77411704, 0.77962432, 0.77021605,
       0.78111588, 0.77794154, 0.7855523 , 0.78134535, 0.77602929,
       0.78432846, 0.77258724, 0.77568509, 0.77090446, 0.77993028,
       0.78000677, 0.7794331 , 0.77499668, 0.78432846, 0.77316092,
       0.7782475 , 0.78348707, 0.76937466, 0.77346688, 0.77614403,
       0.77522615, 0.7683038 , 0.78750279, 0.77817101, 0.77599105,
       0.77782681, 0.77557035]), array([-0.27115705, -0.26327858, -0.26251368, -0.27100407, -0.26239894,
       -0.26740904, -0.26832692, -0.26442593, -0.26002775, -0.25941583,
       -0.26106037, -0.26308735, -0.26324033, -0.27425489, -0.27257212,
       -0.2688241 , -0.2680592 , -0.2638905 , -0.27452261, -0.26584099,
       -0.27004794, -0.2642347 , -0.27008619, -0.26844166, -0.26798271,
       -0.26664414, -0.25815375, -0.2715395 , -0.27463734, -0.26431119,
       -0.26997145, -0.26056318]), array([9.92698693, 9.94213195, 9.93616573, 9.92847849, 9.95188443,
       9.94274387, 9.94469437, 9.93138511, 9.92507468, 9.93394752,
       9.91448082, 9.91562817, 9.91578115, 9.91784638, 9.92308594,
       9.92866971, 9.92920514, 9.94626241, 9.91455731, 9.92675746,
       9.9337563 , 9.93283842, 9.9394548 , 9.93761904, 9.94660662,
       9.94297334, 9.94626241, 9.94626241, 9.95999237, 9.96071902,
       9.95295529, 9.93107915])]

Data using buffered rx(), raw:
Traceback (most recent call last):
  File "/home/analog/Desktop/adxl355/test.py", line 72, in <module>
    print(my_acc.rx())
  File "/usr/local/lib/python3.9/dist-packages/adi/rx_tx.py", line 272, in rx
    data = self.__rx_unbuffered_data()
  File "/usr/local/lib/python3.9/dist-packages/adi/rx_tx.py", line 235, in __rx_unbuffered_data
    x[i][samp] = raw
OverflowError: Python integer 259709 out of bounds for int16

When I separate the variable declaration and print, I got this error:

Data using buffered rx(), raw:
Traceback (most recent call last):
  File "/home/analog/Desktop/adxl355/test.py", line 72, in <module>
    raw = my_acc.rx()
  File "/usr/local/lib/python3.9/dist-packages/adi/rx_tx.py", line 272, in rx
    data = self.__rx_unbuffered_data()
  File "/usr/local/lib/python3.9/dist-packages/adi/rx_tx.py", line 235, in __rx_unbuffered_data
    x[i][samp] = raw
OverflowError: Python integer 260412 out of bounds for int16

I was able to bypass it using:

import numpy as np

...

my_acc._rx_unbuffered_data_type = np.int32
my_acc._rx_data_type = np.int32
raw = my_acc.rx()
print(raw)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions