Open Cathay2017 opened 2 years ago
Same issue here although my problem is reading the Arduino Nano 33 BLE onboard accelerometer. I can’t read at much more than 20 Hz or I see what you describe. Killing me as I’ve tried using mbed::ticker and other workarounds and no luck! BLE is a let down so far.
Hi, I use Arduino Nano BLE 33/Sense (as Bluetooth Periperal) to sample a full rectified sine voltage wave and real-time send it through bluetooth, then bluetooth central (Such as: pad) can show the waveform realtime. In this project,I find an important issue.
To get high ADC sampling rate, I can’t use AnalogRead() which is too slow for my project. Instead, I code based on the sketch which Klaus_K provided in the post (https://forum.arduino.cc/t/increase-the-adc-sample-rate/701813?u=xing_2019).
However, I find a critial issue: When I don’t use ArduinoBLE library, for example:BLE.begin(), nRF52840 ADC works fine,I can achieve high accuracy based on the ADC sampling data. I plot it by using a python script based on the data which my PC computer receive from Serial port of Arduino Nano BLE 33/Sense. Refer to Fig 1, it is a standard full-rectified sine wave (x axis: sample numbers; y axis: ADC value read by Arduino Nano BLE 33/Sense). Great. But when I use ArduinoBLE library, simply BLE.begin(), the wavform received from Bluetooth Central is distorted. There will no accuracy for later computation at all. It seems the ADC sampling is interrupted, refer to Fig 2. Notice: the actual input waveform to A0 is good, refer to Fig 3, just the ADC sampling is interrupted. I also did a further test, if I put BLE.end() after BLE.begin(), ADC sampling works fine. I duplicate this issue in different Arduino Nano BLE 33 uints.
My questions are:
I really appreciate if anyone can help me out in this issue.
I provide code below. You can just comment/uncomment “if(BLE.begin()) { Serial.println( "Bluetooth initialized successfully!");}” to deplicate this issue.
To duplicate this issue, I proivde minimum code below. Again, I make a little change based on Klaus_K’s code. For the hardware connection, I use a circuit to convert a sine wave(input frequency: 30 ~ 300Hz, amplitude: +/-2.5V) to fully recified waveform, then input to A0 of Arduino Nano BLE 33. You can duplicate Fig 1 and Fig2 by using 30Hz Sine waveform. I also attach a 100Hz Sine waveform for reference. OK. Any help, I really appreciate!!!
Fig 1. Singal Generator: 30Hz,+/-2.5V Sine waveform, after full rectified circuit, 60Hz full rectified sine wave to A0. Comment BLE.begin() in codes.
Fig 2. Singal Generator: 30Hz,+/-2.5V Sine waveform, after full rectified circuit, 60Hz full rectified sine wave to A0. Uncomment BLE.begin() in codes.
Fig 3. the actual waveform catched by oscilloscope. Blue waveform: 30Hz,+/-2.5V Sine waveform. Green waveform: 60Hz full rectified sine wave to Arduino A0
Fig 4.Singal Generator: 100Hz,+/-2.5V Sine waveform, after full rectified circuit, 200Hz full rectified sine wave to A0. Uncomment BLE.begin() in codes. The inerrupt seems periodic.