I want to get a temperature reading from ds18b20 with a microcontroller and even though there is so many resources on the internet I could not manage to do it. None of the codes work on their own and I am just unable to figure out how to convert them to my microcontrollers timings etc. Almost all the codes are written in C and this makes it even more difficult for me to understand what happens timing wise and port wise (as opposed to assembly language) I would really appreciate if someone told me what values to assign the port and how many us's to wait in between etc.
I know reset, write1,write0,read codes are necessary. these are the ones I have written (even if you know how to use it on a different device, I can convert them. I just need the timings and the port values)
Reset-- pin=0 wait 500us pin=1 wait 500us write1-- pin=0 wait 1us pin=1 wait 60us write0-- pin=0 wait 60us pin=1 read-- pin=0 us wait 1us pin=1 us wait 13 us (has to be 15us according to the datasheet but previous instructions already should take time) c (carry) = pin (value read) wait 60us
how would I get the temperature measured?
reset send CCh (write1 write0 write1 write0 write1 write0 write1 write0) send 44h wait 1 sec (for the conversion, I assume it is 12 bits by default) reset send CCh send BEh read (do this 16 times and I'll have the measurements MSB.(0:7) and then LSB(0:7))
am I thinking wrong? what do I need to fix? Is there a clean assembly code for ds18b20 (so that I can understand what actually goes on without much abstractions)? I could use a c code but none of them are for the microcontroller I have and I need to adjust the delays and I couldn't get any of them to work. Any help would be much appreciated
After tens of hours wasted not understand what I'm doing wrong, I miraculously managed to read 85C from the machine (using a c code which I do not understand how it works, moreover I overwrote it so now it doesnt work. I guess I make it work again though) (which is the default value the temperature registry starts with) So I am assuming I did not actually ConvertTemperature (44h)?