Recommendations - Model Train Controller


Closed Thread
Results 1 to 40 of 102

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    The 12F675 can run 4mhz on the internal clock. You should be able to easy incorporate the TMR0 interrupt and make a software PWM output that'll run at 3.9khz (which should be plenty high enough) and use the A/D input to set the duty cycle on that PWM. ... Are you familiar with doing software PWM based on interrupts?
    I'd be interested to know how you could do that.
    And since Malcolm was attempting to use MY software PWM routines based on interrupts, I guess you could say I'm familiar with them.

    Let's see, 4 channels @ 3.9khz with 8-bit resolution.

    That'll take (3900 *256) = 998,400 interrupts per second.
    With a PIC running at 4mhz, it'll execute 1,000,000 intructions per second.
    That leaves, 1.0016... instructions per interrupt.

    You wouldn't have a code example for that would you?
    <br>
    DT

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I'd be interested to know how you could do that.
    And since Malcolm was attempting to use MY software PWM routines based on interrupts, I guess you could say I'm familiar with them.

    Let's see, 4 channels @ 3.9khz with 8-bit resolution.

    That'll take (3900 *256) = 998,400 interrupts per second.
    With a PIC running at 4mhz, it'll execute 1,000,000 intructions per second.
    That leaves, 1.0016... instructions per interrupt.

    You wouldn't have a code example for that would you?
    <br>
    Well, yes, I've seen your PWM routines, and fine routines they are, as are most of possibly 100% of the items you post...........ppppfffffffttttttt (that's me fizzling out)

    AND I had a brain fart! I had a whole paragraph typed out explaining my position when I realized I forgot the final divide by 256 for the software PWM. Yep, 15.25hz is about the top for 4mhz. That is unless you start sacrificing resolution for speed...but it still doesn't get you up into the khz range, which is what I did to get a 4khz PWM signal in the blower motor project...then again, I only needed slow, fast and a few speeds in between for that one.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    skimask,

    Aw rat's, gave you a chance, but you missed it.

    You were supposed to say "BAM".

    Bit Angle Modulation.

    For devices that rely on the "Average Current" resulting from a PWM signal, the PWM signal doesn't need to be exactly symmetrical waveforms based on consecutive ON and OFF cycles.

    With BAM, you only need 8 interrupts per cycle. Each time period is "weighted" by it's bit position in the DutyCycle variable.

    This way, you could turn every pin on a PIC18F8720 (all 67 of them) into PWM (BAM) outputs (at pretty high frequencies).

    And of course, with DT_INTS, it's a piece of cake.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Malc

    Some more food for your brain :

    http://www.manhattancontrols.com/for...wtopic.php?t=4

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  5. #5
    Join Date
    Jan 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Red face

    Why not talk to a PIC in the module using I2C?? After all, the track is two wires.

    You could modulate this on top of a standing DC voltage then control a motor using hard coded addresses on the loco module PCB and an H bridge driven by the PWM from the PIC.

    Just a thought. I tried it and it worked fine. Be careful of the need to filter the I2C signals HEAVILY but not so much that you lose them.

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


    Did you find this post helpful? Yes | No

    Default

    Interesting concept, sort of a cross between modern DCC and traditional control. However, its not practical in this instance as the contoller is for a club layout and would mean that every member would have to have the same system installed on their own layaouts at home. Also with the scale, fiting modules to small loco's is a pain in the ***

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


    Did you find this post helpful? Yes | No

    Wink Food for Brain ...

    Hi Malc,

    I Had my father home this week-end ...

    We talked about supplies and it seems the today's "must" is to use switching supply during speed transitions ( or accelerations ) and DC during constant speed running ( of course for noize !!! ) ...

    That meets one of Sougata's threads about signal generation with a Pic ... and opens interesting reflexion and work about what output stage to use !!!

    new challenge for Darrel !!! ( He Looooooves !!!! )

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

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