nebula Posted May 8, 2011 Report Share Posted May 8, 2011 So it seems I got my DOUT pins backwards. Pin 7 is connected to what should be pin 0, pin 6 is connected to what should be 1, etc. I think I'd like to try to modify the app to accomodate this, rather than try to modify my pcb. And so ... this would finally mark my first foray into the world of actual MIDIbox programming. I'd love it if somebody could suggest a place to start, or otherwise tell me it's a stupid idea (and that I should just fix the board) Quote Link to comment Share on other sites More sharing options...
julienvoirin Posted May 8, 2011 Report Share Posted May 8, 2011 (edited) if you have only inverted Oi (i=0 ... i=7) of 74HC595, i think that you can certainly modify it into application declarations (or define) (i will take a fast look) check this section in setup_808_default.asm : ; ========================================================================== ; Following statements are used to assign LED functions to DOUT pins ; ; To enable a LED function, specify the shift register number SR (1-16), ; and the pin number (0-7). ; Note that Pin 0 is D7 of the DOUT register, Pin 1 is D6, ... Pin 7 is D0 ; ; With SR value = 0, the LED function will be disabled ; ========================================================================== ;; SR ignore Pin LED_SECTION_A EQU ((( 2 -1)<<3)+ 6) LED_SECTION_B EQU ((( 2 -1)<<3)+ 5) LED_SECTION_C EQU ((( 2 -1)<<3)+ 3) LED_SECTION_D EQU ((( 2 -1)<<3)+ 1) ;; SR ignore Pin LED_LAYER_GATE EQU ((( 2 -1)<<3)+ 7) LED_LAYER_AUX EQU ((( 2 -1)<<3)+ 0) ;; SR ignore Pin LED_EDIT EQU ((( 7 -1)<<3)+ 3) LED_MUTE EQU ((( 6 -1)<<3)+ 7) LED_PATTERN EQU ((( 7 -1)<<3)+ 1) LED_SONG EQU ((( 7 -1)<<3)+ 2) ;; SR ignore Pin LED_SOLO EQU ((( 0 -1)<<3)+ 0) LED_FAST EQU ((( 0 -1)<<3)+ 0) LED_ALL EQU ((( 0 -1)<<3)+ 0) ;; SR ignore Pin LED_GROUP1 EQU ((( 0 -1)<<3)+ 0) LED_GROUP2 EQU ((( 0 -1)<<3)+ 0) LED_GROUP3 EQU ((( 0 -1)<<3)+ 0) LED_GROUP4 EQU ((( 0 -1)<<3)+ 0) ;; SR ignore Pin LED_SHIFT EQU ((( 6 -1)<<3)+ 2) LED_ALT EQU ((( 6 -1)<<3)+ 1) ;; SR ignore Pin LED_RECORD EQU ((( 7 -1)<<3)+ 4) LED_BEAT EQU ((( 7 -1)<<3)+ 5) ;; SR ignore Pin LED_PLAY EQU ((( 7 -1)<<3)+ 0) LED_STOP EQU ((( 6 -1)<<3)+ 6) LED_PAUSE EQU ((( 0 -1)<<3)+ 0) LED_FWD EQU ((( 6 -1)<<3)+ 5) LED_REW EQU ((( 6 -1)<<3)+ 4) LED_LIVE EQU ((( 6 -1)<<3)+ 3) ;; SR ignore Pin LED_MIDI_RX EQU (((0 -1)<<3)+ 0) ; OPTIONAL! see CHANGELOG.txt LED_MIDI_TX EQU (((0 -1)<<3)+ 0) ; SR=0 -> disabled by default you will have to edit SR and Pin numbers to fit your design, and then recompile if you need to reassign GP_Led, better ask to someone expert with the dedicated code (like TK) Edited May 8, 2011 by julienvoirin Quote Link to comment Share on other sites More sharing options...
nebula Posted May 8, 2011 Author Report Share Posted May 8, 2011 (edited) The GP LEDs are indeed backwards. What I'll need to do is change something about the way the entire app talks to DOUT pins. I hope there may be a single routine that could be modified to solve this across the whole app. Edited May 8, 2011 by nebula Quote Link to comment Share on other sites More sharing options...
nebula Posted May 8, 2011 Author Report Share Posted May 8, 2011 OK, I have just checked the logic of the 7-segment displays. They are inverted as well, in exactly the same way ... pin 7=0, 6=1, etc Meanwhile it occurred to me that if I can't modify the app, I could just get a little ugly with the way resistors are connected and the problem would be solved... no trace cutting at least. Quote Link to comment Share on other sites More sharing options...
nebula Posted May 8, 2011 Author Report Share Posted May 8, 2011 (edited) There are 10 places in "seq_leds.inc" that call MIOS_DOUT_SRSet. Each is preceded by a movff and movlw. Maybe this is the right place to look? I presume movff and movlw are transferring a byte to a place that MIOS_DOUT_SRSet looks to set the value of 8 pins. If so, I think we only need to reverse the 8-bit word before it gets moved ... (Non-programmer trying to reverse-engineer. I must be entertaining some people) Edited May 8, 2011 by nebula Quote Link to comment Share on other sites More sharing options...
Altitude Posted May 9, 2011 Report Share Posted May 9, 2011 (edited) .. Edited May 9, 2011 by Altitude Quote Link to comment Share on other sites More sharing options...
nebula Posted May 9, 2011 Author Report Share Posted May 9, 2011 Looking a little more closely I have found SEQ_GP_LED_Update. I am still poking around in the dark, but I think I may be able to find a place in there where the bits could be reversed, perhaps by way of an existing function. Also, for the BPM display, I should be able to either take the same approach or else modify the lookup table for the 7-segment displays. I will continue to post progress - but I would still love to hear input or guidance from anybody familiar with assembly language. Quote Link to comment Share on other sites More sharing options...
TK. Posted May 9, 2011 Report Share Posted May 9, 2011 Swapping bits within a byte is very time consuming, it will definitely affect the sequencer timings. Don't to this, fix the hardware instead! Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
TK. Posted May 9, 2011 Report Share Posted May 9, 2011 argh - just noticed that you are the guy who developed this great PCB! :) Hm.... it will definitely be difficult to find a good solution. :-/ Maybe patching MIOS would help? You could change the direction of all DOUT registers in MIOS32_SRIO_Loop: [tt] MIOS_SRIO_Loop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 7 bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 7 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 7 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 6 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 6 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 6 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 5 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 5 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 5 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 4 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 4 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 4 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 3 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 3 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 3 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 2 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 2 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 2 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 1 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 1 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 1 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop btfsc MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bsf IRQ_TMP5, 0 bcf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK bsf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss INDF2, 0 bcf MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT btfss MIOS_SRIO_PORT_DIN, MIOS_SRIO_PIN_DIN bcf IRQ_TMP5, 0 bsf MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK nop [/tt] The bold lines mark the code which has to be changed - instead of counting INDF2 from 0 to 7, it's addressed from 7 to 0 in this modification. All LED assignments have to be adapted thereafter, direct (8-bit) SR Writes will be mirrored (as you want) Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
nebula Posted May 9, 2011 Author Report Share Posted May 9, 2011 (edited) I don't like the idea of changing MIOS, but to get this working I will do it. As soon as you suggested it I thought I would probably just reroute 16 resistors and be done with it -- but then I realized I will still need to modify SEQ_BPM_Digit_TABLE. So ... I would rather do one software hack, than a software hack plus a hardware hack. With the help of Altitude, I configured xcode 3 to act as an SVN client so I was able to download the files. (SVN n00b here) I successfully downloaded all the MIOS files into a directory, and I made the changes to MIOS_SRIO_Loop as detailed. From here I'm stuck. I looked at "Makefile" and saw # define the processor here so I changed the following line to read PROCESSOR = 18f4620. I went to the directory and typed make, the response was Makefile:37: /include/makefile/asm_only.mk: No such file or directory make: *** No rule to make target `/include/makefile/asm_only.mk'. Stop. Copied the directory /include/ from a previous app download and compared "asm_only.mk" to one on svn , seems the same. Fixed path at bottom of makefile to point to this file. Now when I try to run make I get a big pile of gpasm messages, no output though. I know I'm close, it is just getting the hang of the syntax behind makefile and gpasm. I think I'm stuck .... might be easier to move a few resistors ;) Edited May 10, 2011 by nebula Quote Link to comment Share on other sites More sharing options...
nebula Posted May 10, 2011 Author Report Share Posted May 10, 2011 WHAT????? HOLY CRAP .... it took about 2 hours of playing around and I figured it out. I rebuilt MIOS with the code changes you described. This reversed all DOUT outputs, and now my box seems to light up flawlessly, except that the cathodes unfortunately got reversed to the BPM display. I'll look in the app to see about fixing that. This is AWESOME. Thanks TK Quote Link to comment Share on other sites More sharing options...
nebula Posted May 10, 2011 Author Report Share Posted May 10, 2011 (edited) Explored the file seq_leds.inc and found that the only reason my bpm display worked at all is because the original code duplicates the 4 common (cathode) pins. So pins 0, 1, 2, and 3 are duplicated on 4, 5, 6, and 7. Nifty ... and that suits me just fine, especially when I saw the following line: xorlw 3 ; (reverse digit select lines) Which I commented out by simply preceding it with two semicolons (;;) ... now my BPM display works perfectly. I only have one more tweak to make to the MB-808 firmware, for which I might need some help. I want the "instrument select" encoder, when turned while holding down SHIFT, to perform "rotate" instead of "instrument select". Let's see how far I get. :thumbsup: EDIT: I know from an old reply from TK that I want to call CS_M_UTILS_RotateLeft and CS_M_UTILS_RotateRight. Having trouble figuring out how to get it to differentiate between encoder events while a button is held down. EDIT: Help!!! I don't think I'm up for this one. I'm having a really hard time figuring out the structure from looking at the way the buttons work. TK, can we call this a "feature request"??? I want to turn the instrument encoder while holding down shift to invoke "rotate". And it doesn't help that this sequencer is so fun to use, it's really distracting! Edited May 10, 2011 by nebula Quote Link to comment Share on other sites More sharing options...
nebula Posted May 11, 2011 Author Report Share Posted May 11, 2011 I've been continuing to poke away at this. I am beginning to understand the code a little, thanks to the excellent commenting throughout, and with the help of the PIC instruction summary at http://www.ic.unicamp.br/~celio/mc404/pic/pic_instructionset_summary.html If I understand correctly, SEQ_BUTTON_Shift gets called every time the SHIFT button changes state. So the first thing it does, not knowing whether it was pressed or released, is clear SEQ_MODE1_SHIFT. Then we check to see if it was released, in which case we set SEQ_MODE1_SHIFT. (I may have this backwards) Now, for example, in SEQ_BUTTON_Rew_Pressed, the first thing we do is check to see if shift is pressed (SEQ_MODE1_SHIFT should be cleared), and if it is, we jump to CS_M_UTILS_RotateLeft. Otherwise we do a bunch of other stuff. The condition is spelled out in this line: btfsc SEQ_MODE1, SEQ_MODE1_SHIFT, BANKED (I still don't know what "BANKED" means) So now we'll look at SEQ_ENC_Inst. I don't understand how to determine the sign of MIOS_PARAMETER2, so that we can determine which way the encoder was turned, and thus which of CS_M_UTILS_RotateLeft or CS_M_UTILS_RotateRight to jump to. I'm thinking that immediately before or after SET_BSR SEQ_BASE, I need to insert the following: ;; If shift is pressed... btfsc SEQ_MODE1, SEQ_MODE1_SHIFT, BANKED goto SEQ_ENC_Inst_Shift Then at the end of the routine, before SEQ_ENC_GP, add a new label for SEQ_ENC_Inst_Shift This will be where I look at MIOS_PARAMETER2 and decide whether to goto CS_M_UTILS_RotateLeft or CS_M_UTILS_RotateRight. I'm still struggling over how to read the sign of MIOS_PARAMETER2, so this is where I'm now stuck. Quote Link to comment Share on other sites More sharing options...
nebula Posted May 12, 2011 Author Report Share Posted May 12, 2011 I have created SEQ_ENC_Inst_Shift ... I just can't figure out how to tell which direction the encoder has been turned. My code looks like this: SEQ_ENC_Inst_Shift btfsc MIOS_PARAMETER2, 0, BANKED goto CS_M_UTILS_RotateLeft goto CS_M_UTILS_RotateRight I tried assembling with every possible bit value, i.e. btfsc MIOS_PARAMETER2, 0, BANKED btfsc MIOS_PARAMETER2, 1, BANKED btfsc MIOS_PARAMETER2, 2, BANKED ... btfsc MIOS_PARAMETER2, 7, BANKED Given TK's comments: ;; -------------------------------------------------------------------------- ;; This function is called by USER_ENC_NotifyChange when the instrument encoder ;; has been moved. Input: ;; o signed incrementer value in MIOS_PARAMETER2: ;; - is positive when encoder has been turned clockwise ;; - is negative when encoder has been turned counter clockwise ;; -------------------------------------------------------------------------- ...I thought there would be a bit in this parameter that would tell me which way the encoder was turned. My method is partially working ... if I hold down shift, the musical part rotates to the right. It won't rotate to the left. I'm so close! How can I determine the sign? Quote Link to comment Share on other sites More sharing options...
nebula Posted May 13, 2011 Author Report Share Posted May 13, 2011 DONE! I recommend this as an app enhancement. I can't believe I figured this out. But here's the final summary of everything I've done. The section "If shift is pressed" has been added to SEQ_ENC_Inst SEQ_ENC_Inst SET_BSR SEQ_BASE ;; If shift is pressed btfsc SEQ_MODE1, SEQ_MODE1_SHIFT, BANKED goto SEQ_ENC_Inst_Shift ;; get current track and copy into TMP[12] call CS_M_HLP_GetSelectedTrk movwf TMP1 clrf TMP2 ;; if all tracks selected: set TMP1 to 16 BRA_IFSET SEQ_MODE0, SEQ_MODE0_CHANGE_ALL_STEPS, BANKED, SEQ_ENC_Inst_All incf SEQ_SELECTED_TRKS_0, W, BANKED bnz SEQ_ENC_Inst_NotAll incf SEQ_SELECTED_TRKS_1, W, BANKED bnz SEQ_ENC_Inst_NotAll The following section has been added before SEQ_ENC_GP SEQ_ENC_Inst_Shift incfsz MIOS_PARAMETER2, TMP1 ; increment MIOS_PARAMETER2. If it was -1 now it will be 0 goto CS_M_UTILS_RotateRight goto CS_M_UTILS_RotateLeft Now, when I hold down "shift" and turn the instrument encoder, the "rotate" feature is invoked! Gotta love trial and error! Thanks TK for your ultra-readable, open-source code. :D Quote Link to comment Share on other sites More sharing options...
nebula Posted May 14, 2011 Author Report Share Posted May 14, 2011 Finally, here's a video I just shot of the sequencer now that it's working. I still need to finish my enclosure and bankstick boards! Quote Link to comment Share on other sites More sharing options...
sneakthief Posted May 14, 2011 Report Share Posted May 14, 2011 That looks great! Such an economic layout - and ergonomic too. How much did those backlit switches cost? Quote Link to comment Share on other sites More sharing options...
nebula Posted May 14, 2011 Author Report Share Posted May 14, 2011 That looks great! Such an economic layout - and ergonomic too. How much did those backlit switches cost? Thanks! For aesthetic reasons, I was planning on using a red Waldorf knob in the centre, but now that I've used it a bit, I think I might instead use something lower-profile, like a flat Albs shuttle knob. I guess I'll see once it gets in the enclosure. The problem is that the big tall shaft in the middle feels like it's in the way. Also, I think I will reverse the behaviour of the shift button on the instrument encoder, so that it is "rotate" with no modifier key. The buttons are Multicomp tactile switches. I was tipped off to them in the "nice buttons" thread on here a few years ago. The red illuminated buttons are part number TS3B23, the black ones are TS0A22. They are available from Newark in for $1.59 and $1.30 (CAD), respectively (the picture on their site is wrong). Elsewhere they're available from Farnell. Quote Link to comment Share on other sites More sharing options...
Digineural Posted May 22, 2011 Report Share Posted May 22, 2011 Sick! I love the rotate feature. I hear you on the ALBS waldorf knobs. I recently switched to smaller soft touch RE'AN knobs on the smaller projects 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.