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

Help getting values of potentiometer

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by macazaga, Nov 7, 2014.

  1. macazaga

    macazaga New Member

    Joined:
    Sep 9, 2014
    Messages:
    3
    Balance:
    16Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino, Joyrider, Motion platform
    Hi

    I'm building a 2dof flight simulator and i have my arduino sketch that gets the position of the aircratf and maps it to the position of a small servo but now i want to do it with a wiper motor building the DIY Linear Actuators (http://bffsimulation.com/linear-act.php) How can i get the value of the position of and map it to my sketch?

    here is part of the code:

    // Roll
    if (discard == 'R'){ // Found the reading "Roll"
    delay (5); // It seems to need a delay here
    roll = "";
    roll += char(Serial.read()); // first digit pof the data
    roll += char(Serial.read()); // Second digit and so-on
    roll += char(Serial.read());
    roll += char(Serial.read());
    roll += char(Serial.read());
    roll += char(Serial.read());
    if (roll != rollold){ // checks to see if its different to the "old" reading
    char carray[7]; //converting a string to number sequence
    roll.toCharArray(carray, sizeof(carray)); //converting string to number sequence
    int n = atoi(carray); //converting string to number sequence

    // maybe the potentiometer value goes here and them map it to the servo

    n = map(n, -90, 90, 0, 179); //Maps the readings to the servo
    myservoroll.write(n); //Sends the data to servo
    rollold = roll; // Writes the current reading to the "old" string.
    } // end of it's a different reading section
    }

    any help will be very appreciated
  2. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,895Coins
    Ratings:
    +2,084 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Help It dépends on what DC driver you intend to use: pwm+1 pin direction
    Or 2 pins direction ?...
    Then you have to change the code accordingly.

    Have a look at my Resources (link below)
    Mat
  3. Mazhar Salam

    Mazhar Salam Member

    Joined:
    Mar 27, 2014
    Messages:
    43
    Location:
    Melbourne
    Balance:
    907Coins
    Ratings:
    +24 / 1 / -0
    My Motion Simulator:
    2DOF, Arduino
    Firstly, you have to implement the POT in such a way that it can read the entire mechanical range of your actuator design. This can be done with the help of gears or multi turn pots. Sketch for servo motors are entirely different and cannot be used. You should be able to use racing mat 2dof sketch as its written for wiper + pot setup.