Transformation and dynamic visualization of images from computer through an FPGA in a matrix of LED

,

designed that allows visualization of a resident image in a personal computer, which, through a simple application and a custom designed hardware with a low energy consumption [24,25], allows its visualization in a matrix system of LEDs of a considerable size.

Methodology
In this application, a methodology that complies with the Top-Down philosophy has been considered as one of the most used in reconfigurable hardware systems, therefore, a general block diagram has been made of the implemented solution and from this, each one of the functional blocks has been designed, see Figure 1. The work done begins with the design of a software script on the personal computer, which sends the data of the digital image in binary-ascii format through a serial port emulated towards the FPGA, after that, the programmable logic device processes the information, sends the data to a power system that supports the electrical requirements at the speed required by the array of LEDs and in this way the correct visualization of the information is made.

Implementation and Results
The first part of the work is shown in the following code, the script reads different formats of images (jpg, png and gif), it will make the conversion to a matrix of valor to create the ROM file, it will be read for the FPGA and put in to LED matrix.
imread () /imshow () to verify that it is in full form for processing. im = imread('Mario_8bits.PNG'); figure () imshow(im) In the following code segment, to scale the image the imresize () function is used, which gives us the facility of scaling the value of a square or rectangular matrix to the size to be visualized in the array of LEDs, a bicubic interpolation algorithm was used, a process that guarantees that do not drastically change the information that will be sent to the FPGA.
The next code shown that the matrices for the images that are entered were defined for a size of 32x32 being this a square matrix, the selection of the size is based on the space to occupy within the ROM memories that will be of 1024 bits maximum size of each block of memory of a standard FPGA, which has a capacity of 8 times the value of each block generated. The image already scaled is broken down into the 3 matrices of the channels that make up a digital image R (network), G (green) and B (blue), maintaining the intensity characteristics to conform the different color possibilities, in each matrix the values of each pixel have a magnitude between 0 and 255. The combination of these channels conforms the scaled image, which will be used to occupy value by value the array of LEDs for their respective visualization. Figure 2 shows the matrices or channels R, G and B in which the most characteristic values of the image to be displayed can be observed. If they are compared, the first array has a prominent white value, which means a 255 magnitude or a strong red color, in the image where it is observed completely and with darker tones blacks are 0 or a red value in a blue representation image. Figure 1. RGB channels of the image that will be scaled and sent to the FPGA

Transmission of Information Blocks from Matlab to FPGA-send in RGB
For the reception of the data is done with a CORE performed directly by Xilinx [17], as one of the modules implemented for the 8 Bit PICOBlaze processor, since this CORE is performed at very low level only uses 22 Slices of the one FPGA Spartan type to perform the data reception. Figure 3 shows the block diagram of the reception design for RS232 on a Xilinxs FPGA made by Mr. Chapman. Figure 2. RS232 reception block; core provided by Xilinx for PicoBlaze [26] The input channel of the module (serial_in) receives the data to work with the waiting of a rising edge for the transmission of the 8 bits. (data_out) is the parallel output of the received data. (read_buffer) in high state of responsible for the transmission of the data to a FIFO memory. (reset_buffer) in active state delete the data saved under the count of 16 data blocks. (en_16_x_baud) in active state makes the counting of 16 cycles of 8 bits which culminates the storage so that the entire block created in the 16x8 memory will be transmitted. (buffer_data_present) gives an input prompt or that there is information block in the memory. (buffer_full or buffer_half_full) indicates in high mode the full state of the memory, indicates how their names say full or half full 16x8/8x8 when it is full memory communicates this state and activates the complete transfer of the memory block wherever your processing is necessary. (clk) system clock for a synchronous multiple system.

Reception and Storage of Blocks of Information in RAM
In the design and implementation of the system it is observed how the CORE of the Uart provided by Xilinx is controlled, by means of a finite state machine, this is in charge of reading the data from the FIFO memory and passing it to the internal RAM memory of the FPGA, in this way it is possible to read blocks of information from the USB-Serial port of the computer to the internal memory, which will then be responsible for displaying the information, as shown in Figure 4.

Generation and Control of PWM
Next, one of the most important hardware blocks is described, which allows to read the value of each of the pixels in all its channels and convert them into a brightness intensity value of the points (LEDS) in the matrix, varying from dynamically the pulse width, all this must be done at the frequency at which the dynamic display works, in other words, at the same time that the data are being enabled to be shown on the display, the pulse width must be changed. It gives the intensity to each of the points of the RGB matrix. The following block of code describes the 8-bit PWM module in the VHDL language, a highly used language, since it is a standard language that allows the description of hardware at a high level of abstraction. In this section of code, the declaration of the inputs and outputs of the system is made; a clock and reset as base signals in any description of a sequential circuit are obtained, in addition to the Duty input that comes from the RAM memory, where they are stored every one of the values of the intensity of the pixels to be displayed in the LED's matrix and finally the output of the pulse width modulation, which will be the last signal to be displayed in each of the points of the matrix. In the architecture the description of a counter is shown, but in this particular case it is compared with the input of Duty, which gives the value that the useful cycle of the system will be given and will give the intensity of brightness of each one of the LED's.

Dynamic Visualization on LED Array
When performing a dynamic visualization in a LED array, the value of the current necessary to see each of the points correctly and have the necessary brightness to handle an RGB matrix must be taken into account. A circuit must be made to deliver the necessary current with the required speed, in this case, some tests were performed with the integrated circuit MAX7219, driver for 8x8 LED array management, which delivers an output of 500 milli Amperes, but the refresh rate of the system is not achieved, since, although the working speed is 10 Mhz for its SPI interface, it only achieves a refresh rate of 800 Hz. For these reasons, it was decided to make a circuit with a Mosfet N channel and its respective driver, since this power element gives a maximum current of 12 Amps continuously and up to 30 Amps peaks and a working speed over 300 Khz, remembering to respect the minimum on and off times of the device, avoiding that the switch is in short circuit or in an indeterminate state.
Having a system that requires handling 32 rows and 32 columns to use the lowest number of outputs of the FPGA, the columns were handled with two shift registers, which only require the input of Din and Clk to perform said task, the clock must have a working frequency of 17.2 kHz to achieve a refresh rate of each of the columns at 45 Hz, this circuit with shifting registers is handled with a Darlington-type current switch of 1.5 amps output for each of the 32 columns and a maximum working speed of 40 Khz, avoiding having pulse widths less than 10% and greater than 90%.
On the other hand, there were 8 outputs of PWM, which were "demultiplexed" to handle the 32 rows, each of them has a power circuit with a Mosfet Channel N in sink configuration. In other words, the current is injected through the columns and the PWM module controls the passage of the current through each LED and towards the ground, it is required that the frequency of this PWM is at least 10 times of the speed of visualization of the columns, that is why the PWM module of 176 Khz was configured with an 8 bit resolution, the pulse width is read from the RAM memory where the channels of the image to be displayed are stored. Figure 5 shows a block diagram detailing the system. It is important to emphasize that both the frequency of the PWM of each channel, the multiplexing speed of the signals and the speed of reading of the memory, would be difficult to achieve with other types of devices than an FPGA.

Conclusions
The treatment of images on the architecture of FPGA's is facilitated by having the ability to perform processes in parallel, both for preprocessing and for the visualization of an image, together with some algorithms that require high demand for embedded processing, but with low amount of hardware, this advantage is evidenced in the refresh rate of the frames shown in the array of LEDs per second, at this point it is important to emphasize that it would be very difficult to increase the speed of work of the system if you were not working with a FPGA.
Thanks to the multiple hardware tools of the FPGA, it is possible to work in conjunction with the computer to perform a fundamental part of the implementation in the reading and storage of FIFO memories, through the USB port to the FPGA and then have data for the visualization in the array of LEDs. The great demand of power in this type of applications requires a control for the injection of current to each one of the points of the matrix of LED, for that reason the capacity of handling of the signals of control and feeding is required, the FPGA fulfills with the technical specifications of this type of implementations. A circuit for dynamic visualization is shown, where it was necessary to design a high-speed current amplifier circuit to perform the correct visualization of the images already processed according to the theoretically planned form.