Jump to content

wackazong

Programmer
  • Posts

    298
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by wackazong

  1. Hello again, one short question (did some searching, not finding anything, although I am pretty sure it must be around): When I talk to my Core32 from my computer (Mac), I can get something which is called "unique id" or to be specific, the kMIDIPropertyUniqueID. Is that in any way related to the device id or anything? Can it be set from MIOS32? This property is only available from CoreMidi (OS X specific). Thanks, wackazong.
  2. That link is too complicated to be true. Conrad does not seem to know the concept of permalinks (which probably says a lot about them :) Could you repost a working link? Thanks!
  3. Funktioniert bei mir ganz gut. Ab und an nicht nachvollziehbare Hänger beim Upload. Dann einfach: Alles neustarten und neu verstöpseln, und einfach ein paar Mal probieren bis es geht.
  4. Hallo und willkommen, Du brauchst ausserdem noch MIDI-Java-Classes: http://www.midibox.org/dokuwiki/doku.php?id=mios_studio#mac_os_x
  5. @Screaming Rabbit: OK, geht raus per B-Post Paket (6 Franken). Gruss, ALEXander.
  6. These were meant for testing only, I do my own PCB design for DIN and DOUT. I ordered these once, but never actually used them since my own design advanced (at that moment, anyway) faster than I thought.
  7. Hi! As I am moving my projects to MIOS32, I sell some older parts: 1 SPRUT USB Burner for PICs, with ICSP cable, for programming Core PICS (I programmed some SMD cores). Works nicely. 20 Euro 1 LTC_V.2 kit from Mike, unused: 5 Euro 1 MBHP-Burner kit from Mike, unused: 8 Euro All together für 30 Euro. I also have a couple of sampled PICS (4620) which I can give away. Either get them from me or order something and I can put them in the package. I also have some SMD PICs 4620 and 4685 which I ordered as samples and would give away, if anybody is interested. ALEXander.
  8. After some months of rather intensive experiences with the MBHP I must say: Just use two cores :) I do that now as well, and seems to work just fine. ALEXander.
  9. Oh, and here is the compiled asm code, now that I looked where stryd told me to look :) _output.zip _output.zip
  10. Yep, would be very nice if I could have a look at that! Thanks and best, ALEXander.
  11. For me, it helps seeing these == <> = errors (assign and logical compare are different signs). Since I am new to C, I always forget this convention, and EVELYN very often points me right to these cases :)
  12. Hi, at the risk of being a bit off-topic: I want to program a driver for a MIDIBox project in Cocoa/Objective C/Xcode. Since some of you are using that as well: Do you have any tips for good classes that provide Core Midi and Serial Port functionality? Thanks, ALEXander.
  13. Wohooo! I shredded one of my four-layer prototype boards, but now it works again, with another core. I have absolutely no idea why.... But I am happy again. ... stryd, therefore looking forward to you looking at how to accelerate my code :) and thanks for the tips. look at the nice colorfade. actually, when I press the buttons, the corresponding led flashes briefly in blue, but the camera cannot really capture it :) 46MERPmsIWQ ALEXander.
  14. Its actually three PCAs connected to the bus, and each one of them worked perfectly... I took all three of them out, soldered in another one, connected them to another core, nothing works.... One question I have: How can I see whether the slave sends an ACK or not? MIOS_IIC_ByteSend gives back 0 when the slave sends a NAK, but the description does not say if not 0 means "ACK received". Regarding the driver: I am happy to share it, I did not so far because there are some features left I want to implement (group brightness for example). But I will, don't worry. I thought about making an assembler module, but its really not wort it since its only a bunch of IIC commands. BTW, its posted here already: http://www.midibox.org/forum/index.php/topic,12257.0.html
  15. Hi! Yesterday I had everything, now nothing.... My IIC stopped working, and I cannot find out why. I made a debug routine which just sends a MIOS_IIC_Start and then a MIOS_IIC_Stop about every second to the IIC bus. Am I right that both SDA and SCL should change from about 5V (after issuing Stop) to about 0V (after issuing start) in that interval? My SDA changes from 0V (after Start) to 4.8V (after Stop) in the said interval, with nothing attached but the pullup resistors. That seems ok. (4.8 V is the supply voltage of the core, the pullup resistors are connected to 5V, because I use a schottky diode in front of the PIC power supplay for other reasons (in-circuit programming adapter)) MY SCL (also with pullup) changes from 4.8V after Stop (the supply voltage of the PIC) to 5V after Start (the supply voltage of the rest of the board). That seems strange to me, shouldn't the line be low then? But maybe the pullup resistors play a role, and whether the PICs Pin is draining power or not. But I have no idea... Do you have any hints for troubleshooting IIC connections? I have an Oscilloscope, but do not really know how to use it for debugging IIC. I use IIC to drive some PCA9635 LED chips (datasheet attached). Please remember: The whole configuration worked beautifully without a flaw yesterday, and then suddenly IIC stopped working. Therefore the basic setup should be ok, I just have no idea what I changed. Any help really appreciated, ALEXander. PCA9635.pdf PCA9635.pdf
  16. Yeah, thats all arrays, because I have to go through the 127 LEDs, with each three colors. Anyway, I did not expect that you really wanted to dwelve that deep into my code, but that is of course more than welcome. All files are attached, the makefile contains the path definitions at the top, after adjusting them it should compile normally. Thanks and best, ALEXander. knoepfli.zip knoepfli.zip
  17. I had a look at the lst file, but I do not really know how to interpret it... ALEXander.
  18. Oh, whatever, I will post it here. What I do is: I have 127 RGB LEDs connected via driver chips to the core. The communication is via IIC. Also, for each LED, there is a button. The LEDs can be set to a color, but they can also go into BLINK modus. In BLINK modus, they fade between two colors in 32 steps in a regular interval. Additionally, when the corresponding button is pressed, the LED FLASHES up in a third color, which is then faded into the normal color in a second or so. Blinking and Flashing can occur at the same time, without disturbing the blinking frequency or phase. These are the variables I am using. Lots of unsigned char arrays, but no problems with variable memory so far. ///////////////////////////////////////////////////////////////////////////// // Global variables ///////////////////////////////////////////////////////////////////////////// //status register for all leds knoepfli_led_status_t knoepfli_led_status[KNOEPFLI_LED_NUMBER]; //timer counter through all leds unsigned char knoepfli_led_counter; //color state arrays for all LEDs. Three separate arrays for the colors because of array size limitations on the pic ///////////////////////////////////////////////////////////////////////////// //this array contains the current color of the LEDs, without the flash effect but with blinking unsigned char knoepfli_led_color_now_red[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_now_green[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_now_blue[KNOEPFLI_LED_NUMBER]; //blink stuff ///////////////////////////////////////////////////////////////////////////// //these arrays contain one of the two blinking colors for all LEDs unsigned char knoepfli_led_color_from_red[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_from_green[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_from_blue[KNOEPFLI_LED_NUMBER]; //these arrays contain the second color for the blinking unsigned char knoepfli_led_color_to_red[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_to_green[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_to_blue[KNOEPFLI_LED_NUMBER]; //this array contains the step counter for the blinking unsigned char knoepfli_led_blink_counter[KNOEPFLI_LED_NUMBER]; //this array contains the direction of the step counter //only one bit per LED is needed, but bitfields with a size of 128 do not seem to work unsigned char knoepfli_led_blink_direction[KNOEPFLI_LED_NUMBER]; //flash stuff ///////////////////////////////////////////////////////////////////////////// //these arrays contain the flash color of all LEDs unsigned char knoepfli_led_color_flash_red[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_flash_green[KNOEPFLI_LED_NUMBER]; unsigned char knoepfli_led_color_flash_blue[KNOEPFLI_LED_NUMBER]; //this array contains the step counter for all LEDs for the flash unsigned char knoepfli_led_flash_counter[KNOEPFLI_LED_NUMBER]; The next function is called periodically by Tick in the main loop. This could be improved by setting a flag in Timer and checking the flag in Tick to get regular intervals ///////////////////////////////////////////////////////////////////////////// // Blink and Flash Handler // Treats only one LED per call // First determines the current color of the LED, if it is blinking // Then additionally applies the flash color fade, if the LED is flashing ///////////////////////////////////////////////////////////////////////////// void KNOEPFLI_Blink_and_Flash_Handler() { unsigned char red,green,blue,change; // //avoid the compiler warnings about non-defined variables // red = 0; // green = 0; // blue = 0; //set change flag to false change = 0; if( knoepfli_led_status[knoepfli_led_counter].BLINK == 1 ) { //the color has to be changed, set the flag change = 1; red = KNOEPFLI_Interpolate32( knoepfli_led_blink_counter[knoepfli_led_counter], knoepfli_led_color_from_red[knoepfli_led_counter], knoepfli_led_color_to_red[knoepfli_led_counter]); green = KNOEPFLI_Interpolate32( knoepfli_led_blink_counter[knoepfli_led_counter], knoepfli_led_color_from_green[knoepfli_led_counter], knoepfli_led_color_to_green[knoepfli_led_counter]); blue = KNOEPFLI_Interpolate32( knoepfli_led_blink_counter[knoepfli_led_counter], knoepfli_led_color_from_blue[knoepfli_led_counter], knoepfli_led_color_to_blue[knoepfli_led_counter]); knoepfli_led_color_now_red[knoepfli_led_counter] = red; knoepfli_led_color_now_green[knoepfli_led_counter] = green; knoepfli_led_color_now_blue[knoepfli_led_counter] = blue; if( knoepfli_led_blink_direction[knoepfli_led_counter] == 0 ) { if( knoepfli_led_blink_counter[knoepfli_led_counter] == 32) { knoepfli_led_blink_direction[knoepfli_led_counter] = 1; --knoepfli_led_blink_counter[knoepfli_led_counter]; } else { ++knoepfli_led_blink_counter[knoepfli_led_counter]; }; } else { if( knoepfli_led_blink_counter[knoepfli_led_counter] == 0) { knoepfli_led_blink_direction[knoepfli_led_counter] = 0; ++knoepfli_led_blink_counter[knoepfli_led_counter]; } else { --knoepfli_led_blink_counter[knoepfli_led_counter]; }; }; }; if( knoepfli_led_status[knoepfli_led_counter].FLASH == 1 ) { //the color has to be changed, set the flag change = 1; red = KNOEPFLI_Interpolate32( knoepfli_led_flash_counter[knoepfli_led_counter], knoepfli_led_color_now_red[knoepfli_led_counter], knoepfli_led_color_flash_red[knoepfli_led_counter]); green = KNOEPFLI_Interpolate32( knoepfli_led_flash_counter[knoepfli_led_counter], knoepfli_led_color_now_green[knoepfli_led_counter], knoepfli_led_color_flash_green[knoepfli_led_counter]); blue = KNOEPFLI_Interpolate32( knoepfli_led_flash_counter[knoepfli_led_counter], knoepfli_led_color_now_blue[knoepfli_led_counter], knoepfli_led_color_flash_blue[knoepfli_led_counter]); if( knoepfli_led_flash_counter[knoepfli_led_counter] == 0 ) { knoepfli_led_status[knoepfli_led_counter].FLASH = 0; } else { --knoepfli_led_flash_counter[knoepfli_led_counter]; }; }; if( change == 1) { //Send Brightness red MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend( knoepfli_led_address_red[knoepfli_led_counter].DRIVER ); // send device address, bit #0 cleared to notify a write!!! MIOS_IIC_ByteSend( 0x02 + knoepfli_led_address_red[knoepfli_led_counter].LED ); // select brightness register of the corresponding led, the first one is 0xa2, no autoincrement MIOS_IIC_ByteSend( red ); // send brightness MIOS_IIC_Stop(); //Send Brightness green MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend( knoepfli_led_address_green[knoepfli_led_counter].DRIVER ); // send device address, bit #0 cleared to notify a write!!! MIOS_IIC_ByteSend( 0x02 + knoepfli_led_address_green[knoepfli_led_counter].LED ); // select brightness register of the corresponding led, the first one is 0xa2, no autoincrement MIOS_IIC_ByteSend( green ); // send brightness MIOS_IIC_Stop(); //Send Brightness blue MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend( knoepfli_led_address_blue[knoepfli_led_counter].DRIVER ); // send device address, bit #0 cleared to notify a write!!! MIOS_IIC_ByteSend( 0x02 + knoepfli_led_address_blue[knoepfli_led_counter].LED ); // select brightness register of the corresponding led, the first one is 0xa2, no autoincrement MIOS_IIC_ByteSend( blue ); // send brightness MIOS_IIC_Stop(); }; //increase the counter for the next run of the routine ++knoepfli_led_counter; if( knoepfli_led_counter == KNOEPFLI_LED_NUMBER ) { knoepfli_led_counter = 0; }; } And this is the interpolation function, now coded in C. Assembler did not work properly, and I decided to try it in C. Maybe this leaves some room for improvement. ///////////////////////////////////////////////////////////////////////////// // Interpolate32 // Gives back an interpolated value between value1 and value2 // The total number of steps is 33, from 0 to 32 ///////////////////////////////////////////////////////////////////////////// unsigned char KNOEPFLI_Interpolate32(unsigned char step, unsigned char value1, unsigned char value2) { unsigned char swap, diff; //send out value2 if step is the max value if( step == 32 ) { return value2; }; //send out value1 if step i 0 if( step == 0 ) { return value1; }; //invert the interpolation if value1 > value2 if( value1 > value2 ) { //swap the values swap = value2; value2 = value1; value1 = swap; //--step because we are counting from 0 to 32, not to 31 --step; //invert the step counter step = ~step; //clear the upper three bits step &= 0x1f; }; //get the difference diff = value2 - value1; //divide it through the total number of steps (>>5) and multiply it with step (gives an integer) then get the high byte, //shift the step counter three to the left to make it 8bit, store it in PRODL PRODL = step << 3; //store diff in PRODH PRODH = diff; //do the multiplication in assembler __asm movf _PRODL, W mulwf _PRODH, 0 __endasm; //add the lower value return value1 + PRODH; } Well, what do you think? Any questions will of course be answered most gladly :) ALEXander.
  19. Ok, I will. Later. You have been warned ;-) ALEXander.
  20. Yeah, I believed so. Nevertheless, when I am constantly fading 128 RGB-LEDs from one color to another, the system does slow down :-) But: The speed is just about ok, I do not want to use the new ARM system yet :) I think I coded more or less efficiently, the things I do are very simple, therefore I think that assembler optimisation is rarely needed. I do a lot of IIC communication, there is a delay in these assembler functions, maybe that consumes a lot of processor time? Anyway, I just wanted to know whether there is an easy way to disable non-neede functions of MIOS in order to speed it up. Am I right that the place to look is the MIOS_config.h file, or is there more? Thanks! ALEXander.
  21. Hi! Is it possible to achieve substantial speed improvements in MIOS when disabling some parts of it? And how is it done? I need only DIN and IIC and MIDI, nothing else regarding input/output, not DOUT, no AIN, no LCD even. Would it be worth disabling these? I think they could just be taken out of the mainloop, or disabled in the mios_config file? Thanks, ALEXander.
  22. Wow, that sounds good. Thanks, I will try.
  23. I need a function that is repeated with a frequency of about 4000Hz (4000 calls of the function per second). I implemented it in two ways: one just puts the function in void Tick(void) __wparam in the main.c sceleton, the other puts it in void Timer(void) __wparam, and initialises the timer with MIOS_Timer_Init(0x03, 50). The one which just uses Tick works beautifully, and the core stays responsive, while the other one does not work at all, only when I increase the second paramer of the init to 100. But also then the function is awfully slow. The core is also responsive then, but the function does not work as expected. I know that Timer uses an interrupt routine, but why doesnt this work with Timer when it works with Tick? This is the code that is called (Flash_Handler is called, and uses Interpolate32): ///////////////////////////////////////////////////////////////////////////// // Interpolate ///////////////////////////////////////////////////////////////////////////// unsigned char KNOEPFLI_Interpolate32(unsigned char step, unsigned char value1, unsigned char value2) { unsigned char swap, diff; //send out value2 if step is the max value if( step == 32 ) { return value2; }; //send out value1 if step i 0 if( step == 0 ) { return value1; }; //invert the interpolation if value1 > value2 if( value1 > value2 ) { //swap the values swap = value2; value2 = value1; value1 = swap; //--step because we are counting from 0 to 32, not to 31 --step; //invert the step counter step = ~step; //clear the upper three bits step &= 0x1f; }; //get the difference diff = value2 - value1; //divide it through the total number of steps (>>5) and multiply it with step (gives an integer) then get the high byte, //shift the step counter three to the left to make it 8bit, store it in PRODL PRODL = step << 3; //store diff in PRODH PRODH = diff; //do the multiplication in assembler __asm movf _PRODL, W mulwf _PRODH, 0 __endasm; //add the lower value return value1 + PRODH; } ///////////////////////////////////////////////////////////////////////////// // Flash Handler ///////////////////////////////////////////////////////////////////////////// void KNOEPFLI_Flash_Handler() { unsigned char red, green, blue; if( knoepfli_led_status[knoepfli_led_counter].FLASH == 1 ) { red = KNOEPFLI_Interpolate32( knoepfli_led_flash_counter[knoepfli_led_counter], knoepfli_led_color_now_red[knoepfli_led_counter], knoepfli_led_color_flash_red[knoepfli_led_counter]); green = KNOEPFLI_Interpolate32( knoepfli_led_flash_counter[knoepfli_led_counter], knoepfli_led_color_now_green[knoepfli_led_counter], knoepfli_led_color_flash_green[knoepfli_led_counter]); blue = KNOEPFLI_Interpolate32( knoepfli_led_flash_counter[knoepfli_led_counter], knoepfli_led_color_now_blue[knoepfli_led_counter], knoepfli_led_color_flash_blue[knoepfli_led_counter]); //Send Brightness red MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend( knoepfli_led_address_red[knoepfli_led_counter].DRIVER ); // send device address, bit #0 cleared to notify a write!!! MIOS_IIC_ByteSend( 0x02 + knoepfli_led_address_red[knoepfli_led_counter].LED ); // select brightness register of the corresponding led, the first one is 0xa2, no autoincrement MIOS_IIC_ByteSend( red ); // send brightness MIOS_IIC_Stop(); //Send Brightness green MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend( knoepfli_led_address_green[knoepfli_led_counter].DRIVER ); // send device address, bit #0 cleared to notify a write!!! MIOS_IIC_ByteSend( 0x02 + knoepfli_led_address_green[knoepfli_led_counter].LED ); // select brightness register of the corresponding led, the first one is 0xa2, no autoincrement MIOS_IIC_ByteSend( green ); // send brightness MIOS_IIC_Stop(); //Send Brightness blue MIOS_IIC_Start(); // start IIC MIOS_IIC_ByteSend( knoepfli_led_address_blue[knoepfli_led_counter].DRIVER ); // send device address, bit #0 cleared to notify a write!!! MIOS_IIC_ByteSend( 0x02 + knoepfli_led_address_blue[knoepfli_led_counter].LED ); // select brightness register of the corresponding led, the first one is 0xa2, no autoincrement MIOS_IIC_ByteSend( blue ); // send brightness MIOS_IIC_Stop(); if( knoepfli_led_flash_counter[knoepfli_led_counter] == 0 ) { knoepfli_led_status[knoepfli_led_counter].FLASH = 0; } else { --knoepfli_led_flash_counter[knoepfli_led_counter]; }; }; //increase the counter for the next run of the routine ++knoepfli_led_counter; if( knoepfli_led_counter == KNOEPFLI_LED_NUMBER ) { knoepfli_led_counter = 0; }; }
  24. I did the interpolation algorithm in C, have a look at the code, should work. It interpolates in 33 steps, step can be 0 to 32. ///////////////////////////////////////////////////////////////////////////// // Interpolate ///////////////////////////////////////////////////////////////////////////// unsigned char KNOEPFLI_Interpolate32(unsigned char step, unsigned char value1, unsigned char value2) { unsigned char swap, diff; //send out value2 if step is the max value if( step == 32 ) { return value2; }; //send out value1 if step i 0 if( step == 0 ) { return value1; }; //invert the interpolation if value1 > value2 if( value1 > value2 ) { //swap the values swap = value2; value2 = value1; value1 = swap; //--step because we are counting from 0 to 32, not to 31 --step; //invert the step counter step = ~step; //clear the upper three bits step &= 0x1f; }; //get the difference diff = value2 - value1; //divide it through the total number of steps (>>5) and multiply it with step (gives an integer) then get the high byte, //shift the step counter three to the left to make it 8bit, store it in PRODL PRODL = step << 3; //store diff in PRODH PRODH = diff; //do the multiplication in assembler __asm movf _PRODL, W mulwf _PRODH, 0 __endasm; //add the lower value return value1 + PRODH; }
×
×
  • Create New...