Sound3

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Here are the few changes made on the multiplex routine and I Must say it went from 30% to 79%!

Im using common cathod with npn...and im using 1K Ohm resistor from base of transistor and the other resistor end goes to enable pin...

I tried putting 10K from base to ground (with that 1 k still connected ) but no change...

Guess I need to move on now...unless I can still improve on this!

thanks
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Not that I noticed.



Rich (BB code):
Presumably W contains the note number here
    call    pr2tab            ; get tone frequency 
          movwf    PR2            ;  
 
    bcf    STATUS,RP0        ; bank 0 
 W now contains the PR2 value, not the note number
    call    ccp1contab        ; configure CCP module as single output-P1A modulated 
          movwf     CCP1CON            ; 2 lsbs are '10' and P1A-P1D are all active 
 W now contains the CCP1CON value, not the note number
    call    ccpr1ltab        ;  
          movwf     CCPR1L            ; 50% duty cycle of PWM period

Yeah and I think it makes sense W here should not contain the 'note' number!!

every up/down press increments/decrements three indexes for the PR2, CCP1CON,CCPR1L....

OK I'll try comming up with all the PWM table and combine all the routine together!

then it will be the zerrrro cross routine :) to integrate!
 

Markd77

Joined Sep 7, 2009
2,806
This could be simplified
Rich (BB code):
        incf    en_cnt,f            ; increment en_cnt for next digit 
        movf    en_cnt,w            ; and copy to W 
 
        ; determine current en_cnt by successive subtraction 
 
        addlw   -1               
        skpnz                    ; if current en_cnt = 0 
        goto    notes_enable         ; display notes  
  
        clrf    en_cnt              ; else en_cnt = 1, so reset to 0 
        goto    octaves_enable         ; and display thousands digit
to something like this plus a line at the start of notes_enable and octaves_enable that set or clear the bit.
Rich (BB code):
        btfsc en_cnt, 0
        goto    notes_enable         ; display notes  
        goto    octaves_enable         ; and display thousands digit
You could move the switching on of the transistors to the next time multiplex gets called, by removing these lines:
bsf notes_enab ; enable notes display
bsf octaves_enab ; enable octaves display

and moving them to here:

Rich (BB code):
multiplex 
    btfsc en_cnt, 0
    bsf    notes_enab        ; enable notes display
    btfss en_cnt, 0
    bsf    octaves_enab        ; enable octaves display
     
    btfss    t4ms            ; 4ms elapsed?             
    return                ; get out if not time
Presumably "multiplex" gets called more often than 4ms and this would give the transistors time to switch off fully (PIC output pins switch much faster than the average transistor with a load).
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Ok! actually I knew that as Im dealing only with 2 SSD the best method is the one you described but as Im rushing...I just edited the my 4 SSDs routine to 2 SSDs..

I will edit the whole multiplex routine...right after Im done with the PWM register table!

thanks!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
These are all the tables that the program will have!!

will I have a 'page' problem? guess not! is it ok the way they are or should I add an 'org'..?

thanks!
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
Small tables like those, I usually put straight after the interrupt, then there is no danger of them crossing pages as the program grows. It also means I can usually leave PCLATH alone.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I guess there's No need to have 3 indexes (index_pr2, index_ccp1con, index_ccpr1l)
they can all be replaced by index_PWM. and this index will be used in the 3 tables, correct?
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Just to make sure that the few lines of code I added on top for both 'scrollup' and 'scrolldown' make sense!

What Im trying to do is that at each up/down button pressed the index of the PWM registers are also updated to match the note on the SSD

thanks!
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Attached is All the routines combined together! the main program is also shown!!

The first routine check first which mode is current then process the current one! Hope it makes sense! Please lemme know!

I think what is left now is to edit 'multiplex' routine as suggested and set system initialization!

thanks!
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
I'll have a proper look tomorrow. I think multiplex and key detection should be called from a regular interrupt, because the frequency detection could take a while. It would be around 1/4 second for 10 cycles at low frequency. Actual key processing would best be called from the main loop, when a flag is set from the key detection in the interrupt. That would avoid all that code happening in the middle of frequency detection.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I been fixing all syntax errors with MPLab...now it the initialization setting that need editing...will post the full code when done with initialization!

Thanks! Hope it works on Hardware too!!!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Attached is a piece of code doing zero cros ...trying to test it then if ok will combine this with the already working code!

I adding the multiplexing routine...but the multiplexing routine uses notes_dsp and octaves_dsp for the segments to be sent to PORT to display...

I am not sure how to integrate these two registers...coz it might detect but not display on the SSDs...

Hope it clear!
 

Attachments

Last edited:

Markd77

Joined Sep 7, 2009
2,806
I've spotted a few things:
There is nothing to set the t4ms flag, but it is better to get rid of the flag and call multiplex from the interrupt.
You don't need clrf INTCON at the start of measure_freq.
You need something to set up notes_dsp and octave_dsp
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Attachement in post #58 edited!!! but notes_dsp and octave_dsp not integrated yet!

looking gud now? actually I edited the wrong code!
 
Top