Hi, new to posting will be an idiot probably but I'm fairly experienced with electronics and Arduino boards. I am building a guitar-playing assembly which uses servos to press the strings because they are relatively cheap. With six full frets (36), initially six high-string half frets (18) and six pluckers, I need exactly 60 servo outputs which I have read can be done with a Due but not a Mega. I cannot find which pin functions are sacrificed to obtain the extra 12 outputs. I could use trial-and-error I suppose. I have asked the question via Google but the exact sense of the question gets hijacked in the usual way. I would be most grateful if some one could enlighten me. The alternative is to add a Uno to the setup to get the extras, a step that I have tested with a Mega.
You can use drivers like this
Thank you! Yes, I saw one of these but only a couple of months ago after I had put a lot of work into my Arduino solution. I was reluctant to change horses at that time. It would probably make a lot of sense if I decided to go for a full 72-note version. Would probably simplify the code.
I don't think it simplifies the code, on the contrary it complicates it a little bit, but it does give you 16 outputs using only 2 pins of the micro and you can expand it up to 992 PWM outputs always occupying 2 pins.
Regards
I wonder where you read that, bearing in mind that not everything one reads is correct. I can't see where you might get another 6 pins with the Due board. Even so, does not leave many pins for anything else.
I guess they might be referring to an alternative board like https://www.aliexpress.com/item/32681732855.html which I think gives access to all the SAM3x IO pins.
I entirely agree with you. I don't know if I can just add a link, I'll try here, I don't want to break any forum rules. ...Servo - Arduino Reference.... States quite clearly, 60 for a Due. It may be that my quest has become entirely academic. Perhaps the Due CAN control that many servos but is pretty useless otherwise. My program needs at least two serial connections for instance. I don't know but I would like to see the answer. No-one seems to give details of how to achieve this, perhaps because it is seen as purely academic. Who'd want to do it? Well, I might. Thanks.
Unfortunately that number is misleading, In the servo library, it supports 12 servos per timer, and since the Due has 5 timers, makes the maximum supported = 5x12 = 60. So that is describing a limitation on the Servo library. It does not provide evidence that 60 servos can be directly connected.
Of course, with port expanders the Due probably can support 60 servos quite easily.
Well the Due has 70 ditital I/Os. With 2 serial connections that leaves 60 for servos and 6 other for something else
With this pin out diagram
I can count 72 IO pins, plus another 3 on the SPI connector. However on this page https://docs.arduino.cc/hardware/due/ it says 54 IO pins, so maybe I miscounted.
D0 to D69 = 70 digital I/Os
What about D70, D71, D74, D75 and D76 can they be used as digital IO?
The Official pinout diagram from the Due product page only has D0 to D69
So it will support 60 servos plus 2 serial with 6 left over for othet stuff, maybe analog, I2C, SPI etc.
So the answer was staring me in the face, I think. I assume this library is the standard one. It will allow me to use at least some of those extra digital pins if I just ask it to. I was seeing a problem that didn't exist. I confess that I was only considering the pins around the edge of the board. I plead old age, I started programming too late in life. But thank you all very much for your responses and suggestions.
You need to specify which pins you want to use for he servos.
Any pins you don't use can be used for whatever else you want
Any other questions?
There shouldn't be questions now. I've used the library for a total of 42 servos with no problems. Thanks a lot.
Further to my posts and following my proceding beyond the orginal 42 servos that I had been using successfully, I added"servo(n).attach" instructions to my code using the as-yet spare digital outputs.. There was no additional wiring yet, just code. The servos on the existing, working, code startted jittering. When examined the control pulse to the jittering servo(s) was varying by about 250 uS. It took me a while because at first I obviously suspected power supply problems. Finally I commented out some of the new attachment instructions and I found some which caused this problem. D64, D66, D67, D68 and D69 all caused existing servos to jitter. Commenting out those attachment instructions cleared the problem. I see no obvious reason why this should be but I think it means I am short of my 60 outputs. As I mentioned previously I already have a solution, which is to add a serial-connected Uno or Nano to provide the extra i/o. Not a problem that I can understand but I can live with adding extra hardware which will also provide useful spare capacity. It is an intellectual connundrum that someone else may be interested in thinking about.
It is simply that the processor is not fast enough to get round all those servos in a timely manner.
It doesn't seem to be linked to the number of servos attached. I can substitute D14,15 and 16 (normally Serials) for D67,68 and 69, and there is no problem. It seems to be that particular digital outputs can't be used, perhaps because of internal commitments or perhaps relating to what bobcousins suggested.