MIDIFighter Source
Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1

    Default MIDIFighter Source

    I just wanted to say thank you for making the source code so easy to read, I have been trying to dissect everything, and the comments have been invaluable.

    Im pretty new to micro-controller programming, so I do have some questions:
    Where are the input/output pins specified? (Im sure its been starring me in the face this whole time)
    How does the TLC5924 work?
    What does the ADC file do?

    Im sure Ill be adding more questions to this.

    Thanks for your time,
    Ben.

  2. #2
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default

    Thanks for the compliment. I spent a long time making the code as easy to use as possible. Most of the example code I see on the Arduino is written by non-programmers, so I thought I'd make a full sized, well documented piece of microcontroller code for a change.

    Your questions:

    Q: Where are the input/output pins specified? (Im sure its been starring me in the face this whole time)

    A: The addresses of the IO pins are specified in the WinAVR headers, specifically the headers:

    Code:
    avr/include/avr/iousb162.h
    avr/include/avr/iousbxx2.h
    It's useful to generate "TAGS" for a project you're not familiar with, so for Emacs (which I use) I run something like:

    Code:
    find . -name "*.[c|h] -exec etags -a {} \;
    find ../WinAVR -name "*.[c|h] -exec etags -a {} \;
    find ../LUFA -name "*.[c|h] -exec etags -a {} \;
    to let the "etags" program visit every .c and .h file in my project and libraries and build a database of where these things are first defined. Then I can do a "M-." search for the definition of the value or function under the cursor and the editor jumps me there.


    Q: How does the TLC5924 work?

    A: The datasheet will tell you everything you need to know.

    http://focus.ti.com/docs/prod/folder...t/tlc5924.html

    There's an LED BLANK pin that can be used to turn off all LEDS at once but we never use that feature, so we set it LOW during setup and keep it there. After setup the chip works using SPI - we shift in two bytes, 16 bits, where each bit represents one of the LEDs and it turns on or off the LED assocuated with those bits. That's pretty much it. The chip has other features for coping with different LED voltages that we never use. Check out the datasheet.


    Q: What does the ADC file do?

    A: It controls the ADC chip we added to the board that allows us to read the four analog inputs on the expansion bus. The chips that the Arduino uses have ADC built in, but our chip doesn't (it has USB hardware instead). So to read analog signals we added a MCP3004 chip to the SPI bus. It's data sheet is here:

    http://ww1.microchip.com/downloads/e...Doc/21295C.pdf

    It's got a fairly straightforward protocol for reading an Analog channel and returning 10 bits of binary data - essentially you shift out 3 specifically formatted bytes over SPI and shifts back in three bytes, the bottom two bytes being the 10-bit ADC value. First byte sent tells it which channel to read and the unused bits in the bytes introduce exactly the right amount of delay for the read and conversion to happen. Nifty.
    Last edited by Fatlimey; 06-28-2010 at 04:16 PM.

  3. #3

    Default

    Awesome, thanks for helping me out, Im so far in over my head
    So Im trying to adapt the MIDIFighter code for the Teensy, so::

    Include the headers for the AVR chip the Teensy uses?
    (And whats that second included header "avr/include/avr/iousbxx2.h"? Is that generic?)

    And I shouldnt have to worry about the ADC stuff because the Teensy already has that, right?
    And what about the LED driver, is that going to be necessary with the Teensy?
    And if I try to document what Im doing and turn it into a tutorial of sorts, would you check over it and make sure I dont say something stupid?

    Thanks,
    Ben

  4. #4
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default

    Quote Originally Posted by BenitoIsAwesomr View Post
    So Im trying to adapt the MIDIFighter code for the Teensy
    You'd best look at the Makefile and change the name of the platform to match the chip in the Teensyduino. The final "midifighter.hex" will be correctly compiled for your board, and the PORT numbers will be correct.

    Quote Originally Posted by BenitoIsAwesomr View Post
    And I shouldnt have to worry about the ADC stuff because the Teensy already has that, right? And what about the LED driver, is that going to be necessary with the Teensy?
    The ADC functions will need to be rewritten to read the ADC ports of your microcontroller rather than trying to communicate with an missing ADC chip. That boils down to replacing the SPI mechanism with a single PORT read.

    The LED driver is a useful device to add to your design as it's made to provide constant current to however many LEDs you use, so they don't change brightness when you turn lots of them on or off.


    Quote Originally Posted by BenitoIsAwesomr View Post
    And if I try to document what Im doing and turn it into a tutorial of sorts, would you check over it and make sure I dont say something stupid?
    Saying something stupid never stopped me! Sure, no problem.

  5. #5
    DJTT Infectious Moderator photojojo's Avatar
    Join Date
    Apr 2010
    Location
    Sherman, TX
    Posts
    13,925

    Default

    Quote Originally Posted by Fatlimey View Post



    Saying something stupid never stopped me!
    I've gotten pretty far in life saying stupid things.
    Chris Jennings FHP

    Podcast - Soundcloud - Mixcloud - Beatport Charts - x

  6. #6

    Default

    Alright thanks I really do appreciate the help.

    So in the makefile I need to change:
    Code:
    # MCU name
    MCU = at90usb162
    to match the processor in the Teensy? Thats it?

    Thanks,
    Ben

  7. #7
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default

    Well, that's where you start. Change that, recompile, see what happens.

    Getting it to compile is the first step to getting to be functional. Remember, the Teensy doesn't have the latch-and-shift-in key readers, the LED controller or the ADC chip, but you should be able to enumerate connect over USB.

  8. #8

    Default

    What do you mean enumerate connect?
    Also I only need the latch-and-shift for multiplexers right? (From what Im reading it doesnt sound like it, woo Google)

    Thanks,
    Ben
    Last edited by BenitoIsAwesomr; 07-02-2010 at 02:11 PM.

  9. #9
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default

    USB devices first connect, then send a big packet of description about themselves to the Host which, if the host thinks they are worthy, they are deemed "Enumerated" and will appear in your list of active hardware.

    "Connecting" is the just first part of that whole process, so I tend not to use that word.

  10. #10

    Default

    Alright, thanks! Now I understand what you meant about getting it to enumerate. Ill probably be back with more questions Thanks for helping me out, I really appreciate it.

    Thanks,
    Ben

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •