element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Detect oscillations
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 33 replies
  • Answers 1 answer
  • Subscribers 396 subscribers
  • Views 2647 views
  • Users 0 members are here
  • oscillations
  • processing
  • accelerometer
  • movement
  • algorithm
  • arduino
Related

Detect oscillations

kosme
kosme over 11 years ago

I'm trying to use an Arduino and a MMA8452Q accelerometer to sense movement and detect oscillations. What would be the best way to analyze and process the info to detect oscillations at a specific frequency range and act accordingly?

 

Edit 1:


Aswering Michael Kellett questions

Must you detect  a single frequency (known in advance) or a band of frequencies.

I must detect if the oscillation is in the 4-8Hz range.

 

Is the sampling rate under direct contorl of the Arduino or is it set by the accelerometer.

It is mostly under control of the Arduino. The accelerometer is set to sample at a certain rate but I can "miss steps" simply by reading the I2C interface at a much lower rate.

 

What is the range of frequencies and amplitudes you must detect.

I must detect if the oscillation is in the 4-8Hz range. The amplitude will be handled by the accelerometer but I expect it to be between ±4G's

 

Are there other signals present at the same time which you must ignore.

No, but it would be nice to be able to log the results.

 

How quickly must you reach a  decision when the signal appears.

I haven't decided that yet but the oscillation must persist for several seconds before action is taken. The exact number of seconds hasn't still been determined.

 

What accelerometer are you suing.

MMA8452Q I2C accelerometer

  • Sign in to reply
  • Cancel

Top Replies

  • michaelkellett
    michaelkellett over 11 years ago +1 suggested
    Hello Enrique, It makes it easier for people to follow the thread if you just add a new message rather than editing the original question. It seems that you want to detect energy in the band 4 - 8Hz, not…
  • D_Hersey
    D_Hersey over 11 years ago +1
    SO has just come down with Parky's, so I know of the characteristics of the tremors, they do seem to have a characteristic wave form, narrow fq, fairly constant amplitude between ramp-up and ramp-down…
  • kosme
    0 kosme over 11 years ago in reply to michaelkellett

    Currently this is a private project but it has the change of turning into a commercial project in the future. I have plenty of time to work on it since this is currently my main concern.

     

    Ps. I finally understood your question about Matlab, the filter design tools. I will work on getting a copy of it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago

    SO has just come down with Parky's, so I know of the characteristics of the tremors, they do seem to have a characteristic wave form, narrow fq, fairly constant amplitude between ramp-up and ramp-down.  I understand these to be the result of some defect in inhibition.  These may be easy to detect, perhaps by using a naive method such as counting.  My one son is a probability theorist and the other is an environmental engineer with tons of experience in statistics.  If you need help, keep posting, if the other clever people on this site cannot help you for some reason, I will get the family on the case.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago

    SO (Terri--database expert) says that maybe something as simple as a HPF might work, as her voluntary movements are way slower than her spasms.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to kosme

    Bit late for this but Hi there and welcome

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ravi_butani
    0 ravi_butani over 11 years ago

    As you want to detect frequency between 4-8Hz u need to implement 4-8 Hz Bandpass filter. In Arduino U can do this by implementing LPF at 8Hz cutoff HPF having 4Hz cutoff freq. LPF: moving average LPF.... Its just like array work as fifo and average of array is your Low pass filtered output. Cutoff frequency of low pass filter is decided by length of array and sampling interval. Filtered stream of data consist signal less than 8 Hz frequency only.

    Now HPF: low pass filtered data stream is now stored in next fifo and you need to just consider difference between first and last sample in fifo... again Cutoff frequency of HPF is also decided by length of array and sampling interval. set to 4 Hz as in HPF by trial and error... Finally High pass filtered data store in next Fifo... average of third fifo with some threshold you can get to conclusion that 4-8Hz signal available in your data or not... Now if for certain time interval this final result remain above threshold can trigger your desired event. If you find problem in understand this then let me know I will be here with some  sample code...

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 11 years ago in reply to ravi_butani

    Ravi - whilst the technique you suggest does make very rough and ready filters it is not an efficient use of processing power and may not give the filter characteristics required. There are free tools around which will design FIR or IIR filters and there are code samples around too.

     

    My suggestion to use MATLAB or similar is based on the OP''s need to work out exactly what sort of filter he needs first.

     

    The methodology to be followed for filter/alogrithm design for detecting some kind of event is always:

     

    acquire a reasonably large data set including events on either side of the boundary conditions (typically 100s of events)

    examine that data with some kind of tool like MATLAB (Maple, Octave etc will do just as well)

    design a set of filters/algorithms to detect the even

    test them on the data set

    refine them

    design the actual code to implement the filters/algorithm

     

    There are no short cuts and the code design is the smallest part of the task.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago

    Here is a uP with a what might be a convenient form-factor for you:

     

    EZ430-Chronos - Texas Instruments Wiki

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago

    Also, take heart, this isn't going to be much of a toughy.  All of your signals are low BW, this means you wont have to worry about crunchiness.  The signal you are after, spasms, are quite distinct from voluntary movements.  Your signal amplitude is high relative to the background, and your desired signal occurs over a narrow frequency range and is quite sinuate.

     

    Put your data through an FFT, that should provide much insight into the type and quality of the filter you will need.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 11 years ago in reply to D_Hersey

    Hello Don,

     

    FFT no, no no a million times no !  (well perhaps not quite a million but certainly not at first !)

     

    Fourier transforms (and FFTs are just computationally optimized Fourier Transforms) convert time domain data to frequency domain data but the price you pay is that the time domain stuff is comprehensively messed up by the details of the way you do the FT.

    People try to address this with waterfall diagrams (a time sequence of (often overlapping) Fourier Transforms plotted on the same chart with some attempt to displace them vertically or horizontally according to time.

    A lot of the information gets lost.

    Spectral analysis has it's place but I very strongly suspect that the best way to start with this one is to look at this in time domain as you would with a scope.

     

    I agree that computationally this shouldn't be too hard because of the low frequencies but there is no way round the steps I suggested earlier - you just have to do the data analysis otherwise the detection algorithm will never be reliable (or more accurately you would never know how reliable it was).

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago

    I think Fourier (actually probably developed by Leonhard Euler) would be real useful here because the signal data is so sinuate.  FFT is commonly used to refer to spectral transforms generally, as I meant.  But you are technically correct, strictly speaking 'FFT' refers a specific algorithmic trick. This would be a very small problem if we had access to the analog signal,  we could be on our way with a dual op-amp and some Rs and Cs.

     

    The Fourier Transform is (like, say, negation) self-inverse:  Therefore it does not lose (aside from quantization) information.  Binoculars turn images into spectral data and back in order to have the optical system track.  Works fine.

     

    Further I never suggested real-time FFT, just that it would be a useful tool for looking at the data.  Voluntary movements are readily distinguishable from spasms.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube