larryfraz 9 Posted October 20, 2012 Share Posted October 20, 2012 I put together a 2 oscillator PWM MIDI synthesizer based on NatureTM's (thanks!) 'simple synth'. No DAC is needed. The second oscillator can be detuned and has a blend control, both accessed via midi cc's. A clip of it, and the code, are on my site at the perspectivesound blog. I haven't added adsr, I may add some more features soon. bluehash, artifus, dacoffey and 1 other 4 Quote Link to post Share on other sites
bluehash 1,581 Posted October 20, 2012 Share Posted October 20, 2012 Thanks! and welcome to 43oh! Link fixed. larryfraz 1 Quote Link to post Share on other sites
larryfraz 9 Posted October 31, 2012 Author Share Posted October 31, 2012 I put up an updated demo, and will post new version code when done _L Quote Link to post Share on other sites
artifus 16 Posted October 31, 2012 Share Posted October 31, 2012 nice work! will be keeping an eye on this one. had a play with naturetm's simple synth a while ago - much fun. http://naturetm.com/?p=111 you mention stuck notes on your blog - i had some midi communication problems when i added an opto isolator, no problems at all without it, but also wanted to stick to midi spec: http://www.midi.org/...electrispec.php which is kinda vague, not for 3.3v and i couldn't source a 6n138 or pc900 so only had a 4n35 available. once i added the opto i had all sorts of problems, erratic response, stuck notes, etc. requiring frequent resets. i fiddled with resistor values on the msp side which improved it somewhat but with still the occasional glitch. adding an led on the midi side has cured it with flawless response and no stuck notes but i've no idea as to why - if anyone can explain it would be appreciated. i had been using the led to check for midi output as here: http://www.alfors.co...estKonektor.jpg and here: http://www.epanorama...s/miditest.html due to an intermittent fault in my midi cable and stumbled upon this 'solution' by accident. anyways, here's what i ended up with (note that the 1k resistor should be 1k47): i used two resistors, 1k and 47ohms in series, on the msp side. might be worth playing with. i look forward to trying out your code. other links i stumbled upon when trouble shooting: http://blog.gg8.se/w..._side_of_things http://www.gammon.co...connections.png larryfraz 1 Quote Link to post Share on other sites
RobG 1,892 Posted October 31, 2012 Share Posted October 31, 2012 (edited) MIDI current loop is 5mA, so 4N35 is not the best choice for MIDI application. On top of that, you have LED, which is in parallel with opto LED and resistor. If you want to see MIDI activity, connect your LED (with current limiting resistor) on the other side of opto. Edited November 10, 2012 by bluehash Removed external link larryfraz 1 Quote Link to post Share on other sites
artifus 16 Posted November 1, 2012 Share Posted November 1, 2012 hi rob - i hoped you'd chip in. either you have misunderstood my post or i am misunderstanding your response. 4n35 is all that was available. i found a work around. it worked. your schematic closely resembles my described solution. i don't understand what it is that you are recommending. please forgive my slowness. Quote Link to post Share on other sites
RobG 1,892 Posted November 1, 2012 Share Posted November 1, 2012 The schematic is exactly your solution, posted it to show the whole loop. I would expect more problems with that extra LED than without, so that is weird. Try removing that extra LED and replace 1k resistor with 270-330ohm. Are you using 2231? If not, try hardware UART instead of the software one. Quote Link to post Share on other sites
larryfraz 9 Posted November 1, 2012 Author Share Posted November 1, 2012 Ok-- posted my current code. Three osc now. Messy code, I know, but it leaves room for playing with, I hope! Quote Link to post Share on other sites
artifus 16 Posted November 2, 2012 Share Posted November 2, 2012 Ok-- posted my current code. Three osc now. Messy code, I know, but it leaves room for playing with, I hope! code link is borked. The schematic is exactly your solution, posted it to show the whole loop. I would expect more problems with that extra LED than without, so that is weird. Try removing that extra LED and replace 1k resistor with 270-330ohm. Are you using 2231? If not, try hardware UART instead of the software one. i agree it's weird but it worked - i've no idea why. tried various resistor values (from 10r to 10k) at the time, with and without the led after replacing the dodgy midi cable, and settled on 1k47r with led for the best response. yes, it's a 2231. it's not an issue - i'm just curious. *edit* forgot to mention - i said above that i had no problems without the opto but this was only true if powering the midi keyboard from usb, as was the msp - sharing ground from the one laptop i presume. all sorts of erratic behaviour if keyboard was powered from it's own psu. no such probs with opto. hope that all makes sense and helps - need sleep. Quote Link to post Share on other sites
RobG 1,892 Posted November 2, 2012 Share Posted November 2, 2012 If I had to guess, I would say that 2231's timing is off and the combination of LED/resistor affects the signal in a way that it is working correctly or almost correctly. Quote Link to post Share on other sites
artifus 16 Posted November 2, 2012 Share Posted November 2, 2012 quite possibly - i wasn't 100% on the dco calib having worked tho it seemed to pass the test... i'll check it out when i next break out the breadboard for some tinker time. i assumed the resistor value was due to the msp's 3.3v rather than midi spec'd 5v. but as i say it works, which is good enough for me. much fun thru lunetta style cmos circuits: http://electro-music.com/forum/forum-160.html Quote Link to post Share on other sites
larryfraz 9 Posted November 3, 2012 Author Share Posted November 3, 2012 Link should be fixed now ...I seem to have had better luck from my DAW than the kbd... artifus 1 Quote Link to post Share on other sites
larryfraz 9 Posted November 10, 2012 Author Share Posted November 10, 2012 I didn't have any luck with the diode and a V900 opto. I'm trying to get UART going, but the only valid data it sees is Ox80 ----note off. I may just be getting garbage, but thats the only valid control byte the prog sees! Any pointers to how to set that up right are very welcome. I am a noob, sorry if its too obvious. [quote]void uart_init(void) { uart_set_rx_isr_ptr(0L); P1SEL = RXD + TXD; P1SEL2 = RXD + TXD; UCA0CTL1 |= UCSSEL_2; // SMCLK==4mhz UCA0BR0 = 32; // DIVIDES SMCLK BY 128/16 = 31250 = MIDI SPEC w/UCOS16 oversample UCA0BR1 = 0; // UCA0MCTL = ~UCBRS0 + UCOS16;// + ~UC7BIT ; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST + ~UCMSB; // Initialize USCI state machine IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt }[/quote] Quote Link to post Share on other sites
RobG 1,892 Posted November 10, 2012 Share Posted November 10, 2012 Try this: P1SEL = RXD; P1SEL2 = RXD; UCA0CTL1 |= UCSSEL_2; UCA0BR0 = 0x80; 31.25k @ 4MHz UCA0BR1 = 0x00; UCA0CTL1 &= ~UCSWRST; IE2 |= UCA0RXIE; larryfraz 1 Quote Link to post Share on other sites
larryfraz 9 Posted November 10, 2012 Author Share Posted November 10, 2012 I made schoolboy mistakes...this is ok.(?) void uart_init(void) { uart_set_rx_isr_ptr(0L); P1SEL = RXD + TXD; P1SEL2 = RXD + TXD; UCA0CTL1 |= UCSSEL_2; // SMCLK==4mhz UCA0BR0 = 8; // DIVIDES SMCLK = 31250 = MIDI SPEC w/UCOS16 oversample UCA0BR1 = 0; // UCA0MCTL = UCBRS0 + UCOS16;// + ~UC7BIT ; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST;// + ~UCMSB; // Initialize USCI state machine IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.