Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/22/06 09:18
Read: times


 
#128405 - This Code Works !
Responding to: ???'s previous message
Dear Russell,

No harm done like mentioned earlier. It's water under the bridge, and life must go on.

I've attached a new set of codes which has produced the ultimate solution desired, since you was the kindest in giving a helping hand.

With this code, I've managed to get a linear ramp-up frequency which is fed into a panasonic servo amplifier. My only problem now is that the ramp is so steep & changing the number of pulses does not reduce the steep. This code is posted as soon result materialized. Now I'm looking at whats causing the steep ramp-up from 1Khz ~ 10Khz ( same even if frequency is higher )& which cannot be reduced despite attempt to increase the number of pulses per Khz.

MAIN:
        ACALL	PCA_INIT
        SJMP	$	             ; Only for testing

PCA_INIT: ;Initializa PCA Timer

        MOV     CMOD,#02H            ; Input to PCA Timer = 1/4 * Fosc
        MOV     CH,#00
        MOV     CL,#00
        MOV     CCAPM0,#04DH         ; HSO with Interrupt Enabled
        MOV     CCAP0L,#.LOW(1000)   ; Not sure what this does !!!!!
        MOV     CCAP0H,#.HIGH(1000)  ; Not sure what this does !!!!!
        CLR     P1.3
        SETB    EC                   ; Enable PCA Interrupt
        SETB    EA
        SETB    CR
        MOV     PULSE_COUNTER,#0     ; ACTUAL PULSES PRODUCED
        MOV     PULSES,#250          ; PULSES DESIRED
        MOV     A,PULSES
        MOV     B,#02H               ; PCA TIMESOUT EVERY 500us ( HOWEVER two 500uS timeouts makes 1 pulse )
        MUL     AB
        MOV     .LOW(PULSES),A
        MOV     .HIGH(PULSES),B      ; Now Pulse Counter Holds correct pulses needed
        MOV     TABLE_POINTER,#0
        RET

PCA_INTERRUPT:
        CLR     CCF0
CONT_INIT:
        PUSH    ACC
        PUSH    PSW
        PUSH    DPH
        PUSH    DPL
        PUSH    B
        MOV     A,TABLE_POINTER       ; POINT TO DESIRED FREQ VALUE
        CLR     C
        RL      A
        mov     dptr,#FREQ_TABLE
        movc    a,@a+dptr             ;get low byte
        mov     b,a                   ;save low into B
        mov     a,TABLE_POINTER
        clr     c
        rl      a
        inc     a                     ;+1
        movc    a,@a+dptr             ;get high byte
        CLR     EA
        ADD     A,CCAP0L              ; ----
        MOV     CCAP0L,A              ;     |
        MOV     A,B                   ;      > generated the actual pulse
        ADDC    A,CCAP0H              ;     |
        MOV     CCAP0H,A              ; ----
ISR_1:  DJNZ    PULSES,DONE
        INC     TABLE_POINTER         ; collect next freq
        MOV     A,TABLE_POINTER
        CJNE    A,#10,FREQ_RAMP
        SJMP    KILL_PCA              ; 10 FREQ REACHED - END OF FREQ TABLE, KILL PCA
FREQ_RAMP:
        MOV     PULSES,#250           ; PULSES DESIRED
        MOV     A,PULSES
        MOV     B,#02H                ; PCA TIMESOUT EVERY 500us ( HOWEVER two 500uS timeouts makes 1 pulse )
        MUL     AB
        MOV     .LOW(PULSES),A
        MOV     .HIGH(PULSES),B       ; Now Pulse Counter Holds correct pulses needed

        MOV     A,PULSES
        CJNE    A,#0,DONE
KILL_PCA:
        MOV     CCAPM0,#00H
DONE:
        INC     PULSE_COUNTER
BIT_HIGH:
        SETB    EA
        POP     B
        POP     DPL
        POP     DPH
        POP     PSW
        POP     ACC
        RETI


FREQ_TABLE:
        .DCW    3125,1563,1042,781, 625,521 ,446,391,343,313 ; 1 ~ 10Khz
;       .DCW    284,260,240,223,208,195,184,174,164,156      ; 11~ 20Khz
;	.DCW    142,136,130,125,120,116,112,108,104,101      ; 21~ 30KHZ

.aseg __data,data

.org 20H
TABLE_POINTER           .DSB
PULSES                  .DSB
GENERATOR               .DSB
PULSE_COUNTER           .DSB

.end



List of 41 messages in thread
TopicAuthorDate
PCA Problems            01/01/70 00:00      
   Problem or deisgn feature?            01/01/70 00:00      
      PCA upsetting Servo Ramp-up            01/01/70 00:00      
         How are you doing this?            01/01/70 00:00      
            more questions            01/01/70 00:00      
            How to connect Cool Edit            01/01/70 00:00      
               does not work            01/01/70 00:00      
                  Pulses generated ok            01/01/70 00:00      
            My Code            01/01/70 00:00      
               ther is your problem            01/01/70 00:00      
               Why are you...            01/01/70 00:00      
                  Assistance Please Russell            01/01/70 00:00      
               A suggestion            01/01/70 00:00      
   Minor Problem in Suggestion            01/01/70 00:00      
      I might have a guess            01/01/70 00:00      
      More comments            01/01/70 00:00      
         Thanks Eric n Russell            01/01/70 00:00      
            A two way street            01/01/70 00:00      
            Lost communication?            01/01/70 00:00      
            not a question of intelligence            01/01/70 00:00      
   This Code Works !            01/01/70 00:00      
      Much better with the comments!            01/01/70 00:00      
      explain a bit here            01/01/70 00:00      
      Moving in the positive            01/01/70 00:00      
         Russell you comment plz !            01/01/70 00:00      
            My comments            01/01/70 00:00      
               Guess you must be right !            01/01/70 00:00      
                  does not work !            01/01/70 00:00      
                     Make it work - thats your job!            01/01/70 00:00      
      Why disable interrupts            01/01/70 00:00      
         I thought the same about the interrupts            01/01/70 00:00      
      Cool Edit            01/01/70 00:00      
         re: Cool Edit            01/01/70 00:00      
            if not square waves - what did you get?            01/01/70 00:00      
               Cool Edit vs Digital Scope            01/01/70 00:00      
                  Cool edit            01/01/70 00:00      
                     Thank You !            01/01/70 00:00      
                     sample rates!!!            01/01/70 00:00      
   Will provide feedback            01/01/70 00:00      
   please help me about visisp52            01/01/70 00:00      
      discussed ad nauseam            01/01/70 00:00      

Back to Subject List