How to change cases inside case structure LabVIEW FPGA - fpga

I've got simple code for generating different frequencies from Digital port of FPGA.
But it does not change the frequency during the execution.
If I stop the execution of the program and change the enum variable, the frequency will change. But inside running cycle it does not.

That is because you read enum value first, and then loop starts executing. So when you change enum while loop is running - it does not make any effect.
So you need to track changes of enum state in the loop (use shift register for this), and then stop it once value is changed.
But also, additional outer loop is needed - so when inner loop is stopped, outer loop will iterate once more, and inner loop will start execution with new frequency.

Related

lldb : Step out of loop?

I have looked around but I can't seem to find that information anywhere so I guess this is not possible
but I would like to be sure.
Is there a way to break out of a loop when using lldb ?
(And if not why has it not been implemented ?)
Debug information doesn't encode source constructs like loops, if branches, etc. That's been true of all the debug formats I've had to do with. So there's really no way that lldb could implement step out of loop - it has no way to know that loops are a thing.
The cleanest way to do this, when it's possible, is to set whatever condition the loop is checking to the "stop looping" value. Then set a breakpoint outside the loop and continue and the iteration you are in will be the last iteration.
You can also use the thread jump command to move the PC out of the loop, continuing from that point. Be very careful using this, however, as it's easy skip over some code you probably should have run. For instance if there were objects scoped to the loop, they won't get destroyed if you jump the PC to some line outside the loop.
If you know line, where loop ends, you can step out of loop with thread until <line>.
This is the same as setting temporary breakpoint in <line> but only one time.

How to process sensor data in LabVIEW? Every value is 255

I'm trying to read data from the Yost Labs 3-Space Sensor Nano into LabVIEW via an NI MyRIO (1900). I was able to set up a sequence that communicates with the sensor through SPI. However, every time I run the program, it just spits out a single value of 255.
I think understand that I need to include something that allows all the bytes to be read. I just don't know how to go about it.
As an example, I'm trying to read the gyros (0x26) which have a return length of 12 and is a vector (float x3).
Here is my labview code
and here is the manual for the sensor. The commands I'm using are on pages 29-33. In the image, 0x2B is 'read temperature'.
Any help would be greatly appreciated! Thanks :)
Edit: i had messed up the wiring so now the output jumps between ~35 to 255. I'm still having trouble getting all 3 gyro values from the SPI read.
Quoting from Joe Friedrichsen in his comment:
The express block that resets the sensor is not guaranteed to precede the loop because there is no data flow between them. The LabVIEW runtime can see two independent and parallel groups and may choose to execute them simultaneously (which on the wire might mean reset comes between loop commands) or in "reverse" order. Add a wire from reset block to create a terminal on the loop.
Here's a picture of the fix.
You may wish to consider stringing the error wire through your program and wiring it to the stop terminal of the While Loop. Currently, your loop will keep running even if there's a fault in your hardware. Using the error wire would eliminate the need for the flat sequence structure.

Play JFugue pattern in an infinite loop for a metronome

How do I a produce an infinite loop using a JFugue pattern. I tried the following
while loop
for loop with a high counter
In both cases, weird sounds get produced which are overlapped. When I run with a small counter like 10 in a for loop, it works fine.
I need a pattern to run infinitely until the player is stopped by calling player.close() by an user action (say from UI).
There's not a specific way to make a pattern run forever. This is partly because JFugue compiles music strings into MIDI code, so a pattern that ran forever would just be a infinitely-long MIDI file. Of course, if you use a specific number of times to repeat a pattern, the pattern could be too long or too short for your needs. The best option might be to look into JFugue's RealtimePlayer class, and create a separate thread that keeps playing sections of the metronome pattern while the thread is still active.
Let me know if that helps you get on the right path!

Saving the simulation time of an event within a Control and Simulation Loop

I've got a Control & Simulation Loop structure in LabVIEW that is sending inputs to and receiving outputs from a Multisim model. I'd like to measure the simulation time difference between when two boolean outputs from the Multisim model go to true. I'm able to add a Control & Simulation -> Simulation -> Utilities -> Simulation Time widget and wire that up to an indicator on my front panel, and see the simulation time progressing as I run it, but I can't find a way to latch that double-precision numerical value into a storage location for later comparison without using a loop structure that isn't allowed within a Control & Simulation Loop structure. Am I missing something straightforward?
The function you're looking to use is called "Memory" and is located in the Simulation Utilities Functions palette. Memory does the following,
"Stores the value of the Input signal from the previous iteration of the simulation. Use this polymorphic function to transfer values from one iteration of the Control & Simulation Loop to the next. The data type you wire to the Initial Value input determines the polymorphic instance to use."
- https://zone.ni.com/reference/en-XX/help/371894H-01/lvsim/sim_memory/

How can I make gdb stop at the breakpoint after loop has been executed n number of times

I want to stop the execution, when the loop has been executed n number of times. I don't want to use the conditional breakpoint using value of loop-counter because initial value of loop-counter is different at different time of run.
You need to use the ignore command. Set a breakpoint at the relevant place in your loop and then use ignore to indicate how many times that the breakpoint is to be ignored.
Syntax, as per help ignore is:
Set ignore-count of breakpoint number N to COUNT. Usage is `ignore N
COUNT'.

Resources