Sound3

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Here are my pins configurations!

Also for the data segments the two tables are what are needed, correct?

as for the key mask for the 4 push buttons, keymask = b'11110000' correct? (for my configuration of course!)

ima try breadboarding 4 leds and try lighting them with 4 button to see if it works.
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I wrote a quick code for 4 buttons and I tested it on breadboard using 4 leds...and it worked perfet! I am confident to use this routine in my sound3 project as I'll be using 4 buttons as well...

each button set an led on!

the half second delay is not needed...
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Again the same problem!!!

At 65 Hz...PR2 = 954 (too much for 8-bit register) at Fosc =4Mhz

Only safe at Fosc = 1Mhz with smaller freq 65Hz -> PR2 = 237.

How to solve this problem!!!:mad::( or does it mean that as Ima use PWM there's no othewr option but to work with 1Mhz?

will that !Mhz ok with the ADC??

thanks!
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Just wana make sure it makes sense!

Assuming the routine 'scrollup' is called everytime a button is pressed!

and should display note A to G and octave 2 to 5..so it goes like: A2, B2,...G2, A3, B3,..G3,...G5 and loop back!

thanks!
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
It looks about right.
Is there a reason you are using ABCDEFG instead of CDEFGAB? It's going to be a bit weird pressing the up button and the note sometimes going lower.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Well I think it should be in that order as written in requirement!...As long as they different sounds it ok I think!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
About this one!? this is for PWM!

This routine is called everytime a button is pressed to play a diffent sound!

there will be 3 tables pr2tab, ccp1contab and ccpr1ltab for PR2, CCP1CON and CCPR1L respectively! T2CON is the same for all frequency and will be put in the initialization!

thanks!
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
Fair enough. Have you managed to get anything displayed on the multiplexed SSD yet? You should probably check that works before making the program more complex.
 

Markd77

Joined Sep 7, 2009
2,806
About this one!? this is for PWM!

This routine is called everytime a button is pressed to play a diffent sound!

there will be 3 tables pr2tab, ccp1contab and ccpr1ltab for PR2, CCP1CON and CCPR1L respectively! T2CON is the same for all frequency and will be put in the initialization!

thanks!
Maybe, give it a try (or simulate :)). I can't see anything stopping the note, the PWM will just continue if not disabled.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Fair enough. Have you managed to get anything displayed on the multiplexed SSD yet? You should probably check that works before making the program more complex.
You are correct! that's why I am writing small routines for eveything then will combine them together! I know there are always ways of combining routines...with very small editing if need!

I tested the multiplexing...its ok...with a press for scrolling up...but have not tested my latest 'scrollup' routine I just posted!

But there is a problem I don't get!!! when the 2 SSD display the same character (note or octave) the display are ok! But when they different character on the two displays...some segment that should not be on are 'slightly' on...I have never seen that before!

I tried again using ONLY initial values of the SSD with different charaters..same problem! And I tried display '00' as initial display it worked ok!

What I mean is if I try displaying: 00, 44, 33, AA, BB...it ok

but for instance 23, B4 CD...(different character) --> not ok!

Will try figuring this out later unless someone can tell me what it might be...


thanks!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Maybe, give it a try (or simulate :)). I can't see anything stopping the note, the PWM will just continue if not disabled.

You are correct! But this little 'code editing' WILL stop the note!

you are smiling coz you know I don't like *simulating* ...lol

Now tell me if the note will still not be stopped from 'making noise' lol ?

thanks!
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Routine 'scrollup' edited ...have included indexes for PWM registers!

Hope it makes sense!

[edited] editing PWM registers on top!
 

Attachments

Last edited:

Markd77

Joined Sep 7, 2009
2,806
:) Correct!
I think the return on the second line means the sound won't stop or ever clear the half second flag.
Also spotted, I think you need to reload W with the note value for some of the table calls.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
:) Correct!
I think the return on the second line means the sound won't stop or ever clear the half second flag.
Yes! that what they mean! only after half second has elapsed it can be stopped and flag cleared! Any other bug with this routine?

Also spotted, I think you need to reload W with the note value for some of the table calls.
Guess you are talking about 'scrollup'..where W needs re-loading? will check but you can tell me!
 

Markd77

Joined Sep 7, 2009
2,806
But there is a problem I don't get!!! when the 2 SSD display the same character (note or octave) the display are ok! But when they different character on the two displays...some segment that should not be on are 'slightly' on...I have never seen that before!
Make sure the first digit transistor is turned off, then the segment port is changed, then the second digit transistor is turned on.
If that's correct then it's probably the transistors taking too long to switch. Try putting a resistor ten times the value of the base resistor to ground from the base (or to 5V if they are PNP).
If all else fails then the multiplexing frequency could be reduced.
 

Markd77

Joined Sep 7, 2009
2,806
Yes! that what they mean! only after half second has elapsed it can be stopped and flag cleared! Any other bug with this routine?
Not that I noticed.


Guess you are talking about 'scrollup'..where W needs re-loading? will check but you can tell me!
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
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Attached is the 'scrolldown' routine!

I tested both scrollup and scrolldown and they both logically work perfectly! but the problem is the multiplexing as adressed in post #31!

I tried posting the 'multiplexing 'code here but could not get the alignment right...so I attached it as well!

the problem is when either 'notes_dsp' or 'octaves_dsp' is used in both *notes_enable* and *octaves_enable*...the 2 SSDs display the same character and it perfect...But logicaly they can be the same...so when they different...the segments that should be on are really on and those that should not are slightl on...

Never experienced that and wasting time trying to figure this out!
 

Attachments

Top