user defined start value for incremented count


Recommended Posts

I've been at the screen a little to long so this may be a silly question.

I've got a simple microswitch that I'm using to increment a count with this event

if ((micro[0] >= 1) && (micro[1] < 1))

count.AddValue(count[0] + 1)

endif

count is a test channel a to d 0 timing.

How can I have the end user set the initial number for the count?

TIA

Link to comment
Share on other sites

  • 3 weeks later...

That absolutely fixed my problem, thank you!

Taking this further, I wanted to use the count as the y axis to a graph. So I set up a trace with test channel 1 as the x expression and count as the y. I then scaled the left axis from count[0] to count[0] - 10. I'm sure I made a mistake somewhere as the graph that results just shows a straight line similar to y=-x no matter how many times i increment the count.

So two questions.

1. What did I do wrong?

2. Is there a way to have the left axis start with 0 on the top and increment down the graph instead of 0 at the bottom and incrementing up?

Link to comment
Share on other sites

You are on the right track. The issue is that count will always have the same timestamp because with every new value you are assigning it the previous value + 1, and since 1 doesn't have time associated with it, the time of the new data point ends up being the same as the previous one. This causes the logging set to ignore the new data because it doesn't line up with the other data (the time stamp is old). To fix this, just change the addValue() line to:

count.AddValue(inserttime(count[0] + 1,systime(), 0))

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.