Arduino Servo Point Motor Control

Discussion in 'Other Electronic Interfaces' started by paul_l, Nov 19, 2016.

  1. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    Hi

    This is more of a starter post, as mentioned in my Victoria Road thread, I am going to change my seep point motors for servo operated point motors.

    The system I will be usuing is the MERG mounting kits and TowerPro SG90 servos, with an Arduino controlling the servo's.

    The circuit board will be in three variants, an analog version (using switches to control the servo's), a DCC version and a DCC version with additional local switches - I hope :scratchchin:

    My first port of call for any arduino based model railway based project is rudysmodelrailway site

    https://rudysmodelrailway.wordpress.com/

    and in particular his software area - the danger for me is I can loose days wandering around this amazing site - thanks Rudy for all your work.

    https://rudysmodelrailway.wordpress.com/software/

    Rudy has clubbed together into 1 zip file his arduino projects for DCC, so I downloaded his latest version, as it contains arduino servo sketches for dcc - a sketch is an arduino program.

    Rudy's sketches are well documented and are an excellant example of how they should be written, as if a bodger like me can understand them, and alter them to suit the application I want then the "jobs a good un".

    Why three variants, well although I may not build all three, it's the DCC version I want, I thought it would be interesting to see how difficult it would be to create an analog, dcc and hybrid solution, which may result in one common module at the end of this journey, that the builder can decide on which bits to use.

    When I'm building a project from scratch I usually use my Arduino Uno (on the right below) and a breadboard, as this allows easy linking of components, the final unit ends up using an Arduino Nano (on the left)

    [​IMG]

    The Uno is an original Arduino board that cost approx £20, the Nano is a Chinese Clone that cost mee approx £15 for 10. The two are very similar, and only require you to change the target device type when you upload the sketch (program) to the arduino.

    So lets define my project - Viccy Road has 6 points on the lift out section

    I need the controller to be able to operate 6 servo's minimum, but 8 may be better.

    Each servo to have its own DCC address - rather than setting the first address, and the remaining addresses are incremented from the first - note some dcc systems may require the numbers to be consecutive, my NCE PowerCab doesn't.

    The end positions need be able to be set.

    A manual control option for either analog operation or testing.

    Some form of position indication would be nice - although not essential.

    DCC input - electrically isolated from the arduino

    Arduino to be powered from its own DC power supply - 5V direct, but an option for 9 - 12V DC supply with a voltage regulator to drop the voltage down to 5V, in case of long distances from the 5V supply there could be a voltage drop.

    Ok now its time for me to do a bit of reading / doodling to get the first bits down.

    Looking forward to any comments or suggestions

    Paul
     
  2. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    For those brave enough to read further, and maybe even give it a go here's a list of what I'll be using - note this list will change as I find out bits I need to add because I missed them :facepalm:

    First up for design and programming - both these applications are open source and free

    A PC (Windows, Linux or Apple), with the Arduino software package installed.

    https://www.arduino.cc/

    Look in the software section

    Fritzing - circuit design software

    http://fritzing.org/home/

    Hardware

    For development, a breadboard is handy and can have either a nano plugged in directly or an uno linked in with wire jumpers

    But for the final version I will need

    Arduino Nano

    Ebay is a great source for these, but are available from many other places

    Stripboard - 24 strips x 37 columns

    Female header strips

    A selection of 1K resistors, 1N4148 diodes and a 6N137 opto-isolator and solid wire to form wire links

    And will be based around the Arduino accessory decoder I've already got working for both the traverser controller and a standard accy decoder.

    The Fritzing diagram below shows the layout for a 10 output DCC accesry decoder

    [​IMG]

    Paul
     
  3. Toto

    Toto I'm best ignored Staff Member Founder Administrator

    Messages:
    15,419
    Likes Received:
    3,842
    Joined:
    Dec 5, 2017
    Ooooops looks like I've wandered onto the wrong forum ..... This ain't Lego.

    :facepalm:
     
  4. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    pretty close its all based on building blocks, and your home for the week is ........
     
  5. Toto

    Toto I'm best ignored Staff Member Founder Administrator

    Messages:
    15,419
    Likes Received:
    3,842
    Joined:
    Dec 5, 2017
    Edinburgh, unless someone of greater vision decides it's Limerick or Dublin.
     
  6. Colin_W

    Colin_W Full Member

    Messages:
    230
    Likes Received:
    95
    Joined:
    Nov 19, 2016
    Ok Paul, I have all the bits kicking round ( may have to shovel a bit to find an opto isolator) so I may try and follow you on this one. I'll download Rudy's libraries to the box in the shed when I get it above freezing in there. Soldering iron was at max this morning and really struggling. I'll knock up the pcb in the morning.
    Colin
     
  7. Colin_W

    Colin_W Full Member

    Messages:
    230
    Likes Received:
    95
    Joined:
    Nov 19, 2016
    Hi Paul I have downloaded and installed Rudy's zip file and all seemed well until I updated the Arduino interface. The program would not accept the libraries for the S88. I tried several times and variations of adding the library but to no avail and eventually reverted to Aduino 1.6.4 and it worked fine. Tried 1.6.8 - 1.6.12 all failed. Have you hit this problem before?
    Colin
     
  8. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    Hi Colin

    Not had any problems yet - but just checked and I'm using 1.6.5 :whatever:, I may have to upgrade. but maybe not just yet :scratchchin:

    Not made much progress over the last week, both Morag and myself have been struggling with a stomach bug and the cold.

    Maybe get the fritzing diagram done over the weekend.

    Paul
     
  9. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    A bit of progress

    Based on my DCC accy decoder

    [​IMG]

    The DCC in works great, and uses a 6N137 opto isolator, a diode and a three resistors, feeding the resulting signal into D2 on the arduino.

    To operate upto 10 servos, D3 to D12 will be used as outputs providing the PWM signal to control the servos.

    The wire coding on the TowerPro SG90 servos is as follows.
    [​IMG]

    With a bit of juggling of comp[onent positions we get version 1

    [​IMG]

    This will not be the final circuit, as several posters on the internet, have said that the servo's tend to glitch while the arduino is booting as there is no signal on the output pins, so to get around this I intend to use a power transistor or a FET, to switch on the power to the servos after the Arduino has finished the bootstrap process.

    Paul
     
  10. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    and the same version without the arduino in place

    [​IMG]

    When the accessory is thrown, the output will change from the current setting (ie min position) to the other setting (ie max position) or vice versa

    The male connectors along the bottom, will have the servo's pluggted into them.

    Paul
     
  11. Colin_W

    Colin_W Full Member

    Messages:
    230
    Likes Received:
    95
    Joined:
    Nov 19, 2016
    This is getting interesting Paul, had to head to deepest Clachmananshire over the weekend,heading back north today (Wednesday). I'll wait until you have the final PCB layout then build it. Out of interest did you use all 1k's ? I think :hammer: the diagram on Rudy's page shows 2 x 10k pullups.
    Colin
    PS auto text thinks I'm a colon, could be right :faint:
     
  12. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    Ordered up some MOS FET's last night - never used them before, so this should be interesting, but should provide the anti-clitch solution.

    The following diagram was found on tinternet - using an Arduino uno, but the principle is the same

    [​IMG]

    With an N channel MosFET you are controlling the path to ground.

    The output (pin 3) is connected to the gate connection on the FET, the 10K resistor is a pull down resistor to stop the output floating during boot. Once the arduino boots pin 3 is made high, this makes the gate connection and allows current flow across the Drain and Source pins.

    I may have ordered the wrong FET's as these need 10V or more to act only as a switch, so below 10V will dissapate heat and over heat and die :eek:

    They will be ok to use as 12V switches thogh so not a waste, but to overcome the mistake a few extra bits may be used.

    Paul
     
  13. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    The MOS FETs I ordered were IRFZ44 - these need the 10V to act as a switch, the IRLZ44 - note the important L for logic level - who knew :whatever:, these will act as a switch at +3V TTL logic levels so will work fine with an Arduino or Raspberry Pi.

    20 ordered from China for £6.70 inc p&p, just got to wait a while for them.

    So will have a go at a fudge until the proper ones arrive.

    Paul
     
  14. Toto

    Toto I'm best ignored Staff Member Founder Administrator

    Messages:
    15,419
    Likes Received:
    3,842
    Joined:
    Dec 5, 2017
    I take it this is the retro fit for Viccie Road ?
     
  15. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    Yep - Viccy Rd will only need 6 servos, but I may as well build the board capable of supporting 10 servo's, as proof of concept, and you never know there could be signals, after all I do have a signal box :whatever:

    Paul
     
  16. Toto

    Toto I'm best ignored Staff Member Founder Administrator

    Messages:
    15,419
    Likes Received:
    3,842
    Joined:
    Dec 5, 2017
    You can get your gantry on the go then. May as well tackle the automation whilst your at it. :avatar: now, that would make for a more relaxed exhibition.:thumbs:
     
  17. jakesdad13

    jakesdad13 Staff Member Moderator

    Messages:
    4,535
    Likes Received:
    2,071
    Joined:
    Dec 14, 2015
    I,m gobsmacked, I normally go into coma mode when electronics are discussed, but I,ve just reread the whole post and I think I understood half of it :eek::eek:.

    Pete. :avatar:
     
  18. paul_l

    paul_l Staff Member Administrator

    Messages:
    9,848
    Likes Received:
    5,902
    Joined:
    Dec 5, 2015
    So Pete, are you going to give a try then :avatar:
     
  19. Keith M

    Keith M Staff Member Moderator

    Messages:
    4,446
    Likes Received:
    2,902
    Joined:
    Dec 16, 2015
    Maybe another MERG member in waiting?????:avatar:

    Keith.
     
  20. jakesdad13

    jakesdad13 Staff Member Moderator

    Messages:
    4,535
    Likes Received:
    2,071
    Joined:
    Dec 14, 2015
    Nahh, I,m still just getting the hang of DCC without complicating matters with electronics and servos :eek:.

    Pete.
     

Share This Page