フィルターのクリア

Why can't I read the values from LSM9DS1 on-board sensor on Arduino Nano 33BLE in Simulink?

5 ビュー (過去 30 日間)
Rohitashva
Rohitashva 2024 年 4 月 6 日
コメント済み: Rohitashva 2024 年 5 月 13 日
Hi there,
I've been trying since weeks now, to read acceleration values in Simulink from the on-board LSM9DS1 sensor of Arduino Nano 33BLE board. I have installed the arduino support packages for both simulink and matlab, and have setup the connection with the board. I tried two approaches and both were unsuccessful:
  1. Adding LSM9DS1 sensor block from simulink's library for the arduino support package and then connecting it with the scope for visualisation. On building and deploying the model, no errors were reported but the scope shows a flat line for all inputs.
  2. Adding a MATLAB function block (below) and connecting the outputs to scope, which gives an error: "Matlab code generation is not supported on arduino nano 33ble sense board."
function [x, y, z] = readAccel()
a = arduino();
lsmobj = lsm9ds1(a, "Bus", 1);
[x, y, z] = readAcceleration(lsmobj);
end
Any guidance/help will be much appreciated?
P.s. Sensor and board are working fine. Tested in Arduino IDE!
  2 件のコメント
Ayush
Ayush 2024 年 4 月 18 日
編集済み: Ayush 2024 年 4 月 18 日
Hi Rohitashva, Are you using the default parameters of the LSM9DS1 sensor block?
Rohitashva
Rohitashva 2024 年 4 月 18 日
Hi Ayush, Yes I'm using the default values. Thanks!

サインインしてコメントする。

回答 (1 件)

Avni Agrawal
Avni Agrawal 2024 年 5 月 9 日
I understand that you are trying to read the values from LSM9DS1 on-board sensor on Arduino Nano 33BLE in Simulink. However, first try to run this command in MATLAB command window:
a = arduino()
When using `arduino()` without specifying parameters, MATLAB tries to automatically connect to an Arduino board, which might not always work as expected, especially if you have multiple devices connected or specific board requirements.
If the above line fails, then try to specify port and correct board type as mentioned below:
a = arduino('Port address', 'Nano33BLE');
Replace `'Port address'` with your board's actual port and `'Nano33BLE'` with the correct board type. This ensures MATLAB connects to the right board.
I hope this helps.
  1 件のコメント
Rohitashva
Rohitashva 2024 年 5 月 13 日
Thank you for your response.
I tried this approach too, and the project gets build and deployed to the board successfully. But, the Scope and the Data Inspector both shows a flat line. I also tried "Monitor and Tune" but it also shows the value zero for all axes.
On contrary, everthing seems to work fine in Arduino IDE.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by