1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Coder needed to properly implement pot filte,

Discussion in 'Miscellaneous' started by Josh Latka, Feb 14, 2025.

  1. Josh Latka

    Josh Latka New Member

    Joined:
    Jan 31, 2025
    Messages:
    21
    Balance:
    130Coins
    Ratings:
    +4 / 0 / -0
    My Motion Simulator:
    2DOF
    My self and several others have experienced fluctuating pot signals resulting in the motors making a crackling noise trying to follow the signal fluctuations
    A capacitor on the pots signal line and ground line make a big difference but still leaves some in wanted jitter
    I found a site explaining this situation with the adruino reading the signal and how a cap and software filter can stabilize the signal fixing the issue
    This explains how https://www.electroniclinic.com/arduino-analog-signal-filter-analog-sensor-value-fluctuates-a-lot/
    I found
    Arduino Filter for Analog Sensors coding to work the best

    after confirming the cap and filter clears up the signal using a print code to see the signal data I added the code to my smc sketch and did not experience the motor noise and jitter from the motor trying to make small adjustments to match the sensor value

    I am not very experienced at writing code, I can modify and edit but am not a coder
    Can someone with coding knowledge and experience put this filter into the code properly please?
    I’m not sure if I implemented it in the correct area and if I did it so it’s reliable

    ‘this is how and where I put the code

    const int FeedbackPin3 = A2; // Motor 3 feedback pin
    const int PotInputPin = A5; // User adjustable POT used to scale the motion (if enabled)

    //Pot Filter added by J Latka
    int PotData = 0;
    int filteredValue = 0; // Initialize filtered value
    float alpha = 0.05; // Filter coefficient (0 < alpha < 1)
    //Pot Filter added by J Latka
    int DeadZone1 = 0; // feedback deadzone
    int DeadZone2 = 0; // feedback deadzone
    int DeadZone3 = 0; // feedback deadzone

    This is the original code the filter was derived from in the attached pic

    Attached Files: