- Disclaimer: I'm not an electric engineer, nor am I a technical writer I share my experiences in order to help others but while what I've done works I don't know if I've managed to miss a detail I don't know about.
Not only is this my first attempt at making a circuit board, it's also my first attempt at writing a how-to document. I apologize if it is hard to follow, I am open to feedback on how to improve my presentation of information.
Goal: Create a light that turns on automatically when the record button is pressed in VMIX
Method: Using the Teensy 4.0 board to create a midi receiver a MOSFET power board handles providing power to an LED light.
The Parts:
- Teensy 4.0 Board Teensy 4.0 with pins from Amazon.com
- MOSFET capable of handling 12V switchable with 3.3 Example MOSFET Board from Amazon.com
- Power supply to power the light Example Power Supply
- LED Light Example Light
- PCB To tie it all together Through Hole PCB
The Tools:
- Soldering Iron
- Solder
- Tape
The Supplies:
- Some wires
- power connectors
- Micro USB cable for the Teensy
The Theory:
The Teensy can act as a midi interface which allows one to capture the midi command from VMIX. It works like an Arduino which means it can put a logic signal to its pins. The MOSFET allows one to switch on a circuit at a higher voltage than the 3.3V the teensy provides. (In my case this was a 12V LED Light). To make it all work together the power supply needs to be connected to the Input pins on the MOSFET board, the LED needs to be connected to the Output pins on the MOSFET board and the MOSFET board needs to be connected to the signal or gate pin on the Teensy.
Part 1: Assemble the parts
This was the part that was scariest for me because I am a novice at soldering at the board level. Wires don't bother me, but through hole soldering was new to me.
I took my Printed Circuit Board (PCB) and clamped them in the set of helping hands my wife got me for Christmas. QuadHands I've seen videos of people using board vises or clamps and those seem better but I used what I had.
Step 1: was mounting the Teensy to the board. I had bought the teensy that was factory mounted to some pins so this part was just a matter of taping the Teensy to the PCB and then touching my soldering iron to each pin, and waiting for the solder to flow into the hole.
Step 2: was mounting a 4 pin header that worked with the MOSFET board I had, again taped the header in place and applied heat and solder
Step 3: Attach the MOSFET board to the header, this didn't work with tape because the header ended up pushing the MOSFET board away from the PCB, I ended up using sticky tack to hold it in place and again solder the MOSFET board to the header.
Step 4: Attach wires to convey electricity from the Teensy to the MOSFET
This one was tricky because I needed the wires to stay in the holes while I applied solder, but I also needed the wires to be small enough to go into the holes. After many false starts I ended up bending the wire into place on the back of my PCB and taping it in place so that it stayed while I applied solder. I picked pin 6 as my signal pin so I ran a wire from Pin 6 on the teensy to the gate pin on the MOSFET board, and another from the ground pin on the Teensy to the ground pin on the MOSFET board.
Optional: I tried to make my life easier by soldering a 2.1X5.5 Barrel jack to board(this is the type of connector on the sample power supply I linked). Then I ran a wire from the board to the screw terminals on the MOSFET board. This is not necessary but I thought it would be a nice touch.
Given full control of the components I would have a board made with the MOSFET board incorporated onto the main board without it being a shield connected via header. And I'd have the Power jacks at each end for connecting power in and out.
Final: Attached a pigtail 2.1X5.5 Barrel Male connector to plug into the LED light.
Part 2: Set up the Teensy
This part gets hard. Before I took on this project I played with Arduino and the Arduino IDE so I already had that installed on my computer. I had to install some drivers on my windows 10 computer to get it to work properly. Sadly that part was long ago so I don't have the step by step for that, but I'll provide some links that got me going.
- Teensy Getting Start First Use
- Teensy Boot Loader Loader
- Troubleshooting Guide TroubleShooting
Assuming I get notified I will be happy to offer what help I can in the comments but I mostly just used a search engine and forums to solve my problems until I could load my code onto my teensy board.
I used the "blink" sample sketch to test if all my connections were working. and they were. The only change I made was to change the pin from 13 to 6.
To Make it respond to VMIX I used the following code adapter from one of the samples provided by Teensy.
/* Receive Incoming USB MIDI by reading data. This approach gives you access to incoming MIDI message data, but requires more work to use that data. For the simpler function-based approach, see InputFunctionsBasic and InputFunctionsComplete. Use the Arduino Serial Monitor to view the messages as Teensy receives them by USB MIDI You must select MIDI from the "Tools > USB Type" menu This example code is in the public domain. */ int ledPin=6; void setup() { Serial.begin(115200); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, HIGH); delay(400); // Blink LED once at startup digitalWrite(ledPin, LOW); } void loop() { // usbMIDI.read() needs to be called rapidly from loop(). When // each MIDI messages arrives, it return true. The message must // be fully processed before usbMIDI.read() is called again. if (usbMIDI.read()) { processMIDI(); } } void processMIDI(void) { byte type, channel, data1, data2, cable; // fetch the MIDI message, defined by these 5 numbers (except SysEX) // type = usbMIDI.getType(); // which MIDI message, 128-255 channel = usbMIDI.getChannel(); // which MIDI channel, 1-16 data1 = usbMIDI.getData1(); // first data byte of message, 0-127 data2 = usbMIDI.getData2(); // second data byte of message, 0-127 cable = usbMIDI.getCable(); // which virtual cable with MIDIx8, 0-7 // uncomment if using multiple virtual cables //Serial.print("cable "); //Serial.print(cable, DEC); //Serial.print(": "); // print info about the message // switch (type) { case usbMIDI.NoteOff: // 0x80 if (data1==0x3C){ digitalWrite(ledPin, LOW); // turns off LED } break; case usbMIDI.NoteOn: // 0x90 if (data1==0x3C){ digitalWrite(ledPin, HIGH); // turns on LED } break; case usbMIDI.AfterTouchPoly: // 0xA0 Serial.print("AfterTouch Change, ch="); Serial.print(channel, DEC); Serial.print(", note="); Serial.print(data1, DEC); Serial.print(", velocity="); Serial.println(data2, DEC); break; case usbMIDI.ControlChange: // 0xB0 Serial.print("Control Change, ch="); Serial.print(channel, DEC); Serial.print(", control="); Serial.print(data1, DEC); Serial.print(", value="); Serial.println(data2, DEC); break; case usbMIDI.ProgramChange: // 0xC0 Serial.print("Program Change, ch="); Serial.print(channel, DEC); Serial.print(", program="); Serial.println(data1, DEC); break; case usbMIDI.AfterTouchChannel: // 0xD0 Serial.print("After Touch, ch="); Serial.print(channel, DEC); Serial.print(", pressure="); Serial.println(data1, DEC); break; case usbMIDI.PitchBend: // 0xE0 Serial.print("Pitch Change, ch="); Serial.print(channel, DEC); Serial.print(", pitch="); Serial.println(data1 + data2 * 128, DEC); break; case usbMIDI.SystemExclusive: // 0xF0 // Messages larger than usbMIDI's internal buffer are truncated. // To receive large messages, you *must* use the 3-input function // handler. See InputFunctionsComplete for details. Serial.print("SysEx Message: "); printBytes(usbMIDI.getSysExArray(), data1 + data2 * 256); Serial.println(); break; case usbMIDI.TimeCodeQuarterFrame: // 0xF1 Serial.print("TimeCode, index="); Serial.print(data1 >> 4, DEC); Serial.print(", digit="); Serial.println(data1 & 15, DEC); break; case usbMIDI.SongPosition: // 0xF2 Serial.print("Song Position, beat="); Serial.println(data1 + data2 * 128); break; case usbMIDI.SongSelect: // 0xF3 Serial.print("Sond Select, song="); Serial.println(data1, DEC); break; case usbMIDI.TuneRequest: // 0xF6 Serial.println("Tune Request"); break; case usbMIDI.Clock: // 0xF8 Serial.println("Clock"); break; case usbMIDI.Start: // 0xFA Serial.println("Start"); break; case usbMIDI.Continue: // 0xFB Serial.println("Continue"); break; case usbMIDI.Stop: // 0xFC Serial.println("Stop"); break; case usbMIDI.ActiveSensing: // 0xFE Serial.println("Actvice Sensing"); break; case usbMIDI.SystemReset: // 0xFF Serial.println("System Reset"); break; default: Serial.println("Opps, an unknown MIDI message type!"); } } void printBytes(const byte *data, unsigned int size) { while (size > 0) { byte b = *data++; if (b < 16) Serial.print('0'); Serial.print(b, HEX); if (size > 1) Serial.print(' '); size = size - 1; } }
This uses the Activators section of VMIX.
Open VMIX and click on the settings button for the application.
Then Click down onto Activators
Make sure Teensy is enabled by clicking on the Enable Devices button
On this screen a Note number needs to be provided that matches what was programmed into the Teensy.
Then under event set it to recording.
The trick that caught me offguard is that I needed to represent the pin in the code with hex, so while I typed 60 in the note field in VMIX I needed to type in 0x3C in the arduino code.
Connect the power supply to the proper screw terminals on the MOSFET and then connect the proper cables from your LED light to the out terminals and then when you hit record the light should come on.
No comments:
Post a Comment