• 0
LLuca93

generate a pwm signal with digilent discovery

Question

Hi,

i'd like to generate a pwm signal (frequency=50khz) with digilent discovery interfaced with labview. I uploaded the code.

I started from the example found online (getting started with digilent discovery:Mso and function generator). The program should do something like this: read a file (txt)  which consists in a single columm of numbers that describe the duty cycle (0 is 0%, 3645 in 100%). This operation is perfomed by using the "Read delimited spreasheet". SIngle numbers are extracted with a for loop and converted in a percentual value. The result is send to the "Basic Waveform block".

The problem is this: the program does not work fine because I obtain a waveform with a fixed low duty cycle (it should increase, reach a max value and then decrease). Moreover  i need to click "run Continuosly" which is not the way it should work.

how can i solve this problem? i was thinking about a while loop but i have no idea where i have to put it.

 

Thanks in advance.

 

I added some files (code and txt document with the value of the duty cycle).

(the output waveform is readed with an external oscilloscope).dutycycle.txt

creodutyvar.vi

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @LLuca93,

I don't have the same version of LabVIEW as you (2017 I believe) so I'm not able to view your project. Could you save your project for LabVIEW 2014 so I can take a look and see if I can spot something? There are some details on how to save to a previous version here.

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0

Hi @LLuca93,

I'm almost able to open it; it looks like one of the VIs (read delimited spreadsheet) looks like it was named differently in 2014, so I'm not able to directly open your project. I'll ask some of the other engineers around the office who have some newer versions of LabVIEW to see if they can review your project and see what might need changed.

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0

Hey LLuca93,

When you click 'Run Continuously' the entire VI will run to completion, then the entire VI will start over and run to completion.  As you found this is not what you want because each time the VI starts over it will open the text file and read the values.  What you really want is to open the file once, read the values, then cycle through them.  As James mentioned you can do this using a while or for loop.  Add the code to process the file input before the loop and pass the data into the loop to write it out to the hardware.

I also suggest breaking this down into pieces.  First can you create a program that outputs the correct signal.  This will confirm that the hardware is working correctly and that you are able to generate the signals you need.  Next extend that program to cycle through a few duty cycles that are hard coded into your program.  This will confirm that you are able to change duty cycles correctly and at the rates you need.  Finally add the file IO to your code the load the values once when your program starts, then iterate though writing them to the hardware.

You can find some getting started material for LabVIEW here.

Let us know if you have more questions.

Thanks!

-Kristoff

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now