Jump to content

Can I toggle controls with boolen operators?


henrygr
 Share

Recommended Posts

Hi there,

This is my first post on this forum. I generally don't like to post as I try to find the answer to my problem in previously discussed issues....but I'm stuck.

I am building- well nearly finished- my first project. It is a live controller for Native Instruments B4. I've essentially tried to keep it as true to ancient specs as possible eg, refurbised old drawbars fron a Vox Super Continental, built it into an old valve radio casing with french polish veneer, using chicken neck knobs on the pots, and ultimately, no digital buttons.

My conundrum however is such. I have nine drawbars with which to control the NI B4 drawbars. Is there a way that I can add a switch to toggle the function of these between thae upper and lower manual, through use of an AIN switch.

I know that if it can be done it would be a question of a boolean operator in the code checking the status of this switch being either a value of 0 or 127 ie. repalcing a pot with a toggle switch.

I have not the need for a DIN thus far, and as I am near completion, do not want to have to put one in. I know this forum is immensly busy with all us newbie questions, so I'm just going to finish the project and leave a spare button till somone gets round to me.

Before I go....Thank you all for what I consider to be the most valuable resource on the world wide web ;)

MP

Link to comment
Share on other sites

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Gday mate :)

Good news! Yes, what you have suggested will work for sure...however you don't have to use a DIN module to get a digital input, you can run a single DIN directly off the core :)

I'm at work right now so just making a quick post. I'm pretty sure that the instructions you need are on this forum, but if you can't find them, let me know, and I'll show you how.

good luck!

Link to comment
Share on other sites

Happy days!! :)

Thank you for your swift reply. I hope to have photos of this baby up by the weekend. Can't find what I'm looking for on the forum though. Just one thought- would the toggle have to be dependant on on a DIN. My idea is that if it were based on analogue inputs, I could perhaps put in lets say a three or four way rotary switch to change between different messages eg, top keyboard drawbar, lower keyboard drawbar, volume control of midi tracks.

Or am I asking too much.... 

Regards,

MP

Link to comment
Share on other sites

On reflection, I think my question should be such, as I am not a compentant programmer.

Can I assign a value to a variable based on the position of an analogue switch, and subsequently add that value to a midi contol value?

Am I making sense?

eg Upper keyboard, drawbar 1, has ctrl no 13. This is the preprogrammed control number of the slide pot drawbar. Lower keyboard, drawbar 1, has ctrl no 23. Flick the switch and hey presto. Slide pot drawbar now sends to lower keyboard.

Am I making sense. It's raining here in Dublin. Should I just go out and stand in it with my face pointed to the sky, and do you all a favour and drown slowly?

Thanks for your patience ???

MP 

Link to comment
Share on other sites

I'm not sure if I understand your question right, because I don't know what an "analogue switch" should look like...  ???

If you're searching for a hint on how to connect one or more buttons to a DIN or directly to the Core, see here:

http://www.midibox.org/forum/index.php?topic=6717.msg42619#msg42619

and here:

http://www.midibox.org/forum/index.php?topic=6528.msg40953#msg40953

You might also connect a multistate-button (DIP-switch, 3-state-slide-switch, radio-button-matrix ....) to more than one input (eg. you need 3 DIN-Pins for one 3-state-button), that seems a bit easier and more relyable than defining an analogue pot-range, esp. if you're not used to programming.

If you have additional questions, feel free to ask ;)

regards,

Michael

Link to comment
Share on other sites

Right,

I'll play around with it, see how I get on. The only problem I see with multistate switching is that all values will be switched to zero when one goes to use the drawbars for other purposes!

Hopefully I'll figure it out though. 

Thanks all,

MP :)

Link to comment
Share on other sites

Hehehe you're stuck in an analog frame of mind... It won't set them all to zero unless they should be set at 0...

Think of the button/switch as like shift, ctrl and alt keys on your keyboard. When you press 'c', you get a 'c', but with the above keys pressed you get C, copy and close... Your drawbars would work in a similar fashion...

Link to comment
Share on other sites

Right then. It's raining again. Off I go.....

Will have photo of the unit up tonight. Any suggestions on how to programme my alt and shift of the midi world. I figure it would be a couple of lines at the beginning ot the .hex file.

See, even with all this cloud cover, I'm beginning to see the light ;)

MP

Link to comment
Share on other sites

henrygr, have you looked at the links I posted above?

The main information is contained in an example from the download section, so the code is there, waiting to be read. I don't know about your project and I'm not used to organs, but I assume if you don't have no DIN-module, you're not using one of the precompiled applications, but trying to customize your own thing, right?

It might be worth reading this article if you haven't done so: http://www.midibox.org/dokuwiki/doku.php?id=application_development

You need to install SDCC, GPUtils and all the other things described at uCApps. Then load the C-Skeleton from the uCApps-Download-Page. You just have to add a couple of lines to the NotifyDIN-Functions ("pseudo-C": if DIN1 do this and that; else if DIN2 do this; else if DIN3 do this).

Of course you might also code ASM, but I wouldn't recommend if you don't know it.

The hex-file is the result of compiling the application code, so changing lines there is no good idea (except you speak machine code ;D )

Regards, Michael

Link to comment
Share on other sites

Have followed up on everything you posted. I know I promised a photo by this stage, but soldering in the rain cooled the solder down :P

I've wired up a 3 way 3pole switch (I know they come in three pole four way, but i'm only using three of the poles) to send out on an analogue in that at any time, only one of the positions is true.

eg- pole one is on (midi signal 127) when pole two and three are at ground (midi signal 0)

      pole two is on and pole one and three are at ground etc.......you get the gist.

So, using this toggle switch, can I use the information sent to the PIC to change the characterisics of nine other different analogue inputs. As I have searched this forum, I have realised that this has not really been approached at all. It is not about an analogue switch that changes midi channel (although that could be a workaround), but more about changing the the algorithmic result of one  (or in my case nine) potentiometers,  based on the value of another.

It's still pi**ing rain, but my neck is too sore, and I'm going to bed.

Thanks for everything,

Mark.

Link to comment
Share on other sites

I've wired up a 3 way 3pole switch (I know they come in three pole four way, but i'm only using three of the poles) to send out on an analogue in that at any time, only one of the positions is true.

So are you going measuring analogue voltages with an AIN or switching digital with a DIN?

If you're sticking to analogue, I can't help you further, 'cause I can't see any advantage about that proceeding? - if you meant, you now have a standard 3-pole-switch connected to 3 digital input pins (DIN or Core), here are some questions:

Are you using an DIN-Board and if not, what exactly what Pins on the Core do you use?

Have you found the PDF where connection of switches (and one resistor for each) are described and did you follow that?

We first have to make sure, the hardware is connected right, before proceeding to software!  ;)

Regards,

Michael

Link to comment
Share on other sites

Micheal,

I see what you mean. I have just finished the unit now and am about to plug it up to the PC (yes, XP based stryd_one). I will get my nose dirty with the information that you have asked.

I am assusimg that it is possible to use the remaining four (in my case three of the four) pins of J5 to set up a digital switch, even though I have attached one AIN module to the core?!

Please find some photos as promised. An no Flash Gordon jokes. I know it looks a bit like a 1930's sci-fi special effects prop!

As I explained earlier on the post, they are old Vox Continental Super II drawbars that I refurbished, and the whole unit is built into the case of an old valve radio. At the end, I attached one of the original valves to to the case, into which I dropped an amber LED for aesthetics.

The knob on the left of the front panel is the three way switch wired to set any one selection to 'on' and the remainder two to 'off' simultaneously. I will use this (hopefully) to decide whether the drawbars control either upper keybaord, lower keyboard, or volume control of midi channels 1 through 9.

During the whole project, I purposfully avoided using push button or DOUT LED signals. I wanted to keep a sense of authenticity to its tactile use. A quick look at the box will tell me how everything is set, just like playing the real thing (I hope!)

So I am indebted to all of you for your patience and knowledge. I will begin now see how it performs when Mideed Up!

Regards,

Mark. :)

35_Image006_jpge9103f5161f68ec554ffb49b1

37_Image007_jpg21417f0327bf5e715deadb6d9

39_Image008_jpg0679c57152b1e5343ba7513f5

Link to comment
Share on other sites

this is looking awsome :o

(and besides I love Flash Gorden Retro-SciFi-Style ;D )

I see, the switch seems perfect for your needs and it should be easy to wire.

You want to take a look into "mios_pin_list.txt" (it's also in the download section of uCApps.de).

It contains valueable information on the pins of the core and if you can use them - so to speak you are free to use nearly any free pin, not only remaining AIN-pins (=> possible future upgrades?) Besides, this list contains the IDs (eg. "RC5"), that we need to refer later on by code.

It's much easier with a DIN-board, but it's not really more complicated without. I will help you, if your application is written in C. If you use an assembler application or an assembler based ready project, I have to pass (though I'm sure, someone else can help in this case ;)

However (for MIOS-C-Applications):

When using a DIN-module, you have a function called

[tt]void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value)[/tt],

it notifies you automatically whenever a DIN-state changes.

When using no DIN-module, you have to check the state by yourself. The basic concept is to set up a timer with [tt]MIOS_TIMER_Init(4,10000);[/tt] (please anyone correct the value if inappropriate :-[).

In the function [tt]void Timer(void)[/tt] you have to check the pin states by yourself (for example: [tt]if(PORTDbits.RD4) { ... }[/tt] checks if S0 from J10 of the Core is selected. Additionally we need to have a variable that stores the last state, to prevent any looping unnecessary executions. That's all.

If I know the application you're using, I may add a WIKI tutorial on how to connect and use pins as DIN.

Regards,

Michael

...and don't forget the resistors, when connecting the pins to the switch  :)

Link to comment
Share on other sites

Moving on now,

Got rid of the random midi- well kind of. When the rocker switches are thrown into the off position, random midi starts again. And now a new problem. I am getting no messages at all from any of the pots and faders. I know this is the wrong post in the forum for this, but would appreciate a pointer in the right direction!!

Have downloaded Active Perl and MPLAB. Are these the tools I need? I followed the links in ucaaps.de. My first port of call eill be to set the first few headers in the main.asm file- ie no of pots, no DIN etc. I wonder if that is why I am not recieving ant data from the pots.

Still raining in Dublin. Probably just as well. If it was sunny, I'd pask all of this in and beeline for the park with a ball or something. Nice result in Heineken Cup it has to be said!!

Enough waffle,

MP :)

Link to comment
Share on other sites

well, I think you got a few things mixed up.

*.asm means it's an assembler file

*.c / *.h means it's C.

either you grab one of the precompiled applications like MidiBox 64 (but then you have to make sure you got the hardware requirements) -

or you code your own application, but that means, you have to program it! You need to download the C-Skeleton (with main.c not main.asm!). Stryd_one is writing a step-by-step tutorial at the moment, maybe you're going to take a look (wiki -> application developement -> wintel...).

In other words: if you haven't said the box what to do when turning a know, it won't do nothing  :-\

Asking again: C or ASM?

(I'm always assuming C is the best choice, but I don't know if you're an assembler-pro, right?  ;D

(btw: it's sunny in Nuremberg, but they say it should rain this afternoon :)

Link to comment
Share on other sites

You can have our rain of you want! ;D

The plan was to take the MidiBOX64 app and make changes to it based on the notes from TG in main.asp. So I followed the MPLAB link in ucaaps to follow this through. Is this an option? I see that others have done this successfully.

MP

Link to comment
Share on other sites

Stop Press.

Found the section on C Interface. My god, that is much easier to grasp. My programming experience comes from BASIC and a bit of PERL (Black Book on a shelf behind me). Also downloaded the app in the MIOS/Dowlnload section that sets for 64AIN, 128DIN, 128DOUT.

Will try to get my head around it.

Seeing clearly now but the rains not gone.....Obstacles? Don't start me off....

MP

Link to comment
Share on other sites

No more jitter. I have a bizzar situation where the second half of each gang of eight pots work and the first doesn't!!

eg pots 0x00 to 0x03 don't give a signal and pots 0x04 to 0x07 work perfectly. I think it's a question of rebooting Mios, and certainly isn't a post for this section of the forum.

Getting to like C though. Have a few ideas that once i'm finished with this baby (which I need asap for gigs) I'll endeavour to try out....

Keep watching though, I will need help with that switch!!

Mark. ;D

Link to comment
Share on other sites

OK

Here we go.

From examples I have seen, using AINNotify_Change, it is alwasy followes in brackets by 'unsigned char pin, unsigned char pin_value'

Can I set a specific char oun and pin value in brackets instead, so as to react only to the movement of one particular switch (eg when pot x is value 127). Then I could use the function to set a value to a variable, and in turn use that variable (or array of variables) to change the output control of another pot?

Make Sense?

MP

Link to comment
Share on other sites

You need to use a DIN board to be notified by DINNotify_Change (as with AINNotify_Change).

If you don't want to use a DIN module, please refer to the concept I already posted: http://www.midibox.org/forum/index.php?topic=6754.msg43142#msg43142

Check the pintable listing, decide for three appropriate pins of the core module and see the hardware example (http://www.ucapps.de/mios/j5_din.pdf) on how to connect your switch! The resistor is important, otherwise your core will be shortened!

when you're done with that, tell us and then I'll start a wiki how-to...

michael

Link to comment
Share on other sites

Great Michael,

I'll get that set up asap. Now that I understand C a bit better, I see exactly what you have been trying to explain to me. Apologies for the slow uptake.

Now that I have a better grasp, I can say now that I will be setting up the three DIN on J5 of the Core on pins A4, A5 and A6.

"Additionally we need to have a variable that stores the last state, to prevent any looping unnecessary executions. That's all."

As I am using a toggle switch that will always leave one of these pins on at all times, there would be no need to check for a switch off, but instead change the value of the variable accordingly.

if(PORTDbits.[i]example[/i]) { ... } 
What I need to find out now is the value required in example field to check one of those three pins. To finish my query I will use their pin names as per pdf schematic.
MIOS_TIMER_Init(0x00, 20000){

if(PORTbits.A4){
variable=value1
}

if(PORTbits.A5){
variable=value2
}

if(PORTbits.A6){
variable=value3
}
}

Here, every 2ms the pins will be checked. Am I heading the right direction? This now leaves me with the task of executing commands based on the value of variable, but one step at a time.

Thanks Again,

Mark. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share


×
×
  • Create New...