Leds and speakers controlled with Matlab
5 ビュー (過去 30 日間)
古いコメントを表示
Hi all! I want to write a Matlab code to emit tones and ligh under control by an external trigger signal. It's the first time I am doing this, and I am a bit lost. The tones will be produced by my laptops soundcard, and the ligh by LEDs. I have seen people using Arduino boards to control the LEDs, but I'd like to know if there's a simpler solution. The trigger signal will be processed with a PC card. Any help, recommended links or tutorials, possible solutions, ideas how to do this are more than welcome.
Thank you very much
1 件のコメント
Daniel Shub
2011 年 11 月 28 日
How many LEDs and how many channels of sound. How accurately do the LEDs need to be synced to the sound?
採用された回答
Gergely Öllös
2011 年 11 月 28 日
Hi,
I suppose the simplest solution is to hook the LEDs to the LPT port and control it through the putvalue CMD. It’s fast enough to control hundreds of LEDs (if you serialize the data transfer). If you need to control up to 8 LEDs you can directly connect the LEDs to the LPT port through a single resistor/LED (then you can turn on/off these LEDs independently, without any serious hardware). There are additional ports on the LPT that you can use for additional LED control; these are the 4 ctrl (control) lines. You can use the putvalue CMD as for the 8 data lines (then you can control 12LEDs independently). The reason I mentioned them separately is that those lines are inverted (except INI). Here is the code that controls the 8 data lines and the 4 control lines:
warning('off', 'daq:digitalio:adaptorobsolete');
%Creating the digital I/O object
dio = digitalio('parallel','LPT1');
%Adding the lines to the object
daio = addline(dio,0:7,0,'out'); ctrl = addline(dio,0:3,2,'out');
%D0 D1 D2 D3 D4 D5 D6 D7
putvalue(daio,[0 1 0 1 0 1 0 1]); % Here every second led is lit.
%~TR ~AU INI ~SL
putvalue(ctrl,[1 1 0 1]); %Here every LED is off
The hardware: Connect to each led a 100ohm resistor. Connect the cathode (-) of each led to the GND (25. LPT pin). Each anode (+) connect to the following pins: DATA (pin 2., pin 3., pin 4., pin 5., pin 6., pin 7., pin 8., pin 9.), CONTROL (pin 1., pin 14., pin 16., pin 17.) and that’s all.
If you have trouble controlling the LPT port use the "FAST io32" object.
If you need to have a trigger (this not generates any interrupts) from outside (up to 5 sources) scan the input lines of the LPT port with the getvalue CMD.
stat = addline(dio,0:4,1,'in');
%ER SE PE AK ~BY
getvalue(stat);
INPUT PINS (pin 15, pin 13, pin 12, pin 10, pin 11 inverted)
I hope this helps, Gergo
2 件のコメント
Daniel Shub
2011 年 11 月 28 日
This solution requires the DAQ toolbox (and hence Windows). The standard serial port I/O should be able to do similar things with standard MATLAB on any platform. In all cases syncing the LEDs to the sound is going to be difficult.
その他の回答 (1 件)
Image Analyst
2011 年 11 月 29 日
I like the devices from Measurement Computing http://www.mathworks.com/products/daq/supportedio.html, like the PMD-1024LS. They're USB devices but they have other kinds too.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Digital Input and Output についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!