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

servo gauge with arduino uno

Discussion in 'SimTools compatible interfaces' started by fancrash, May 9, 2011.

  1. fancrash

    fancrash New Member

    Joined:
    Nov 20, 2010
    Messages:
    5
    Balance:
    - 19Coins
    Ratings:
    +0 / 0 / -0
    :hi: :clap: hello everyone this place is awesome and very didactic. :sos: I need you help to build a simple tachometer with a servomotor and arduino uno.
    i read a lot of post but i can´t start to build this, i need your help. sorry for my english is a google translate :blush:
    pd:I apologize for my mistakes is my first post :yes:
  2. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    And what do you need help with?
  3. fancrash

    fancrash New Member

    Joined:
    Nov 20, 2010
    Messages:
    5
    Balance:
    - 19Coins
    Ratings:
    +0 / 0 / -0
    :hi: hello frakk, thank for your reply. will i need help with the program inside the arduino. i tell you . i copy other profiler file for x-sim and i think it works, the led rx blink fast. now for the arduino program i copy from the other proyects but not work nothing. any program with serial.begin and servo library makes the servo turn continuously and no reaction from x-simulator2 program. i think that is also misconfigured . i have a servo 360° and arduino uno. :yippiee: my dream is to build a simulator with motion with my hands but I have to get started learning how to assemble a servo tachometer. thanks for your time :thbup:
  4. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    For arduino specific questions you have a better chance in the arduino forums. For Profiler specific questions you can search this forum, lot's of info on it. There are even arduino projects here.
  5. fancrash

    fancrash New Member

    Joined:
    Nov 20, 2010
    Messages:
    5
    Balance:
    - 19Coins
    Ratings:
    +0 / 0 / -0
    :hi: At last I have a communication between the Arduino and x-simulator. I test this mount some leds as shiftlight with the rpm and pitlight with the speed but when I connect a servo motor that spins and spins until touch the throttle rpm gently and almost reach the maximum limit, the motor tends to stop and when he does turn it counterclockwise, then starts to shake and the arduino is showing off by displaying a writing error in serial port, but at least the LEDs work well :yippiee: please need your help. :sos:
    This is the arduino program:

    #include <Servo.h>

    Servo rpmservo;
    Servo Speedservo;
    int rpm;
    int Speed;
    char kind_of_data;

    void setup(){

    Serial.begin(115200);
    pinMode(3, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    pinMode(11, OUTPUT);
    pinMode(12, OUTPUT);
    pinMode(13, OUTPUT);
    }
    void loop()
    {
    while(Serial.available() > 0)
    {
    kind_of_data = Serial.read();
    if (kind_of_data == 'R' ) Read_rpm();
    if (kind_of_data == 'S' ) Read_Speed();
    }

    }
    void Read_rpm(){
    delay(2);
    int rpm100 = Serial.read()- '0';
    delay(2);
    int rpm10 = Serial.read()- '0';
    delay(2);
    int rpm1 = Serial.read()- '0';

    int rpm = 100*rpm100 + 10*rpm10 + rpm1;
    analogWrite(9,map(rpm,127,255,0,253));
    if (rpm >=250) digitalWrite(13,HIGH);
    if (rpm <=250) digitalWrite(13,LOW);

    rpmservo.write(rpm);
    }
    void Read_Speed(){
    delay(2);
    int Speed100 = Serial.read()- '0';
    delay(2);
    int Speed10 = Serial.read()- '0';
    delay(2);
    int Speed1 = Serial.read()- '0';

    Speed = 100*Speed100 + 10*Speed10 + Speed1;
    analogWrite(3,map(Speed,127,255,0,253));
    if (Speed >=150) digitalWrite(12,HIGH);
    if (Speed <=150) digitalWrite(12,LOW);
    if (Speed >=155) digitalWrite(11,HIGH);
    if (Speed <=155) digitalWrite(11,LOW);
    if (Speed >=160) digitalWrite(10,HIGH);
    if (Speed <=160) digitalWrite(10,LOW);
    if (Speed >=165) digitalWrite(7,HIGH);
    if (Speed <=165) digitalWrite(7,LOW);



    Speedservo.write(Speed);

    }

    What is my fault?
  6. kubing

    kubing Member

    Joined:
    Sep 27, 2010
    Messages:
    259
    Occupation:
    teacher, Industrial electronic programmer
    Location:
    kelantan Malaysia
    Balance:
    350Coins
    Ratings:
    +0 / 0 / -0
    use timer interrupt rather than delay(2) :yes:
  7. fancrash

    fancrash New Member

    Joined:
    Nov 20, 2010
    Messages:
    5
    Balance:
    - 19Coins
    Ratings:
    +0 / 0 / -0
    hi kubing, how do this?
  8. kubing

    kubing Member

    Joined:
    Sep 27, 2010
    Messages:
    259
    Occupation:
    teacher, Industrial electronic programmer
    Location:
    kelantan Malaysia
    Balance:
    350Coins
    Ratings:
    +0 / 0 / -0
    check your timer interrupt routine in arduino forum. I give you a key. then go to find a treasure :highfive:
  9. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    The timer interrupts or delays have very little to do with the servo operation.

    Look into the functions: analogWrite(9,map(rpm,127,255,0,253)); and rpmservo.write(rpm);

    Look into example projects and try to get the servo working alone, with only a potentiometer for testing.
  10. kubing

    kubing Member

    Joined:
    Sep 27, 2010
    Messages:
    259
    Occupation:
    teacher, Industrial electronic programmer
    Location:
    kelantan Malaysia
    Balance:
    350Coins
    Ratings:
    +0 / 0 / -0
    wish i have a time to help you. i can't find my old sample used for my old version of 2dof simulator. since big failure of my hardrive recently. I am busy with 32bit mcu system right now. Good luck fancrash.
  11. fancrash

    fancrash New Member

    Joined:
    Nov 20, 2010
    Messages:
    5
    Balance:
    - 19Coins
    Ratings:
    +0 / 0 / -0
    :cheers: thank you very much kubing. :yes: