Model Train controller - revisited


Results 1 to 33 of 33

Threaded View

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


    Did you find this post helpful? Yes | No

    Wink simple way ...

    Hi, Malc

    Try this:

    TEMP var WORD

    Main:

    ADCIN 0, DUTYVAR[0] ; if having more channels add ADCIN 2, DUTYVAR[2] etc

    TEMP = DUTYVAR[0] * DUTYVAR[0] / 256 '********************

    IF DUTYVAR[0] < 10 THEN ' 10 = value for a neat motor start , if needed !

    DUTYVAR[0] = 0
    GOTO Jump0

    ENDIF

    DUTYVAR[0] = TEMP MAX 10

    Jump0:


    ADCIN 1, DUTYVAR[1]

    TEMP = DUTYVAR[1] * DUTYVAR[1] / 256 '********************

    IF DUTYVAR[1] < 10 THEN ' 10 = value for a neat motor start ,if needed !


    DUTYVAR[1] = 0
    GOTO Jump1

    ENDIF

    DUTYVAR[1] = TEMP MAX 10

    Jump1:

    GOTO Main ; program simply loops round reading ADC and sending corresponding PWM out

    That what I use for my boat speed controllers ... works really fine !!!

    Regards
    Alain

    PS: here is the original

    '************************************************* *****************************
    'Mise à l'echelle 0 - 255 de la sortie PWM pour 0 - 96 % de la course
    '************************************************* *****************************

    ' 265 = 255 / 0.96 ... CQFD

    '************************************************* *****************************
    'Moteur Gauche
    '************************************************* *****************************

    EcartGazG = ( ABS ( PulsGazG - MidGaz)) ' for fwd/rev on the same stick

    IF EcartGazG < 55 THEN 'Center Deadband
    PowerG = 0
    GOTO MotD
    ENDIF

    dummy = EcartGazG * 265
    PowerG = DIV32 CourseGaz

    PowerG = (PowerG + 1 ) MIN 255 ' 255 value as MAXI for PWM

    '************************************************* *****************************
    'Variation exponentielle
    '************************************************* *****************************

    dummy = PowerG * PowerG
    PowerG = DIV32 255

    '************************************************* *****************************
    'Puissance mini appliquee au moteur - démarrage franc ( 20/255 )
    '************************************************* *****************************

    PowerG = PowerG MAX 20
    Last edited by Acetronics2; - 22nd April 2007 at 18:27.
    ************************************************** ***********************
    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. Graphics controller for the Sitronix ST7549
    By ttease in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th May 2007, 21:45
  4. Recommendations - Model Train Controller
    By malc-c in forum mel PIC BASIC Pro
    Replies: 101
    Last Post: - 8th March 2007, 08:17
  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