Guest kostix Posted November 21, 2004 Report Posted November 21, 2004 Hello guys!well, recently i decided to try and build a midi controller, but starting from zero..what i wanted is to have 8 knobs, analog ones, and 3 seven segment delays per knob, to show the value2 additional displays to show which mode the box is in: if they're off, it means that actual midi value is sentif it display "Ch" then u can change the midi channel on the knob u turn, and the 3rd is "Cc", where u can change the controller number on the knob. the modes are changed when u press 2 buttons, one for channel another one for controller number. and there is a 3rd button available, which is "assign", when u r pressing "channel" button for example, hold it down , turn a knob to select its channel, and press "assign" , the midi channel will be assigned to the knob. same for cc.so i designed a board, with the 26 displays, driven by 3 latches (74HC373) and a little main board consisting of a 18F452 , running at 10mhz with 4x PLL option oni wrote the program on HiTech PIC C18the display is working great, i put it on the tmr0 interrupt. with the driver i wrote, i only have to fill an array with appropriate data and its displayed.using the 10bit adc, i connected the 8 pots to the pic directly. i'm using another interrupt to read the knobs, and when knob position has changed then send midi data.but i am having a BIG problem with jitteringto get a relatively stable value i have to do more than 64 samples averaging, which takes a lot of time, so i'm loosing the speed at which midi is sent.. therefor - resolution.i am wondering what could anyone suggest me to do to get rid of the jittering. i've been messing with this 5 days straight non stop, and still no luck :(what i have is a bidimentional array, one value holding knob index, the other the average indexi tried doing it all the possible waysfirst fill in all samples for knob 1, then average and if different than previous averaging, then send data. then go to next knobalso tried filling sample 1 for every knob, then sample 2 for every knob etc, and then averagestill no luckits too slowi've been considering the idea of writing this in assembler, but i have really little experience with it so i am not sure it will be in any way efficienter.how do people usually go in these situations ?i can imagine there are different ways of cleaning up an unstable signal, but i'm running out of ideas...any suggestion is welcomecheers Quote
TK. Posted November 21, 2004 Report Posted November 21, 2004 Hi Kostix,a simple solution (which I've used in MIOS) is to define a so called "deadband" in within a value change won't trigger a new (MIDI) event. Here the pseudo code (not tested, since the original one is written in assembler) if( abs(new_value-value) > deadband) { value = new_value; notify_value_change(); } (abs() returns the unsigned absolute value)of course, the penalty of this solution is a redocued effective resolution - on the other hand it doesn't produce additional delays and is very memory friendly (you only need to store the last sent value once...). A deadband of 1..3 is mostly sufficient, even when multiplexers are used on the analog inputsBest Regards, Thorsten. Quote
Guest kostix Posted November 22, 2004 Report Posted November 22, 2004 You are a life saver !I cannot believe how simple this is, and it works perfectly!At last it works, i was so desperate.my ADC reading interrupt now looks like this:// Take a sampleGODONE=1;while(GODONE) continue;// Divide the 10bit value by 4 to get 8bitsnewvalue[knob] = ((256*ADRESH)+ADRESL)>>2; // Check if different than oldif(abs(newvalue[knob] - oldvalue[knob]) > 1){ oldvalue[knob] = newvalue[knob]; finalvalue[knob] = newvalue[knob]>>1; Shift for 7bits newdataready[knob] = 1;}// Increment knob, select ADC Channelknob=(knob+1)&7; // Increment and rolloverselect_chan(knob);I can go on now and finish the rest of the coding, and build the box :)I have another question:my displays datasheet says that they support Forward Peak current of 150mA, and this is at duty cycle of 1:10.my design has 26 displays , 3 latches and 9 transistors to turn on the common anode, so basically i am lighting 3 displays at once. i believe this gives me a duty cycle of 1:9 moreless. How do I calculate the value of the segment resistors to use on the leds, to have maximum brightness , without damaging them in anyway ?Thorsten, you've been an inspiration to me over these years. Its great to see the progress you are achieving, and personally, this kind of work just pushes me to do something that i've always liked - the electronics.thanks for your help :)and keep up the good work!Cheers! Quote
Guest kostix Posted November 22, 2004 Report Posted November 22, 2004 btw, my display interrupt is on the tmr0 with 1:64 prescalerthis gives me 10000000/256/64 = ~610Hzso this lights 3 displays every 610 cycles Quote
TK. Posted November 22, 2004 Report Posted November 22, 2004 I fear that there is no simple formula to calculate the required resistor values for muliplexed LEDs, because the brightness has a non-linear curve which you maybe can read in a datasheet (if it exists...). So, just try out different values :)Best Regards, Thorsten. Quote
Guest kostix Posted November 22, 2004 Report Posted November 22, 2004 Hey, thanks for the quick reply!alright I'll experiment and see what is goodthe board is looking nice :)http://www.avantel.net/~kostix/display_pcb_finished.jpghttp://www.avantel.net/~kostix/display_pcb_finished_(bottom).jpgalso some pics of the 2 midibox plus i built (slightly outdated, i added an LCD to the wooden one, and on the metalic, i changed the front panel with one made out of 3mm wood, added the bank selector switches and 8 buttons)http://www.avantel.net/~kostix/box/sometimes the images wont open ok from the page, but try several times and they should appearThanks again ;) Quote
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.