Notifications
Clear all

Adeept Hexapod kit ADA033, thirteenth servo will not attach

54 Posts
4 Users
12 Likes
5,412 Views
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  
Posted by: @ronbentley1

try increasing your number of servos to 14, to see if you get the 13th working.

Yes, that would be a good approach to try. If that doesn't work, I will try changing the frequency of timer1. 

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

Things that make you say,"Humm". There is a lot more to this than just messing with the timers. Changing the prescaler values for the timers would effect certain PWM pins. Timer0 (TCCR0B) is the system timer affecting pins 5 and 6. Changing timer0 would affect timing functions like delay(), millis(), and micros(). Best not to mess with that. Timer1 controls PWM pins 9 and 10, and timer2 controls PWM pins 3 and 11. Knowing this still doesn't make a lot of sense to me regarding how the servos are seized by the timers according to the servo.h and timers.h files. I could experiment, but it would be like giving a hammer to a monkey (not a good idea). 

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

Hi again,

the readme file on github for the servo library states:

Servo library

This library allows an Arduino board to control RC (hobby) servo motors. Servos have integrated gears and a shaft that can be precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds.

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

I understand that the microcontroller is a Mega?  If so then the above constraint may well be the issue, ie the disabling of PWM pins 11 & 12?

The code affected from the servo sketch may be:

  for (int index = 0; index < servoData; index++) { //Attach servos to pins 2 through 14
    myServo[index].attach(index + 2);
  }

However, applying the above constraint the logic would suggest that you would lose 2 x servos as the mappings made by the above code would encompass pins 11 &12?

I watch with interest!

 

Ron Bentley

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@ronbentley1 

The original post stated that the Pixie was based on a "Adeept Pixie, with a Mega328P" which doesn't exist. A true Arduino MEGA would have a ATmega2560, so I suspect that the Pixie has only an ATmega328P or the same base as the UNO, NANO etc.

It's unlikely that it really corresponds to an Arduino MEGA, so I doubt that it actually has 48 pins capable of driving servos.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  
Posted by: @will

I suspect that the Pixie has only an ATmega328P

Yes, a surface mount ATmega328P. In the Arduino IDE, I select Genuine Arduino Uno as the target board. The Pixie board has connections for the various sensors for the robot. It's a nicely featured board, except for it's short comings. I have an Elegoo board with a Mega2560. I am still considering using a 16 channel PWM servo driver based on the PCA9685 with I2C interface. Two pins of the microcontroller to control up to 16 servos. I haven't tried using the I2C library yet. This is a good time to take that next step. 

ZoolanderMicro, where small ideas are a big deal


   
Inst-Tech reacted
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

Hi again

If your target ide board is uno, then this has only one 16 bit timer, Timer 1:

.....Arduino Uno has 3 timers: Timer0, Timer1 and Timer2. Timer0 and Timer2 are 8-bit counters (they count from 0 to 255), while Timer1 is a 16-bit counter (it counts from 0 to 65535). Internally, Timer0 is used for the millis() function, and therefore, it is recommended not to mess with it. You can use Timer1 and Timer2 for your custom requirements.

One 16 bit timer supports 12 servos, hence the failure for servo 13 as a second 16 bit timer is not available.

 

Hopefully this addresses the issue?

Ron Bentley

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Inst-Tech reacted
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

That was a fair piece of investigation, thanks @ronbentley1. Well, mystery solved. It's not an issue with code, just a short coming of the microcontroller. Poor engineering on Adeept's part. If it had worked perfectly the first time, I wouldn't have learned as much. I'm ordering an Arduino Nano and 16-channel servo driver board today. I'll have to learn how to address the servos in code using the I2C library. Thanks again for all the help and suggestions. 

ZoolanderMicro, where small ideas are a big deal


   
Inst-Tech reacted
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

😀 👍 

Its always nice to bottom such an annoying issue!

Pleased to have assisted, do keep the community updated as to your progress with the new incarnation

Ron Bentley

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Inst-Tech reacted
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

Hi,

I did a bit of investigation into the servo library code and added a little debugging code to test out my above assertion.

My debug code showed that with an IDE target board of UNO the number of timers (16bit) assigned is definitely 1, hence your 13 servo issue (only 12 servos per 16bit timer), and the debug code then showed 4 x 16bit timers assigned when I changed over to a Mega 2560 board.

Conclusive.

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
ReplyQuote
Page 4 / 4