Arduino Forum

Topics => Robotics => Topic started by: Bob_McNair on Mar 20, 2018, 08:04 pm

Title: Servos and software serial
Post by: Bob_McNair on Mar 20, 2018, 08:04 pm
Hi All, I wonder if anyone can help.
Ive googled a lot and not really found anything helpful.
Im working on a project where I need to use HC12 radio modules to control Servos.
Thje problem is that software serial libraries and Servo libraries appear to clash as many threads I have found on Google confirm.
I have a servo library (Servo2) which is supposed to cure this, it doesent.
Ive tried NeoSWSerial as well as SoftwareSerial neither work together.
Depending where in the main loop the code is, either Servo will work or SW serial but never both.
Does anyone have a solution to this as wireless is the only option and this needs SW Serial to talk to the HC12.

Thanks in advance

Bob
Title: Re: Servos and software serial
Post by: Bob_McNair on Mar 20, 2018, 09:35 pm
Hi All,
Problem solved.
Ive ditched using the now old hat Uno.
Im using a Mega for development and will use a Leonardo in my project, which has a second hardware serial port.
So no need for the crappy Software serial.
I will make sure anymore Duinos I buy use the newer 32U4 chip with a spare serial port for radio devices!!!
Better buy a few in for my development work.

Cheers
Bob
Title: Re: Servos and software serial
Post by: cod65 on Apr 10, 2018, 09:15 am
hmm ,
maybe this is why my life with Arduinos and controlling servos over serial  has been so horrible!?

I've been trying to use an Uno i had around  mostly, wondering if the usb serial was a bottleneck ?
I'm fairly noob I don't fully understand but ....Uno only has 1 serial port, correct? and that is thru usb? Whereas a Leonardo has an additional hardware serial port ? is this more apropos for realtime control of servos from a PC?

Title: Re: Servos and software serial
Post by: slipstick on Apr 10, 2018, 10:07 am
Servos don't use Serial. It's just that the Servo library and SoftwareSerial use the same timer. For most people using ServoTimer2 library solves that. No idea why it didn't for the OP.

If you need several different serial connections then something other that the UNO/Nano (ATmega328P boards) may be better but controlling servos doesn't have a lot to do with it.

Steve
Title: Re: Servos and software serial
Post by: cod65 on Apr 10, 2018, 03:06 pm
ah ok. i think i should probably start my own thread with my code.