DCN LED controller

From biophysics
Revision as of 14:00, 24 January 2024 by Lof (talk | contribs) (→‎Matlab code)
Jump to navigation Jump to search
DCN-LED controller
DCN-LED controller inside

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.

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 (ledpattern).

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.

1:  n = 8;
2:  s = ledpattern(n);
3:  for i = 1:2:n
4:     s(i).set(0:2:14,'r');
5:     s(i).set(1:2:15,'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);

If multiple hosts should get each their own instruction you have to create multiple instances of ledpattern and of ledcontroller_pi.

  • 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 even channel numbers are made red.
  • In line 5 the leds with odd channel numbers 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.