Motor Current Signature Analysis for Gear Train Fault Detection
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
main temas
2020-10-23
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 个评论
Bora Eryilmaz
2020-12-22
编辑:Bora Eryilmaz
2020-12-22
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Instrument Connection and Communication 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!