Difference between revisions of "DCN LED controller"
(10 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
*The LEDs that are used in all the labs are [[LED specifications|Bivar 5BC-3-CA-F LED]]. | *The LEDs that are used in all the labs are [[LED specifications|Bivar 5BC-3-CA-F LED]]. | ||
− | == | + | ==How to use== |
− | + | Connect the controller box to a 5V power supply.<br> | |
− | + | Connect the controller box to Ethernet.<br> | |
− | + | Connect a trigger signal to the signal input.<br> | |
− | + | Connect on or more LEDs to the output channels (stereo mini-jack).<br> | |
+ | Create in matlab a ledpattern array (up to 16 ledpatterns).<br> | ||
+ | Each ledpattern consists of an array of bits for red LEDs and an array of bits for green LEDs, as well as an overall Red intensity and a Green intensity.<br> | ||
+ | Create a ledcontroller_pi object with one or more hostnames (name is on the box). | ||
+ | Write the ledpattern array with the ledcontroller_pi object to the controller(s).<br> | ||
+ | Trigger the DCN-LED controller(s) with a 5V trigger signal.<br> | ||
+ | After each trigger the next ledpattern is activated.<br> | ||
==Matlab code== | ==Matlab code== | ||
Line 40: | Line 46: | ||
2: s = ledpattern(n); | 2: s = ledpattern(n); | ||
3: for i = 1:2:n | 3: for i = 1:2:n | ||
− | 4: s(i).set(0 | + | 4: s(i).set([0,2,4],'r'); |
− | 5: s(i).set(1 | + | 5: s(i).set([1,3,5],'g'); |
6: s(i).intensity('r', 50); | 6: s(i).intensity('r', 50); | ||
7: s(i).intensity('g', 50); | 7: s(i).intensity('g', 50); | ||
Line 53: | Line 59: | ||
*In line 2 an array of n ledpatterns is created. | *In line 2 an array of n ledpatterns is created. | ||
*In line 4 to 7 the ledpatterns of pattern 1, 3, 5 and 7 are set. | *In line 4 to 7 the ledpatterns of pattern 1, 3, 5 and 7 are set. | ||
− | *In line 4 the leds with | + | *In line 4 the leds with channel numbers 0, 2 and 4 are made red. |
− | *In line 5 the leds with | + | *In line 5 the leds with channel numbers 1, 3 and 5 are made green. |
*In line 6 the intensity of the red leds are set to 50. Allowed values are 0 to 50. | *In line 6 the intensity of the red leds are set to 50. Allowed values are 0 to 50. | ||
*In line 7 the intensity of the green leds set to intensity 50. The green intensity must be equal to the red intensity or 0. | *In line 7 the intensity of the green leds set to intensity 50. The green intensity must be equal to the red intensity or 0. |
Latest revision as of 14:24, 24 January 2024
Description
The DCN-LED controller is a 16 channel two color led controller with an Ethernet interface. The controller is developed in house by our Technical Support Group. The controller is based on an Arduino Mega for the control of the LED output channels and a Raspberry Pi for the Ethernet communication. A pair of Matlab functions is available for the programming of the controller.
Specifications
- Arduino Mega
- Arduino software: Standard_32_LEDModule_V1.16.ino
- Response time to trigger < 200 micro sec
- Raspberry Pi 3 or 4
- Raspberry Software: %todo
- External 5V Raspberry power supply
- 16 mini jack connectors for LEDs
- Test buttons for Red and Green LEDs
- BNC connector for input trigger
- Ethernet connector for communication with the Raspberry Pi
- The LEDs that are used in all the labs are Bivar 5BC-3-CA-F LED.
How to use
Connect the controller box to a 5V power supply.
Connect the controller box to Ethernet.
Connect a trigger signal to the signal input.
Connect on or more LEDs to the output channels (stereo mini-jack).
Create in matlab a ledpattern array (up to 16 ledpatterns).
Each ledpattern consists of an array of bits for red LEDs and an array of bits for green LEDs, as well as an overall Red intensity and a Green intensity.
Create a ledcontroller_pi object with one or more hostnames (name is on the box).
Write the ledpattern array with the ledcontroller_pi object to the controller(s).
Trigger the DCN-LED controller(s) with a 5V trigger signal.
After each trigger the next ledpattern is activated.
Matlab code
In the biofysica toolbox in Gitlab (see led code) there are two functions for controlling the DCN-LED controller:
- ledcontroller_pi.m
- ledpattern.m
The <ledcontroller_pi> function can control up multiple hosts at once with the same instructions (ledpatterns).
The files starting with <ex_led> are examples for how to use the functions.
Here is an example where two hosts (LED-controllers) are used with a single ledpattern array of 8 pattern. Patterns 1, 3, 5 and 7 have red and green LEDs activated, while patterns 2,4,6 and 8 have all LEDs deactivated.
If multiple hosts should behave independently you have to create multiple instances of ledpattern and of ledcontroller_pi.
1: n = 8; 2: s = ledpattern(n); 3: for i = 1:2:n 4: s(i).set([0,2,4],'r'); 5: s(i).set([1,3,5],'g'); 6: s(i).intensity('r', 50); 7: s(i).intensity('g', 50); 8: end 9: host1='dcn-led01.local'; 10: host2='dcn-led02.local'; 11: leds = ledcontroller_pi(host1, host2); 12: leds.write(s);
- In line 1 the number of ledpatterns is specified.
- In line 2 an array of n ledpatterns is created.
- In line 4 to 7 the ledpatterns of pattern 1, 3, 5 and 7 are set.
- In line 4 the leds with channel numbers 0, 2 and 4 are made red.
- In line 5 the leds with channel numbers 1, 3 and 5 are made green.
- In line 6 the intensity of the red leds are set to 50. Allowed values are 0 to 50.
- In line 7 the intensity of the green leds set to intensity 50. The green intensity must be equal to the red intensity or 0.
- In line 9 and 10 the host names of the devices are assigned. These are the names on the box followed by '.local'.
- In line 11 the ledcontroller is created with references to the hosts.
- In line 12 the ledpatterns are written to the two hosts.