Jump to content

jrp

Members
  • Posts

    221
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by jrp

  1. i jst saw that tk answered the same question regarding mios8. The same should apply here. It works alsmost like the code i suggested above, with one big difference: I was suggesting a global variable. That does work, but is usually a good idea to avoid. The neat thing i just learned, and since we are both learning i like to share this:: What is a static variable? It is a variable that will be created once and not change over function calls. So if the code below would read "unsigned char ain_sent = 0;" without the static keyword, the variable would be recreated every tick and midi would be sent every ms. With static, this variable will be created once inside the function block (so it is not polluting the global namespace). Next time it will be 1 and the condition in the if statement will fail. ///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS in the mainloop when nothing else is to do ///////////////////////////////////////////////////////////////////////////// void Tick(void) __wparam { static unsigned char ain_sent = 0; if( ain_sent == 0 ) { unsigned char pin; unsigned char num_ain = MIOS_AIN_NumberGet(); ain_sent = 1; // only sent once after startup for(pin=0; pin < num_ain; ++pin) { MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); } } }
  2. it´s in the manual under din http://midibox.org/mios32/manual/ I cannot try this right now, but i would assume something like int my_button = MIOS32_DIN-PinGet(0); will save 1 or 0 to the variable my_button. But again, if you have a normal "digital" push button this will only work while the button is actually pressed.
  3. s32 MIOS32_DIN_PinGet (u32 pin) With this function you gen poll the state of a din pin, eg when using switches in your setup.
  4. The thing is: With all digital inputs you cannot get any state UNLESS a button is pressed. It would be different with actual switches that hold their state low or high. But a button or encoder has no permanent state. When you press or turn it you get a pulse that will trigger the mios callback routine. Thats it. So the direction you should be looking is to save the last state of all buttons and encoders in your code, and load it on startup. Unfortunately i am still a noob, so i cannot really tell you how to do that. But there is some example code for sd cards and bancsticks.
  5. i am also wondering about running a function once. I was under the impression that this could be done within the init function, but that does not seem to work. What does work (please tell us if this is not the way to do this) is defining a variable like: u8 has_run = 0; then in the background task you can check for has run == 0, do your stuff, set has_run to something different than 0. Your code inside the if statement will never run again... if (has_run==0){ do everything you want; has_run = 1; }
  6. Dear Forum, like the titel suggests. The TLC5947 can be bought in ready soldered modules and was suggested to me for dynamically driving solenoids, as an alternative to dac channels i proposed in my other thread. Reason is the parts count, so before i build 24 ladders with analog shaping and drivers i thought i should maybe look into pwm once more. So the question is if from within an mios32 application, i can use the SPI interface. If so i would try to code some form of "hello world" example with the pwm module first and then go from there. Also is it fast enough? I need a pulse of less than 5ms to minimize the on time of the solenoids and give good response with pecussive instruments. Has anyone done something similar? Thanks!
  7. i think it´s super cool that you post this after three years - we all know how fast a project can be on halt and never be returned to... I woul love to try this! Go midibox 2025!
  8. If anyone is interested, this sort of works, turning off the pins/updating the lcd after a specified time. It works as in the J5 debounce tutorial 006_rtos_task. Thanks for all the great tutorials, they really provide a good starting point for people like me!
  9. // $Id$ /* * MIOS32 Tutorial #020: LCD Output * see README.txt for details * * ========================================================================== * * Copyright (C) 2009 Thorsten Klose (tk@midibox.org) * Licensed for personal non-commercial use only. * All other rights reserved. * * ========================================================================== */ ///////////////////////////////////////////////////////////////////////////// // Include files ///////////////////////////////////////////////////////////////////////////// #include <mios32.h> #include "app.h" #include <stdbool.h> const char* bool_to_string(bool value) { return value ? "1" : "0"; //u8 velocity_dependent_timings[16]={20,18,17,16,14,13,10,10,10,10,10,10,10,10,10,10}; } u8 note_off_timers[24]; ///////////////////////////////////////////////////////////////////////////// // This hook is called after startup to initialize the application ///////////////////////////////////////////////////////////////////////////// void APP_Init(void) { // initialize all LEDs MIOS32_BOARD_LED_Init(0xffffffff); // initialize all pins of J5A, J5B and J5C as outputs in Push-Pull Mode int pin; for(pin=0; pin<12; ++pin) MIOS32_BOARD_J5_PinInit(pin, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); int i; for(i=0; i<24; ++i) { note_off_timers[i]=0; } } ///////////////////////////////////////////////////////////////////////////// // This task is running endless in background ///////////////////////////////////////////////////////////////////////////// void APP_Background(void) { // clear LCD // MIOS32_LCD_Clear(); } ///////////////////////////////////////////////////////////////////////////// // This hook is called each mS from the main task which also handles DIN, ENC // and AIN events. You could add more jobs here, but they shouldn't consume // more than 300 uS to ensure the responsiveness of buttons, encoders, pots. // Alternatively you could create a dedicated task for application specific // jobs as explained in $MIOS32_PATH/apps/tutorials/006_rtos_tasks ///////////////////////////////////////////////////////////////////////////// void APP_Tick(void) { // PWM modulate the status LED (this is a sign of life) u32 timestamp = MIOS32_TIMESTAMP_Get(); MIOS32_BOARD_LED_Set(1, (timestamp % 20) <= ((timestamp / 100) % 10)); int i; for(i=0; i<24; ++i) { if( note_off_timers[i]>0) { --note_off_timers[i]; } else { int j = i*4; MIOS32_BOARD_J5_PinSet(j, 0); MIOS32_BOARD_J5_PinSet(j+1,0); MIOS32_BOARD_J5_PinSet(j+2,0); MIOS32_BOARD_J5_PinSet(j+3,0); MIOS32_LCD_CursorSet(j, 0); // X, Y MIOS32_LCD_PrintString(" "); } } } ///////////////////////////////////////////////////////////////////////////// // This hook is called each mS from the MIDI task which checks for incoming // MIDI events. You could add more MIDI related jobs here, but they shouldn't // consume more than 300 uS to ensure the responsiveness of incoming MIDI. ///////////////////////////////////////////////////////////////////////////// void APP_MIDI_Tick(void) { } u8 start=0; // to clear the lcd... int velocity_4bit; ///////////////////////////////////////////////////////////////////////////// // This hook is called when a MIDI package has been received ///////////////////////////////////////////////////////////////////////////// void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package) { // toggle Status LED on each incoming MIDI package MIOS32_BOARD_LED_Set(0x0001, ~MIOS32_BOARD_LED_Get()); // no idea how and where else i can clear the lcd if( start == 0 ) { MIOS32_LCD_Clear(); start=1; } if( midi_package.type == NoteOn && midi_package.velocity > 0 ) { u8 note_number = (midi_package.note % 12); u8 dout_pin = note_number * 4; velocity_4bit = midi_package.velocity >> 3; //note_off_timers[note_number] = velocity_dependant_timings[velocity_4bit]; MIOS32_BOARD_J5_PinSet(dout_pin, !((velocity_4bit >> 3)) & 1); MIOS32_BOARD_J5_PinSet(dout_pin+1, !((velocity_4bit >> 2)) & 1); MIOS32_BOARD_J5_PinSet(dout_pin+2, !((velocity_4bit >> 1)) & 1); MIOS32_BOARD_J5_PinSet(dout_pin+3, !((velocity_4bit >> 0)) & 1); // Just for testing: Print to lcd: MIOS32_LCD_CursorSet(dout_pin, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 3) & 1)); MIOS32_LCD_CursorSet(dout_pin+1, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 2) & 1)); MIOS32_LCD_CursorSet(dout_pin+2, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 1) & 1)); MIOS32_LCD_CursorSet(dout_pin+3, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 0) & 1)); note_off_timers[note_number] = 3000/(velocity_4bit*2); // just for testing, this has to be tested and maybe we want longer gate for low velocity MIOS32_LCD_CursorSet(0, 1); MIOS32_LCD_PrintFormattedString("%02d:%02d:%02d", midi_package.velocity,velocity_4bit,note_off_timers[note_number]); } else if( (midi_package.type == NoteOff) || (midi_package.type == NoteOn && midi_package.velocity == 0) ) { u8 dout_pin = (midi_package.note % 12)*4; MIOS32_BOARD_J5_PinSet(dout_pin, 0); MIOS32_BOARD_J5_PinSet(dout_pin+1,0); MIOS32_BOARD_J5_PinSet(dout_pin+2,0); MIOS32_BOARD_J5_PinSet(dout_pin+3,0); //MIOS32_LCD_CursorSet(dout_pin, 0); // X, Y //MIOS32_LCD_PrintString(" "); } } ///////////////////////////////////////////////////////////////////////////// // This hook is called before the shift register chain is scanned ///////////////////////////////////////////////////////////////////////////// void APP_SRIO_ServicePrepare(void) { } ///////////////////////////////////////////////////////////////////////////// // This hook is called after the shift register chain has been scanned ///////////////////////////////////////////////////////////////////////////// void APP_SRIO_ServiceFinish(void) { } ///////////////////////////////////////////////////////////////////////////// // This hook is called when a button has been toggled // pin_value is 1 when button released, and 0 when button pressed ///////////////////////////////////////////////////////////////////////////// void APP_DIN_NotifyToggle(u32 pin, u32 pin_value) { } ///////////////////////////////////////////////////////////////////////////// // This hook is called when an encoder has been moved // incrementer is positive when encoder has been turned clockwise, else // it is negative ///////////////////////////////////////////////////////////////////////////// void APP_ENC_NotifyChange(u32 encoder, s32 incrementer) { } ///////////////////////////////////////////////////////////////////////////// // This hook is called when a pot has been moved ///////////////////////////////////////////////////////////////////////////// void APP_AIN_NotifyChange(u32 pin, u32 pin_value) { }
  10. ///////////////////////////////////////////////////////////////////////////// // Include files ///////////////////////////////////////////////////////////////////////////// #include <mios32.h> #include "app.h" #include <stdbool.h> const char* bool_to_string(bool value) { return value ? "1" : "0"; }
  11. now i have to look into timers to get some way of resetting my pins after some ms. Solenoids don´t like to be "on" for long, and the glockenspiel needs only a short percussive hit.
  12. that was easier to code than i thought. I really enjoyed learning about this. I dont have my scope, my douts or any leds here, so i added some code to print the output pattern to the lcd. I noticed that if i put the clear_lcd command outside any of the function blocks, i get an error during compilation. No sure how this should be done. I found a workaround though... #include <stdbool.h> is needed at the top of main.c for the display of the boolean values on the lcd u8 start=0; // to clear the lcd... int velocity_4bit; ///////////////////////////////////////////////////////////////////////////// // This hook is called when a MIDI package has been received ///////////////////////////////////////////////////////////////////////////// void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package) { // toggle Status LED on each incoming MIDI package MIOS32_BOARD_LED_Set(0x0001, ~MIOS32_BOARD_LED_Get()); // no idea how and where else i can clear the lcd if( start == 0 ) { MIOS32_LCD_Clear(); start=1; } if( midi_package.type == NoteOn && midi_package.velocity > 0 ) { u8 dout_pin = (midi_package.note % 12)*4; velocity_4bit = midi_package.velocity >> 3; MIOS32_BOARD_J5_PinSet(dout_pin, !((velocity_4bit >> 3)) & 1); MIOS32_BOARD_J5_PinSet(dout_pin+1, !((velocity_4bit >> 2)) & 1); MIOS32_BOARD_J5_PinSet(dout_pin+2, !((velocity_4bit >> 1)) & 1); MIOS32_BOARD_J5_PinSet(dout_pin+3, !((velocity_4bit >> 0)) & 1); // Just for testing: Print to lcd: MIOS32_LCD_CursorSet(dout_pin, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 3) & 1)); MIOS32_LCD_CursorSet(dout_pin+1, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 2) & 1)); MIOS32_LCD_CursorSet(dout_pin+2, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 1) & 1)); MIOS32_LCD_CursorSet(dout_pin+3, 0); // X, Y MIOS32_LCD_PrintString(bool_to_string((velocity_4bit >> 0) & 1)); MIOS32_LCD_CursorSet(0, 1); MIOS32_LCD_PrintFormattedString("%02d:%02d", midi_package.velocity,velocity_4bit); } else if( (midi_package.type == NoteOff) || (midi_package.type == NoteOn && midi_package.velocity == 0) ) { u8 dout_pin = (midi_package.note % 12)*4; MIOS32_BOARD_J5_PinSet(dout_pin, 0); MIOS32_BOARD_J5_PinSet(dout_pin+1,0); MIOS32_BOARD_J5_PinSet(dout_pin+2,0); MIOS32_BOARD_J5_PinSet(dout_pin+3,0); //MIOS32_LCD_CursorSet(dout_pin, 0); // X, Y //MIOS32_LCD_PrintString(" "); } }
  13. i looked through the analog toolbox code, there it appears that a timer is set to produce a tick every 1ms. So i will try to got that route in mios32.
  14. This looks amazing! With some of the older chips like vintage vca, filter or delay chips you really have to be careful regarding heat and also (or even more so) static discharge. Nowadays with most ics these issues have long been solved by modern manufacturing processes and built in safety measures. I had to lear the hard way that this is not the case with chips from the 80s... So the heatsink is probably a good idea, as would be any way to allow for some airflow. On the other hand, i have removed the fans from some of my gear with no issues at all, as commercial units have to consider every worst case scenario (crowded rack in hot environment). So if you know how you use your gear you can get away with things that could not be allowed for every scenario.
  15. Thanks! Since i need two octaves the resistor ladder cv-lc will not get me far. Using three Midibox_CV_NG would do the trick, but i consider this really overkill since i am pretty sure that i will not get more than 8, maybe 16 different amplitude levels with the solenoids and Glockenspiel. So 3 or 4 bit resolution should be ideal. I have since been looking once more into the dout example in the mios32 programming section. The code to adress 4 dout pins for every note to get 16 voltage levels should be very straight forward. I am sure to get something running over the weekend. I will see if there are any general design problems with this idea.
  16. Dear forum, i would love to designa midibox that gives me up to 32 custom velocity sensitive envelopes with some special shapes (i want two attack phases) That makes me think: How do you program the timing of an envelope? I would love to learn about this :) In Mios32 there are timers, ticks, delay, freeRTOS tasks.... Where would you built an simple envelope generator? The finished apps like midiboxCV2 are so complex that i could not really find the answer in the code myself. Btw, midiboxCV2 would fit my usecase perfectly, but it is limited to one AOUT module. Thank you very much!
  17. i have not tried this, but from what i understand most parameters of the sid are controllable from cc or sysex. MidiboxNG could be used to enhance the midibox Sid control suface. Or maybe(!) MidiboxNG could function as a complete programmer for the MB_SID, also handling saving of patches. Not sure though, if i remember correctly not all parameters are available as sysex... If you have any findings please let us know, i am also interested in this. A midibox Sid with an extended control suface, led-rings, maybe with motorfaders, oled displays, BL-Matrix....
  18. Dear Forum, to drive electro magnetic actuators with some velocity sensitivity i am thinking about -instead of using 4 expensive Aout modules with the need of bipolar power: - mapping midi note on and velocity to 3 or 4 dio pins with a resistor ladder to get 8 or 16 voltage levels. I would tune the resistors to get a custom curve because solenoids need a minimum impulse to get moving (initial lowest level around 50%, then linear to 100% from there). Is this a reasonable idea? What Midibox App is a good starting point? Can this be done with MidiboxNG? From reading through the Manual i assume yes, but is it reasonable and fast enough for 24 3 or 4 bit outs? (Midifying a 2 octave Glockenspiel) Or should i start from scratch with a new mios32 app? I know a little C and i have worked through most of the tutorials.... but not much more. The documentation is superb, but still i feel a little lost... My solution is sure to have a lot of if statements, propably hard coding every velocity of every note value by hand... Or is it necessary to program a driver for a new "Midibox Aout_4Bit" module? (<- would be the thing i feel least confident about, no idea where to start...) As an alternative i tried using the pwm signal from dimmed LEDs in MidiboxNG, but that did not work very well bacause the pwm frequency is rather low (around 4 pulses in 10ms), to slow for very short trigger impulses. I am really excited to getting started with 32 bit Midibox - my last build was the MB Sid, quite some years ago :) Thanks for any comments!
  19. Thank you! Didn´t think of mouser! Even on Amazon they are only listed as smd. My next step would have been to solder them using little wires on every second pin... like with the mb-cv dac on my avatar photo. At Reichelt it can be found as 74HC 541 in dip, but i assume this will not work with the logic level coming from the controller. 75HCT541 is only available as SO20.
  20. I have the same problem... where has it been answered?
  21. Hi Thorsten, thanks so much! I tried everything suggested in that other thread, with no result. Then i managed to get my hands on a few more micro-usb cables. Guess what, i had been switching between two faulty cables. Everything is running fine now, core is detected in Mios-Studio. PS.: I am happy to be back with this stuff :) Back at ucapps.de Didn´t find the time for a long while. Now i got a job at the HfM Nürnberg to (among other stuff) build robotic percussion... If all goes to plan they will be powered by midibox :)
  22. Dear Midibox-Forum, i just was trying to use a core32 for the first time. I flashed the ST-Link firmware, installed the driver and uploaded the bootloader on my STM32F4Discovery following the described methode using my win11 Laptop. Unfortunately, when i connect the micro-usb port neither my windows, nor my m2 mac computers detect any midi interface. When i look at the system-info under usb, i see the st-link, but nothing else. I tried both micro-usb cables i could find around the house. Of course they could both be faulty, i have no other device to test them with. I attached a short video of me pressing the reset button. Is this the correct light pattern on the board? In other words, is my bootloader running? Thanks, Jens IMG_2901.MOV
  23. anyone using all their gates at J5?
  24. i cannot recomend this. Linear regulators will be very unhappy in such a case. It is not that the regeulator can adapt in a mannor: "Ok, i need to drop 3V, so i just adjust myself to 8.5V." The Voltage will drop, yes, and the regulator will be fighting and sweating, not being able to do what it´s supposed to do: Stabilize voltage and get rid of any ripple. It will lead to hum and possible failure. For non demanding circuits (not this one!) it would then be better to go without a regulator altogether. Don´t try this with your sid though. Also, to be safe it is common practice to account for 10% mains variations. If you measure voltage and the regulator is a little of, just check the voltage at it´s input. These Parts have tolerances, so you might be getting 8.7V from 12v. That would be fine.
  25. jrp

    External switches

    Any news on this? I also noticed that with some patches it can happen that the AOUT or triggers aren´t working as expected. Sume other functions as well, seems rather strange and hard to repeat. I have another thread about this, but i just saw yours. Propably it has to do with new assignments in the setup file in conjunction with older patches. Problem is i always noticed this late, so i cannot say what changes exactly made this happen. In my case Trigger 1 and 8 are not working on my slave core, on my master core i had the same problem with triggers falling back to 0. Maybe someone else besides TK can check on this or confirm it is working for them... Someone with a MB_SID using all triggers, or with an "exposed" core module so they don´t need to take stuff appart. Then at least we know it´s not a bug (what i actually doubt) but some mistake at our side (although i carefully inspected solder joints a thousand times). Thank you!
×
×
  • Create New...