I need a push in the right direction, the answer is probably very simple.
What I want to do is read the DS18B20 ID, save it to the EEPROM, read it back from the EEPROM into a variable to use in the program.
I will have up to 5 DS18B20's that I want to save the address to the eeprom incase one fails I can change on the fly with out reprogramming.
I know I'm going about this all wrong, BUT...
the typical read DS18B20 ID:
From there I save it to the EEPROM:Code:Start_Convert: owout dq, 1, [$33] ' issue read rom command ID_Loop: owin dq, 0, [str id\8] ' Read 64-bit device data into the 8-byte array "ID"
Then I can read it from the EEPROM at program startCode:write 106, ID[0] write 107, ID[1] write 108, ID[2] write 109, ID[3] write 110, ID[4] write 111, ID[5] write 112, ID[6] write 113, ID[7]
And then I get totaly confused as to how I can select the right sensor and insert the corresponding IDCode:READ 98, Tempsensor1[0] READ 99, Tempsensor1[1] READ 100, Tempsensor1[2] READ 101, Tempsensor1[3] READ 102, Tempsensor1[4] READ 103, Tempsensor1[5] READ 104, Tempsensor1[6] READ 105, Tempsensor1[7] READ 106, Tempsensor2[0] READ 107, Tempsensor2[1] READ 108, Tempsensor2[2] READ 109, Tempsensor2[3] READ 110, Tempsensor2[4] READ 111, Tempsensor2[5] READ 112, Tempsensor2[6] READ 113, Tempsensor2[7] READ 114, Tempsensor3[0] READ 115, Tempsensor3[1] READ 116, Tempsensor3[2] READ 117, Tempsensor3[3] READ 118, Tempsensor3[4] READ 119, Tempsensor3[5] READ 120, Tempsensor3[6] READ 121, Tempsensor3[7] and so on...
Right now I am trying with a select case lookup, but clearly thats not working...
Code:Begin: sensor= TEMPSENSOR 'I am reading 5 DS18b20 sensors... FOR hexbyte=0 TO 7 'each sensor address is 8 bytes GOSUB GetID 'go look up each sensors address ID[hexbyte]=col 'load the ID array with the retrieved address byte NEXT hexbyte 'go get the rest of the address bytes OWOUT DQ, 1, [$55,STR ID\8,$44] 'instructs sensors to match[$55] this[ID] rom code and 'initiates[$44] temperature conversion on matching sensor CkAgn: OWIN DQ, 4, [Busy] ' Check for still busy converting IF Busy = 0 THEN CkAgn ' Still busy?, then loop OWOUT DQ,1,[$55,STR ID\8,$BE] 'instructs sensors to match[$55] this[ID] and start sending back scratchpad[$BE] OWIN DQ, 2, [Raw.LOWBYTE,Raw.HIGHBYTE]' Read two temperature bytes, then end communications Dummy = 1125 * Raw TempF = DIV32 100 TempF = TempF + 3200 GetID: SELECT CASE sensor CASE 1 :LOOKUP hexbyte,[HEX Tempsensor1[0],HEX Tempsensor1[1],HEX Tempsensor1[2],HEX Tempsensor1[3],HEX Tempsensor1[4],_HEX Tempsensor1[5],HEX Tempsensor1 [6],HEX Tempsensor1[7]], col CASE 2 :LOOKUP hexbyte,[Tempsensor2[0],[Tempsensor2[1],[Tempsensor2[2],[Tempsensor2[3],_ [Tempsensor2[4],[Tempsensor2[5],[Tempsensor2 [6],[Tempsensor2[7]], col CASE 3 :LOOKUP hexbyte,[Tempsensor3[0],Tempsensor3[1],Tempsensor3[2],Tempsensor3[3],_ Tempsensor3[4],Tempsensor3[5],Tempsensor3[6],Tempsensor3[7],], colI think the array thing is confusing me for some reason.Code:;*** Temp Sensor 1********************************************************** ReadTemp1: TEMPSENSOR = 1 GOSUB Begin RETURN ;*** Temp Sensor 2 ********************************************************* ReadTemp2: TEMPSENSOR = 2 GOSUB Begin RETURN ;*** Temp Sensor3 ********************************************************* ReadTemp3: TEMPSENSOR = 3 GOSUB Begin RETURN and so on..


 
		
		 
						
					 
			 
			 
			 
					
					 DS18B20 ID saving To and Reading From EEPROM
 DS18B20 ID saving To and Reading From EEPROM
		

 
						
					
 Originally Posted by Charlie
 Originally Posted by Charlie
					




Bookmarks