Multiswitch de Robbe y Arduino.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pedro gomez
    • Sep 2007
    • 91

    #1

    Multiswitch de Robbe y Arduino.

    Hi folks:

    I started to use Arduino in my Ictineo-II. I am very pleased with what I've got and that I see that it can be done, but I'm stuck in a challenge.

    I always used multiswitches, first a canadian device a lot of years ago and lately Robbe units.

    I've managed to "manipulate" with pulseIn any channel signals in my F14, but now I want to replace the Multiswitch 16 Robbe module with Arduino.

    This multiswitch use channel 7 or 8 to decompose in 16 switches. The radio signal from therefore is not usual normal PWM channel.

    The question is how to decipher the signal generated by the multiswitch encoder at the transmitter, at the receiver with Arduino, to get on arduino digital outputs a signal ON or OFF, mara in the same way that makes the multiswitch decoder, off and on things.

    Anyone know how?

    Best Regards

    Pedro
  • tsenecal

    #2
    Re: Multiswitch de Robbe y Arduino.

    Pedro,

    i have code for arduino at home that shows how to decode a multiprop module (not exactly the same as the multiswitch module) when using FM (not PCM) receivers. I can post it later today, when i get home from work, if you think it will help.

    Tim

    Comment

    • tsenecal

      #3
      Re: Multiswitch de Robbe y Arduino.

      Pedro,

      attach the signal (white or orange) wire from the receiver to the digital pin 3 on the arduino

      this should print out lines to the serial monitor that look like:

      channel_val 0 1500
      channel_val 1 1504
      channel_val 2 1502
      channel_val 3 1500
      channel_val 4 1500
      channel_val 5 1500
      channel_val 6 1504
      channel_val 7 1502
      channel_val < 1000 8 954 this is sync signal
      channel_val 0 1500
      channel_val 1 1504
      channel_val 2 1502
      channel_val 3 1500
      channel_val 4 1500
      channel_val 5 1500
      channel_val 6 1504
      channel_val 7 1502

      and so on. the values should range between 1000 and 2000. there should be 8 of them. different switch settings should change the value, but each position of the switch should return very similar values. ie switch 1 should alter one of the values (channel_val 0, lets say) similarly. switch 1 in lower position should always return a very similar value (somewhere around 1100. middle position should be around 1500, upper position should be around 1900. those values should be consistent.

      this code does not use pulsein, it uses interrupts, it can also tell if you have lost the signal from the transmitter, you can add code to respond accordingly

      this is the code... paste the following lines into a new sketch in arduino program, compile, and upload to arduino

      // for further info on using interrupts to decode servo signal, please see
      //
      // http://rcarduino.blogspot.com/
      //
      // Posts in the series will be titled - How To Read an RC Receiver With A Microcontroller

      #define CHANNEL_SIGNAL_INT 0 // INTERRUPT 0 = DIGITAL PIN 3 - use the interrupt number in attachInterrupt
      #define CHANNEL_SIGNAL_INT_PIN 3 // INTERRUPT 0 = DIGITAL PIN 3 - use the PIN number in digitalRead # changed to pin 3 for micro


      volatile int nCHANNELIn = 1500; // volatile, we set this in the Interrupt and read it in loop so it must be declared volatile
      volatile unsigned long ulStartPeriod = 0; // set in the interrupt
      volatile unsigned long prev_StartPeriod = 0; // set in the interrupt
      volatile boolean bNewCHANNELSignal = false; // set in the interrupt and read in the loop

      unsigned long dead_time;
      unsigned long current_time;

      char buffer[80] = "";

      int multi_servo[50];
      int current_servo = 0;

      int channel_val = 1000;

      void setup()
      {
      // should only have to see 8 of these... 9th should be sync signal
      multi_servo[0] = 1500;
      multi_servo[1] = 1500;
      multi_servo[2] = 1500;
      multi_servo[3] = 1500;
      multi_servo[4] = 1500;
      multi_servo[5] = 1500;
      multi_servo[6] = 1500;
      multi_servo[7] = 1500;
      multi_servo[7] = 1500;

      // tell the Arduino we want the function calcReceiver to be called whenever INT0 (digital pin 3) changes from HIGH to LOW or LOW to HIGH
      // catching these changes will allow us to calculate how long the input pulse is
      attachInterrupt(CHANNEL_SIGNAL_INT,calcReceiver,CH ANGE);

      //we will be sending a ton of data
      Serial.begin(57600);

      dead_time = millis();

      Serial.println("system ready");
      }

      void loop()
      {

      if(bNewCHANNELSignal)
      {
      //copy to our non volatile var
      channel_val = nCHANNELIn;
      if (current_servo < 50) {
      multi_servo[current_servo] = channel_val;
      }

      current_servo++;

      bNewCHANNELSignal = false;
      } // end bNewCHANNELSignal

      sprintf(buffer ,"channel_val %d , counter %d", channel_val, current_servo);
      Serial.println(buffer);

      //servo channel orientation normal
      if (channel_val < 1000) {
      sprintf(buffer ,"channel_val < 1000 %d %d this is sync signal", channel_val, current_servo);
      Serial.println(buffer);
      current_servo = 0;
      }

      //servo channel orienttion reversed
      if (channel_val > 2000) {
      sprintf(buffer ,"channel_val > 2000 %d %d this is reversed sync signal", channel_val, current_servo);
      Serial.println(buffer);
      current_servo = 0;
      }


      current_time = millis();

      //it has been 3 seconds since we got a servo pulse...
      if ((current_time - dead_time ) > 3000) {

      Serial.println("receiver lost signal");
      //change multi_servo[0]..multi_servo[7] to failsafe values
      }

      // put your code here to run through values stored in multi_servo[0]...multi_servo[7] to position switches/lights/horns/servos accordingly

      delay(10); // delay in between reads for stability

      // other processing ...
      } //end of void loop()


      void calcReceiver()
      {
      // if the pin is high, its the start of an interrupt
      if(digitalRead(CHANNEL_SIGNAL_INT_PIN) == HIGH) {
      // get the time using micros - when our code gets really busy this will become inaccurate, but for the current application its
      // easy to understand and works very well
      prev_StartPeriod = ulStartPeriod;
      ulStartPeriod = micros();
      }
      else
      {
      // if the pin is low, its the falling edge of the pulse so now we can calculate the pulse duration by subtracting the
      // start time ulStartPeriod from the current time returned by micros()
      if(ulStartPeriod && (bNewCHANNELSignal == false)) {
      nCHANNELIn = (int)(micros() - ulStartPeriod);
      ulStartPeriod = 0;

      // tell loop we have a new signal on the CHANNEL channel
      // we will not update nCHANNELIn until loop sets
      // bNewCHANNELSignal back to false
      bNewCHANNELSignal = true;

      //reset our dead-man's switch
      dead_time = millis();
      }
      }
      } //end of void calcReceiver()

      Comment

      • tsenecal

        #4
        Re: Multiswitch de Robbe y Arduino.

        Pedro,

        as i said before, the code is written for the mult-prop robbe module that i have plugged into my fc-28, but a french website that i found with google indicates that the multi-switch transmitter module uses the same multi-plexing protocol to send data to the receiver. the difference is in how the data is interpreted by the multi-switch decoder module that plugs into the receiver. the system is very simple in its theory, 8 separate signals are sent to the receiver, in round-robin fashion, with a 9th "sync" signal which is outside the value normally sent for a servo. the arduino code loads the values it reads into an array, and it resets the array index when the 9th "sync" signal is seen.

        I was trying to use this with my 433mhz modules, but the 9th sync signal is interpreted by the transmitter module as a bad value, and thrown away, so i cant use this code with the 433mhz modules. the same thing happens with the 2.4ghz modules made by other manufacturers. I have only tried the code with FM receivers, I haven't yet tried it with PCM receivers.

        Comment

        • KevinMC
          SubCommittee Member
          • Sep 2005
          • 463

          #5
          Re: Multiswitch de Robbe y Arduino.

          Hi Tim,

          I've wondered about making a decoder for one of these units myself. Do you know to a certainty that it's the transmitter that's tossing the sync signal? (I know that SL-8's will throw away the sync even when the transmitter sends it.)

          Have you ever measured how much less than 1 ms the sync signal actually is? If it's a lot less than 1 ms I can understand how a Tx/Rx might throw it away as "bad data", but as you're aware 1 ms is a completely valid pulse width for a servo... (If the module is throwing 500 us for a sync I'd expect it to get tossed, but 900 us not so much.)
          Kevin McLeod - OSCAR II driver
          KMc Designs

          Comment

          • tsenecal

            #6
            Re: Multiswitch de Robbe y Arduino.

            Kevin,

            this is being typed from memory, i can't find the output of my sketch that i emailed off showing the actual data... sent during my testing.

            all of the 2.4ghz RX and TX modules i tried didn't work (futaba, Assan, Corona, FrSky)
            all of the 433mhz RX and TX modules i tried didn't work (orangerx, DTF)

            of the 75mhz systems i tried:
            the testing i did was with three different receivers, and two different transmitter modules.

            RXs:
            futaba r149dp
            futaba r148df
            sombra SL8

            Tx modules:
            hitec spectra 75mhz module
            futaba FP-PK-FM 75mhz module

            of the three RX, only the r148df worked correctly for all setups. this worked correctly regardless of which TX module i used. I also tried two different multi-prop modules, one manufactured by Robbe, and a knock-off manufactured by this guy:



            in both scenarios, either multiprop TX module worked with either multiprop RX module. after finding a scenario that worked, i started messing around with adjusting endpoints and servo reversing. the wetronic system only worked with servo reverse set to normal, and with the endpoint adjustment beyond 110% (i used 120%, just to be safe). the Robbe setup was a little more lenient, it worked with endpoints at 100%, but still required normal servo movement. when i hooked all this up to my arduino, with the code above, the 120% endpoint gave values below 750, and above 2200 if reversed. the 100% adjustment gave values below 900, and above 2000.

            the fact that endpoint adjustment and servo reversing caused differences in the sync value leads me to believe that the TX is doing the sync signal.

            the Robbe multi-prop RX module has a switch to select PPM vs PCM, and that did allow it to work with the r149dp. I only tried that configuration with the Robbe multi-prop TX and RX modules however.

            Alwin at wetronic indicates that the Jeti Duplex 2.4ghz TX module and receivers do work with the mutli-prop devices.

            I assume the filtering of the "noise" is being done at the receiver, since all the "smart" receivers failed to work properly.

            You do have a valid argument, i do think that all the new systems decode the PPM signal to build packets to be sent from the transmitter module to the receiver. if that is the case, they could certainly ignore any "noise" in the decoded signal while building the packet.

            the sad news is that my fc28 is currently out for repair. i won't be able to do any new testing until it gets back.

            Comment

            • tsenecal

              #7
              Re: Multiswitch de Robbe y Arduino.

              Kevin, I have downloaded and checked the source code for the 433mhz OpenLRSng modules.

              2 things of note:

              1) the PPM signal is being interpreted by an interrupt, so it should be able to decode the 9 (8 + sync) multiplexed values coming across the PPM signal.
              2) there is a lovely function labeled servoUs2Bits which converts from the PPM signal (0 -> 2200+ microseconds) to a value of 0 -> 1023 for the packet transferred to the receiver.

              in that function anything below 800 microseconds is returned as a zero, and anything higher than 2200 microseconds is returned as 1023. there is also a sliding scale involved for values below 1000 microseconds and values above 2000 microseconds. In other words there is no way the wetronic kit will work without altering the code. I will investigate the Robbe stuff again to see if i can get sync consistent sync values if the sync value is between 800 microseconds and 1000 microseconds.

              Comment

              • pedro gomez
                • Sep 2007
                • 91

                #8
                Re: Multiswitch de Robbe y Arduino.

                Hi Tim:
                Thanks for your help.This week I'll work with your sketch.
                Yes, I'm been working in a easy sketch, similar to the one of the internet french friend, which works, but not in all switches... only 1,3,5 and 7.. 2,4,6 and 8, don't works, but in the array the values are good.
                You can suspect why the impair run and the pair not?




                int multiswitch = 8; // receiver channel 8 (multiswitch16 pin1) in arduino pin 8
                int duracion; // pulse lenght
                int note[] = {};
                int ledpin1 = 13;
                int ledpin2 = 12;

                void setup()
                {
                pinMode(multiswitch, INPUT);
                Serial.begin(9600);
                pinMode (ledpin1, OUTPUT);
                pinMode (ledpin2, OUTPUT);
                }
                void loop()
                {
                duracion = pulseIn(multiswitch, HIGH);
                if (duracion <=950)
                {
                for (int i=0; i <= 8; i++)
                {
                note[i] = pulseIn(multiswitch, HIGH);
                Serial.print(note[i]);
                Serial.print(" / ");
                }

                if ((note[8] >= 900) && (note[8] <= 1100))// note[1] se corresponde al switch 7
                {
                digitalWrite(ledpin1, HIGH);
                }
                if ((note[8] >= 1900) && (note[8] <= 2100))
                {
                digitalWrite(ledpin2, HIGH);
                }
                if ((note[8] >= 1400) && (note[8] <= 1600))
                {
                digitalWrite(ledpin1, LOW);
                digitalWrite(ledpin2, LOW);
                }

                Serial.println();
                }

                delay(100);
                }

                Comment

                • tsenecal

                  #9
                  Re: Multiswitch de Robbe y Arduino.

                  Pedro,

                  your line:

                  Serial.print(note[i]);

                  prints all nine values? and they are values you expect?

                  if that is true, the issue is not in reading the values from the receiver, but in the other part of the code.

                  i do not understand what the rest of the code is attempting to do. it only checks the value of note[8], which should be the sync signal, and should be less than 950.


                  because you are using pulsein, and you are only executing the rest of the code to fill in the note array if the value you got from pulsein is less than 950, you could be missing several iterations of the signal coming from the receiver. inside the loop function, you basically read a pulsein, if it is greater than 950, you don't do anything else in loop. if it is less than 950, you run through all your steps to fill the note array, and set the LEDs.

                  your sketch could be missing lots of data from the receiver, while it looks for the sync signal.

                  Comment

                  • pedro gomez
                    • Sep 2007
                    • 91

                    #10
                    Re: Multiswitch de Robbe y Arduino.

                    Hi Tim:
                    The array in the IDE is complete , 8 values and sincronization values. And all the values change when I move the switches. The array is OK. The first item in the array is note[0] and is the sincronization value. After read note[1] to note[8], right to left. These are the values I use in if conditions.
                    Above is complete sketch.
                    Curiously, you can see that in switches 1,3,5 and 7, there are not no correspondence with the positions in the array. 1,3,5,7 runs OK.
                    Switches 2,4,6,8 , there are correspondence with the positions in the array. 2,4,6,8 don't run.



                    // 8 switches, don'n run 2, 4, 6, 8.


                    int multiswitch = 8; // receiver channel 8 (multiswitch16 pin1) in arduino pin 8
                    int duracion; // pulse lenght
                    int note[] = {};

                    int ledpin11 = 16; //note[1], switch 7 OK
                    int ledpin12 = 17;
                    int ledpin71 = 2; //note[7], switch 1 OK
                    int ledpin72 = 3;
                    int ledpin31 = 11; //note[3], switch 5 OK
                    int ledpin32 = 12;
                    int ledpin41 = 9; //note[4], switch 4 NO, only light red led in upper swuitch position, and no more,
                    int ledpin42 = 10;
                    int ledpin51 = 6; //note[5], switch 3 OK
                    int ledpin52 = 7;
                    int ledpin21 = 4; //note[2], switch 2 NO, nothing occurs
                    int ledpin22 = 5;
                    int ledpin61 = 14; //note[6], switch 6 NO, nothing occurs
                    int ledpin62 = 15;
                    int ledpin81 = 18; //note[8], switch 8 NO, nothing occurs
                    int ledpin82 = 19;

                    void setup()
                    {
                    pinMode(multiswitch, INPUT);
                    Serial.begin(9600);
                    pinMode (ledpin11, OUTPUT);
                    pinMode (ledpin12, OUTPUT);
                    pinMode (ledpin71, OUTPUT);
                    pinMode (ledpin72, OUTPUT);
                    pinMode (ledpin31, OUTPUT);
                    pinMode (ledpin32, OUTPUT);
                    pinMode (ledpin41, OUTPUT);
                    pinMode (ledpin42, OUTPUT);
                    pinMode (ledpin51, OUTPUT);
                    pinMode (ledpin52, OUTPUT);
                    pinMode (ledpin21, OUTPUT);
                    pinMode (ledpin22, OUTPUT);
                    pinMode (ledpin61, OUTPUT);
                    pinMode (ledpin62, OUTPUT);
                    pinMode (ledpin81, OUTPUT);
                    pinMode (ledpin82, OUTPUT);
                    }

                    void loop()
                    {
                    duracion = pulseIn(multiswitch, HIGH);
                    if (duracion <=950)
                    {
                    for (int i=0; i <= 8; i++)
                    {
                    note[i] = pulseIn(multiswitch, HIGH);
                    Serial.print(note[i]);
                    Serial.print(" / ");
                    }

                    if ((note[1] >= 1020) && (note[1] <= 1070)) // switch 7, OK
                    {
                    digitalWrite(ledpin11, HIGH);
                    }
                    if ((note[1] >= 1940) && (note[1] <= 1980))
                    {
                    digitalWrite(ledpin12, HIGH);
                    }
                    if ((note[1] >= 1480) && (note[1] <= 1540))
                    {
                    digitalWrite(ledpin11, LOW);
                    digitalWrite(ledpin12, LOW);
                    }
                    if ((note[3] >= 1020) && (note[3] <= 1070)) // switch 5, OK
                    {
                    digitalWrite(ledpin31, HIGH);
                    }
                    if ((note[3] >= 1940) && (note[3] <= 1980))
                    {
                    digitalWrite(ledpin32, HIGH);
                    }
                    if ((note[3] >= 1480) && (note[3] <= 1540))
                    {
                    digitalWrite(ledpin31, LOW);
                    digitalWrite(ledpin32, LOW);
                    }
                    if ((note[4] >= 1020) && (note[4] <= 1070)) // switch 4, NO OK .
                    {
                    digitalWrite(ledpin41, HIGH);
                    }
                    if ((note[4] >= 1940) && (note[4] <= 1980))
                    {
                    digitalWrite(ledpin42, HIGH);
                    }
                    if ((note[4] >= 1480) && (note[4] <= 1540))
                    {
                    digitalWrite(ledpin41, LOW);
                    digitalWrite(ledpin42, LOW);
                    }
                    if ((note[5] >= 1020) && (note[5] <= 1070)) // switch 3, OK
                    {
                    digitalWrite(ledpin51, HIGH);
                    }
                    if ((note[5] >= 1940) && (note[5] <= 1980))
                    {
                    digitalWrite(ledpin52, HIGH);
                    }
                    if ((note[5] >= 1480) && (note[5] <= 1540))
                    {
                    digitalWrite(ledpin51, LOW);
                    digitalWrite(ledpin52, LOW);
                    }
                    if ((note[2] >= 1020) && (note[2] <= 1070)) // switch 2, NO OK
                    {
                    digitalWrite(ledpin21, HIGH);
                    }
                    if ((note[2] >= 1940) && (note[2] <= 1980))
                    {
                    digitalWrite(ledpin22, HIGH);
                    }
                    if ((note[2] >= 1480) && (note[2] <= 1540))
                    {
                    digitalWrite(ledpin21, LOW);
                    digitalWrite(ledpin22, LOW);
                    }
                    if ((note[6] >= 1020) && (note[6] <= 1070)) // switch 6, NO OK
                    {
                    digitalWrite(ledpin61, HIGH);
                    }
                    if ((note[6] >= 1940) && (note[6] <= 1980))
                    {
                    digitalWrite(ledpin62, HIGH);
                    }
                    if ((note[6] >= 1480) && (note[6] <= 1540))
                    {
                    digitalWrite(ledpin61, LOW);
                    digitalWrite(ledpin62, LOW);
                    }
                    if ((note[7] >= 1020) && (note[7] <= 1070)) // switch 1, OK
                    {
                    digitalWrite(ledpin71, HIGH);
                    }
                    if ((note[7] >= 1940) && (note[7] <= 1980))
                    {
                    digitalWrite(ledpin72, HIGH);
                    }
                    if ((note[7] >= 1480) && (note[7] <= 1540))
                    {
                    digitalWrite(ledpin71, LOW);
                    digitalWrite(ledpin72, LOW);
                    }
                    if ((note[8] >= 1020) && (note[8] <= 1070)) // switch 8, NO OK
                    {
                    digitalWrite(ledpin81, HIGH);
                    }
                    if ((note[8] >= 1940) && (note[8] <= 1980))
                    {
                    digitalWrite(ledpin82, HIGH);
                    }
                    if ((note[8] >= 1480) && (note[3] <= 1540))
                    {
                    digitalWrite(ledpin81, LOW);
                    digitalWrite(ledpin82, LOW);
                    }
                    Serial.println();
                    }

                    delay(100);
                    }

                    Comment

                    • tsenecal

                      #11
                      Re: Multiswitch de Robbe y Arduino.

                      pedro,

                      i am confused.

                      at first you say array is filled correctly. 9 values are read by pulsein with note[0] being the sync signal.

                      then you come back and say they aren't.


                      either they are or they aren't.

                      please do this for me:

                      copy and paste the serial print output for the 3 positions of the 8 switches and the sync signal.

                      i need to see what the pulsein values are for the 8 switches, when they are in their three different positions.


                      Tim

                      Comment

                      • tsenecal

                        #12
                        Re: Multiswitch de Robbe y Arduino.

                        pedro

                        which model of arduino are you using?

                        Comment

                        • pedro gomez
                          • Sep 2007
                          • 91

                          #13
                          Re: Multiswitch de Robbe y Arduino.

                          Hi Tim:
                          Arduino UNO rev.3

                          The array is filled correctly, 9 values are read by pulsein with note[0] for the sync signal.
                          The problem is that: Arduino doesn't put ON, the leds for switches, 2.4.6 and 8. Arduino does it, in switches 1,3,5 and 7 , in both positions. The if conditions, are the same for the 8 switches.


                          I'll copy and paste the serial print output for the 3 positions of the 8 switches and the sync signal. I take pictures and I'll send you tomorrow.

                          Comment

                          • pirate
                            Member
                            • Oct 2005
                            • 849

                            #14
                            Re: Multiswitch de Robbe y Arduino.

                            Blah, blah, blah.

                            Why don't you guys get a relaxing hobby... like whittling? You're making my brain explode!

                            Pete

                            Comment

                            • Ralph --- SSBN 598
                              Junior Member
                              • Oct 2012
                              • 1417

                              #15
                              Re: Multiswitch de Robbe y Arduino.

                              These guys are looking for an alternative to the 75mhz we use in the USA.
                              It is become very hard to find these radios.
                              2.4ghz is taking over and the manufacturers are leaving us.

                              I for one am very glad they are doing the tech stuff.
                              I would like to just buy what is needed and not have to do all the research that is needed to get something to replace the 75mhz.

                              Comment

                              Working...