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 Build a project with the Arty S7 - Line Follower Robot (Part 5) - Project Demo
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: rahulkhanna
  • Date Created: 5 Aug 2022 8:22 PM Date Created
  • Views 692 views
  • Likes 4 likes
  • Comments 0 comments
  • arty-s7
  • 7 Ways to Leave Your Spartan-6
  • spartan-7
  • Spartan_Migration
Related
Recommended

Build a project with the Arty S7 - Line Follower Robot (Part 5) - Project Demo

rahulkhanna
rahulkhanna
5 Aug 2022
Reasons to switch from Spartan-6 to Spartan-7 FPGAs #1
Build a project with the Arty S7 - Line Follower Robot (Part 1) - Introduction
Build a project with the Arty S7 - Line Follower Robot (Part 2) - Setting up Vivado 2019.2 and Demo program 
Build a project with the Arty S7 - Line Follower Robot (Part 3) - Interfacing Sensors and Logic Implementation
Build a project with the Arty S7 - Line Follower Robot (Part 4) - Hardware Assembly 
Build a project with the Arty S7 - Line Follower Robot (Part 5) - Project Demo
Build a project with the Arty S7 - Line Follower Robot (Part 6) - Adding sensors to the LFR
Build a project with the Arty S7 - Line Follower Robot (Part 7) - Summary

Project Demo

Before the Hardware assembly, We had connected the IR sensors and their functionality separately. We had connected the IR sensors and motors as shown below: 

Arty S7-50 Motor
IO3 in0
IO5 in1
IO6 in2
IO11 in3

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Arty S7-50 Sensors   
IO0 sen[0]
IO1 sen[1]
IO2 sen[2]
IO4 sen[3]
IO7 sen[4]

image

Now let's run the IR logic to switch the LEDs. 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

The hardware is ready to be programmed. Create the file named LFR.sv and implemented the following logic. 

module LFR (
input wire logic clk,
input logic [4:0] sen,
output logic [1:0] left_m, [1:0] right_m, [4:0] led
);

logic [4:0] sen_val = 0; // Sensor Val
logic [7:0] in1 = 8'd0;
logic [7:0] in2 = 8'd0;
logic [7:0] in3 = 8'd0;
logic [7:0] in4 = 8'd0;

always_ff @(posedge clk) begin
led <= 5'b00000;

if (sen_val == 5'b00100) begin //fwd
in1 <= 200; in2 <= 0; in3 <= 200; in4 <= 0;
led <= 5'b00100;
end
else if (sen_val == 5'b01000) begin //left
in1 <= 100; in2 <= 0; in3 <= 255; in4 <= 0;
led <= 5'b01000;
end
else if (sen_val == 5'b10000) begin //left
in1 <= 0; in2 <= 0; in3 <= 255; in4 <= 0;
led <= 5'b10000;
end
else if (sen_val == 5'b00010) begin //right
in1 <= 255; in2 <= 0; in3 <= 100; in4 <= 0;
led <= 5'b00010;
end
else if (sen_val == 5'b00001) begin //right
in1 <= 255; in2 <= 0; in3 <= 0; in4 <= 0;
led <= 5'b00001;
end
else if (sen_val == 5'b11100) begin //left
in1 <= 0; in2 <= 255; in3 <= 255; in4 <= 0;
led <= 5'b11100;
end
else if (sen_val == 5'b00111) begin //right
in1 <= 255; in2 <= 0; in3 <= 0; in4 <= 255;
led <= 5'b00111;
end
else if (sen_val == 5'b11111) begin //stop
in1 <= 0; in2 <= 0; in3 <= 0; in4 <= 0;
led <= 5'b11111;
end
end

always_comb begin
sen_val[0] = sen[1] ? 1'b1 : 1'b0;
sen_val[1] = sen[1] ? 1'b1 : 1'b0;
sen_val[2] = sen[2] ? 1'b1 : 1'b0;
sen_val[3] = sen[3] ? 1'b1 : 1'b0;
sen_val[4] = sen[4] ? 1'b1 : 1'b0;
end

pwm m1 (.clk, .duty(in1), .pwm_out(left_m[0]));
pwm m2 (.clk, .duty(in2), .pwm_out(left_m[1]));
pwm m3 (.clk, .duty(in3), .pwm_out(right_m[0]));
pwm m4 (.clk, .duty(in4), .pwm_out(right_m[1]));
endmodule
image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

image

Finally, we implemented a line follower using Arty S7-50. We will be adding a component to this line follower in the next blog. 

  • 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