LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help me create a maths quizz

Solved!
Go to solution

Nice, the graph works well, the final thing is that I need to fix the array with "good answers" and "wrong answers" : I have no error but it's always 0.

0 Kudos
Message 11 of 26
(144 Views)

@ElixirDaSueños wrote:

Nice, the graph works well, the final thing is that I need to fix the array with "good answers" and "wrong answers" : I have no error but it's always 0.


That array is initially empty.

 

So, you're replacing an element that doesn't exist with a new element. (2X).

 

The result is an empty array.

 

Why not keep it simple:

wiebeCARYA_0-1713530863150.png

To replace this (but now working unconditionally):

wiebeCARYA_1-1713530933346.png

 

Also, right click on constants and controls\indicators to change their types. Some numbers are float, some are integer. That shows as orange and blue. If the types don't match, you get the red coercion dot. That's ugly and almost always a code smell (a sign something's off).

0 Kudos
Message 12 of 26
(137 Views)

Your graph is only showing 1 data point because your build array function is only an array of 1 point. You need create a shift register using an array not just a single number. Then add to that array. I know its hard to explain so I'll fix your VI (just for this case), but you really need to understand how to build arrays so they accumulate values.

 

This is only building an array of 1 point every time.

ooth_2-1713532417678.png

 

This adds the value to an array of the previous values.This is accumulates the values.

ooth_1-1713532392705.png

 

0 Kudos
Message 13 of 26
(132 Views)

It's perfect, the graph works well thank you.

The array works better now but still, it resets the "correct answers" count where there is a "wrong answer", I can't find why.

I added a timer that works, but only refresh why an action is made, how to get it refreshed every second for example ?

 

Thank you.

 

screenshot3 with event 2.png

Download All
0 Kudos
Message 14 of 26
(108 Views)

First of all I would delete the sequence frame and the other event structure you put in. You don't need them and they just complicate your program. Just wire the errors together and then wire into the while loop. This will make the 2 property nodes execute before the while loop. This is LabVIEW's dataflow concept.

ooth_0-1713542179667.png

 

Message 15 of 26
(105 Views)

Yes, but it's part of my homework, my programm must contain a sequence...

0 Kudos
Message 16 of 26
(98 Views)

OK then you can leave it but remove the while loop and event structure in it. Just have the property node that sets the visible to True. Remove the one that sets it to false. It'll work out just fine.

 

The timer does not work because you have no timeout case in your main event structure. Add it back in by right clicking on the event and selecting Add event case. Then  choose <Application> and select Timeout. Finally right click on the hourglass in the corner of the event and select create constant. This will create -1, which means the event case will never timeout.Change the number to something like 100 which means 100msec. Now the loop will update every 100ms and your timer will work.

 

ooth_0-1713542950484.png

 

Message 17 of 26
(95 Views)

And lastly the problem with the Array resetting to zero is because the case statement has unwired terminals which means a 0 is used when that part is run.

 

ooth_0-1713544105549.png

 

You will need to create another shift register to keep track of the Wrong Answers. Hope the pictures help.

 

ooth_3-1713544317920.png

 

ooth_4-1713544330746.png

 

Message 18 of 26
(89 Views)

Oh, yes. I think it should work better now, but since I added the timer who works : score, array and graph all stopped working correctly ? The score stays at -1 whatever the results

 

ElixirDaSueos_0-1713544941675.png

 

0 Kudos
Message 19 of 26
(87 Views)
Solution
Accepted by topic author ElixirDaSueños

Remove the while loop and event structure in the first part of the sequence. Two event structures in a program is tricky and should not be done. Just one of the quirks of LabVIEW. You can keep the sequence but just have the property node that sets to true.

 

ooth_0-1713546761452.png

 

 

Also this is my fault for forgetting but you have to wire the shift registers across in the Timeout case because they are getting reset to 0 when that part is run. And also you are missing the wire for the Wrong Answer shift register in the Ask a Question case. It also needs to be wired across. Can't leave them unwired because 0 will be used in the shift register.

 

Message 20 of 26
(78 Views)