Jump to content

how to adapt prioriy codifiers in the digital input of pic


filmcomposer
 Share

Recommended Posts

hello every body and happy new yar.

      i was planing  to install a serie of switches from 0 to 12 and wanted the codifier to select the highest value, codify it and assign a note to each switch. no need of velocity and so on.  Is it possible to do that? or if not, what would be the diagram or a 6x6 matrix to do the same, still using a codifier with priority. i only need one note at  the time. could you give me any advice? thanks o all of you, super experts in midibox guts..                     

Link to comment
Share on other sites

No worries on the bad English, but you must understand that repeating your post in a private message (to me or anyone else) is as unacceptable as crossposting.

The way it works here is you ask a question one time, and if someone understands the question and knows the answer they will reply.

Please understand, I'm not critcal of you or the question, but I do not want it repeated at every possible chance until answered......

Best Regards

SmashTV

Link to comment
Share on other sites

Hi,

i was planing  to install a serie of switches from 0 to 12

what do you mean? you plan to build a MB with 12 butons?

and wanted the codifier to select the highest value

I suppose you're talkin about an "encoder" (encodeur, en français, en tout cas tout le monde ici comprendra  ;) ), but which highest value ? is this value comin from the MIDI in? what type of MIDI event?

codify it

what is the operation you want to do on the value?

and assign a note to each switch

aaaaah!

en fait, peut-être veut-tu simplement envoyé une note à ta MIDIbox, et pouvoir assigner cette note ainsi que celle qui suivent ou qui précèdent à tes boutons?

si c'est ça, tu as une fonction MIDI Learn et une fonction de mappage automatique (par canal ou par cc/note) pour la 64E:

quote from the MB64E tutorial Page)

he MIDI Learn function allows to customize the encoders and buttons for your own needs. How does it work: plug a MIDI cable from the MIDI IN port of the MIDIbox to the MIDI Out port of your keyboard or PC. Enter the MIDI Learn Mode. Now, the box waits for a message from MIDI IN:

MIDI Learn 0

Send a controller to the MIDIbox (just use your Synth or MIDI-OX for this). The MIDIbox regogninzes all MIDI events and displays the last received one:

MIDI Learn 1

If you want to assign the event to a encoder, just rotate it shortly. If a button should learn the event, just push the button.

"Learn Single" means, that the controller will be learned from one Encoder or Button, only. But sometimes, it is usefull to assign all encoders or buttons with the same controller but for different channels. MIDIbox offers a special function for this, just select it with the menu buttons:

MIDI Learn 2

It is also possible to increment the controller value automatically. This is favorable, if all encoders or buttons should be quickly assigned to unique numbers:

MIDI Learn 3

A special feature is implemented for the buttons: the behaviour of every button can be specified with the Snapshot Button before a event will be assigned to it:

MIDI Learn 4

Send learned value when button pressed, send zero when button released.

MIDI Learn 5

Send learned value only when button pressed, don't send a zero value when button released.

MIDI Learn 6

Send learned value with the first keypress, send zero value with the second keypress.

Beside of controller events, Note On/Off, Program Change, PitchBender, ... can be learned:

MIDI Learn 7 MIDI Learn 8 MIDI Learn 9 MIDI Learn 10 MIDI Learn 11 MIDI Learn 12

je sais, je sais, j'aurais pu copier-coller la version française...  ;)

or maybe I don't understand anythings...

Link to comment
Share on other sites

Ahhh now I know what a Priority encoder is :)

I have a similar thing in the vX, if adapted to your needs you could use a bitfield and then hold the button states within it, then bitshift it left and count how many shifts until the carry bit is set, or use a for... loop and test each bit from highest to lowest. The counter is then subtracted from the total number of bits and that will tell you the number of the highest set bit.

In your case you could optimise this for speed at the expense of code space and ram by holding the current highest button in a variable. When a button is set, compare that button number to see if it is higher that the current highest button, and then setting the current button to be the highest. When a button is unset, if it is the highest number, you could start reading all the lower pin numbers than that, with the method described above, and if the button is lower it is ignored. .

I'd be interested to see if the hardware method in the link above could be easily adapted to software but I'll leave that up to you :)

Hope that helps!

Edit: There may be much better ways to do this, as it's a very common requirement it wouldn't surprise me if there's a standardised method... Hopefully my method isn't too clumsy!

Link to comment
Share on other sites

  j'imagine que tu es francais comme moi, alors je voudrais t'expliquer. au depart, je voulais simplement utiliser un pot de 250k de la mdbox et pouvoir le programmer de maniere a ce qu'il envoie un ordre de note-on par ex. DO en bougeant le bouton entre o et 10kohm. de 10 a 20 kohms, qu'il envoi un ordre de note-on de DO diese, de 20k a 30kohms qu'il envoie un ordre de note on de RE. ETC. je voudrais pouvoir avoir la possibilite de programmer la note initiale du pot a l'etat zero par ex:de 0 -10k re, 10-20k re diese etc ou bien par ex: 0-10k mi3, 10-20k fa3, 20-30k fa diese 3 etc. comme je ne sais pas si c'est possible ou alors peut etre en le programmant (dur,dur pour moi), j'ai entendu parler des encodeur de priorite qui permettent 10 entree analogiques type switch et en choisissent la plus haute valeur en sortie et codifiee endigital. cela etant possible,comment attaquer la pic? par ou entrer? et pour cela, j'avais pense aux 12 switch et l'encodeur, n'etant interesse que par une seule note a la fois, la plus haute valeur toujour d'entre elles, meme si 7 switchs sont acciones. la velocity ne me preocupe pas car elle peut etre programmee sur un pot different ou un piezo ou quoi que ce soit. voila. j'espere que je suis plus clair come ca. je fais appel a ton savor car mes connaissances en programation et hardware sont basiques. je suis compositeur classique mais la quete d'un instrument a ma mesure est un vieux reve rendu possible aujourd'hui a la flexibilite de la midibox et au genie de thorsten klose, son auteur et a vous tous qui contribuez a cette machine incroyable. merci d'avance. a biento.

Link to comment
Share on other sites

filmcomposer,

pourquoi to ne utilise un pot 10k, simplement?

quand tu programme toi application en C, il y a une fonction "AIN_NotifyChange(pin, pin_value)": pin_value est un numéro 10-bit (0 á 1023). C'est plus simple que utiliser douze pots á un AIN-pin.

hope I got that right ;)

Michael

Link to comment
Share on other sites

je voulais simplement utiliser un pot de 250k de la mdbox

c'est des pots de 10k qu'il faut utiliser.

Un pot qui envoie des valeurs de note, ça doit être pas trop compliqué à programmer, mais il me semble mieux d'utiliser un encodeur rotatif "cranté" ("detended")...moi je suis une bille en prog mais d'autres pourront t'aider ici...

notes que ton encodeur rotatif doit aussi emettre un message de type note Off, il te faut donc utiliser une variable pour sauver la valeur de la dernière note envoyée pour que à chaque incrementation de l'encodeur il soit d'abord envoyé le note Off de la note précédente.

Sans doute (je suis une bille en prog) tu peux utiliser une table contenant toute les notes, table dont les entrées seront lue l'une aprés l'autre, en montant ou descendant selon la direction de la rotation de l'encodeur.... une fonction en asm te permet d'incrementer/décrementer un pointeur pour accéder aux différentes location d'une table (page 216 et 250 de la datasheet du PIC18F452)...

pour choisir la note de base, il te faut créer une variable supplémentaire, déterminée par des messages de note entrants ou/et par tes boutons qui determinera quelle entrée de ta table est lue en premier..

prends le temps de traduire ton dernier post, c'est trés clair comme ça, et il y a des anglophones bien plus doués que moi pour ce genre de chose...

relance le sujet dans la partie MIOS programming (Assembler) ou ©....

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...