Arduino als toevoeging in duw-sleepboot

Discussie in 'Bouwtips varende modellen' gestart door Pergotje, 28 jan 2016.

  1. Pergotje

    Pergotje

    Lid geworden:
    21 apr 2005
    Berichten:
    788
    Locatie:
    Rozenburg
    Ik denk dat ik beter een opzet kan maken met alleen de ontvanger op mijn arduino uno en zonder servo's en ander programma alleen het signaal even moet inlezen wat uit de ontvanger komt. Weet niet of het aan de uitgang van de ontvanger ligt of dat de arduino bij het inlezen al varieert.
     
  2. marten77

    marten77

    Lid geworden:
    22 jul 2007
    Berichten:
    2.325
    Locatie:
    Gouda
    Hetgeen wat er nu ook gebeurt, de stapjes vanuit de ontvanger worden nu ook zeker 2x vergroot ! (vermoed zelfs meer)
    Dit kan dat Jitter gedrag ook veroorzaken, dit word dadelijk ook deels door de servo slow opgevangen.
     
  3. Pergotje

    Pergotje

    Lid geworden:
    21 apr 2005
    Berichten:
    788
    Locatie:
    Rozenburg
    Blij met je antwoord, dat is wat ik al zei. Dus het gaat beter worden. Het werkt, daar ben ik al blij mee. Helaas kan ik de servos pas inbouwen als ik zeker ben dat de failsave werkt. Anders kunnen mn roeren beschadigen omdat de servo op de arduino een grotere slag kan maken.
     
  4. Pergotje

    Pergotje

    Lid geworden:
    21 apr 2005
    Berichten:
    788
    Locatie:
    Rozenburg
    Doe servo maakt op de arduino nu een slag dubbel zo groot als op de ontvanger. Dus minstens 2x klopt
     
  5. bram1324

    bram1324

    Lid geworden:
    18 jul 2012
    Berichten:
    504
    Locatie:
    Hilversum
    Gebruik je PulseIn voor het lezen van de ontvangersignalen? Feitelijk doet de code dan niets zolang je een pulsje krijgt van je ontvanger. Daardoor kan het pulsje naar je servo net wat te lang duren. Daarom varieert het signaal en krijg je jitter.

    Je hebt de PinChangeInt library nodig.

    Leesvoer hier:
    http://rcarduino.blogspot.co.uk/2012/01/how-to-read-rc-receiver-with.html
    http://rcarduino.blogspot.co.uk/2012/04/how-to-read-multiple-rc-channels-draft.html
    http://rcarduino.blogspot.co.uk/2012/11/how-to-read-rc-channels-rcarduinofastlib.html
     
  6. marten77

    marten77

    Lid geworden:
    22 jul 2007
    Berichten:
    2.325
    Locatie:
    Gouda
    PulsIn is hier nog prima te gebruiken, daar het ook gelijk de timing van de servo's bepaalt.
    Het klopt inderdaad dat die PulsIn wacht op een nieuwe puls, echter de ontvanger voert zelf daarna nog 7 of meerdere pulsen uit.
    Dus de tijd is ruim aanwezig en dit geeft gelijk de juiste timing in het geheel.

    Het programmeren wil ik langzaam laten groeien naar de wat verdere opties.
    (dus alle extra info/input is uiteraard super, maar nog even te vroeg om daar direct mee verder te gaan)
    Vele zijn nog beginnende en snappen er dan niks meer van en haken daardoor al snel af.

    Zie het niet verkeerd, je input is uiteraard van harte welkom :friends:
     
  7. bram1324

    bram1324

    Lid geworden:
    18 jul 2012
    Berichten:
    504
    Locatie:
    Hilversum
    Dat verklaard precies de jitter. Vaak is de timing goed, af en toe gaat die net mis waardoord de servo wil bewegen.

    Ik had dit probleem ook in mijn boot, en bovenstaande methode lostte het op. Just saying.
     
  8. John FB

    John FB

    Lid geworden:
    29 okt 2011
    Berichten:
    4
    Locatie:
    Dordrecht
    Leuk project!!

    Zef ben ik ook bezig om een arduino in mijn Springer in te bouwen. (Nou ja....Ik ben alleen nog aan het coderen en aan elkaar plakken van shields ed.)

    Ik gebruik de pinchange library die hierboven al genoemd wordt.
    Ook ik heb last van jitter op de servo's. Andere interupt libraries geven bij mij dezelfde problemen.
    Servo's direct aan de ontvanger geven dit probleem niet. (Servo's hebben eigen voeding)
    Ik ga dit denk ik oplossen door de input 2 keer door een map() functie te halen.


    Code:
    PWM_Value = map(input_PWM, 1090, 1950,1,30);
    PWM_Value = map(PWM_Value, 1,30,1090,1950);
    1090-1950 komt uit mijn ontvanger.
    1-30 dan krijg je 15 stappen elke kant op.

    Door 1-30 aan te passen naar een hogere waarde tot de jitter terug komt, vlak je het signaal af.
    Dit is nog maar een hersenspinsel, nog niet uitgestest.

    Even terzijde,
    Ik heb een 6 kanaals setup. Door een combinatie van de flaps-schakelaar en de rechter stick, kan ik meerdere functies kiezen en gebruiken.

    Groeten John
     
  9. marten77

    marten77

    Lid geworden:
    22 jul 2007
    Berichten:
    2.325
    Locatie:
    Gouda
    @bram1324

    Als de zender niet constant dezelfde pulsbreedte uitstuurt (wat we terug kunnen zien vanuit de metingen van Pergotje zijn zender)
    Dan word de servo voortdurend van plaats verwisseld, daar de stapjes nu te groot zijn, lijkt dit op het jitter effect.
    Hieronder meer hierover, zoals ik er nu naar kijk.

    @John FB

    Dank voor het delen van je ervaring.
    Het jitter effect komt na mijn idee (en zoals eerder vermeld) vooral door de grotere stappen die een servo moet maken.
    Verder gebruik ikzelf liever deze Servo functie:
    https://www.arduino.cc/en/Reference/ServoWriteMicroseconds
    Dit vergroot de resolutie enorm en heb je er ook meer controle over.

    Daar de meeste servo's vanaf 700 MicroSeconds kunnen beginnen en dan uiterst tot 2300 MicroSeconds aankunnen.
    Dit is ongeveer dezelfde range als die 0 tot 180 graden, oftewel 1600 stapjes i.p.v. 180 !
    1600 / 180 = 8,88 MicroSeconds per graden.
    Die stapjes van 8,88 veroorzaakt deels dat jitter effect, daar ook de kwaliteit van de servo een belangrijke factor is.
    Als we deze map functie met de grotere resolutie gaan gebruiken, dan word het al veel interessanter.
    Even als voorbeeld:
    BBpos = map(RX_var, Midden, RXmax, 1500, 2300); // scale it to use it with the servo (value between 1500 and 2300)

    Uit een eerder bericht van Pergotje, weten we zijn Max waarde vanuit de zender en ook de Midden waarde.
    Hier nogmaals dezelfde som, alleen nu met de waardes vanuit zijn zender:
    BBpos = map(RX_var, 1500, 1950, 1500, 2300); // scale it to use it with the servo (value between 1500 and 2300)
    Het verscheel is nu maar 350 en dit moeten we dus opnieuw gaan schalen.
    (2300 - 1500) / (1950 - 1500) = 1,78
    Oftewel, ruim 4x zo klein en dus (in theorie) minder jitter.

    Hierover later meer :thumbsup:
    Ik zal bovenstaande in de huidige code zetten en later hier posten.
    (Mooier is het natuurlijk, dat Pergotje dit zelf probeert:yes:)
     
  10. John FB

    John FB

    Lid geworden:
    29 okt 2011
    Berichten:
    4
    Locatie:
    Dordrecht
    Ik zal eens moeten kijken wat de maximale uitslag van mijn servo's zijn :)

    {edit} mijn servo uitslag is 60 graden (hxt900){/edit}

    Als ik vanavond thuis ben zal ik mijn code eens posten.
    Het is nog niet af :) De compiler geeft in elk geval geen fouten aan.

    {edit} Hier is de code {/edit}
    Code:
     // MultiChannels
    //
    // rcarduino.blogspot.com
    //
    // A simple approach for reading three RC Channels using pin change interrupts
    //
    // See related posts -
    // http://rcarduino.blogspot.co.uk/2012/01/how-to-read-rc-receiver-with.html
    // http://rcarduino.blogspot.co.uk/2012/03/need-more-interrupts-to-read-more.html
    // http://rcarduino.blogspot.co.uk/2012/01/can-i-control-more-than-x-servos-with.html
    //
    // rcarduino.blogspot.com
    //
    
    // include the pinchangeint library - see the links in the related topics section above for details
    #include <PinChangeInt.h>
    #include <Adafruit_MotorShield.h>  // Library Motor/Stepper shield
    #include <Servo.h>  // remove l8ther if not needed
    #include <Wire.h>  // i2c bus
    #include <LiquidCrystal_I2C.h>
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
    
    Adafruit_MotorShield AFMS1 = Adafruit_MotorShield(0x60); // Adafruit motorshield 1 on (0x60)
    Adafruit_StepperMotor *Whouse_Lift = AFMS1.getStepper(200, 1); // motor 1 200 steps/rev on shield 1
    Adafruit_StepperMotor *Winch = AFMS1.getStepper(64, 2);     // motor 2 64 steps/rev on shield 1
    
    // pwm output on pins 3.5.6.9.10.11   Nano /UNO
    
    // Digital input on pins 2.4.7.8.12.13
    // Assign your channel in pins
    #define RStick_UD_IN_PIN 4
    #define RStick_TURN_IN_PIN 7
    #define Flaps_IN_PIN 2
    #define Gear_IN_PIN 8  //Decoupler
    #define Whouse_Bottom_IN_PIN A1
    #define Whouse_Top_IN_PIN A2
    
    // Assign your channel out pins
    #define Firemon_Pump_OUT_Pin 3     //placeholder should the pump be run by an ESC
    #define Firemon_Turn_OUT_PIN 5          // otherwise pump should be run by motorshield
    
    #define RStick_UD_OUT_PIN 3
    #define RStick_TURN_OUT_PIN 5
    
    #define Flaps_OUT_PIN 6
    #define Gear_OUT_PIN 9  //Decoupler
    
    //Define Limmits
    #define Firemon_Turn_UL 1725  // Left (UpperLimit)
    #define Firemon_Turn_LL 1305  // Right (LowerLimit)
    #define Firemon_Pump_UL 1725
    #define Firemon_Pump_LL 1305
    #define Whouse_UL 1725          
    #define Whouse_LL 1305
    #define Crane_Turn_UL 1725
    #define Crane_Turn_LL 1305
    #define Crane_Arm_UL 1725
    #define Crane_Arm_LL 1305
    #define Decoupler_UL 1725
    #define Decoupler_LL 1305
    #define RStickUD_UL 1900       // define Rightstick limits
    #define RStickUD_LL 1100
    #define RStickRL_UL 1900       // define Rightstick limits
    #define RStickRL_LL 1120
    #define RStick_Center_UL 1545
    #define RStick_Center_LL 1505
    #define Flaps_ON 1900
    #define Flaps_OFF 1100
    #define Gear_ON 1900
    #define Gear_OFF 1100
    
    
    // Set RStick_modes. selected by txflaps 1 and setting RStick. Choice recorded by txflaps to 0
    #define Fire_Monitor 1       // Top Left
    #define Crane 2              // Top Right
    #define Tow_Winch 3   // Bottom Right
    #define Light_Radar_Whouse 4 // Bottom Left
    int RStick_Mode = 0;
    int Active = 0;
    int Do_Step=0;
    int steps = 200;
    int step_direction = BACKWARD;
    int reel_out = 0;
    int lastButtonState = LOW;   // the previous reading from the input pin
    int Whouse_Lift_Top = LOW;    // What is the State of the Endswitches of the Whouse
    int Whouse_Lift_Bottom = LOW;
    int Set_Pump = 0;
    int Stick_Pos = 0;
    int RStickUD = 0;
    int RStickRL = 0;
    int reel_locked=1;
    // Servo objects generate the signals expected by Electronic Speed Controllers and Servos
    // We will use the objects to output the signals we read in
    // this example code provides a straight pass through of the signal with no custom processing
    Servo servoFiremon_Pump;
    Servo servoFiremon_Turn;
    Servo servoRStick_UD;
    Servo servoRStick_TURN;
    Servo servoFlaps;
    Servo servoGear;
    Servo servoCrane_Arm;
    Servo servoCrane_Turn;
    
    // These bit flags are set in bUpdateFlagsShared to indicate which
    // channels have new signals
    #define RStick_UD_FLAG 1
    #define RStick_TURN_FLAG 2
    #define Flaps_FLAG 4
    #define Gear_FLAG 8
    // holds the update flags defined above
    volatile uint8_t bUpdateFlagsShared;
    
    // shared variables are updated by the ISR and read by loop.
    // In loop we immediatley take local copies so that the ISR can keep ownership of the
    // shared ones. To access these in loop
    // we first turn interrupts off with noInterrupts
    // we take a copy to use in loop and the turn interrupts back on
    // as quickly as possible, this ensures that we are always able to receive new signals
    volatile uint16_t unRStick_UDInShared;
    volatile uint16_t unRStick_TURNInShared;
    volatile uint16_t unFlapsInShared;
    volatile uint16_t unGearInShared;
    
    // These are used to record the rising edge of a pulse in the calcInput functions
    // They do not need to be volatile as they are only used in the ISR. If we wanted
    // to refer to these in loop and the ISR then they would need to be declared volatile
    uint32_t ulRStick_UDStart;
    uint32_t ulRStick_TURNStart;
    uint32_t ulFlapsStart;
    uint32_t ulGearStart;
    
    void setup()
    {
      Serial.begin(9600);
      Serial.println("multiChannels");
       Wire.begin()     ;   // Start I2C
       lcd.begin(20,4);       // Start LCD
      // attach servo objects, these will generate the correct
      // pulses for driving Electronic speed controllers, servos or other devices
      // designed to interface directly with RC Receivers
      servoRStick_UD.attach(RStick_UD_OUT_PIN);
      servoRStick_TURN.attach(RStick_TURN_OUT_PIN);
      servoFlaps.attach(Flaps_OUT_PIN);
      servoGear.attach(Gear_OUT_PIN);
      servoFiremon_Pump.attach(Firemon_Pump_OUT_Pin);
       AFMS1.begin();  // create stepper instance with the default frequency 1.6KHz on Shield 1
        Whouse_Lift->setSpeed(60);  // 60 rpm
      Winch->setSpeed(60);
    
      // using the PinChangeInt library, attach the interrupts
      // used to read the channels
      PCintPort::attachInterrupt(RStick_UD_IN_PIN, calcRStick_UD,CHANGE);
      PCintPort::attachInterrupt(RStick_TURN_IN_PIN, calcRStick_TURN,CHANGE);
      PCintPort::attachInterrupt(Flaps_IN_PIN, calcFlaps,CHANGE);
      PCintPort::attachInterrupt(Gear_IN_PIN, calcGear,CHANGE);
    
    
    }
    
    void loop()
    {
      // create local variables to hold a local copies of the channel inputs
      // these are declared static so that thier values will be retained
      // between calls to loop.
      static uint16_t unRStick_UDIn;
      static uint16_t unRStick_TURNIn;
      static uint16_t unFlapsIn;
      static uint16_t unGearIn;
      // local copy of update flags
      static uint8_t bUpdateFlags;
    
      // check shared update flags to see if any channels have a new signal
      if(bUpdateFlagsShared)
      {
        noInterrupts(); // turn interrupts off quickly while we take local copies of the shared variables
    
        // take a local copy of which channels were updated in case we need to use this in the rest of loop
        bUpdateFlags = bUpdateFlagsShared;
     
        // in the current code, the shared values are always populated
        // so we could copy them without testing the flags
        // however in the future this could change, so lets
        // only copy when the flags tell us we can.
     
        if(bUpdateFlags & RStick_UD_FLAG)
        {
          unRStick_UDIn = unRStick_UDInShared;
        }
     
        if(bUpdateFlags & RStick_TURN_FLAG)
        {
          unRStick_TURNIn = unRStick_TURNInShared;
        }
     
        if(bUpdateFlags & Flaps_FLAG)
        {
          unFlapsIn = unFlapsInShared;
        }
           if(bUpdateFlags & Gear_FLAG)
        {
          unGearIn = unGearInShared;
        }
      
        // clear shared copy of updated flags as we have already taken the updates
        // we still have a local copy if we need to use it in bUpdateFlags
        bUpdateFlagsShared = 0;
     
        interrupts(); // we have local copies of the inputs, so now we can turn interrupts back on
        // as soon as interrupts are back on, we can no longer use the shared copies, the interrupt
        // service routines own these and could update them at any time. During the update, the
        // shared copies may contain junk. Luckily we have our local copies to work with :-)
      }
      // do any processing from here onwards
      // only use the local values unFlapsIn, unRStick_UDIn and unRStick_TURNIn, the shared
      // variables unFlapsInShared, unRStick_UDInShared, unRStick_TURNInShared are always owned by
      // the interrupt routines and should not be used in loop
    
      // we are checking to see if the channel value has changed, this is indicated
      // by the flags. For the simple pass through we don't really need this check,
      // but for a more complex project where a new signal requires significant processing
      // this allows us to only calculate new values when we have new inputs, rather than
      // on every cycle.
      if(bUpdateFlags & RStick_UD_FLAG)
      {
        if(servoRStick_UD.readMicroseconds() != unRStick_UDIn)
        {
          Stick_Pos = servoRStick_UD.readMicroseconds();
          //      servoRStick_UD.writeMicroseconds(unRStick_UDIn);
         switch (RStick_Mode)
             {
               case Fire_Monitor:
              
                  Set_Pump = map(Stick_Pos,RStick_Center_UL,RStickUD_UL,Firemon_Pump_LL,Firemon_Pump_UL) ;
                  servoFiremon_Pump.writeMicroseconds(Set_Pump);  // (1/2 stick (start at +10%)throw needs mapping to full pump)
                  break;
               case Crane:
                   if( Stick_Pos > Crane_Arm_LL   &   Stick_Pos < Crane_Arm_UL)     //limits
                     {
                      servoCrane_Arm.writeMicroseconds(servoRStick_UD.readMicroseconds());  // Direct drive
                     } // endif limits
    
                  break;
               case Light_Radar_Whouse:
                 RStickUD = servoRStick_UD.readMicroseconds();
                 RStickRL = servoRStick_TURN.readMicroseconds();
          
             // Whouse_Lift
           
            
             
               
                 Read_Whouse_End_switches();
                 if (RStickUD > RStick_Center_UL & RStickUD <= 1641 & Whouse_Lift_Top != HIGH)           { Do_Step=1; Whouse_Lift->setSpeed(10);step_direction = FORWARD;}  //  1/4 stick
                 if (RStickUD > RStick_Center_UL & RStickUD <= 1737 & Whouse_Lift_Top != HIGH)           { Do_Step=1; Whouse_Lift->setSpeed(20);step_direction = FORWARD;}  //  1/2 stick
                 if (RStickUD > RStick_Center_UL & RStickUD <= 1833 & Whouse_Lift_Top != HIGH)           { Do_Step=1; Whouse_Lift->setSpeed(40);step_direction = FORWARD;}  //  3/4 stick
                 if (RStickUD > RStick_Center_UL & RStickUD <= RStickRL_UL & Whouse_Lift_Top != HIGH)    { Do_Step=1; Whouse_Lift->setSpeed(60);step_direction = FORWARD;}  //  full+96 stick
                 if (RStickUD < RStick_Center_LL & RStickUD >= 1402  & Whouse_Lift_Bottom != HIGH)       { Do_Step=1; Whouse_Lift->setSpeed(10);step_direction = BACKWARD;}  //  - 1/4 stick
                 if (RStickUD < RStick_Center_LL & RStickUD >= 1299  & Whouse_Lift_Bottom != HIGH)       { Do_Step=1; Whouse_Lift->setSpeed(20);step_direction = BACKWARD;}  //  - 1/2 stick
                 if (RStickUD < RStick_Center_LL & RStickUD >= 1196  & Whouse_Lift_Bottom != HIGH)       { Do_Step=1; Whouse_Lift->setSpeed(40);step_direction = BACKWARD;}  //  - 3/4 stick
                 if (RStickUD < RStick_Center_LL & RStickUD >= RStickRL_LL & Whouse_Lift_Bottom != HIGH) { Do_Step=1; Whouse_Lift->setSpeed(60);step_direction = BACKWARD;}  //  - full stick
    
                  // Do we need to step?
                if (Do_Step == 1)
                {
                Whouse_Lift->step(steps, step_direction, MICROSTEP); //DOUBLE/SINGLE/MICROSTEP
                Whouse_Lift->release(); //Brakes off eg power off Steppermotor
                }
        
                 break;
               case Tow_Winch:
                 if (Stick_Pos > RStick_Center_LL & Stick_Pos < RStick_Center_UL & reel_locked == 0) {Winch->step(1, FORWARD, MICROSTEP); reel_locked=1;} // Lock reel
                 if (Stick_Pos > RStick_Center_UL & Stick_Pos <= 1641 )        { Do_Step=1; Winch->setSpeed(10);step_direction = FORWARD;}  //  1/4 stick
                 if (Stick_Pos > RStick_Center_UL & Stick_Pos <= 1737 )        { Do_Step=1; Winch->setSpeed(20);step_direction = FORWARD;}  //  1/2 stick
                 if (Stick_Pos > RStick_Center_UL & Stick_Pos <= 1833 )        { Do_Step=1; Winch->setSpeed(30);step_direction = FORWARD;}  //  3/4 stick
                 if (Stick_Pos > RStick_Center_UL & Stick_Pos <= RStickRL_UL ) { Do_Step=1; Winch->setSpeed(40);step_direction = FORWARD;}  //  full+96 stick
                 if (Stick_Pos < RStick_Center_LL & Stick_Pos >= 1402  )       { Do_Step=0; reel_out = 1; reel_locked = 0;}                                        //  - 1/4 stick
                 if (Stick_Pos < RStick_Center_LL & Stick_Pos >= 1299  )       { Do_Step=1; Winch->setSpeed(10);step_direction = BACKWARD;}  //  - 1/2 stick
                 if (Stick_Pos < RStick_Center_LL & Stick_Pos >= 1196  )       { Do_Step=1; Winch->setSpeed(20);step_direction = BACKWARD;}  //  - 3/4 stick
                 if (Stick_Pos < RStick_Center_LL & RStickUD >= RStickRL_LL ) { Do_Step=1; Winch->setSpeed(30);step_direction = BACKWARD;}  //  - full stick
    
                  // Do we need to step?
                 if (Do_Step == 1) {Winch->step(steps, step_direction, MICROSTEP); reel_locked=1;} //DOUBLE/SINGLE/MICROSTEP
                 if (reel_out == 1) {Winch->release();} //Brakes off eg power off Steppermotor
    
    
                 break;
               default:
    
                  break;
              }
    
    
        }
      }
      if(bUpdateFlags & RStick_TURN_FLAG)
      {
        if(servoRStick_TURN.readMicroseconds() != unRStick_TURNIn)
        {
          servoRStick_TURN.writeMicroseconds(unRStick_TURNIn);
    
        }
      }
      if(bUpdateFlags & Gear_FLAG)
      {
        if(servoGear.readMicroseconds() != unGearIn)
        {
          servoGear.writeMicroseconds(unGearIn);
    
        }
      }
      if(bUpdateFlags & Flaps_FLAG)
      {
      //  if(servoFlaps.readMicroseconds() != unFlapsIn)
      //  {
        lcd.setCursor ( 0, 0 );
          lcd.print("RS_Mode =");
          lcd.setCursor ( 0, 1 );
        if (unFlapsIn > Flaps_ON)
         {
          Active = 0;
          if (unRStick_UDIn > RStickUD_UL & unRStick_TURNIn > RStickRL_UL) {lcd.print("Firemonitor        ");RStick_Mode = Fire_Monitor;}        // Stick is Top Left
          if (unRStick_UDIn > RStickUD_UL & unRStick_TURNIn < RStickRL_LL) {lcd.print("Crane              ");RStick_Mode = Crane;}              // Stick is Top Right
          if (unRStick_UDIn < RStickUD_LL & unRStick_TURNIn > RStickRL_UL) {lcd.print("Lights_Radar_Whouse");RStick_Mode = Light_Radar_Whouse;}// Stick is Bottom Left
          if (unRStick_UDIn < RStickUD_LL & unRStick_TURNIn < RStickRL_LL) {lcd.print("Winch              ");RStick_Mode = Tow_Winch;}   // Stick is Bottom Right
          lcd.setCursor ( 0, 2 );
          lcd.print(unRStick_UDIn);
          lcd.setCursor ( 0, 3 );
          lcd.print(unRStick_TURNIn);
          lcd.setCursor ( 11, 0 );
          lcd.print("IN-Act");
         } // Endif Flaps_ON
    //   } // endif servoFlaps
      } // endif Flaps update
      // Run Selected mode. Active is true if Right Stick is centered after Flaps becomes 0
      if (unFlapsIn < Flaps_OFF & !Active)  // Wait for RStick Center
      {
          
        if (unRStick_UDIn >= RStick_Center_LL & unRStick_UDIn <= RStick_Center_UL) // up-Down is Centered and..// RStick is Centered   ------>Activate !!...
        {
          if (unRStick_TURNIn >= RStick_Center_LL & unRStick_TURNIn <= RStick_Center_UL)
          {
          Active=1;
          lcd.setCursor ( 11, 0 );
          lcd.print("Act   ");
          }
        }
      }  // Endif Activate
      bUpdateFlags = 0;
    } // End---LOOP
    
    
    
    
    // Smooth-out input from reciever
    int  clean_PWM(int PWM_Value)
    {
    PWM_Value = map(PWM_Value,1040,1950,0,29);
    PWM_Value = map(PWM_Value,0,29,1040,1950);
    
    return PWM_Value;
    }
    
    void Read_Whouse_End_switches()      // could need debouncing
    {
    Whouse_Lift_Top    = digitalRead(Whouse_Bottom_IN_PIN);    // What is the State of the Endswitches of the Whouse
    Whouse_Lift_Bottom = digitalRead(Whouse_Top_IN_PIN);
    }
    
    
    
    // simple interrupt service routine
    void calcRStick_UD()
    {
      // if the pin is high, its a rising edge of the signal pulse, so lets record its value
      if(digitalRead(RStick_UD_IN_PIN) == HIGH)
      {
        ulRStick_UDStart = micros();
      }
      else
      {
        // else it must be a falling edge, so lets get the time and subtract the time of the rising edge
        // this gives use the time between the rising and falling edges i.e. the pulse duration.
        unRStick_UDInShared = (uint16_t)(micros() - ulRStick_UDStart);
        // use set the RStick_UD flag to indicate that a new RStick_UD signal has been received
        bUpdateFlagsShared |= RStick_UD_FLAG;
      }
    }
    
    void calcRStick_TURN()
    {
      if(digitalRead(RStick_TURN_IN_PIN) == HIGH)
      {
        ulRStick_TURNStart = micros();
      }
      else
      {
        unRStick_TURNInShared = (uint16_t)(micros() - ulRStick_TURNStart);
        bUpdateFlagsShared |= RStick_TURN_FLAG;
      }
    }
    
    void calcFlaps()
    {
      if(digitalRead(Flaps_IN_PIN) == HIGH)
      {
        ulFlapsStart = micros();
      }
      else
      {
        unFlapsInShared = (uint16_t)(micros() - ulFlapsStart);
        bUpdateFlagsShared |= Flaps_FLAG;
      }
    }
    
    
    void calcGear()
    {
      if(digitalRead(Gear_IN_PIN) == HIGH)
      {
        ulGearStart = micros();
      }
      else
      {
        unGearInShared = (uint16_t)(micros() - ulGearStart);
        bUpdateFlagsShared |= Gear_FLAG;
      }
    }
     
    Laatst bewerkt: 17 feb 2016
  11. containerschipcaan

    containerschipcaan

    Lid geworden:
    9 okt 2010
    Berichten:
    25
    Locatie:
    rosmalen
     
  12. containerschipcaan

    containerschipcaan

    Lid geworden:
    9 okt 2010
    Berichten:
    25
    Locatie:
    rosmalen
    Een goede dag ik zit het met het zelfde probleem
    Met de uitslag roerwerk En ik zie dat jij dit hebt op gelost met twee servo en met print graag zou ik meer info willen hebben van de print en type servo
    Gr Hans
     
  13. containerschipcaan

    containerschipcaan

    Lid geworden:
    9 okt 2010
    Berichten:
    25
    Locatie:
    rosmalen
    Een goedendag ik zie dat jij een heftconstructie hebt gemaakt voor de mast stuurhut ik zou graag meer info van willen hebben zo dat ik dit probleem waar ik tegen aanloop kan tekkelen

    gr Hans
     
  14. containerschipcaan

    containerschipcaan

    Lid geworden:
    9 okt 2010
    Berichten:
    25
    Locatie:
    rosmalen
     
  15. containerschipcaan

    containerschipcaan

    Lid geworden:
    9 okt 2010
    Berichten:
    25
    Locatie:
    rosmalen
    Ik zelf heb ook een model met dubbel roeren
    Nu zie ik op de foto van het nummer staan 39382H2 die jij met de nano hebt gekoppeld nu is mijn vraag hoe heet de print met de nummer 39382H2 van het merk arduino

    met vriendelijke groet

    Hans v hooft
     

Deel Deze Pagina