06-27-2025 10:01 AM
I have a problem in creating this circuit that is rat or well the idea is "Create a program with commands
that modify the value of a PWM and
control the servo motor with a push button. When it reaches its maximum value , press the button again to turn it off and continue the cycle."
But the servo does not turn but I do not know if it is a problem with the communication or something else and when I release the button the angle value changes to zero.
06-27-2025 12:32 PM
There's a lot "wrong" with your code. Some is "cosmetic" (but important, as it "hides the bugs"), some is possibly "wrong thinking about LabVIEW". I've made some changes such as straightening out wires to run left-to-right (mostly), right-clicking "mysterious numbers" (such as "31" and "0" and choosing "Visible Items", then "Label" and puzzling why your Case statements only handle 0 and 1 (and are Dbls, rather than I32).
I don't have LabVIEW 2019, so I'm going to (sorry) paste a "picture" of your code after my house-keeping. Please feel free to explain the Case Statements (which only look at 0 and 1, everything else being treated as 0, default). Note that the two Case statements appear to be "unfinished" (and I'm not sure what they are trying to do).
Bob Schor
06-27-2025 06:21 PM
What I was trying to do is that the lower part will be in charge of increasing the digital output when it is one so that I can use one button to make an increment work and the other one is intended to be used for comparison and when it reaches 180 it will decrease to 0.
06-27-2025 08:59 PM
If you are counting things, use I32 (not I16 nor I8, and certainly not a Floating Point number). Why? Ask a Comp. Sci. student. Similarly, if you are measuring things, you may well want to use Floating Point (even though, technically speaking, a "voltage" (which your A/D converter "approximates" with dividing -10 v to +10 v into 12-bit, or 16-bit, approximations).
When thinking about writing computer code, first figure out what you want to do, and then worry about how you want to do it. I still don't understand (because you haven't clearly stated it) "what" it is you want to do. What are you measuring? What are you controlling? You might say something like "I have a gadget that I want to move. It rotates (which means if you keep moving at a fixed velocity, you'll eventually get back to the same place when you "go around once"), or maybe it translates (which means if you want to get back to the same place, you need to "back up")."
What are you controlling? Position? Speed? Velocity? (I'm making a subtle distinction between speed and velocity).
Explain, and we'll help you "fill in the gaps".
Bob Schor