Electronics > Beginners
How to Implement 1-wire Devices
<< < (3/6) > >>
Docara:
Hello C,

Thank for you input.

You are quite right about the binary tree. I just cant visualise how to formulate even an idea to sort out a program of what's going on beyond one branch. How you make sure you go down all possible branches whilst keeping track of where you are is hard and confusing.

I now what I want to achieve and roughly what I need to do but I then read the datasheets for these devices and I suddenly develop Maxim dyslexia - I read the words ......... and that's it!!! No understanding or comprehension whatsoever comes out the other side - very weird.

C:

With the scan function you get three answers for each bit.

There are some devices with a One in this position.
There are some devices with a Zero in this position.
else there are no devices.

Now the easy way is to use recursion.
start with what Current_bit = 0

Pass the current_bit to recursion sub
add one to local_current_bit
While local_current_bit<64
Check for One for bit if so
  Add One-Bit folder
  and recurse ( local_current_bit) .

Check for Zero for bit if so
  Add zero-bitfolder
  and recurse ( local_current_bit) .
end while
return

You can do the same with lists by creating a check from here list.
As you check a bit level remove from list.
If you find a device at bit level then add to list.

So a blank list causes a check of bit one.
No response = nothing on bus.
In place of creating files above you add to the liist.


You need to think of simple

Then you start doing an address, you have all devices monitoring the bus.
If the address bit does not match bit in device ID then that device will stop monitoring.
A good address leaves one device still monitoring bus waiting for commands.

If you want C source code for this there are some examples on net.

 
Think of what you should see.
You have three temp sensors
You should have one path containing all three sensors and then a path change for each due to serial number.
 
Docara:
Hi C,

I see that you have tried to put into words what I should do in code - thank you for that.

I'm just re-reading Maxim's Application Note 187 and have your example on screen - I have just noticed that in the AP187 version I found on the net it includes code at the end. Again I will go through it and see if anything sticks in the grey matter.

Will report back
Matt
C:
If you look
the low level is not too bad

APPLICATION NOTE 126
1-Wire Communication Through Software
https://pdfserv.maximintegrated.com/en/an/AN126.pdf




The search is doing two reads for each ID bit then writing what path you want to continue on.
This two bit response gives you four states.
shown in table 1 of APPLICATION NOTE 187
1-Wire Search Algorithm

There are many complete libraries that exist all ready for one-wire
just pick a language that you understand and check if it's search function will return many devices.

The hard part is the low level timing. Smart would be to use a table to make these easy to adjust.

C
Docara:
Yeah the timing and slew is why I would like to use the DS2480B (RS232) line driver as the master (or one of the other variants for I2C). The DS2480 also has part of the search algorithm built in.
Its keeping track of the path is causing me the headache, I think I could eventual muddle through the (basic) search function.

like I said I'm not software where do these libraries exist that you refer to? The only ones I can find is via Maxim.


Additionally, I remember that there was another line driver which included the full search algorithm the DS9490R but it's for a USB interface.
I subsequently found this for android which looks really interesting and handy for a fall back. Worse case scenario I could always enter the address in manually via a simple touch screen.

https://www.maximintegrated.com/en/app-notes/index.mvp/id/5705
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod