Recommendations - Model Train Controller


Closed Thread
Results 1 to 40 of 102

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Recommendations - Model Train Controller

    Hi guys and gals,

    Just want to pick your brains over a project I'm looking at starting. I want to build a controller for a club layout and thought that I could use a PIC rather than traditional descrete components.

    The controler will initially have direct control (ie no simulated coasting and breaking), so I thought of two possible ways the PIC could be used, and wondered if you had any comments.

    The first is to use A/D to read the voltage on one pin, and then output a DC voltage to a FET / power transistor to drive the motor from a 12v supply.

    The second uses the same A/D to read the voltage on a pin, but the output is PWM (or more exact PPM), which is then used to drive the FET or power transistor in the same way.

    The reason I wanted to use a PIC was to add things later such as auto station stops (triggere by a sensor on the track) and simulated inetia, and programming the pick to to that might be better than loads of high value capacitors and the like

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Hi guys and gals,

    Just want to pick your brains over a project I'm looking at starting. I want to build a controller for a club layout and thought that I could use a PIC rather than traditional descrete components.

    The controler will initially have direct control (ie no simulated coasting and breaking), so I thought of two possible ways the PIC could be used, and wondered if you had any comments.

    The first is to use A/D to read the voltage on one pin, and then output a DC voltage to a FET / power transistor to drive the motor from a 12v supply.

    The second uses the same A/D to read the voltage on a pin, but the output is PWM (or more exact PPM), which is then used to drive the FET or power transistor in the same way.

    The reason I wanted to use a PIC was to add things later such as auto station stops (triggere by a sensor on the track) and simulated inetia, and programming the pick to to that might be better than loads of high value capacitors and the like
    Not 100% sure what it's called, but have you ever heard of DMC control (again, not sure what it really is)?
    As far as I know, you put DC power to the track, superimpose a digital HF signal over the top of the DC power (AC riding on DC). Each 'unit' has a receiver waiting for some sort of encoded sequence, whatever. 1000 different ways of doing it I suppose. Not sure how I'd do it if I had to. Maybe even IR LEDs spaced out everywhere along the track and IR detectors in each 'unit' to detect various codes and commands...

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the input

    Yes I'm awear of the "digital revolution" that is now appearing in the model railway world, however its not a possibility here for several reasons.

    1) - its a club layout, so we need to use "traditional" controllers so that members can run their own locos, and most don't use DMC

    2) - we're modelling in N gauge, and most of the modules are too large to fit is the intended stock

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Thanks for the input

    Yes I'm awear of the "digital revolution" that is now appearing in the model railway world, however its not a possibility here for several reasons.

    1) - its a club layout, so we need to use "traditional" controllers so that members can run their own locos, and most don't use DMC

    2) - we're modelling in N gauge, and most of the modules are too large to fit is the intended stock
    So, you have member A, with his regular ol' analog controller (big transformer, big pot, reversing switch, etc) running his loco on the same length (electrically and physically) of track (only for arguments sake) as member B who has his own controller and his own loco...

    And you want them to be able to control their 2 loco's independently...using those same controllers so the members don't have to go out and buy completely new stuff, but instead add new stuff to the output of their old stuff to make their old things do new things...

    And be able to fit these controllers inside an N gauge loco...

    Woof! Ya don't ask for much do ya

    Or have I missed something...(I probably have). I've got a few ideas (as I'm sure others do), but each one of them would require some sort of PCB to be added to each loco so it could decode what it needs to do. A small PIC based decoder with a MOSFET using bidirectional PWM drive shouldn't take up that much space (maybe 1 or 2 sq.inches. at most). I've got a 3 channel driver board that'll handle a few amps on each channel, has a 16F628A onboard along with a few other things and it's almost small enough to fit inside an N gauge loco. Take off those 'other things', redesign the board and it should fit...but again, I've probably missed something...

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post

    Or have I missed something...(I probably have).
    - yeah you've gone a little off the rails

    So, you have member A, with his regular ol' analog controller (big transformer, big pot, reversing switch, etc) running his loco on the same length (electrically and physically) of track (only for arguments sake) as member B who has his own controller and his own loco...
    No - the member will not be asked to bring their own controllers. The idea is that the club layout will have its own control panel with its own controllers, and as 96% of the membership don't have DCC type control the decision was taken to build "traditional" means of control so that on a club night any member can bring their own locos along and "play trains"

    As we need the option to control four trains at one time, I thought that the use of a PIC could reduce the amount of descrete components required (or use 2 pics if there aren't any that have 4 A/D ports - have yet to check the Microchip site) - especially when the controller gets developed a stage further and we build in delays to represent coasting, and simulated acceleration.

    Hope that makes it clearer

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink Good Engineering Exercise

    Hi, Malc

    Here you have THE Thing you look for ...

    just to translate from "Old" logical circuits to PIC ...

    All functions to program are clearly shown.

    Alain
    Attached Images Attached Images
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink The next step ...

    Hi, Malc

    When your 1 Channel PWM will work ...

    Have a look there, then :

    http://www.pbpgroup.com/modules/wfse...p?articleid=12

    for implementing the 4 Channels ...

    Alain
    Last edited by Acetronics2; - 11th February 2007 at 11:17.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the link, and really interesting site.

    I'm going to browse the forum to sort out my basic config problems ( Its often months between projects and I forget how to do the simple stuff ) That was the one thing I liked about JAL, you simply added something like #include 16F628a.inc at the start of the code and that took care of all the config settings.

    Thanks guys for your input - much head scratching to do !

  9. #9
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Ok I now realise where I went wrong.. since I last used PBP I re-built the PC and thus the changes made to the 16F628a inc file had been lost.. I followed Steves advice and now have a working device..sorta !

    Just need to tweek the scale so that I get a full duty cycle from 0 to 255

  10. #10
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Change of tactics

    Ok I got nowhere with that POT command, so jump in the deep end and try using ADC.

    I've used a 12F675 with the following code. As I've never used ADC before and still find datasheets confusing I just cut and pasted examples from the PBP manual for ADC.

    Code:
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
    
    TRISIO.2 = 0   'Set GPIO.2 to output.
    ANSEL.2 = 0    'Set GPIO.2 to digital		
    GPIO.0 = 1      'gpio.0 set to input
    VRCON = 0        ' Voltage reference disabled
    OPTION_REG.7 =    0
    
    DEFINE ADC_BITS 8	' Set number of bits in result
    DEFINE ADC_CLOCK 3	' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50	' Set sampling time in microseconds
    
    led var GPIO.2
    i var byte
    D var byte
    
    main:
    ADCIN 0, D                                   
        Pwm GPIO.2,D,1
    goto main
    To my suprise, the code compiled and works, well sort off !

    using a 10K pot connected between +5v and GND with the wiper connected to GPIO 0, my DVM reads between +0.14v and +5 on GPIO 2 when the pot is turned through its range - connecting an LED to GPIO 2 confirms that something is working as its brightness can be controlled via the POT... so far so good

    I then tested the FET by connecting a 10K pot between gnd and +5v with the wiper going to the gate, the track between +12v and FET and the FET to GND. Adjusting the pot produced some degree of control over a loco... so I moved the link from the pots wiper and connected it to GPIO 2. However the DVM reads the same vdd of the 12v rail regardless of the setting of the POT.

    I can only assume that its something to do with the PWM output from the PIC that is turning on the FET continiously ?? anyone have any suggestions ?? Can a PIC have DAC so I could convert the resulting digital value to a voltage that would be used to drive the FET (or whatever output stage I use).

    I want to stick with a PIC for the control as it would be easier to use simple for next loops / or counters for programmable stops, acceleration, etc

    Comments welcome as always

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i think it's more a matter how this PWM function is made...i'll do some test here first. How many different channel you need?
    Which other PIC you have on hand?
    Last edited by mister_e; - 11th February 2007 at 16:41.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Microstepper controller
    By aratti in forum Schematics
    Replies: 14
    Last Post: - 3rd January 2015, 16:52
  2. problem with the GSM controller
    By Dariolo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th May 2009, 20:33
  3. Replies: 2
    Last Post: - 14th July 2008, 22:11
  4. Model Train controller - revisited
    By malc-c in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 8th May 2007, 09:40
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts