Arduino Servo Point Motor Control

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

  1. Keith M

    Keith M Staff Member Moderator

    Messages:
    3,654
    Likes Received:
    2,104
    Joined:
    Dec 16, 2015
    jakesdad13 wrote:
     
  2. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    Now looking on the web - where else these days, I found the DCC++ project

    https://github.com/DccPlusPlus/BaseStation/blob/master/README.md

    This uses an Arduino UNO or MEGA plus the Arduino motor shield to form the base station, in addition JMRI now has support for the DCC++ system. By using off the shelf shields no soldering is required, but does work out dearer than building your own.

    Communication between a PC and the Arduino is via a serial connection (USB port) or via blue tooth (provided a bluetooth adapter is fitted).

    JMRI would give an easy way of producing a mimic interface, and also routing.

    DCC++ also has its own software application, primarily aimed at running trains, but also can make a mimic panel and operate accessories.

    For those already having DCC, this be able to make a standalone programming track.

    I know you could use the MERG Command station kit, or a Sprog,

    Paul
     
  3. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Hi Keith I have the Lenz LZV100 with the LH90. I have also got the usb interface for it. Second hand job lot. It seems a good system except for the LH90. As I don't have a completed layout yet (I've just hung the N gauge on the wall) I seem to be using it to program engines and MERG accessories through JMRI Decoder pro which is good and running the odd train with the JMRI Throttles. The rest of the club I'm a member of seem to have gone Gaugemaster.How do you find it?Sadly more of an electronics hacker than a modeler so don't often finish a layout but maybe one day :lol:
    Col
     
  4. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Have just spent the best part of the day doing the same Paul, saw some of you postings trawling through the 'Dark Side'. :).Just about to down load the DCC++ and have a look at it. I have all the bits :oops: (sad man I really must get out more).Have a squint at this guy www.youtube.com/watch?v=qyKNKQ0msZQ I built the infrared throttle on his website
    Col
    Coffee time me thinks. Then get ready for belated B'Day bash with the Boys http://www.click I use the term Boys lightly.
     
  5. Keith M

    Keith M Staff Member Moderator

    Messages:
    3,654
    Likes Received:
    2,104
    Joined:
    Dec 16, 2015
    Hi Colin.
    I also have the LZV100 and the TR150 5amp transformer, all version 3.6 LZV and LH100's, plus the LH 90, which I bought to see if I preferred it to the pushbutton LH100's. I find the LH90 such a faff to use, although some folks prefer a rotary speed control to a stepping pushbutton one. As my loco decoders are all set to 128 speed steps, I much prefer the pushbutton setup, just as seamless speed control as the rotary type I think. Also got the USB interface, but never got around to using it yet, and like you, I bought all the Lenz stuff used, as it's pretty pricey new.
    Keith.
     
  6. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    I'm fairly sure (Paul may know more) but if you hook up to JMRI you can have several throttles up on screen with associated engine numbers and pictures on them. I'll visit it again soon and come back to you on that. Just bailed out of the shed too cold now :( off for a triple S then some beer and curry. YES!!
    Cheers Keith
    Col
     
  7. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    With JMRI, you can use either the throttles on the computer screen, or via the appropriate app (engine driver for android) use mobile phones as wireless throttles.

    They do work very well, and can have multiple throttles running on each device - I've found more than two locomotive throttles open on a device becomes awkward. The application also has access to the mimic panel, turnout tables and routing tables, so you can fully control your layout from a phone or tablet.

    JMRI support for DCC systems can be found here

    http://jmri.sourceforge.net/help/en/html/hardware/index.shtml

    MRC (Gaugemaster is a rebranded MRC system), have only recently released the specifications to allow the JMRI teams to develop support, so can have issues or features missing compared to other systems, but I'm sure will catch up. The same can also be said for DCC++ as it is a relatively new system, however being an open system has allowed developers complete access to the system and features / functionality are catching up with the other systems.

    And for what we are looking at is more than capable.

    Paul
     
  8. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    Back on track now......

    I think the DCC for DC topic should go on its own thread, so I will create one.

    A question no one asked was how do you know what to set the off and on angles to ?

    servos[1].address = 2;
    servos[1].outputPin = 13;
    servos[1].servo.attach(4);
    servos[1].offangle = 112;
    servos[1].onangle = 62;


    Well Ruud Boer comes to the rescue again.

    Within his Arduino_DCC_S88 download is a servo tune utility.

    Servo Tune v3.0
    Ruud Boer
    April 24, 2015

    Can tune one servo at a time.
    Uses 2 setpoints: min, max

    Use a wire or switches to make A0 - A3 LOW.

    A0 = select max angle setpoint, CCW (looking at axle)
    A1 = select min angle setpoint, CW (looking at axle)
    A2 = increase angle, CW
    A3 = decrease angle CCW


    So I will make up this one using an arduino UNO, as per Ruud's instructions.

    Paul
     
  9. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    Early on in this thread Reidy asked how do I know what to connect to the arduino.

    For Sketches / projects that are done correctly, the introduction should make all clear.

    As for this sketch - as normal Ruud does an excellant job.

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Ruud Boer April 24, 2015
    // DCC Servo Tune v3.0
    //
    // PURPOSE: Tune the angles of 2 setpopints of servos.
    // Values are shown on Serial Monitor to be (manually) transferred to DCC_Decoder_Servo.
    //
    // CONNECT THE SERVO TO PIN 3
    //
    // REMARK 1: when looking at the axle of the servo, CW = lowe angle values, CCW = higher angle values.
    //
    // REMARK 2: Timing for Servo, Setpoint and Print can be changed in lines 37,38,39.
    //
    // REMARK 3: To avoid servo movement which can give high current draw at startup,
    // first start the Arduino and after led blinked 5 times switch the servo power on.
    // Before power down, move the servo to setpoint 1 = CCWidle.
    //
    // OPERATION:
    // A0: Select setpoint 0 MAX angle, CCW (looking at axle)
    // A1: Select setpoint 1 MIN angle, CW (looking at axle)
    // A2: Increase angle of current Setpoint, CCW
    // A3: Decrease angle of current Setpoint. CW
    //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    From the above Pin D3 will connect to the servo signal wire (the +5V and 0V will connect direct to the 5V power supply with possibly an off/on switch added) & four switches will be required which will be connected Analog ports A0 to A3.

    The arduino will also be connected to a PC via its usb cable to display the values.

    These values will then need to be manually added to the servo controllers sketch and uploaded to the servo controllers arduino.

    Will post more later - my services are required by SWMBO and Spawn of SWMBO :avatar:

    Paul
     
  10. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    Ok

    In its basic form, all I needed to make this was

    1 x Arduino UNO
    1 x SG90 servo
    4 x jumper wires
    1 x USB cable connected to the PC running the Arduino software

    The sketch was loaded into the arduino via the usb cable, the cable is also providing the power supply - some PC usb ports may not be able to power the arduino and the servo, and a separate 5V power supply will be needed.

    [​IMG]

    Vin (white wire) is connected the positive wire for the servo.
    Gnd (black wire) is connected to the 0V or ground of the servo
    Gnd (grey wire) is used to insert in either A0, A1, A2 or A3 to act as a switch

    [​IMG]

    The orange wire is connected to D3 and the servo signal wire.

    On start up the sketch sets the servo to mid point.

    The serial monitor window needs to be started, which will also restart the sketch.

    The serial monitor will then output the current settings

    [​IMG]

    By connecting A0 to ground the sketch will make adjustments to max position

    then by connecting either A2 or A3 to ground will adjust the position either clockwise (A2) or anti-clockwise (A3).

    Once the final position is determined, connect A1 to ground to carry out the same for the min position.

    Even keeping the connection in the movement is slow so it is easy to get the setting correct.

    Simples

    [​IMG]

    Take note of the final settings and enter the values into the DCC_servo sketch.

    Paul
     
  11. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Thanks for that Paul, had seen the ref to the servo tuner but not been there yet. Looks like you don't have to build a unit but just use the wires as switches and then the Uno/Nano can be reused.Nicely explained. Cheers
    Col
     
  12. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    Hi Col

    My two current layouts - Victoria Road, and Gasworks layout, will only use 10 servo's between them, but as this circuit is so simple, I'm going to see what would be needed to complicate it up a bit :facepalm:

    Thinking of adding an lcd screen, switches and a battery for power to make a portable unit, well see........

    Paul
     
  13. Sandbar

    Sandbar Full Member

    Messages:
    108
    Likes Received:
    5
    Joined:
    Sep 18, 2016
    As mentioned, Dave Bodnar has a site that is worth a look. Mainly large scale but a lot of ideas can be used in smaller scales.

    http://davebodnar.com/

    Andrew
    Sandbar & Mudcrab Railway
     
  14. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    mmmm looks like I've got a bit of reading to do

    Thanks for the link

    Paul
     
  15. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Hi Andrew, the link I put into my earlier message is actually to Dave Bondar's latest DCC++ wireless throttle. The one I built was an earlier version with infra red control.He's into some very interesting stuff.http://www.youtube.com/watch?v=qyKNKQ0msZQThis is the link to his new video.Meanwhile I think I'll hide behind the couch and watch what Pauls coming up with next. He's worse than Dr Who.
    :eek:

    Col
     
  16. paul_l

    paul_l Staff Member Administrator

    Messages:
    7,324
    Likes Received:
    2,837
    Joined:
    Dec 5, 2015
    mmmmmm even better, well impressed.
     
  17. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    I Built it :avatar:
    OOps! will make the pics smaller
     
  18. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Pic 1

    Attached files [​IMG]
     
  19. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Pic 2

    Attached files [​IMG]
     
  20. Colin_W

    Colin_W Full Member

    Messages:
    177
    Likes Received:
    50
    Joined:
    Nov 19, 2016
    Pic 3

    Attached files [​IMG]
     

Share This Page