Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:03 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : 1-Wire Search-Find-Read.

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 01:17am 21 Apr 2016
Copy link to clipboard 
Print this post

A call to Pmather,

Your name was mentioned in this tread

1-Wire devices, multiples on a single pin.

I'm sure someone with the know how could interrogate the bus, identify the devices & load all their serial numbers into an array, where variable names could also be assigned.

Then from a cFunction we could call "Read Outside Temp", "Read Lounge Room Temp", "Read Bedroom Temp" etc, etc.

All off one pin with about 30m of cable running back to the controller, as opposed to the 100+ metres and 10+ cable runs required if each temp sensor had it's one individual pin.

What others have contributed to this request I've previously made is working great & doing the job, but taking it to the next level has to open great opportunities to other & should be widely accepted.

Hope you find it valid suggestion.

Cheers

Phil.

PS, The analogue clock blows me away.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10213
Posted: 03:20am 21 Apr 2016
Copy link to clipboard 
Print this post

  Quote  A call to Pmather,


Sorry: not interesting enough to me to justify the time setting up a big enough test environment and getting it all to work. I think the relevant C-code is in the Micromite source within a conditional compilation clause if someone else is interested.

For your requirement I would just use 6-core burglar alarm cable which is available for almost nothing which would allow 4 x DS18B20 per cable (+ve, GND, + 4 signal)
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 12:57pm 26 Apr 2016
Copy link to clipboard 
Print this post

Wondering if anyone can offer a little further help with the basic code for finding 1-Wire devices?
I've seen a few other threads on the issue, but not sure what is ultimately out there.
I'm sure lot would put a search routine to use if it was available.


I Currently have 6 Temp Sensors, (Plus another dozen or so in transit).

Connecting them one at a time & reading their serial numbers I get these results using this code, 2016-04-26_223939_1-Wire_Search-Single.zip,
the results I get for each sensor are, for sensors 1 to 6:-
[Code]RUN
Temp Sensor Should be 28 / 28H Sensor 1
Ser# C95D4B070000H
CRC 60H
> RUN
Temp Sensor Should be 28 / 28H Sensor 2
Ser# 24724A070000H
CRC 1BH
> RUN
Temp Sensor Should be 28 / 28H Sensor 3
Ser# 46B94A070000H
CRC E4H
> RUN
Temp Sensor Should be 28 / 28H Sensor 4
Ser# 29954A070000H
CRC DAH
> RUN
Temp Sensor Should be 28 / 28H Sensor 5
Ser# 1D854A070000H
CRC 97H
> RUN
Temp Sensor Should be 28 / 28H Sensor 6
Ser# FFA667A81501H
CRC 6FH
>
[/code]
I connected the just the first 3 sensors & ran this code,
2016-04-26_224103_1-Wire_Search-Multi.zip .

The output was, pretty much as expected, and returned the correct serial numbers:-


[Code]RUN
Family 28H
ID: 24 72 4A 07 00 00 Sensor 2
CRC: 1B

Family 28H
ID: 46 B9 4A 07 00 00 Sensor 3
CRC: E4

Family 28H
ID: C9 5D 4B 07 00 00 Sensor 1
CRC: 60

DeviceCount 3 device(s).
--Done--
>
[/code]
I then added sensor 4, and the program goes into an indefinite loop, listing the first 3 sensors repeatedly.

I also tried attaching just sensors 4,5 & 6, and get the following output:-

[Code]RUN
Family 28H
ID: 29 95 4A 07 00 00
CRC: DA

Family 28H
ID: FE A6 67 A8 15 01
CRC: 6F

DeviceCount 2 device(s).
--Done--
>
[/code]

It's only seeing sensors 4 & 6 and you will notice, it's got the first part of sensor 6's ID wrong, FE instead of FF.

With a large number of sensors for intended projects, this will be valuable if I can get it working right.
I don't completely understand the code, but I think it's something to do with the search_direction part.

I can only offer further help, by the ability to test changes with various different devices connected.

As you can see, 6 sensors is already creating a birds nest at the controller,

10 to 12 will become a complete nightmare.
I've read other suggestions of multiple Micromites talking back to a master, but think that's way out of my league at this point in time.

Just a single bus would be wonderful, but also don't quite understand what might be it's other limitations.

If anyone can offer suggestions on what's going wrong in the code, I'm happy to provide the feedback from a test environment.

Thanks

Phil.


 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 01:57pm 26 Apr 2016
Copy link to clipboard 
Print this post

The other thought I had was that each sensor could have a physical connection, like an RJ-12 or RJ-45 at it's location, and the devices could be added to the circuit one at a time while the routine found each new sensor as it was added.

Don't know if that would help or complicate matters.

Presume the serial numbers would need to be saved somewhere, and assume it would always find them in the same order.

Then maybe they could be stored in an array, where meaningful variable names could be applied to each sensor.

Sensor1="Attic Temp"
Sensor2="Ambient Temp"
Sensor3="Lounge room Temp"

etc.

Guess that hints as to where this project in leading.

Cheers

Phil.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 01:58pm 26 Apr 2016
Copy link to clipboard 
Print this post

Hi Phil

I dont have that many sensors to test with but i will order a few so we
can test it

Do you have the sensors connected like the pic below?
What value is your pullup resistor? and is to 5V





Regards
Jman
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 02:06pm 26 Apr 2016
Copy link to clipboard 
Print this post

  jman said   Hi Phil

I dont have that many sensors to test with but i will order a few so we
can test it

Do you have the sensors connected like the pic below?
What value is your pullup resistor? and is to 5V





Regards
Jman


Hi,

That's basically how I have them connected. the pullup is right at the MicroMite, between +5 & the I/O pin I am using, and it's 4.7k. They are all powered off the 5 Volt rail.

Happy to post feedback from the 6 sensors I currently have. I have another dozen or so on the way.

Edit:-
I can easily drop individual ones out of circuit by pulling the data wire on the breadboard.

Cheers

PhilEdited by Phil23 2016-04-28
 
piclover
Senior Member

Joined: 14/06/2015
Location: France
Posts: 134
Posted: 10:46pm 26 Apr 2016
Copy link to clipboard 
Print this post

I already made a successful project with 5 DS18B20 sensors connected to the same pin of a PICAXE 28x2 (it was for a battery charger: 1 sensor per battery cell + 1 for ambient temperature, so to get a delta-T for each cell), but the wiring was very short.

For very long wiring you might want to use shielded wires and a lower pull-up resistor value (3.3K or even 2.2K).
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:52am 27 Apr 2016
Copy link to clipboard 
Print this post

  matherp said  I think the relevant C-code is in the Micromite source within a conditional compilation clause if someone else is interested.


I certainly don't understand what's involved in creating cFunctions, but does the above mean that that the source code for OWSEARCH in Version 4.5 could be "exported" as a cFunction and operate the same way as the obsolete command?

Thanks

Phil
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 03:55pm 25 Jun 2016
Copy link to clipboard 
Print this post

  jman said   Hi Phil

I don't have that many sensors to test with but i will order a few so we
can test it.

Regards
Jman


Hi Jman & others.

Wondering if anyone could take a look at this code & see if they can spot where it's going wrong.


It gets stuck in it's loop & only finds two of the four sensors on the bus.

It works Ok with 3 particular sensors, different serial numbers, but with the 4 currently connected, it does not.

The 4 Sensors connected are:-
[Code]&HFFE244001601E7 'Sensor1 Ambient Temp
&HFF94580016013C 'Sensor2 Roof Temp
&HFFA257001601BE 'Sensor3 Lounge/Dining Room Temp
&HFF2C5A0016014A 'Sensor3 Bed Room Temp[/code]

And as can be seen it is only seeing the 2nd & the 4th one.
Something do do with the search direction I think.


[Code]
RUN
Family 28H
ID: FF 94 58 00 16 01
CRC: 3C

Family 28H
ID: FF 2C 5A 00 16 01
CRC: 4A

Family 28H
ID: FF A2 57 00 16 01
CRC: BE

Family 28H
ID: FF 28 5A 00 16 01
CRC: 4A
[/code]

I've had a look at this tutorial but the whole lot is a bit over my head.

I know it needs a test environment, and if anyone would like to take a look I can provide an IP & a port to either of the 2 micros I have sensors connected to.

One has 4, the other 5.

The search with one device only present works fine, but it would probably be handy to me and a few others if we could find all those present on a single pin.

It's got to be something simple to the right eyes & mind, given that with the first set of three sensors I tried it worked fine.

Thanks

Phil

Edit.....

Actually, it's identifying 4 in this case (Must have tested on a different set previously),

But it is still stuck inside the loop.

My posting with too many distractions...


Edit #2.....

Looks like it's reporting a couple of them wrongly.

2016-06-26_015242_1-Wire_Search-Multi.zip Edited by Phil23 2016-06-27
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 04:24pm 25 Jun 2016
Copy link to clipboard 
Print this post

Just correcting my previous post.

[Code]
FF E2 44 00 16 01 E7 'Sensor1 Ambient Temp
FF 94 58 00 16 01 3C 'Sensor2 Roof Temp
FF A2 57 00 16 01 BE 'Sensor3 Lounge/Dining Room Temp
FF 2C 5A 00 16 01 4A 'Sensor4 Bed Room Temp[/code]

And as can be seen it is only seeing the 2nd, 4th and 3rd one.

It's reporting annother that is incorrect.

[Code]
RUN
Family 28H
ID: FF 94 58 00 16 01 Sensor 2 - Correct
CRC: 3C

Family 28H
ID: FF 2C 5A 00 16 01 Sensor 4 = Correct
CRC: 4A

Family 28H
ID: FF A2 57 00 16 01 Sensor 3 - Correct
CRC: BE

Family 28H
ID: FF 28 5A 00 16 01 Looks like Sensor 4 but isn't
CRC: 4A
[/code]


Thanks

Phil

 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 04:39pm 25 Jun 2016
Copy link to clipboard 
Print this post

I would be looking at length of cables, value of pullup resistor and connections.
VK7JH
MMedit
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 04:46pm 25 Jun 2016
Copy link to clipboard 
Print this post

  TassyJim said   I would be looking at length of cables, value of pullup resistor and connections.


Not sure Jim,

Do you think that my influence the search.

Everything is working fine on all three devices as far as reading the sensors is concerned. I'm reading off known numbers I've identified individually.

That's not a problem, I'm not getting any errors there.

2 of the MM's are live running things, one is just a test case.

It would be just useful to be able to run the search again when an unknown sensor is added to the bus.

I do notice though that the output from the search varies with different serial numbers present, as I'd mentioned before.

Cheers.

 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:58pm 25 Jun 2016
Copy link to clipboard 
Print this post

  TassyJim said   I would be looking at length of cables, value of pullup resistor and connections.


Hi Jim & others,

Just thinking further to you comment.

In the picture I posted above, sensors connected to the bread board;
5 have 3m cables, the 6th one is only 1m.

Initially I had 3 connected;
the routine ran & terminated normally.

I added 3 more & it got stuck in the loop.

At the time I removed the first 3 & tried it again on the remaining 3 sensors, and got the same result, it got stuck in the loop.

Tried the original 3 again & all fine, added a 4th & stuck in the loop again.

Tried a couple of different combinations of 3 & they didn't work as expected.

Just suspect that the logic is not fully progressing for given bit map patterns in the serial numbers.


The tutorial I read said 63 passes were needed for each bit search, but I think it drops out before completing graciously.


The logic of how to search a bus only half makes sense to me, but don't quire get how it relates to the BASIC code.

Have tried looking at Arduino example that are supposed to work, but get lost in the code variation & their dependencies on libraries, but it seems pretty accepted in their world that search routines can be easily written.

Phil

 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025