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 Learning AMD Zynq: a project to generate a set of PWM signals. 1 - problem statement and possible approach
  • 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: Jan Cumps
  • Date Created: 21 Apr 2023 11:42 AM Date Created
  • Views 4024 views
  • Likes 12 likes
  • Comments 36 comments
  • pynq-z2
  • amdzynqultrasoundpulse
  • zynq
  • fpga
  • vivado
  • vhdl
  • pynq
  • spartan
Related
Recommended

Learning AMD Zynq: a project to generate a set of PWM signals. 1 - problem statement and possible approach

Jan Cumps
Jan Cumps
21 Apr 2023
Learning AMD Zynq: a project to generate a set of PWM signals. 1 - problem statement and possible approach

 yepe has to resolve this problem for a project assignment:

Hi Jan Cumps, I hope you don't mind if I ask a question regarding the PYNQ half-bridge PWM driver. I am working on a student project for school and I need to drive a half-bridge for an ultrasound pulser. I was working through your great tutorial and I had the complementary pwm output on my board PYNQ Z1. However, I have to make certain changes to the operation to make it compatible with my needs which I attempted to do, but I could not determine the best approach. First off, I need to simplify that I only need 50% duty cycle and no other duty cycles needed. I have made a timing diagram for the various waveforms:
image

CLK should be a continuous 20 MHz signal, PRF should be a 10 kHz 50% duty cycle signal that synchronizes the rest of the waveforms. PWM&PWMN are the complementary PWM signals with dead-time of programmable N cycles with a timed delay from a falling edge of PRF. PULSE should be equal to the length of the PWM pulse train, and GATE is equal to pulse but with a programmable delay. The PWM pulse-train should be 5 MHz. The first thing I tried to do is to change your example to see if I could get a 5 MHz complementary PWM but I could not see how the frequency is determined so I was playing around with the board clocks and only could get it up to 650 kHz.

I am a biginner at vhdl so I am a bit out of my element. I have developed all the electronics and analogue demodulation circuits but I still lack the control system to tie it together. If I were to implement these signals in the PYNQ, where do you propose to start?

My suggestion is to cut the task in simple(r) chunks:

I think that the easiest way to achieve this, as beginner, is to eat the elephant in pieces. Ignore my code, because it's not the basis for what you need.

  • make a design that can generate the clock. Confirm by probing.
  • make a design that can generate one of the easy signals, based on that clock. PWM maybe? If you can make that clock, you know that you'll be able to generate the slower ones too (edit jc: the max frequency will a function of the resolution of the dead time).
  • add PWMN to the design. That should be easy, because it's NOT PWM
  • try a separate design with the PRF logic. If you have that working, add to the original one (or keep separate, feeding it from the same clock?)
  • same for the remaining ones.

image

The advantage of little steps is that you'll get early success, and that boosts the morale.
Advantage of separate blocks for a beginner is that the code stays separate and graspable. 

The main job for each signal will will be to:

  • find out after how many ticks of the clock the signal should change
  • count the clock ticks and compare it to the figure(s) figured out above
  • set the output(s) to the desired state.

If you'd handle this different, comment below.

Capture of status after post 2:

image

link to all posts.

  • Sign in to reply

Top Comments

  • michaelkellett
    michaelkellett over 2 years ago in reply to Jan Cumps +1
    Looks to me as if it would be much better with maybe 100MHz internal clock - if the 20MHz is a fixed thing from outside then use an FPGA PLL to get up to 100M (or more). You can get really sassy with…
  • michaelkellett
    michaelkellett over 2 years ago in reply to yepe +1
    Much clearer now - thanks I'll leave Jan to get on with helping (mostly ), otherwise it'll get confusing. MK
  • yepe
    yepe over 2 years ago in reply to Jan Cumps +1
    Hi, sorry for the late response. The delay between the falling edge of the PRF and the beginning of the pulse train should be such that the end of the pulse-train is the same as the end of the low…
  • Jan Cumps
    Jan Cumps over 2 years ago

    If you follow this story: this will be the end state:
    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • yepe
    yepe over 2 years ago in reply to yepe

    Also just want to correct I made a silly typo writing the speed of sound in water, it should be 1540 m/s as in the calculations

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • yepe
    yepe over 2 years ago in reply to yepe

    So technically the GATE pulse is tied to the moment PULSE rising edge to determine the sample depth, as the rising edge of PULSE is the beginning of the pulse-train

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • yepe
    yepe over 2 years ago in reply to Jan Cumps

    Hi, sorry for the late response.

    • The delay between the falling edge of the PRF and the beginning of the pulse train should be such that the end of the pulse-train is the same as the end of the low-period of PRF.
    • Generally the pulses per PRF are between 5 and 10 pulses. But any number between that would be fine.
    • The delay between PRF rising edge and GATE rising edge is also variable. Technically, the variable is called sample_depth and is equal to the beginning of the transmitting pulse-train and the beginning of GATE rising edge expressed by the formula for speed of sound in water (here assumed to be 1540 cm/s)
      • image
      • Where the expression above back-calculates the depth. When setting the sample depth, let's say 1.5 cm, the delay becomes:
      • image
      • image
    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to Jan Cumps

    looks like my Enable signal drops 1/4th of a cycle too late, compared with the required design.

    In that one, it falls at the falling edge of signal PWM...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
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