As of May 2, 2022 the LabJack forums have been set to read-only.
If you are in need of support, please contact us via one of the methods described on our contact page.
Home/Forums/T7/ Reset Counter to Value Other Than 0
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.
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.
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.
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.
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.