Recommendations - Model Train Controller


Results 1 to 40 of 102

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Malc,
    it's little bit more than rem ADCIN line. i'll place all the changes i made in RED

    Code:
    @	__CONFIG  _HS_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_OFF 
    
    
    	ANSEL = %00010111    			; - dt suggested value
    
    
    
    	DEFINE OSC 20
    	CMCON=7
    	TRISA=%11111111        			'set PORTA as all input 
    	TRISC=%00000001        			'set PORTC as all output apart from RC0
    
    	DEFINE ADC_BITS  8     			' ADCIN resolution  (Bits)
    	DEFINE ADC_CLOCK 2     			' ADC clock source  (Fosc/32)
    	DEFINE ADC_SAMPLEUS 11 			' ADC sampling time (uSec)
    
    	INCLUDE "DT_INTS-14.bas"            	; Base Interrupt System
    	INCLUDE "SPWM_INT.bas"              	; Software PWM module
    
    	DEFINE SPWM_FREQ  150                	; SPWM Frequency
    	DEFINE SPWM_RES   255               	; SPWM Resolution
    
    	DutyVar VAR byte[4]
    
    ASM
    SPWM_LIST  macro                    	        ; Define Pin's to use for SPWM
        SPWM_PIN  PORTC, 2, _DutyVar                ; and the associated DutyCycle variables
        SPWM_PIN  PORTC, 5, _DutyVar+1              ; Notice the underscore before variables
        SPWM_PIN  PORTC, 4, _DutyVar+2
        SPWM_PIN  PORTC, 3, _DutyVar+3
      endm
      SPWM_INIT  SPWM_LIST                  	; Initialize the Pins
    ENDASM
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  SPWMhandler,  ASM,  yes
        endm
        INT_CREATE                      	        ; Creates the interrupt processor
    ENDASM
    
    @ 	INT_ENABLE  TMR1_INT              	; enable Timer 1 interrupts
    
    	;_____________________________________________________________________________
    
    Main:                               
     	ADCIN 0, DUTYVAR[0]
     	ADCIN 1, DUTYVAR[1]
    	ADCIN 2, DUTYVAR[2]
     	ADCIN 4, DUTYVAR[3] 
     
    	GOTO Main
    Now for the noise, to me, as i'm not a motor pro, there's something normal in that. Your motor have a comfort zone in which he can operate. So if you're under that (let's call it threshold, lower possible voltage or else), for sure he will yell. It has to fight the inertia.. (OK OK probably not the right term... but it's how i understand )

    Now, is this louder using PWM or not? this is why i asked for a variable supply before.

    If it's better, we could still redesign the whole thing... same thing if you find a PWM frequency which reduce the noise.

    Time for few tests on your side... even if you use few battery in serie
    Last edited by mister_e; - 17th February 2007 at 20:56.
    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