henrygr Posted June 21, 2006 Author Report Share Posted June 21, 2006 OK.Is that pins 0,1 and 2 on the AIN module?As I am only using one AIN and still have four pins available on J5 of the core, could I utilise these even in muxed mode? If you are unsure I'll try it anyway.Nice to be home.Mark. :) Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 21, 2006 Author Report Share Posted June 21, 2006 An afterthought: could I build a DIN with one 74HC165 and deacrease the size of the board. Space is getting tight in there!!MP Quote Link to comment Share on other sites More sharing options...
stryd_one Posted June 21, 2006 Report Share Posted June 21, 2006 Of course, that's why they're called DINx4 modules, they're 4x DIN modules on one board... You could make a DINx1 PCB :)http://www.ucapps.de/mbhp/mbhp_dinx1.pdf Schematic and...http://www.ucapps.de/mbhp/mbhp_dinx1.jpg Breadboard layout :) Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 21, 2006 Report Share Posted June 21, 2006 sorry, I've been a bit confusing, of course I meant "AIN board" :)the thing is: if you check pin 24 to 26 and only "default" is being called, that means, that you get no signal on pins 24 to 26. On previous postings you used pin 0 - pin 3 and it worked, I don't know how you changed your wiring... but the syntax of the switch case is now correct ;)you have to write"case 24:" if your pin is connected to pin 24 (=25 of AIN if you count from 1).you may add a debug line just below the beginning of the function: MIOS_LCD_PrintBCD2(pin);Then the currently active pin will be printed to your LCD and you know how to address your "case" right ;)Cheers,Michaelps: I don't think there is need for you to build a DIN-module. Just find the right numbers for your three pins ;) Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 21, 2006 Author Report Share Posted June 21, 2006 Thank you both:Just tried it with pins 1 2 and 3 and still no joy. I get the impression from all of the results on the screen that conditions would have to be programmed for each individual switch which would mean both lots of workload and perhaps a slower machine. Put that versus a DINX1 and I thinf I will go with the latter.Will let you all know!!Regards,Mark. Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 21, 2006 Report Share Posted June 21, 2006 hey, please check my hint with the LCD!:) Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 21, 2006 Author Report Share Posted June 21, 2006 Sorry Michael,I should have said that pins 25-27 do return a value according to pot_event_map.When I programme 1-3, same result.Thanks Anyway,Mark. :) Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 21, 2006 Report Share Posted June 21, 2006 I should have said that pins 25-27 do return a value according to pot_event_map.When I programme 1-3, same result.hmm, so I don't understand the problem ???I think there's still one basic misunderstanding:- What do you want to happen when pressing pin 1/2/3 of your switch?- what are the numbers of the AIN pins where you connected to your switch?if you answer these two questions, I'll code the relevant lines for you to shorten this...;)Cheers,Michael Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 21, 2006 Author Report Share Posted June 21, 2006 Hi Michael,The switch itself is a 4 pole three way switch, correctly wired with 10k resistors, to do the following (I am replacing numbers with letters for clarity)When A is on, B and C go to ground.When B is on, A and C go to ground.When C is on, A and B go to ground.The values of the above work correctly. I tested it with the code'MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number'and got the correct values.ie.When the midi signal form A is 127, B and C are at 0....you get the picture.Now the purpose of this switch is to ast as a toggle switch, which will change the purpose of all 24 other controllers on the fly. To add, I havn't built an LCD to the core. I don't particularly need it, sind I built a 15" LCD monitor onto my keyboard!! ;)(No, not touch screen- they use up too much valuable processsing power). :-\I have ordered a DIN module from SmashTV, which, even if I do find a workaround here, will be put to good use anyway. :).The AIN pins are the first three pins of the last multiplexer. ie pins 25, 26, 27- thus in the switch-case code- 24,25 and 26.One more thing,It is still p***ing rain in Dublin. The offer to go out and stand in it is still valid!Regards,Mark. Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 21, 2006 Report Share Posted June 21, 2006 Hi Mark :)Super. Tested all the code by sending one set of variables at a time and they all do what they are suppesed to (except one, but I think it is a programming bug in B4)The values of the above work correctly. I tested it with the code'MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number'and got the correct values.so is it working or not?(sorry if I'm slow on the uptake, but I can't find the question out of your last postings :-\except this one:All I get is the default. If I remove the default from the code I get nothing except the harmless channel 16 messages from the switch itself (pins 24, 25 and 26)But I don't understand this either: do you only get the default-case-section? But if you remove it, you shouldn't get anything else... somehow this doesn't make sense... ???The switch executes only the [tt]case[/tt] of the relevant [tt]pin[/tt] until the [tt]break; [/tt]then it leaves the switch routine.(anyone else, maybe?)Regards,Michael Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 21, 2006 Author Report Share Posted June 21, 2006 To answer:Yes, both cases above are working. All values in pot_event_map work when I specifically programme them directly without any switches.The switch works- ie. properly wired and sends values as intended when turned.But I don't understand this either: do you only get the default-case-section? But if you remove it, you shouldn't get anything else... I get the default-case-sections on all other switches, and erroneous data wherever I set the toggle, be it pin 1,2 and 3 or 24, 25 and 26. If I remove the default, I don't get anything. I am trying all sorts of different ways around the argument. I will keep at it for know.Right now though, I have to run to give the baby a bottle! :DWho's a pretty girl......Mark. Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 22, 2006 Author Report Share Posted June 22, 2006 Michael,Thanks for all your help in the programming. The code to me looks spot on, but i'm no expert. I have a hunch that it may be to do with thw flow of data in the PIC chip, in that such changes cannot be made on the fly.I am wondering how the MIOS deals with loading a new bank from the bankstick. If there is a system reset or something similar that sets the new values in place. When I get home later, I will put a reset into each block of 'case', and then set up a loop to return values (while pin_value>512.....) to appropriate pins until the condition has changed.Just a thought...Mark.PS Check this out. What do you think for the price?http://cgi.ebay.ie/JDM2-ISO-MICROCHIP-PIC-EEPROM-CARD-PROGRAMMER-JDM-MCU_W0QQitemZ7630631527QQihZ017QQcategoryZ4661QQrdZ1QQcmdZViewItem Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 22, 2006 Report Share Posted June 22, 2006 Mark,If I remove the default, I don't get anything. that means, that your pin-numbers don't match.please look back some postings and add that line to send the pin via midi message.As I am only using one AIN and still have four pins available on J5 of the core, could I utilise these even in muxed mode?If you are using an AIN-module connected to the core, I doubt you can then use the remaining AIN-pins of J5, because the core is in muxed mode. Not sure, thoughHowever, have you set [tt]MIOS_AIN_Muxed() [/tt](need that if you have any AIN-board) and [tt]MIOS_AIN_NumberSet(maximum pot number)[/tt]; // in your case 26? in the init() section of your code!Please don't open up another battlefield (banksticks) while struggling with this one, it brings only more confusion. Don't call any system resets unless you have a pretty good reason to do so.Cheers,Michael Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 23, 2006 Author Report Share Posted June 23, 2006 Sorry,I've read somewhere earlier about someome slapping their own wrists for rusing posts during a coffee break at work. Well, I'll slap my own wrists now, and say that caring for a teething nine month old baby with one eye on the PC and the Mbox is certainly not to be tried...I set up Code Blocks- GREAT. Tells me where my script is wromg as I type etc....Back to the code above. Pins values spot on. Argument is not though. The only returned values are of those three pins, and values only above 512. So it is the syntax of the code.I don't know. I will have a good look at it now that I have a text editor that is more akin to working on a ZX81 over a C=64.Ahhhh...the days of sprites and (cough)SID chips!!!!Regards,MP Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 23, 2006 Author Report Share Posted June 23, 2006 OKI tried the same code but with the IF control statement, and substituted a vairiable in the code that calls the sub array:void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam { unsigned char knob_pos_1; unsigned char knob_pos_2; if(pin == 24 && pin_value > 512) { knob_pos_1 = 0; knob_pos_2 = 2; } if(pin == 25 && pin_value > 512) { knob_pos_1 = 0; knob_pos_2 = 3; } if(pin == 26 && pin_value > 512) { knob_pos_1 = 1; knob_pos_2 = 4; } MIOS_MIDI_TxBufferPut(pot_event_map[pin][knob_pos_1]); // first corresponding value from table MIOS_MIDI_TxBufferPut(pot_event_map[pin][knob_pos_2]); // second corresponding value from tab MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // 7bit pot value } The result is unusual.Pins 0 to 23 send two midi messages per movement sequentially.The first is on Channel 1 with a value of 0, Control no 1.The second is still on channel 1, with a value of 0, but the contol no corresponds to pot movement ie increases or decreases depending on movement.When I flick the knob, its as though the positions of every pot is taken and echoed back through the channel corresponding to the position of the knob.Any comments? Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 23, 2006 Report Share Posted June 23, 2006 Hey Mark ;)I know it's hard in the beginning, but please take a look into some basic C-books. There a lot of links in the Wiki. C is a very easy language, if you ignore all the bit-stuff and concentrate just on the basic things:- fundamental variable types, variable declaration and -definitions- control flow (eg functions, if/then/else, switches, loops ...)so: if you declare your variable(s) inside a function, what's the scope of this variable?(do you know what "declaring a variable" means?)I still don't know exactly what your ahundredandfiveentriesarray does, but if you let this complex array aside for a moment and concentrate on the logic and getting this function to send the right values, this might really help.Pins 0 to 23 send two midi messages per movement sequentially.The first is on Channel 1 with a value of 0, Control no 1.The second is still on channel 1, with a value of 0, but the contol no corresponds to pot movement ie increases or decreases depending on movement.of couse!this is exactly what you wrote. pin 0 to 23 is neither pin 24, nor pin 25, nor pin 26. So what happens? Right, just the three lines below are executed. and knob_pos1 and knob_pos2 are undefined (scrambled unknown values!)It might really be of some good if you look into the literature link list of the wiki and print some pages out of your favorite C-book and read about basic variables and control flows. You could get the basics in 1 or 2 days and know what you're doing afterwards, instead of trying and trying for weeks without getting this thing to do what you want.I would really help you more concrete with some lines, if I would know exactly what you want to do ::)Keep it up, man! You're just a few steps from gettin the complete picture and things will become clear as a shiny crystal :)Cheers,Michael(ps: I'm away the next two weeks, so don't think I left you alone with that when I'm not answering the next days, I'll be back to check your proceedings! ;) ) Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 23, 2006 Author Report Share Posted June 23, 2006 OK OK I hear you. And I promise to do my homework. I'd buy you an apple, but they cost too much.Pins 24,25,26 will not be used so much. When I flick them, I want the other pots to behave as instructed. Essentially change what each of the other pots controls depending on the condition of 24, 25 or 26.eg Pot 1 controls volume on channel 2 when pin 24 is selected.Pot 1 controls modulation on Channel 15 when pin 25 is selectedPot 1 controls reverb depth on Channel 3 when pin 26 is selected.In essence, 45, 25 and 26 act as a program shift for the Mbox.Am I making any sense?Going anywhere nice?mark Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 23, 2006 Report Share Posted June 23, 2006 okay, I'll give it a try:I don't know about pin 45 (AIN has only 32 inputs?), but I assume you have 23 analogue inputs and pins 24 to 26 are your switchand remember: I type without having tested this!You still have to try to think with me, and I'm not perfect either! :)let's define some values to increase readability: #define SWITCH_STATE_UP 24 #define SWITCH_STATE_MIDDLE 25 #define SWITCH_STATE_DOWN 26 this is your mapping: (I hope this multidimensional array works, haven't tried it!!) // adapt these numbers to your needs, // these are basically three arrays filled with 24 values // just fill your mapping with different values. // if switchState is UP (24) it'll be the first mapping (mapping[0]), // if it's MIDDLE (25) it's the second and for _DOWN it's the third (mapping[2]!) const unsigned char mapping[3][24] = { { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 1x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 1x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 1x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 } } it's better to introduce another variable so we can easily track the setting of the switch: unsigned char switchState; now, we go to the Init() section, where we have to setup the AIN-module and set the inital switchState: void Init(void) __wparam { // configure AIN MIOS_AIN_Muxed(); MIOS_AIN_NumberSet(26); // read current state of the switch button: if(MIOS_AIN_Pin7bitGet(SWITCH_STATE_UP) { switchState = SWITCH_STATE_UP; } else if(MIOS_AIN_Pin7bitGet(SWITCH_STATE_MIDDLE) { switchState = SWITCH_STATE_MIDDLE; } else if(MIOS_AIN_Pin7bitGet(SWITCH_STATE_DOWN) { switchState = SWITCH_STATE_DOWN; } } and finally, here is your AIN-section: void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam { // check if it's the switch if(pin > 23) { // update switch state switchState = pin; } else { // now send your values // begin stream MIOS_MIDI_BeginStream(); // send note on ch 1 MIOS_MIDI_TxBufferPut(0x90); // send mapped value -> array[0, 1 or 2][pin] MIOS_MIDI_TxBufferPut(mapping[(switchState - SWITCH_STATE_UP)][pin]); // send velocity of 100 MIOS_MIDI_TxBufferPut(0x64); // end stream MIOS_MIDI_EndStream(); } } that's it.And again: it's not tested, just written out of my hand directly into the browser ;)And before you start to make it more complex (eg. sending controllers) give it a try this way, so you understand what's happening here. If you got that, it should be very easy to update it for more complex stuff...Cheers,Michael Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 27, 2006 Author Report Share Posted June 27, 2006 :) :) :) :)MISSION ACCOMPLISHED!!!!!!! :) :) :) :)So now there is a switch that will change the control functions of analogue (and maybe DINX, but I havn't built them yet) controls on the fly without the need to upload different configurations from a bank stick.I will post the results in the WIKI and place a link here as soon as its done so that others who stumble upon here can follow it.Thanks you all for your patience and support.Mark. 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.