×

Sparkfun support will be closed from 3:00PM to 4:15PM on April 27th for a company-wide townhall meeting. We will resume regular hours on the 28th.

barryjh

Member Since: March 2, 2012

Country: United States

Profile

Programming Languages: C, C++, Java, Linux shell scripts.

Web Site: www.miser-tech.com

Lessons in Algorithms

December 21, 2016

Learn techniques on how to use Finite Impulse Response (FIR) filters and other data-processing tools to turn data into information.
  • I know it was intentional but I had to bitch anyway since the possible methods are numerous. I’ll be interested to see the method you went with and the reasons you selected the method. If it does include filtering sampled data I’ll be interested to see if you designed a FIR using TFilter :)

  • Well at least you’re not expecting anything to be inside. When Geraldo Rivera opened a safe live, it didn’t end well for him :)

    This is tough because you didn’t give much information as to how quickly you can try a combination or your method used. Even at 1 second per combination try, it would take over 11 days to try all combinations. So you must be doing something with listening, and then trying a combination based on where on the dial particular sounds showed up, after filtering out the ratchet sound of course. If its by listening, then it seems like a few listen cycles and then try the combination and see if it works. If it doesn’t not sure what step 2 is, perhaps changing some filtering parameters and listening again? If so seems like it would be pretty quick or never unless the algorithm can learn from its mistakes.

    I’m going to go with quick or never.

    crack time: 00:07:30, combo 26, 33, 92

  • Awesome, I’ve needed a reason to blow the cob webs out of my hot air nozzle :)

    Also, from the new Library code it looks like the only difference is the ID value from the ID register, other than that they work the same, is that correct?

  • Oh cool I’m going to try that. My HTU21D failed and unfortunately I just bought a new board last week, wish I knew about the new change. I was going to try putting Teflon tape over the HTU21D, but now I’ll try both. Also I was going to try to replace the bad HTU21D on the old board. It sounds like the Si7021 is footprint compatible and perhaps I can install an Si7021 on my bad board without any other changes?

  • Now you know why Nate had to implement the “No Beer until an hour before the end of your Shift” rule. His 30 day binge not only jeopardized his own health, but he trashed his office and stole all his co-workers USB cables.

  • Good point about not throwing it away. Thinking about how these boards are used by Maker Spaces to do projects and then possibly put back in a bin for others to use, boards should be able to be wiped before returning to the bin. In the DOD world if a board with Non Volatile memory is plugged into a classified network that board must be maintained in a secure environment unless it has a sanitization procedure to wipe all non volatile information. Perhaps SparkFun can include on the product page a sanitization procedure or some executable that can be flashed onto the board and run that will remove all stored user parameters.

  • While as mentioned the fact that it’s defined local to the class it won’t have a conflict, but it might be a little confusing. One standard notation for a class member variable is to use m_ prefix. For example m_i2cPort.

  • In silent protest, “Left Shark” refused to race on a track with all right hand turns!!!

  • Yea, that would be tuff to discard that bad hit, it seems to create more acceleration then some of the early on good hits. To do it you’d probably have to make the live feed a punch estimate and then after calculating all the meta data over the total punch workout, then go back a reprocess the data to try to filter out bad hits.

    I’m thinking improving from the 28% error rate to around 1% is probably good enough for what’s trying to be accomplished with a low cost low hassle device.

  • Current Numbers:

    3-77hits -> 77

    4-81hits -> 81

    5-93hits -> 94

    6-79hits -> 79

    Mystery1 -> 172

    Mystery2 -> 158

    Status: It’s been a long road to get here, as I’ve reworked the algorithm 6 different times. I started out coding in Java so I could easily create a GUI and plot the data to understand how to process it. It seemed somewhat easy to make a Nate punch detector, but just wasn’t confident any of those could work for other boxers. This 6th generation seems to be on its way to working for most boxers so I’m going to submit it, I wanted to get a horse in the race with all the work I’ve put in so far. I implemented the algorithm first in java code that I wrote in a way the can be easily ported to C. Once I was ready I then quickly ported it to C/C++ in a Visual Studio 2015 project. Next I took the code from the VS 2015 project and ported it into Nate’s original Arduino project. All the code from all 3 phases is in the Git Hub repository. I’ve also included a PDF design document in the repository. The Java application can be run from a Linux or Windows command line by going to the project directory and typing: “java -jar dist/SpeedBagAlg.jar <filename>”

    You can view the Java source code in the src directory under Java folder with any editor or use netbeans to open the project. If your interested in using this java technique to quickly workout algorithms and then port them to microcontroller code you can see some examples on my website, here is an example of parsing AT command input data from an ESP8266 module, I plan to continue demostrating this in some of my future posts. The link is to the ported C but it has a link to the original Java code.

    Project: GitHub

    Approach: Since this is to run on a micro controller I decided to not use any floating point or time consuming math functions. All math used by the algorithm is integer addition, subtraction, multiplication or division. I used a Front End processor to remove bias and condition the raw input signal. Then a detection processor to find the mins and maxs to count punch. I want to add a tracking processor to track the punches and be able to open and close both amplitude and frequency thresholds plus the possibility of lighting an LED when the rhythm is staying consistent.

    Front End Processor: Starts with a High Pass FIR filter to remove static bias, then decimating the signal to squelch more noise then taking the absolute value of the signal and followed by a small smoothing average to clean up the signal so it can be fed into the detection processor.

    Detection Processor: Decimates the signal squelching more values near the floor to zero and then taking the magnitude squared (Mag Square) of the signal. The mag square signal is then feed into a Low Pass FIR filter. The output of the FIR filter is feed into a medium size smoothing algorithm that also spits out a delayed signal that is right in the middle of the averaged signal so it is aligned in such a way to be used as a punch threshold template. The algorithm adjusts automatically to amplitude variations to keep from getting confused on the many resonant addition and subtraction phases that seem to occur. Right now punch frequency gate is fixed at 260 ms, but this may be a problem for the same algorithm working for amateurs and speed bag pros, which is why a Tracking processor would most likely be needed to be highly accurate across boxers and different speed bag platforms.

    Tracking Processor: Not implemented yet, but will track the frequency of peak punch detections and be able to better regulate punch frequency gate to be able to increase accuracy for amateurs and speed bag pros.

No public wish lists :(