LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scaling time axis on a chart

Solved!
Go to solution

Hello everyone,

 

to scale the x axis according to the refresh rate of the loop i previously used the Xscale.multiplier node. In a new version of the program i used the same principle and it scales the x axis in some wired way and i cant figure out why. Does any of you have an idea why?

 

Regrads,

Phillip

0 Kudos
Message 1 of 10
(3,723 Views)

I'm not sure what is wrong.

 

I do thing it's a bad idea.

 

Changing the multiplier continuously, will only represent correct values for the most recently added samples at best. The rest will be completely wrong. If you have 1000 samples at 1 ms, that's one second. If you change it to 1 second, all the data will get this multiplier, and you'd be looking at 1000 seconds of data. I don't see how that's going to work.

 

If you have variable timed samples (dT changes), you should consider an XY graph. Downside is that each channel needs it's own timestamp, and that you need to keep your own array. Upside is that it will work.

Message 2 of 10
(3,708 Views)

Thanks for the quick answer.

 

I do not have dT changes. I want to sample the values about 2-10 times a second continuously. I also tried to move the multiplier node outside of the loops but that did not resolve the issue. The only thing i can see that changed between the old and the new version is that data in the new version get red inside the loop of the chart, while in the old version the data gets passed into the loop and is then recorded for the duration of the loop (witch is not what i want to do, it was just a test program)

0 Kudos
Message 3 of 10
(3,695 Views)

You should really spend some time doing courses. There are tons of tiny things, and quite a few big things that need to be done different. Probably not what you wanted to here.

 

As for the problem, I can run those VIs. Can you delete everything that is not relevant, and make an example that shows just the problem?

0 Kudos
Message 4 of 10
(3,683 Views)

I have absolutely no idea why but the code started working. Thank you for your feedback. I am sure as i am a total beginner in labview and coding in general a lot of things are not very efficient or elegant. Could you give me some more precise examples what i should do differently (especially the big things) and maybe point me towards those courses you are talking about?

0 Kudos
Message 5 of 10
(3,678 Views)

Sometimes when the Big Picture seems to go astray, wiring a Tiny Example can "prove a point".  Here is a demonstration that (in principle) your method should work (assuming that your Refresh Rate is constant and not so fast that the rest of the stuff inside the loop can't keep up).Scaled Time Axis DemoScaled Time Axis Demo

Bob Schor

Message 6 of 10
(3,672 Views)

@PTimmer wrote:

I have absolutely no idea why but the code started working. Thank you for your feedback. I am sure as i am a total beginner in labview and coding in general a lot of things are not very efficient or elegant. 


It's not just about efficiency or elegance.

 

Bugs hide in code. The more code, but especially the messier the code, the more bugs will hide. Bugs can be in clean code, but they usually can't hide. So they are easier to find.

 


@PTimmer wrote:

 Could you give me some more precise examples what i should do differently (especially the big things) and maybe point me towards those courses you are talking about?


The small things:

Left to right wiring, straight wiring, use some build in functions iso lengthier replacements (=0).

 

bigger things:

Start using sub VIs. One big VI will outgrow your project soon.

Start using some architecture. A state machine, queued message handler, producer\consumer, maybe even actor framework.

 

You can't keep developing by simply adding things to one VI. People tried before. Most fail. But at best, you have a program only you will understand.

 

I know most of these (not the wiring though: no excuses for that!) are only possible with experience. So, get experienced would be the advice.

Message 7 of 10
(3,664 Views)

Thank you for your input i will certainly have a look at the architecture stuff.

I am however using subVIs and build in functions (please disregard the old version as it was just a very early trial for some things that just happens to contain a working version of the xscale multiplier) or am i missing some major pre build function i could have used somewhere?

0 Kudos
Message 8 of 10
(3,654 Views)
Solution
Accepted by topic author PTimmer

There are functions for:

Equal?(x,0) -> Equal to 0? (x)

Select (0,x,1) -> Boolean to 0,1 (x)

Or ( Not(x), y) -> Compound Arithmetic (x, !y)

 

You didn't do too bad, but these still scream 'beginner'.

 

Case defaults can be removed. For instance empty arrays or 0's inside a case can be deleted. NI style guide says you shouldn't IIRC, but it's better AFAIC.

 

You have some VIs, and that looks good (can't look into them of course). You should do the same for the serial device. Imaging how your code would look if the rest was in sub VIs. That is everything that makes sense, everything that could potentially be reused, and does (only) one thing.

 

You still have duplicate code. The Get Array Element\ Fract\Ext String to Number\ Case \ SubVI seems 4 times duplicate. More then 2 call for a for loop. And maybe a sub VI.

 

Some feedback nodes should be shift registers. They will introduce problems if\when you start looping this code, as the init only happens once, not every time the loop runs.

 

Use the correct types You have a few doubles, that seem to be indices. So, make them I32 integers! That not only removes coercion dots, it's also much clearer to read.

 

Those indices (Gas 1, Gas 2, ..) should probably be something stronger. Like a type def'd enum.

 

Use CTRL+ALT+Drag to remove all the empty space. You'll have a much better programming experience once the VI (every VI) fits the screen. And having a bigger screen doesn't count.

Message 9 of 10
(3,642 Views)

Thanks a lot. I will follow your advises especially the one about getting experience 😉

Message 10 of 10
(3,624 Views)