11 Replies Latest reply on Jan 27, 2015 12:08 AM by Mason17

    Multiple servo controlling issues on Edison Arduino board

    Mason17

      Hi,

       

      I found a strange servo controlling issue with the edison arduino board. I would like to ask  if someone had the same problem and have any idea how to solve it.

      The problems are the follows. There is a servo example in Arduino what i modified to move two servo parallel . If i run on it on Arduino Leaonardo than two servo moving as they should be  and the movement is smooth.

      If i run it on Edison Arduino board than i have a few problem.

      - If i have two servo than multiple servos just working on the PWM pins ( 3 and 9 ) in other pin configuration just one servo working but than also just these 3,4,9,10.

      - The secondary problem is whit them is the servo movement characteristic. It is not smooth or lagging. So in other word it moves instead of 180 times  just 20-22 times in a 0-180 grad movement. Instead of moving smoothly the servos are jumping. 

      - If i use these libraries next to servo.h (at my other sketches )  than i cant get into work both servo. Just one is initialized.

                #include <Servo.h>

                #include <WiFi.h>

                #include <SPI.h>

                #include <WiFiUdp.h>

         .

       

      It is very strange and if anybody have an advice or solution than i would really appreciate it.

       

      Thanks

      Mason

       

       

       

      #include <Servo.h>

      Servo myservo0;

      Servo myservo1; 

      int pos = 0;    // variable to store the servo position

      int s1_pin=3;

      int s2_pin=9; 

      void setup()

      {

        myservo0.attach(s1_pin);  // attaches the servo on pin 9 to the servo object

        myservo1.attach(s2_pin);

      }

      void loop()

      {

        for(pos = 0; pos < 180; pos++)  // goes from 0 degrees to 180 degrees

        {                                  // in steps of 1 degree

          myservo0.write(pos);              // tell servo to go to position in variable 'pos'

          //delay(15);

          myservo1.write(pos);

          delay(100);                       // waits 15ms for the servo to reach the position

        }

        for(pos = 180; pos>=1; pos--)     // goes from 180 degrees to 0 degrees

        {                               

          myservo1.write(pos);              // tell servo to go to position in variable 'pos'

          //delay(15);

          myservo0.write(pos);

          delay(100);                       // waits 15ms for the servo to reach the position

        }

      }

        • 1. Re: Multiple servo controlling issues on Edison Arduino board
          CMata_Intel

          Hi Mason17

           

          I'm not very sure of what is the issue that you are having. Do you have problems when using 3,4,9 and 10 pins? If you do which of the pins are working?

          I understand that you are able to use the servos connected to pins 3 and 9 but not with the other ones. Is this right?

           

          Regards

          CMata

          • 2. Re: Multiple servo controlling issues on Edison Arduino board
            Mason17

            Hi CMata,

             

            thank you for your fast response! The issue is not easy to explain therefor I made a quick animation about what I experienced whit the servos.

            Video Link:

            http://fusion17.com/transfer/edison_servo_issues.wmv

             

            I`m not tested all of the pin setup variant but in general these are worked till yet:

            In one connected servo case:  2,3,8,9,10 ( other pins like 11,12 wasn't able to drive  one servo )

            In two connected servo case:  3 and 9 was the pins where both servo moved.

             

            In two connected  servo case till yet I not found any other workable pin setup . I can live gladly just whit 3,9 but the Issue 1 demonstration in the video  makes the board unusable for a precise and smooth propulsion of a servo . If you need a real video about the problem i can do it also.

             

            I hope there is any solution to solve this. I read a few similar issue whit servos at the Galileo board. There they had to make a new servo.h library to solve the problem.   

             

            Please if you have time try to connect two servo  and let me know if you can reproduce the problem what I experienced. I can imagine that the problem can caused by a HW issue.

             

            Thank you!

            • 3. Re: Multiple servo controlling issues on Edison Arduino board
              Mason17

              Update: I made more tests and i found a new workable pin config  for two servos which are the  pin 3,5 .

               

              I´m also realized if i setup the servo degree from 0 to (1-6 degree )  than it not moves . The servo moves first than if i set it to 7 Degree. than from 8-13 Degree also not moves just than if i reach the 14 ...  So it seems the servos have a limited sensitivity. The servo angle just than moves to the next angle position  if the for loop  reach ( 7,14,21,28.... )   It seems like the servo have in this case just 26 position instead of 180. In summary, the servos are moving to the next angle position just in case if the next position what we give is more or less whit 7 degree as the current angle position. It is weird..

               

              Thanks,

              Mason

              • 4. Re: Multiple servo controlling issues on Edison Arduino board
                CMata_Intel

                Hi Mason17;

                 

                Take a look at the Intel® Edison Arduino Board Hardware Guide, in page 15 you will see the PWM configuration for the Edison, in there you will see the pins that you are able to use and how to enable them. As you can see, you will not be able to use the pin 4 and 12, it's weird that the last test in the video the pin that it's working it's the number 4, it's that right? I think it shouldn't work with those pins.

                 

                Regards;

                CMata

                • 5. Re: Multiple servo controlling issues on Edison Arduino board
                  CMata_Intel

                  Hi Mason17

                   

                  Have you had updates in this? Was the last information provided useful for you?

                   

                  Regards;

                  CMata

                  • 6. Re: Multiple servo controlling issues on Edison Arduino board
                    Mason17

                    Hi CMata,

                     

                    Actually i can not use the servos properly. I need to go through your document more deeper and test it out . I investigate the issue more than 2.5 weeks long without positive result. Now i solved the issue at my project temporally whit a second Arduino micro (connected on serial bridge) to drive the servos.  I thought i will wait till the next edison linux or IDE  update come out and than i will try it again. The issue can be in the servo library  and in this case i can not do much.   As soon i have more test done whit servos I will let you know.  The document was helpful but i have to done first a full test sequence to understand the issue. on the other hand i´m waiting for others maybe someone else have the same issue. In this case the edison library can cause the problem or if i´m alone than can be caused by  a special problem whit my board.    But let see. I give you an update as soon as i have any result to share.

                     

                    Thank you!

                    Regards

                    Mason

                    • 7. Re: Multiple servo controlling issues on Edison Arduino board
                      Aenimated

                      Hi Mason,

                       

                      I'm currently trying to control a servo with the Edison as well, and I think I might have some insight to share.  It would appear that the pulse width on the Edison PWM pins is limited to 8-bit granularity.  In other words, the pulse width can only be effectively set to 256 different values, ranging from 0 (creating a minimal duty cycle) to the configured period (creating a maximum duty cycle).  (If anyone knows of a way to change the granularity, certainly chime in - I haven't found any such feature.)

                       

                      It looks like the problem with this is that servos typically expect a period of ~20ms, while only the pulse width range of 1-2ms is used.  So in order to use the Edison PWM capabilities, you're forced to set the period to 20ms.  But 20ms/256 is roughly 80us - that's the granularity you have to work with in setting the pulse width.  Because the full range of motion is represented from 1-2ms pulse width, that means you have a total of 1000us/80us steps or ~12.

                       

                      In the end, I won't be using the PWM pins for this, but for what it's worth, I started investigating a possible workaround.  You could set the period to something much smaller (I was experimenting with 8ms), in order to gain pulse width granularity.  Then, in a timed loop (preferably running in a background thread) just enable the PWM pin briefly to emit a single pulse and then disable it.  If I'm reading my oscilliscope correctly, it looks like it's basically working.  The only downside is that it seems to take a while to enable the PWM pin sometimes, and so once in a while I see a period closer to 30ms.  I don't have an actual servo to hook up yet, so I don't know whether that would create problems.

                       

                      Anyway, just some thoughts - hope that helps,

                      Rob

                      • 8. Re: Multiple servo controlling issues on Edison Arduino board
                        Mason17

                        Hi Rob,

                         

                        Thank you for your explanation! This is exactly the issue from  a bit more scientific aspect . So this means the PWM ports for servo controlling on edition not working as they should be, caused by the pulse granularity.I think the issue can solved by a new/updated servo library what handle  the pulse granularity.


                        I connected once the Arduino Motor shield . The motor speed also defined on a way just like a servo position and there i not sensed this (1000us/80us) or ~12 step  . It seemed a bit  more smooth. But at a motor case you can not see it so exactly just like at a servo case.  So if you will have any update on this than please share whit us.  I´m a programmer and not an electronic  expert so this issue is more complex like  i´m able to solve.

                         

                        Thank you again for the exact  issue description, it helps a lot. I hope CMata will have some idea how can we solve it on a gentle way.

                        Thanks,

                        Mason

                        • 9. Re: Multiple servo controlling issues on Edison Arduino board
                          KurtE

                          Personally I except for limited things where you don't need a lot of control or precession, I think 8 bit resolution may not be sufficient for using with servos.  if I were needing to control servos, I would probably use some external board to do so.  Example: the Lynxmotion SSC-32u allows you to connect up to 32 servos by USB (or TTL serial).  Or Adafruit sells controllers that you can connect by I2C.  Likewise I believe Sparkfun sells some different USB ones as well.

                           

                          Kurt

                          • 10. Re: Multiple servo controlling issues on Edison Arduino board
                            Aenimated

                            Hi Mason,

                             

                            Ultimately, I agree with KurtE - the 8-bit resolution offered by the Edison PWM pins is probably not adequate for servo control.  Unfortunately, this is unlikely to be something addressable with a different servo library.  I don't know much about how this is implemented under the hood, but I suspect that this is a limitation in either the hardware or firmware.  Perhaps someone from Intel could confirm this.

                             

                            Regarding the motor control, typically motors are controlled by changing the duty cycle, which is a bit different than the pulse width.  The duty cycle is a ratio of the pulse width to the period.  The Edison can give you 256 different duty cycles for a given period, so this provides decent granularity in that case.  The problem with driving servos is that they're controlled by the pulse width - not the duty cycle - and servos expect a period of about 20ms.  Since the usable range of pulse widths is only from 1ms to 2ms, this leave 19ms worth of potential pulse width settings that simply can't be used.

                             

                            Anyway, I hope that helps explain the behavior you're seeing.

                            Regards,

                            Rob

                            • 11. Re: Multiple servo controlling issues on Edison Arduino board
                              Mason17

                              Thanks Rob,

                               

                              Your answer explained well the issue. In Summary since we have just 8bit resolution for Servo controlling we have to use for a more precise control a second Arduino connected on Serial Bridge or we can use I2C servo extension boards just like KurtE suggested. Nevertheless I found this solution a little bit over complicated if you want just use one or two single servo ( i.e. just like in my case i wanted do drive 2 servo to create a 3D sonic / laser radar system for my robot project ) . 

                               

                              I hope in the future the Edison Arduino board will capable to drive servos just like any Arduino board.

                               

                              Thanks for anybody for the great help!

                               

                              Regards 

                              Mason