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

5 次查看(过去 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 中查找有关 Modeling 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by