Results 1 to 10 of 10
  1. #1
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    DC Motors for pitch and roll

    Has anyone seen any Arduino sketches, where the data for pitch and roll is taken from FSX with Jim's Link2fs_multi_inout_5h, and Arduino controls two Megamoto plus driven high am DC motors? I have been struggling with this for many months, and I'm getting very discouraged. The motors run fine with Megamoto plus test sketch, and I can control the motors with pots, but even after pouring over dozens of sketches I've downloaded, I am totally lost.

  2. #2
    10+ Posting Member
    Join Date
    Feb 2014
    Location
    Rome, NY
    Posts
    19
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    Let me know when you figure it out. I am still working on getting the motors for mine. Then I guess I will need help on what else to get to work them.

  3. #3
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    I found this,which compiles all right, and I changed to pins 8 and 12 for theMegamoto shields. It will be interesting to see if soft start/stopcan be applied. And has adjustable dead zone. It also uses PID, whichmakes me nervous.
    The next step will be marrying it to Jim'slink2fs_multi_fsx_v5h.
    The Megamoto program is written for justone motor, but I don't expect it will be any problem adding moremotors. The Megamoto Shields can be stacked for up for 3 motors,bidirectional.

    https://code.google.com/hosting/sear...earch+projects

  4. #4
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    I just noticed that it's also set up for wireless communication. Maybe we can build a replacement for the space shuttles....

  5. #5
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    I forgot to mention. Megamoto test runs very smoothly

    /*
    MegaMoto Test Sketch
    Simply runs a motor back and forth
    ramping the speed from 0 to full (255)

    This example code is in the public domain.
    */
    int EnablePin = 8;
    int duty;
    int PWMPin = 11; // Timer2
    int PWMPin2 = 3;
    const byte CPin = 0; // analog input channel
    int CRaw; // raw A/D value
    float CVal; // adjusted Amps value
    void setup() {
    // initialize the digital pin as an output.
    // Pin 13 has an LED connected on most Arduino boards:
    pinMode(EnablePin, OUTPUT);
    pinMode(PWMPin, OUTPUT);
    pinMode(PWMPin2, OUTPUT);
    setPwmFrequency(PWMPin, ; // change Timer2 divisor to 8 gives 3.9kHz PWM freq
    }
    void loop() {
    // To drive the motor in H-bridge mode
    // the power chip inputs must be opposite polarity
    // and the Enable input must be HIGH
    digitalWrite(EnablePin, HIGH);
    analogWrite(PWMPin2, 0);
    for(duty = 0; duty <= 255; duty += 5){
    analogWrite(PWMPin, duty);
    delay(20);
    }
    analogWrite(PWMPin, 255);
    CRaw = analogRead(CPin);
    delay(2000);
    for(duty = 255; duty>=0; duty -= 5){
    analogWrite(PWMPin, duty);
    delay(20);
    }
    analogWrite(PWMPin, 0);
    delay(500);
    // Toggle enable to reset the power chips if we have had
    // an overcurrent or overtemp fault
    digitalWrite(EnablePin, LOW);
    delay(500);

    // Swap pins to make the motor reverse
    if(PWMPin == 11) {
    PWMPin = 3;
    PWMPin2 = 11;
    } else {
    PWMPin = 11;
    PWMPin2 = 3;
    }
    }
    /*
    * Divides a given PWM pin frequency by a divisor.
    *
    * The resulting frequency is equal to the base frequency divided by
    * the given divisor:
    * - Base frequencies:
    * o The base frequency for pins 3, 9, 10, and 11 is 31250 Hz.
    * o The base frequency for pins 5 and 6 is 62500 Hz.
    * - Divisors:
    * o The divisors available on pins 5, 6, 9 and 10 are: 1, 8, 64,
    * 256, and 1024.
    * o The divisors available on pins 3 and 11 are: 1, 8, 32, 64,
    * 128, 256, and 1024.
    *
    * PWM frequencies are tied together in pairs of pins. If one in a
    * pair is changed, the other is also changed to match:
    * - Pins 5 and 6 are paired (Timer0)
    * - Pins 9 and 10 are paired (Timer1)
    * - Pins 3 and 11 are paired (Timer2)
    *
    * Note that this function will have side effects on anything else
    * that uses timers:
    * - Changes on pins 5, 6 may cause the delay() and
    * millis() functions to stop working. Other timing-related
    * functions may also be affected.
    * - Changes on pins 9 or 10 will cause the Servo library to function
    * incorrectly.
    *
    * Thanks to macegr of the Arduino forums for his documentation of the
    * PWM frequency divisors. His post can be viewed at:
    * http://www.arduino.cc/cgi-bin/yabb2/...1235060559/0#4
    */

    void setPwmFrequency(int pin, int divisor) {
    byte mode;
    if(pin == 5 || pin == 6 || pin == 9 || pin == 10) { // Timer0 or Timer1
    switch(divisor) {
    case 1: mode = 0x01; break;
    case 8: mode = 0x02; break;
    case 64: mode = 0x03; break;
    case 256: mode = 0x04; break;
    case 1024: mode = 0x05; break;
    default: return;
    }
    if(pin == 5 || pin == 6) {
    TCCR0B = TCCR0B & 0b11111000 | mode; // Timer0
    } else {
    TCCR1B = TCCR1B & 0b11111000 | mode; // Timer1
    }
    } else if(pin == 3 || pin == 11) {
    switch(divisor) {
    case 1: mode = 0x01; break;
    case 8: mode = 0x02; break;
    case 32: mode = 0x03; break;
    case 64: mode = 0x04; break;
    case 128: mode = 0x05; break;
    case 256: mode = 0x06; break;
    case 1024: mode = 0x7; break;
    default: return;
    }
    TCCR2B = TCCR2B & 0b11111000 | mode; // Timer2
    }
    }

  6. #6
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    This I changed this to pins 8 and 12, and it ran! Unfortunately, very briefly. Now it just sits there

    Control_2_motors_b

    int joy1 = 0;
    int motor = 8;
    int joy2 = 1;
    int motor2 = 12; // pin 4 isn't pwm so use 5

    void setup(){

    pinMode(motor,OUTPUT);
    pinMode(joy1,INPUT);

    pinMode(motor2,OUTPUT);
    pinMode(joy2,INPUT);
    }

    void loop(){
    int ppp;
    int ppp2;
    ppp = analogRead(joy1);
    ppp = map(ppp, 0, 1023, -255, 255);
    analogWrite(motor,ppp);

    ppp2 = analogRead(joy2);
    ppp2 = map(ppp2, 0, 1023, -255, 255);
    analogWrite(motor,ppp2);
    }

  7. #7
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    Can someone recommend an appropriate tutorial, so that I can upload stuff for this. I've googled myself to oblivion. And how do I disable this damn auto spellcheck?

  8. #8
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    OK. Using https://www.youtube.com/watch?v=PGSim_eTokU I set one shield for int EnablePin = 8: and the other shield
    for int EnablePin = 12

    I ignored the pot on the motor shaft, and I replaced the wireless receiver with a 10k pot. I connected the pot signal wire to A4 on the UNO.
    Each motor runs on individual code, one at a time. I haven't figured out yet how to marry 12 and 8 into one code. Both motors are bidirectional. There is no dead space. There is no soft start/stop. And I don't know if this can be written into Jim's link2fs_multi_fsx_v5h.

    Read the Megamoto manual very closely!

    Thank you greatly, bzeog. Your You-Tube contributions are outstanding!

  9. #9
    10+ Posting Member
    Join Date
    Mar 2014
    Location
    Israel
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    Hi,

    I suffer and struggle with this issue as well. Unfortunately my posts to Jim and the forum have not yet been replied for more than a month .....
    I also contacted a forum of Simtools builders whose motion seat I copied, answered and supported me immediately.
    However- the Simtools sketch and set up do not fit the Link2FS. I am very enthusiastic by Link2_FS which is very frienly, but all of Jim's work is sending data from Arduino to FSX and I need the opposite...
    I buikt a 2 DOF motion seat with wiper motors 2 pots. and MonsterMoto driver. All testings of other sketches OK including the pots' control.
    PLEASE HELP!!!!!!!!!!!

    Dovale

  10. #10
    10+ Posting Member



    Join Date
    Oct 2012
    Location
    Nanaimo, B.C. Canada
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: DC Motors for pitch and roll

    Hello Dovale. At least we canít complain of boredom! And I have to admit, once a hurdle is crossed, it feels pretty good.

    There is one more piece of software that I'm going to try, to fiddle with and see what happens. It uses a L298N motor driver board, which I hope can be somehow replaced with the Megamoto board. This is http://ufonv.com/viewtopic.php?f=32ahh&t=3180
    It's a bit of an unusual Web site.
    Could you tell me which pins you connected to the Megamoto with the pot?
    On another path, I'm experimenting with a mechanical linkage between the Logitech FF stick and a KTA198 via a pot. It's a lot of trial and error, and throwing a lot of money away, and maybe giving up on the Arduino. I never was any good at programing anyways. As for buttons and switches, the keyboard can be mapped out for that.
    I recently joined an organization here called Makerspace. There's some promise there
    I've noticed that, other than the Stewart Platform, everyone is going away from dc motors, and using a static platform.
    We've gotten so close with the Link2_FS. Maybe another day