Int vs byte in internal memory

Do you have a question on how to do something.
Ask in here.

Posts: 115
Joined: Tue May 08, 2012 8:16 am
PostPosted: Mon Jul 24, 2017 7:35 am
I was wondering what the difference is between the two in memory. I think that I messed up and changed a value to something from the app and it's causing some problem. I was changing the byte read for the water level low. I made it 970 thinking that would correspond to 97% .

I don't think that it does. I can still make changes to the settings in the memory with both The uapp and the reefangel app. They update but if I go back and read the byte for that location it's always 970 , the int value does change and is read correctly.

What the hell did I do, and can I fix it via the apps?


Sent from my Lenovo TAB 2 A10-70F using Tapatalk
Image
User avatar
Posts: 2602
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Mon Jul 24, 2017 8:26 am
the difference is a byte uses 1 block of memory and an int uses 2 blocks of memory.
if you changed the water level low location, you can easily change it back.
if you set it to 970, that value would wrap around since a byte can only store 0-255. depending on what app you used to change it, they should have validated the input and not let you change it....regardless though.

if you set it to an int value instead of a byte value, that would just use 2 locations to store the value and overwrite the next one. So you overwrote the water level high location as well.

So, if it was location 100 and you were going to use a byte in it. the value would be stored at location 100.
if you wrote an int value to location 100, that would use locations 100 and 101. i believe the low byte gets stored in 101 and the high byte in 100.
To fix the problem, you will need to store 97 in the water level low location and make sure you use a byte value.
You will also want to set the water level high value to what it is supposed to be as well.
So set water level low to 97 and then set water level high to 100 and you should be good. wait for a minute before you try to reload/re-read the value to ensure it is set and you are reading the new value.

if that fails, then you may have to update it manually but it should work. i know with my android app, you should be able to fix it with no problems.

Posts: 115
Joined: Tue May 08, 2012 8:16 am
PostPosted: Mon Jul 24, 2017 1:37 pm
I think that the byte location actually stored the zero level for when you calibrate the water level sensor. The first location, bit holds the low level to turn on the ATO circuit. The upper level byte which is the 100% mark after calibration is a 4 digit number, 2345 or on that order. Any chance that someone with the level sensor could shoot me their low level byte number in the memory? In theory that being zero should be the same for everyone.

Sent from my Lenovo TAB 2 A10-70F using Tapatalk
Image
User avatar
Posts: 2602
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Mon Jul 24, 2017 2:31 pm
The calibration for water level uses an INT location since it's 2 bytes (up to 32767 value).
You could just recalibrate your water level sensor and the value would be updated and it would be set to your container.

Posts: 115
Joined: Tue May 08, 2012 8:16 am
PostPosted: Mon Jul 24, 2017 3:19 pm
Yeah I could do that but I am currently 700 miles away from the tank on vacation....

I guess maybe I can get someone to go to the house and hold it out for me.

Sent from my SAMSUNG-SM-G935A using Tapatalk
Image
User avatar
Posts: 5328
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Tue Jul 25, 2017 10:04 pm
I think it should be around 350-400 for out of the water. If you look at your graph and you know what it was and can guess what it should be, you can plug in a number and see where it puts your percent. It's not that hard to figure out either. If you look up the map function in ardunio, your in_min is the WLMin and the in_max is the WLMax, the out_min and out_max are 0/100. Just a matter of solving for one of the numbers. Guessing works well. I usually plug a number and see and narrow it down.

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 3 guests