What is the Arduino Simulink BLE data transmission frequency using matlab block and ble() function

조회 수: 4 (최근 30일)
Hello!
I am using Matlab block in Matlab Simulink to connect, send and receive data between my laptop and 3 Arduino Nano BLE devices.
Within the matlab block I use:
  1. blelist and ble('devicename') to search and connect to the device
  2. Characteristic(device name,"ServiceUUID", "CharacteristicUUID")
  3. Convert the received data from Byte format to double double(typecast(uint8(read(Received data structure)), 'uint32'))
The connection works well and is stable etc. however when I plot the data I can only get it to receive data every 3 seconds.
I already tried to change the simulink time step settings etc without success.
My question: How can I receive data at a higher frequency? Am I making any obvious error?
Many thanks in advance
  댓글 수: 5
Marvin Wright
Marvin Wright 2022년 4월 27일
Yes, I currently dont use a loop. In my understanding the Simulink model would continously loop through the matlab block. Also, yes I am using persistent variables within the Matlab block.
So I should run a loop within the matlab block? while(1) ?
Thank you
Walter Roberson
Walter Roberson 2022년 6월 12일
You should move the setting of characteristics to inside the if isempty() . Outside of the isempty() should be reserved for making changes to setting or reading or writing from the device.
If you need to read an indefinite number of times after each write (perhaps the writes are triggered or due to user input), then you should split the function into a read function and a write function. In that situation you would probably convert from persistent variable to global variable in a Data Store, and probably use an initFcn() callback to trigger initialization of the ble object.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by