This module cannot manage frog polarization, if you need that use Peter Giling boards. But just to move servos, is a great and cheap solution. It's possible to adjust the movement and speed of each of the 8 servos. And the module sends back 8 feedback signals for the software to know when the servo movement has finished and can allow move a train on it. Many servo modules that you can find in the market cannot be used with slow movement because trains are released before reaching the end position and provoques short circuits or derailments.
Configuration is very easy, using the GCA50 configuration screen of Rocrail. It has an special tab for servo adjustment.
So, let's go for the shopping list:
An Arduino UNO:
A Loconet shield GCA185:
And finally a Sensor Shield V5. This is just to make the connection of servos easy:
Sketch is using pins 2,3,4,5,6,9,10 and 11 to connect servos. Pin 13, connected to the on board led, is also reserved and will be activated during a servo movement.
You can download the last version of the sketch (software) for Arduino from the ClubNCaldes github repository:
This sketch is using the ServoTimer2 library. This is a special library developed by Michael Margolis not using the internal Timer1 of Arduino as this timer is already in use by the Loconet libraries and wouldn't work. I had to fix the code to make it work with the last version of the Arduino environment and you can find also this fixed library in the code repository with the sketch.
Once uploaded, you can configure it going to GCA50 configuration screen in Rocrail, under "Programming" menu. In this screen go to Addresses tab and click the Query button. By default sketch is configured with the 81/1 identification, and it should be shown in the screen. It's recommended to change first of all this address to any other number. You can change it in the general tab.
Going to the Easy Setup tab you can read the board configuration clicking the button Get All. The first 8 ports must be configured as output and assign an output number for each of the 8 servos. The last 8 ports, from 9 to 16, are the input numbers assigned to the feedback signal of each servo. You can use the same number for the input as assigned to the output. In Loconet input numbering is independent from the outputs:
Click the Set All button to write configuration into the board. The last tab labelled Servo is used to adjust the movement and speed of each servo:
Select which of the 8 ports (=servos) are you configuring. Each of the two positions have a range from 1 (equivalent to 0 degrees) to 127 (equivalent to 180 degrees). "V" is the speed of movement, being 0 the slowest and 5 the fastest. Each time you press the Set button configuration will be stored and servo will move one side and the other at the selected speed.
Current to feed arduino and servos is taken directly from Loconet, but you can feed also the sensor shield with an external 5V power supply removing the jumper in the sensor shield board.
Here you can see it in action. I hope you like it:
Ya tengo dos módulos de servo funcionando y doy fe que el sistema funciona perfectamente.
ReplyDeleteHi Dani, I am looking to operate a pair of railway crossing barriers ( not gates) using servos connected to the Adruino mega and a shield. What can you suggest.
ReplyDeleteHi Savio, I'm not sure if the sketch can work directly in Arduino Mega... I never tested it. If not you can always take an Arduino UNO and use the sketch I did, it will work perfect as you can adjust the movement and speed of each of the servos independently.
DeleteHello, I updated the post as I uploaded the code to my GitHub repository. It includes also the needed libraries to make it work. Just follow the link in the edited post. In the same link you will always find the last version of the code, and there you can also report bugs or suggest improvements.
ReplyDelete