Motor Current Signature Analysis for Gear Train Fault Detection
4 views (last 30 days)
Show older comments
Hello,
I'm working on the Motor Current Signature Analysis for Gear Train Fault Detection example. I have a problem with the choice of component since I cannot get a sample rate of 1500Hz. Could someone tell me how to get such a sample rate with an arduino?
Thank you
0 Comments
Answers (2)
main temas
on 23 Oct 2020
I think the problem comes from Matlab, it slows down aqcuisition a lot. try to use directly in arduino you will see that it will go much faster. with Python or Labview also it goes faster. I hope Mathworks can explain to us one day why it slows down so much !!!!
0 Comments
Bora Eryilmaz
on 22 Dec 2020
Edited: Bora Eryilmaz
on 22 Dec 2020
Hi,
I am one of the author's of this example. It is definitely possible to achieve 1500 Hz sampling rate with Arduino Uno and transfer real-time data to MATLAB, without any slowdown, by following a couple of rules.
(1) You have to set the prescaler of the ADC converter to speed up analog to digital conversions. This requires a few lines of low-level Arduino Uno code as follows:
// ADC Prescaler set to 64. Default was 128.
ADCSRA |= (1 << ADPS2) | (1 << ADPS1);
ADCSRA &= ~(1 << ADPS0);
(2) In order to transfer data sampled at 1500 Hz to MATLAB in real time, you also need to set the serial communication speed to 250 kbaud:
Serial.begin(250000);
(3) You have to set a 666 usec loop for 1500 Hz sampling rate, something like
// Variables for the timed loop
constexpr uint32_t sample_time = 666; // microseconds for 1.5 kHz loop
uint32_t previous_time = 0;
// Compact binary data buffer
constexpr uint8_t sz = 5;
uint8_t buffer[sz];
void loop() {
// Run main event at constant rate of sample_time
uint32_t current_time = micros();
uint32_t delta = current_time - previous_time;
if (delta >= sample_time) {
previous_time = current_time;
// Read using analogRead
// Send data using Serial.write and the buffer
}
}
Depending on the size of the data you want to acquire, you might also save the data in an array first and send it later after the data acquisition is complete.
0 Comments
See Also
Categories
Find more on Instrument Connection and Communication in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!