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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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 4487 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…
Parents
  • Jan Cumps
    Jan Cumps over 2 years ago

    yepe , in rest, your PWMN signal is high. Is it the desired state when the bridge is not active?

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

    Dear Jan Cumps , I am amazed by your thorough explanation and demonstration, I greatly appreciate it. At rest, the PWM can be low but will be inverted to high after. I will invert it before it is ported out of the GPIO as such in my simulation here:
    image
    image
    So, PWM and PWMN is a regular complementary PWM with dead-band, but PWMN is inverted after it is made complementary. The gate driver is a bit odd, but is built for specific ultrasound half-bridge and is driven as such. I will follow along on my end and try to do the implementation on my PYNQ Z1

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

    When tying it to the 20 MHz clock I suppose it makes each clock duration to be 50 ns. In that case, a single clock is more than enough. Of course having a variable dead-time would be supreme

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

    image
    Here is the switching waveform of the diode array where t_d(off) is 20 ns

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

    MOSFET array* (instead of diode array) in above^

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

    > When tying it to the 20 MHz clock I suppose it makes each clock duration to be 50 ns.

    Yes:

    image

    The (possible) issue is, that on a 5 MHz signal (= 200 ns period), each half of the PWM is 100 ns. One unit of deadband takes away half the up pulses of A and B.

    I'll set my design to a 5 MHz complementary signal and show how it looks with 0 units of deadband and 1 unit of 50 mS.

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

    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 some Xilinx (AMD) FPGAs and use precision timing control on IO pins but I wouldn't go there unless you really have to.

    MK

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • michaelkellett
    michaelkellett over 2 years ago in reply to Jan Cumps

    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 some Xilinx (AMD) FPGAs and use precision timing control on IO pins but I wouldn't go there unless you really have to.

    MK

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to michaelkellett

    Yes. 20 MHz to control a 5 MHz complementary, gives too little resolution. That's what I was trying to show by generating the outputs.

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

    Ah yes good point.. I am not dead-set on having a 20 MHz master clock, only that I need a quadruple constant clock of the pulser due to the quadrature demodulation scheme I am using on the receiver. It has to be 4 times the frequency and in-phase of the transmitting pulses. Probably a higher system clock is better and then generate a lower frequency 20 MHz demodulation clock

    • 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