drumwide Posted January 3, 2004 Report Share Posted January 3, 2004 can someone help me to write a loop in assembly.I want to scan the analog inputs for votage, loop until peak voltage is reached, then transmit the peak voltage as velocity via midi,and then start over after the pin voltage goes to zero.I have several ideas about how to do this, I am looking for the best way. ??? Quote Link to comment Share on other sites More sharing options...
TK. Posted January 3, 2004 Report Share Posted January 3, 2004 Hi Drumwide,if you want to realize it on a modular (re-usable) way, it makes sense to split the "loop" over different tasks, and to control them via a finite state machine. This needs some experience, but once you've started the implementation in this way, changes in the concept will be easier. So, before I describe how to setup the framework, I just did this for you.Download this file:http://www.ucapps.de/tmp/drums.inc.txtcopy it into your application directory, rename it to drums.inc and #include it from "main.asm" (e.g. after the midi_evnt.inc module)Add following lines to app_defines.h:;; used by drums.inc DRUMS_STATE_BEGIN EQU 0x050 ; for 8 drum triggers DRUMS_STATE_END EQU 0x057 DRUMS_MAX_VALUE_BEGIN EQU 0x058 ; for 8 drum triggers DRUMS_MAX_VALUE_END EQU 0x05f DRUMS_CTR EQU 0x060 ; used as loop counter Add: "call DRUMS_Init" to the USER_Init function "call DRUMS_Tick" to the USER_Tick function "call DRUMS_Timer" to the USER_SR_Service_Finish function change USER_AIN_NotifyChange to: USER_AIN_NotifyChange ;; convert 10-bit value to 7-bit value rrf MIOS_PARAMETER3, F ; value / 2 rrf MIOS_PARAMETER2, F rrf MIOS_PARAMETER3, F ; value / 2 rrf MIOS_PARAMETER2, F rrf MIOS_PARAMETER3, F ; value / 2 rrf MIOS_PARAMETER2, F bcf MIOS_PARAMETER2, 7 ; clear 8th bit ;; now: pot number in MIOS_PARAMETER1 ;; 7-bit value in MIOS_PARAMETER2 ;; if drum trigger (MIOS_PARAMETER1 < 8): ;; branch to the DRUMS module movlw 8-1 IFLEQ MIOS_PARAMETER1, ACCESS, goto DRUMS_AIN_NotifyChange ;; else continue with MB64 pot handler ;; (expects number of pot in WREG) movf MIOS_PARAMETER1, W goto MB64_POT_Handler I've added some comments to drums.inc - hope they are understandable. It took 15 minutes to program this framework, but one hour to write the comments ;-)However, this module should work ok for the beginning, but a really good drum trigger handler requires some fine tuning effort. And - maybe also a hardware improvements - I don't, how long the peak value from the drum trigger output is available, than more inputs are sampled, than higher the propability that you miss the peaks. A solution for this problem would be an integrator circuit which forwards the envelope of the sensor out to the analog input of the core. With a release time of ca. 5 mS you should get perfect results, in this way up to 64 triggers could be handled under very relaxed conditions.Best Regards, Thorsten.P.S.: try this module with MIOS V1.5 I sent you yesterday, it needs only 200 uS for every analog input Quote Link to comment Share on other sites More sharing options...
drumwide Posted January 6, 2004 Author Report Share Posted January 6, 2004 :-XI am truly speechless. You have done in 15 minutes what it would take me years to learn. Thank You. 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.