logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

Intro to FPGAs with the Mojo – Part 2

Rahul Iyer
Published by Rahul Iyer at July 14, 2017
Categories
  • Arduino
Tags
  • fpga
  • mojo
  • pulse-width modulation
  • pwm
fpga mojo
  • Intro & Pulse-Width Modulation (PWM)
  • Hardware PWM on the Mojo FPGA
  • Hardware PWM on the Mojo FPGA (Continued) & Appendix

Now that we’ve created the PWM module, we can instantiate it within in the mojo_top module!  In Verilog, instantiating a module within another allows you to use the sub-module’s functionality within the higher-level module one or more times without having to copy its code.  In our case, we can create as many PWM signals as we would like to either drive different LEDs or even connect to output pins on the Mojo!  To configure a PWM signal to light up the 8th LED on the Mojo, we can append the line

PWM my_pwm(.clk(clk), .rst(rst), .duty(8’b01000000), .sig_drv(led[7]));

The first word in the line is the name of the module that we want to instantiate, PWM.  The next string is the name that we are going to give this instance of the module within our higher-level module.  This helps identify different instances of the same PWM module if we choose to instantiate multiple copies.

Inside the parentheses that follow the module name, we use the .<module_signal_name>(signal_name) format to assign signals in the higher-level module (signal_name) to the corresponding signals in the sub-module (module_signal_name).  

If we want to vary the duty cycle of the PWM signal, all we have to do is change the value passed into the duty cycle parameter.  If we want to change the output signal being driven, we merely change the signal passed as a parameter to .sig_drv .  

Your completed mojo_top module should look something like this:

fpga mojo

To upload this code to the Mojo board, follow the same steps as before: generate the programming file in ISE, load the Mojo Loader application, and load the .bin file to the Mojo.

Congratulations, you’ve implemented hardware PWM on the Mojo!  To experiment further, try creating multiple hardware PWM signals and supply them with different duty cycle parameters!  Can you modify your code so that the duty cycle value can be input to the Mojo with some toggle switches?

We hope you enjoyed your first FPGA projects!  Check back soon for more FPGA and microcontroller tutorials!

Appendix

Binary Arithmetic: https://www.tutorialspoint.com/computer_logical_organization/binary_arithmetic.htm

 

Binary Representation of Numbers: https://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html

 

W13 Rahul Iyer

1 2 3
Rahul Iyer
Rahul Iyer
Studying Electrical Engineering at UCLA, Rahul loves to work on electronics and robotics projects as a hobby. He is especially enthusiastic about electric vehicle technology and assistive robotics.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • FPGA Tutorial: Intro to FPGAs with the Mojo – Part 1FPGA Tutorial: Intro to FPGAs with the Mojo – Part 1
  • Servo Motor Controlled Wireless Light SwitchServo Motor Controlled Wireless Light Switch
  • Intro to CMUcam5 Pixy Vision Camera Sensor Part 2 – Creating a Ball Balance BeamIntro to CMUcam5 Pixy Vision Camera Sensor Part 2 – Creating a Ball Balance Beam
  • Arduino Robot RF Explorer – Part 2 – Putting Everything TogetherArduino Robot RF Explorer – Part 2 – Putting Everything Together
  • How To Make Your Own RobotHow To Make Your Own Robot
  • Make a Smart Automatic Pet Feeder with Arduino Uno (Cont.)Make a Smart Automatic Pet Feeder with Arduino Uno (Cont.)
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort