LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A button (or switch) to stop/activate the PWM

Hi,

I have a project I am working on and everything is finished the only thing I have left is that I need to add a button (or switch) to stop/activate the PWM. I feel like I have tried everything, case structor around everything inside the while loop, case structor around the LED, now I am trying to solve it with a select block but it seems like all it is doing is slowing down the LED for a bit. Any advice? 

 

Best Regards,

Nick

 

 

0 Kudos
Message 1 of 6
(1,155 Views)

Okey, I am not sure how to remove the question but I solved it

0 Kudos
Message 2 of 6
(1,116 Views)

Hi Nick,

 

instead of deleting the question you should provide the solution!

This is how this forum works...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(1,111 Views)

Thanks, for the answer.

 

So I used a selector block which I spoke of before but instead of connecting a button I used a switch. 

 

In the file you can se how I did it.

 

Best,

Carl

0 Kudos
Message 4 of 6
(1,107 Views)

@Nicklabview wrote:

In the file you can se how I did it.


Now you want to simplify your code. Is it way more complicated than in should be.

 

  • If the cleanup button significantly improves the look of the diagram, your code layout was very poor.
  • To toggle between 0 and 1 with each iteration, all you need is a bitwise AND of the iteration terminal with 1. (eliminating your case structure, "+1", shift register, etc.)
  • Your lower case structure contains duplicate shared code (e.g. the wait) that belongs after the structure as one instance.
  • Try to do your math on integers. There should be no blue wires anywhere.
  • Make the pause switch to be False if paused and just AND it with the PWM result.
  • You can eliminate the NOT by swapping the constant values inside the case.
  • Give your terminals reasonable names ("Numeric Control", "string", and "Boolean" are not reasonable labels)
  • etc.
0 Kudos
Message 5 of 6
(1,098 Views)

You might want to re-think the entire approach and use a loop with a fixed loop time and just toggle based percentage. With your design, you can easily get into log wait where the controls can react very slowly to user interactions.

 

Here's a "literal translation" of your code to give you some ideas about the points I made above, but you should really redesign it from scratch.

 

altenbach_0-1607622397063.png

 

0 Kudos
Message 6 of 6
(1,085 Views)