element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Reducing the time to send data over UartLite on Arty S7-50 (7 Ways to Leave Your Spartan-6 FPGA : Experiment)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
FPGA requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: cbohra00627
  • Date Created: 5 Aug 2022 5:37 PM Date Created
  • Views 529 views
  • Likes 4 likes
  • Comments 0 comments
  • 7 Ways to Leave Your Spartan-6 FPGA
  • spartan-7
  • cbohra00627
  • Spartan_Migration
  • spartan-6
Related
Recommended

Reducing the time to send data over UartLite on Arty S7-50 (7 Ways to Leave Your Spartan-6 FPGA : Experiment)

cbohra00627
cbohra00627
5 Aug 2022

Introduction:
In my project, I am sending the blurred image to my PC over uartlite. I had to put some delay (50 us) between sending consecutive data packets. Due to the large size of the image, it takes around 8-9 mins to transfer the image.
Maybe reducing the delay might help in reducing this time. But reducing it much will cause my python code running on the PC (to capture the data) to miss some data. So, I will keep reducing the time delay and watch till what point it is able to capture all the data.

Modifying the receiving code:
I need to modify the python code to print everytime I receive a pixel. The modified code is shown below:

uart_recv.py:

import serial

#Image dimensions and total number of pixels in it
WIDTH = 400
HEIGHT = 400
PIXELS = WIDTH*HEIGHT
IMAGE = []

#Setting the serial port
ser = serial.Serial()
ser.baudrate = 9600
ser.port = 'COM7'
ser.timeout = None
print(ser)

#Opening the serial port
ser.open()
print(ser.isOpen())

print("Receiving...")

#Number of pixels received
num_pix = 0

#Getting the pixel data one byte at a time
for i in range(PIXELS):
	R = ser.read(1)
	G = ser.read(1)
	B = ser.read(1)

	IMAGE.append([R,G,B])

	num_pix += 1
	print(num_pix)

print("Received!")

#Closing the serial port
ser.close()

#Converting the pixel data into int
for pixel in IMAGE:
	pixel[0] = int.from_bytes(pixel[0], 'big', signed=False)
	pixel[1] = int.from_bytes(pixel[1], 'big', signed=False)
	pixel[2] = int.from_bytes(pixel[2], 'big', signed=False)

#Open the file to write to 
file = open("C:/Users/Chinmay/Desktop/image/blur_image.txt", "w")

#Write the pixel data to the file
for pixel in IMAGE:
	file.write("{" + str(pixel[0]) + "," + str(pixel[1]) + "," + str(pixel[2]) + "},\n")

print("Written to File!")

#Close the file
file.close()

And below shown is the code section in the project that contains the delay for uartlite. I will be changing this delay to know till what point, it can work properly.
Delay Section

I will be using the following image. The blur box matrix is (5x5).
Image1

The image has (400x400) dimension, so there are a total of 160000 pixels.
Its pixel data is loaded in an array in my Vitis project.
All the other things will remain same as in this blog.

Receiving the data:
Now, run the code on the board and run "uart_recv.py" on the PC. The number of pixels received will be printed on the terminal as soon as it starts receiving data.
The delay is between sending every pixel.

delay = 50us | time take  = 9:18 | pixels received = 160000
50 us delay

delay = 40us | time take  = 7:43 | pixels received = 147843
40 us delay

delay = 45us | time take  = 8:30 | pixels received = 160000
45 us delay

So, after viewing the result, I guess I was already at the minimum delay possible. For delay = 40 us, the terminal stuck at 147843 pixels. My project would work fine if my delay is 45 us or above.

Actually, I had checked the same for a delay of 20 us also earlier and I could only receive around half the pixels. I think it might require higher delay (higher than 50 us) if the image is larger. So, to confirm this, I am changing my test image and using a larger image and running the code with 45 us delay. The image is shown below:

image

The image's dimension is (600x600). So, there are a total of 360000 pixels. I ran my Vitis code with this image and ran the uart_recv.py on my PC after doing some changes in it for this particular image (changing the dimension variable). The result is shown below:

delay = 45 us | time take = 19:07 | pixels received = 360000

Other test image terminal

So, it can be seen that I was able to receive all the pixels for this larger image also. So, it seems that if the delay is more than 45 us, then any size image can be transferred with it. I checked the received image also. It was correct. Its shown below:

Blurred image 1

Conclusion:

So, we can conclude that to send large amount of data from the board to the PC over uartlite, we need to insert some delay between sending consecutive data packets. Now, this minimum delay can vary with the number of bytes that are sent in one go. In my case, I am sending 3 bytes at a time and I needed 45 us as the minimum delay required to capture it correctly on my PC.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube