LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone spot the error in this code?

It's supposed to provide pulse width modulation but when I change the clock frequency control input, the output remains at 1Hz. 

 

The speed of the modulation should be determined by the delay VI inside the sequence structure, but it seems to not be changing when I move the control.

 

PWM.png

0 Kudos
Message 1 of 17
(4,026 Views)

In the future you should post the actual VI not a picture.

 

Bob_Schor.png

 

Because in this case we don't know how that wait until next tick is configured.  I assume it is in ms, in a 32bit form but can't know for sure from a picture.  Also in FPGA I generally just leave the loop with a constant in the stop function so it never stops.  I know this is generally bad edicate in other LabVIEW programming, but in FPGA is there ever a time you don't want your code to respond?  It's dedicated and its deterministic, and I just let it run forever.  Not that changing that would fix your issue, unless the loop stops running, at which point your Direction of motor wouldn't respond anymore either.

Message 2 of 17
(4,014 Views)

It is configured as you mentioned. Ok I will bear that in mind in future. 

 

Can you see anything obvious that might be causing this problem? Its stuck at 1Hz, my control doesn't do anything.

 

I have attached it but I dont think the VI will give you much more. I think the issue is with the logic in my code.

0 Kudos
Message 3 of 17
(3,971 Views)

I don't see anything obvious. You've compiled this code before running it on the FPGA, right? And you're using the Run button, not Run Continously?

 

How are you measuring the loop frequency? I would add an indicator for the loop rate, as shown below, in case the issue is actually in how you're measuring the loop rate.

With Loop Rate Indicator.png

Message 4 of 17
(3,938 Views)

What about your direction control?  Does that work?

Message 5 of 17
(3,924 Views)

So FPGA is not (yet) "my thing", but it almost has to be something to do with timing, initialization of Controls, etc. involving the FPGA.  When I ran this on my PC (removing the FPGA-specific functions and substituting the Wait (ms) for the FPGA Wait), it ran fine, although the default value of the Control was way off the value(s) suggested by its appearance on the Front Panel.

 

How does FPGA code interact with Front Panels?  [Sorry for my ignorance, but I didn't think there was the kind of "interactivity" that "regular" LabVIEW VIs have].

 

Bob Schor

Message 6 of 17
(3,921 Views)

@Hooovahh wrote:

In the future you should post the actual VI not a picture.

 

 


Nice.  BS will be proud. 

aputman
0 Kudos
Message 7 of 17
(3,919 Views)

Yeah direction control works fine, I've tested it on oscilloscope im both states.

 

Good idea regarding an indicator on the number of cycles. I will do that. Helps to see whats going on with the loop.

0 Kudos
Message 8 of 17
(3,915 Views)

@Bob_Schor wrote:

 

How does FPGA code interact with Front Panels?  [Sorry for my ignorance, but I didn't think there was the kind of "interactivity" that "regular" LabVIEW VIs have].

 


You access the front panel controls/indicators from the FPGA VI on your host (e.g. RT/PC) using the FPGA Read/Write Control node. Every front panel control/indicator becomes a 'property' which you can select on the read/write control.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 9 of 17
(3,913 Views)

Bob are you saying that when yuou ran the code, you got some variation in frequency when you moved the control?

0 Kudos
Message 10 of 17
(3,910 Views)