×

Forget something during Black Friday/Cyber Monday? Check out the Week of Deals!

TheRegnirps

Member Since: January 8, 2009

Country: United States

Profile

Bio

Purveyor of fine ARM products and various very cool things.

Role

CTO

Organizations

Sigma Pi Sigma

Spoken Languages

English, Mandarin

Programming Languages

Forth, C, Assembler(65C02, 68HC11, PPC, ARM)

Expertise

Godlike

Interests

Embedded instrumentation. Detection of the weakest of signals of all sorts. Synthetic aperture RADAR/SONAR and interferometric radio astronomy. Algorithms for multi-beam and spotlight. Inventor of the Rotating Graviometer.

Websites

www.regnirps.com www.andahamer.com

Publications

I share not with mere Earthlings!

  • OK OK "use case" has swept the tech world, ever in search of complicated ways to say something simple. "the A111's primary use case is distance-sensing", but isn't that the same as just "use"? Make us oldsters happy and hyphenate the darn thing! I come to a halt every time I see that I need to 'use a case' where it doesn't apply.

  • We have come a long way from demonstrating a switch with a battery and light bulb! I think your demo took over a billion transistors.

  • It is Amazon style as far as the vertical layout and finding reviews. Amazon puts a lot of resources behind finding the best way to generate sales so why not copy them?

  • I thought it fit the hysteresis version.

  • Yes, give it a try. I can think of reasons it will be faster and reasons it will be slower :-) Smaller, I'm pretty sure about.

    The other code does 1, 2, or 3 IF's, and the inner IF's test a math result, so this just might be faster on the average as well.

  • I looked at the problem a bit, and with some assumptions about the overall code, I think this will do it.

     if( abs( input-currentValue) > hysteresis){
         newData = 1;
         currentValue = input;
     }
    
  • I'm missing something I guess. In the snippet, newData is set in all four cases, and they all fall though if there has been no change. Hmmm. Are you saying this detects changes as it executes? Not like a case statement, but dependent on the order of the IF statements, which execute based on the update that may have happened in the previous if statement? I think I see.

  • if( input != currentValue){ //Skip if value has not changed 
        if( hystState==0 && input < currentValue - hysteresis ) hystState = 1;
        if( hystState==1 && input > currentValue + hysteresis ) hystState = 0; 
        NewData=1 
    } 
    currentValue = input; //Always update
    
  • I don't know the expectation for the code, but I think this does it with a smaller footprint and maybe more clear logically.

    if( input != currentValue){  //Skip if value has not changed
        if( hystState==0 && input <  currentValue - hysteresis ) hystState = 1;          
        if( hystState==1 && input >  currentValue + hysteresis ) hystState = 0;
        NewData=1
    }
    currentValue = input;  //Always update 
    
  • //---Hysteresis10BitKnob--------------------------------------------------------

    if(hystState == 0){ 
    
        if( input < currentValue - hysteresis ) hystState = 1;          
        if( input > currentValue + hysteresis ) hystState = 0;
    
        currentValue = input;
        NewData=1
    }
    

No public wish lists :(