Arduino Uno - 12 servos and RF module (virtualwire? rcswitch? servotimer2?)

Hi everyone.

My project is a self designed/assembled/programmed quadruped. Each leg has 3 degrees of freedom, so I need to control 12 servos in total. I also wanted to receive some simple commands via an RF module.

I found out that the VirtualWire library I used for this was incompatible with most servo libraries as they use the same timer. Googling about the subject, I discovered the ServoTimer2 library, but this library only supports 8 servos. I also found the RCswitch library, an alternative to VirtualWire library, but while It worked with some servos attached, I never managed to make it work with more than 8, I don't know why (also it caused extra jitter in the servos, for some reason)...

I also tried using SoftwareServo, but the precision was not very good...

I'm this close to finish my project but at the risk of not being able to add wireless control.

So here I am, asking you people for help. I wonder... is it possible to change virtualwire library to use timer2? I don't know if this is possible since it is a 8bit timer...


Question, what pins are you using and have you looking into Bluetooth?

Bluetooth uses the Serial port pins 0 and 1, but if your not using the Serial port, then I would suggest you also not use the servo library. Take a look at this chip, HERE, it is a 23ch servo controller that uses the TX port on the Arduino. I have a 4ch controller myself, and using the example code that was provided with the chip, I was able to make a working library. If you want to use this chip, I will provide you with the library, and an example sketch.

I see that your almost done with your project, so its just an alternative.

I would prefer a software solution if avaiable.... But thanks for the suggestion.

The UNO can control 12 servos, but that means you won't be able to use virtual wire. If you go with Bluetooth, then you can do it with an UNO. However if you still what to use virtual wire, then I suggest you get a Mega.

That is if no one else can think of anything. There may be a way to do it with an UNO, but I wouldn't know how, sorry.

I actually managed to modify virtualwire to use timer2, with the help of FlexiTimer2 library. The only problem is that I had to greatly reduce the bitrate, because the greater the bitrate, the greater the number of timer overflows (which interrupt the normal flow of the program). Since servo library also uses timer overflows to run code , even thought it uses a different timer, there will be a lot of overall interruptions in the program.

So sometimes servo timer will interrupt virtualwire code and vice-versa... Causing the servos to jitter and the virtualwire to miss more messages (This is what I observed, the justification might be wrong but it seams to make sense). The solution is to greatly reduce the bitrate transmission with the obvious drawbacks.

Still, can you link me to one of these bluetooth modules you are talking about?

A lot of times, you can modify libraries to fit your needs, other times as you found out, they don't always work. I found that if a library is using timers, then there is a reason that particular timer was used, so I learned not to modify those parts of the code. Adding new functions are find but modifying timers will cause problems.

Here is the Bluetooth module, this is the most common one we usually tell people to get.

It's not that things stopped working... The modifications I did were successful. If my arduino had more processing power, even with the same number of timers, I think it would run perfectly fine. It's working right now, virtualwire and normal servo library... I just can't transmit a lot of orders per second...

The bluetooth module seems to be a good idea. However it is much more expensive... I need two of those modules right? so 12 euros in total with shipping costs included... Can I control it with an android phone with bluetooth (so I would only need one?) ?

Another question... does this module use any kind of timer? Cause in case it uses I'll have problems again.... :/

Thanks for your big help !

Edit: there seams to be much cheaper modules. What are the drawbacks? Shorter range?

No timers I know of, Bluetooth is serial, so you can test your code with the serial monitor and see if it gives you any problems. The serial monitor does take some processing time, but it should be fast enough to work.

Cheaper modules can have shorter ranges and even burnout if the proper voltage is not supplied.

I've been researching a bit and these modules can only act as a receiver, correct? So in order to send data to them, I can't use an arduino with another one... I need something with Bluetooth host capabilities like a phone or a laptop, right? (by the way, can you link me to any android application using bluetooth to send data to a module like this?)

No, they support two way communication but they only work when paired. So you can use two Arduinos and have them talk back and forth. You can have the servo arduino get commands from the controlling arduino and you can also talk directly with a computer using a terminal program like Putty or Realterm.

There are also simple android programs like Bluetooth Chat. I can't provide a link from my phone sorry.

Is this an option?

Yea, that will work great.