eufex Posted April 28, 2012 Report Share Posted April 28, 2012 (edited) After quite a while from looking at midibox I'm back making a new project. I hope this is in the right section because this time it isn't a HUI but a B4/ VB3 type controller. I see things have changed quite a lot since I biult my boxes on the PIC platform and due to the number of analogue inputs needed (I@m using genuine hammond drawbars) I'm considering going the MIOS 32 route. Anyway, my question is this, w.r.t organ rocker switches (i.e. they latch on and off) and position switches (6 position vibrato chorus selector and 3 position leslie switch). Now I know from when I created my midiboxes before that DINs only work with momentary switches so my thought is that for latching switches I need to measure voltage and therefore use analogue inputs - now 1 switch on one AIN should be easy - 5v = on 0v = off. My question is this, I think it should be do-able but maybe someone else could confirm it? For a 6 position switch (or a 3 position switch...or 4 x rocker tabs with a resistor matrix for percussion) could I link between the terminals with resistors so that each position ouputs a different voltage then read the switch (or group of switches) with 1 x AIN input? Coding along the following lines would be required for a 3 position switch: If input = aa then output = zz If input = bb then output = yy If input = cc then output = xx Cheers fellas :) Edited April 28, 2012 by eufex Quote Link to comment Share on other sites More sharing options...
technobreath Posted April 29, 2012 Report Share Posted April 29, 2012 Yo! It would've been great if u drew a schem on how u plan to wire it together... I don't know what u mean by the res. Matrix and how to wire it... But it might be just me having an early morning hehe. I love the b3 sound! Good luck with the build! Quote Link to comment Share on other sites More sharing options...
eufex Posted April 29, 2012 Author Report Share Posted April 29, 2012 Yo! It would've been great if u drew a schem on how u plan to wire it together... I don't know what u mean by the res. Matrix and how to wire it... But it might be just me having an early morning hehe. I love the b3 sound! Good luck with the build! It's really simple - an analogue input measures voltages between 0 and 5 spread across a potentiometer - usually 10K. That is inifinitely variable and then scanned to the bit depth of the system. Now imagine that there isn't a potentiometer there but a potential divider (i.e. a series of resistors). All an AIN does is measure voltage. Now if you have 4 rocker tabs as on the right hand side of a B3 all you do is split the voltage across 4 resistors (each resistor is switched in with the corresponding switch and each resistor is a different value so that each combination of switch positions outputs a unique voltage), so each switch being switched on outputs a different voltage. There's more to the code than I put in my example - 4 switches on 1 AIN will give (I think) 9 different voltage combinations including all off. A position selector is a similar idea but in that instance only 1 position can be switched on at any one time so the code is a little simpler as in my example from before. Quote Link to comment Share on other sites More sharing options...
technobreath Posted April 29, 2012 Report Share Posted April 29, 2012 (edited) OK, I see what you mean :) I agree with your logic ;). I thought you were talking about two different things earlier on, but if the AIN can read the voltage across a potmeter, sure it will read voltage across such a matrix. I was just thinking if there was another way of doing it, but this way seems just as good as any... Edited April 29, 2012 by technobreath Quote Link to comment Share on other sites More sharing options...
Imp Posted April 30, 2012 Report Share Posted April 30, 2012 What you describe here is a simple form of DAC, since your switches are digital inputs and you get a (kinda steppy) analog output. It's called R2R-DAC and it's also used in the aout-LC, so yout might want to check out its schematic. Quote Link to comment Share on other sites More sharing options...
eufex Posted April 30, 2012 Author Report Share Posted April 30, 2012 What you describe here is a simple form of DAC, since your switches are digital inputs and you get a (kinda steppy) analog output. It's called R2R-DAC and it's also used in the aout-LC, so yout might want to check out its schematic. Cool, cool. That's pretty much what I mean. So there should be no problem with the AIN reading it afaik?? I noted Thorsten's comment re type of resistor and temperature tolerance levels which I imagine will be the same for an input to give consistent voltage levels, although at the code level I can program for a range of values for each switch as the voltage range allowed for each switch will depends on the number of switches attached to the ladder - i.e. the fewer switches the wider the allowed range can be. Quote Link to comment Share on other sites More sharing options...
Imp Posted May 1, 2012 Report Share Posted May 1, 2012 the fewer switches the wider the allowed range can be Since position switches usually only make a connection to one of their contacts, you'll be using 6 values ( e.g. 000001 or 001000) out of 64 possible values (6bit). Your steps will be huge, compared to the normal usage of the DAC, so resistor tolerance wont matter. So there should be no problem with the AIN reading it afaik?? No problem, as long as you hit the right voltage range. If you need 8 analog inputs or less, I'd recommend you ommit the AIN module and use the analog inputs of the CORE_LPC17 Module (J5a/b). You'll need to power your R2Rs with 3,3V if you go this route. Anyway, this whole approach feels like a workaround to me, because you would convert a digital input to analog, to have the chip convert it back to digital. I think it must be possible to read the digital inputs directly, despite the fact they are latched. This would reduce the part count a lot. Quote Link to comment Share on other sites More sharing options...
eufex Posted May 1, 2012 Author Report Share Posted May 1, 2012 Since position switches usually only make a connection to one of their contacts, you'll be using 6 values ( e.g. 000001 or 001000) out of 64 possible values (6bit). Your steps will be huge, compared to the normal usage of the DAC, so resistor tolerance wont matter. No problem, as long as you hit the right voltage range. If you need 8 analog inputs or less, I'd recommend you ommit the AIN module and use the analog inputs of the CORE_LPC17 Module (J5a/b). You'll need to power your R2Rs with 3,3V if you go this route. Anyway, this whole approach feels like a workaround to me, because you would convert a digital input to analog, to have the chip convert it back to digital. I think it must be possible to read the digital inputs directly, despite the fact they are latched. This would reduce the part count a lot. Well, if there's another way of doing it I'm all ears :) Yes it is a workaround as I'm not aware of another way of doing it. AINs have to be in the system anyway - as I mentioned I'm using a full set of Hammond drawbars, which have to be read with AINs. Quote Link to comment Share on other sites More sharing options...
eufex Posted May 1, 2012 Author Report Share Posted May 1, 2012 (edited) Actually...I've just had another thought :sorcerer: Obviously this depends on the wiring of the rocker tabs that I have - I will need to take a look. If I use 2 DINs on a rocker I can use one DIN per state - if din1 is energised (switch position 1) output aa, if din 2 is energised (switch position 2) output aa again. AFAIK the midi implementation of the s/w works on a momentary basis so I just need to detect the change of state . Then I need to read the position of the switch at mios boot and output a message that switches the VST from its loaded state to the current state on the front panel...I think. Edited May 1, 2012 by eufex Quote Link to comment Share on other sites More sharing options...
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.