View Single Post
Old 07-11-14, 05:57 AM   #8
takyka
Helper EcoRenovator
 
Join Date: Jul 2014
Location: Hungary
Posts: 34
Thanks: 0
Thanked 16 Times in 10 Posts
Default

Quote:
Originally Posted by jeff5may View Post
I have another question I'm just dying to ask. How did you work out the menu to assign 1-wire devices to actual values in the controller?
Your starting point should be listOwDevices() function in HMI.ino
What it does,
- it searches for next 1w device in the given bus.
- Prints to buffer the number & serial number
- If no CRC error, it tries to read the temperature
- prints the result to the buffer
- It looks for matching serial number in eeprom repeatedly (eeprom address deterines the function the sensor assigned to. one sensor can be assigned to more functions)
- If succes, it writes eeprom address to buffer, than digs out function name from array of function names
- The resulting string is added to the buffer
- the buffer is sent to the output

Next functions are related too to 1W device management all in HMI.ino:
(if you need detailed explanation on these too just let me know)
listOwFunctions()
unlinkOwFunctions()
assignOwToFunction()
1w related commands are handled by commandInterpreter() function
look down to line "case l:" for listing,
"case a:" for assigning.

When the process want to get a temperature for a given function, it looks for 1w device address (serial number) at a given eeprom location.
locations are defined in globalvar.h currently at line 100-121
#define EEOWBUSADDR(a)
#define EEOWADDR(b)
...
#define AINADDR 0
#define AOUTADDR 1
#define AEVAPADDR 2
#define WEVAPLADDR 3
...

The function updateTemperatures() in basicfunctions.ino fills up a global array variable of temperatures. The indexes are the same like for the eeprom. I know, some has concerns with global variables, but it soooo effective.
The updateTemperatures() is called every 300ms from loop() in heatpump.ino
We need this buffering, because to get fresh temperature value from 1w devices takes ~700ms even if we want to read out the result of the last measurement takes significant time. So better is to do it once then use the buffered datas as frequently as convenient.

T.
takyka is offline   Reply With Quote