Reset Counter to Value Other Than 0 | LabJack
 

Reset Counter to Value Other Than 0

4 posts / 0 new
Last post
mike63
mike63's picture
Reset Counter to Value Other Than 0

Hello, I keep losing my count values after a loss of power to my T7.

Is there a way to keep these values (DIO0, DIO1, etc.)?

Can I reset the counter to another value other than 0?

Thank you for your help.

LabJack Support
labjack support's picture
What are you using for

What are you using for software?  Usually a situation like this would be handled on the software end.

You can use the IO Config system, programmatically or through Kipling, to save the state of most I/O, but this requires writing to flash each time so you don't want to do this too often as flash memory has limited lifetime.

https://labjack.com/support/datasheets/t7/io-config-default

Note that if you want battery-backed power for the T7, you can do that easily with a USB battery that everyone uses to charge cell phones:

https://labjack.com/support/datasheets/t7/vs

If you can't handle your scenario in software, a possible solution would be something along the lines of:

    1.  Use battery-backed power.

    2.  Use some sort of input on the T7 to detect when power is lost.

    3.  Write a Lua script that saves all your desired information when power is lost.

    4.  Have the Lua script load your saved information at start-up.

mike63
mike63's picture
Thank you for the feedback. 

Thank you for the feedback.  The USB battery backup is a good idea.

I can read the count from DIO0, for example, but how would I restore a value to the read-only address of 3000?

I am using FIO0 with an index of 9.

LabJack Support
labjack support's picture
I can read the count from

I can read the count from DIO0, for example, but how would I restore a value to the read-only address of 3000?

You mean for the idea of using software to handle this?  You would not actually store the count back to the counter on the T7, but rather in software you know that you need to add 3000 to your counter readings from that point forward.

In a Lua script, a solution would be something like:

    When you detect that power is lost, you store the current count to non-volatile memory and call this CountOffset.

    When running normally, the script continuously reads the current counter value, adds CountOffset, and puts this in a user-ram register.

    Your software reads the count+countoffset value from user-ram, rather than just reading the counter.