# How can I send complex data using serial communication to an fpga?

7 views (last 30 days)
Pablo Medina on 15 Nov 2016
Commented: Walter Roberson on 20 Nov 2016
I developed a UART system for a Virtex 5 Xilinx FPGA. It work fine but I only sent binary data. In the other hand, my main function gives me a complex data which I want to send using the uart unit.
%main function
function tx = main_fcn(rx)
rx = uart_rx();
%I receive binary data from my uart_rx
rx = [1 0 1 0 1 1 0 0]; %as example
%Then I modulate rx
x = qpsk(rx);
%x = 1 + j; %as example
Xt = ifft(x); %then I calculate de IFFT of x
%I want to send Xt = a + bj to my uart_tx
tx = uart_tx(Xt);
the problem is that I need to send indiviual bits to my uart_tx (8-databits) but I have a complex number.
So my question is how I can covert the Xt complex number into binary data to sent it to the computer using my uart unit.

Walter Roberson on 15 Nov 2016
Pull apart the number using real() and imag() and send the pieces .
##### 3 CommentsShow 1 older commentHide 1 older comment
Walter Roberson on 20 Nov 2016
There are many ways to convert floating point to binary.
Since you are using FPGA you should be using the fixed point toolbox. The fixed point toolbox offers a method to extract the bit sequence of the representation. Look at the properties and methods of fixed point objects.
Walter Roberson on 20 Nov 2016
For any given fi, say A, you can
bin(A) - '0'
to get the bit values. If you follow RS232 protocol, you need to transmit the least significant bit first, which would be right to left in the order you get from bin()
The start bits and stop bits are constants, logical 0 (positive voltage) for the start bit, and logical 1 (negative voltage) for the stop bit; https://wcscnet.com/tutorials/introduction-to-rs232-serial-communication/

### Categories

Find more on Xilinx FPGA and SoC Devices in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!