Page 1 of 1
One Wire example files.
Posted: Tue Apr 02, 2013 10:09 pm
by andyduell
I'm new to Flowcode V5 for PIC with EB006 multiprogrammer board using a 16F877A chip trying to get into One Wire devices. I have several DS18S20 sensors and so far have not had any luck in getting the sensors to communicate with the PIC. The Multiple Onewire example file compiles to the chip O.K. and when I edit various variables with I.C.D. I get predictable results. I think that my hardware is O.K. but?
Re: One Wire example files.
Posted: Tue Apr 02, 2013 11:21 pm
by kersing
Have you added the mandatory pull-up on the signal pin? (Recommended 1K to 4K7)
Re: One Wire example files.
Posted: Wed Apr 03, 2013 8:35 pm
by andyduell

- Close up.jpg (70.9 KiB) Viewed 12281 times

- Overall layout.jpg (72.5 KiB) Viewed 12281 times
I think that I have included the pull up resistor, can you have a look at the photos and see if I have got the circuit correct? I have been reading all the posts in the forums with any reference to One Wire and also the DS1820 data sheet. I have changed the One Wire connection both on the breadboard and in the Flowcode file to Porta1 because there seems to be a problem with Porta0 in various posts.
Re: One Wire example files.
Posted: Wed Apr 03, 2013 9:38 pm
by kersing
The connections look right. Have you checked the voltage between pin 1 and pin 3 of the DS1820?
To start I would just use one DS1820. Once that works add the second.
If you post your code I'll try to find time during the weekend to find my DS1820s and replicate your setup.
Re: One Wire example files.
Posted: Thu Apr 04, 2013 8:06 am
by andyduell
I get 5 volts between pin 1 and 3. It is the Multiple Onewire example from Matrix downloads with the Onewire connection changed to Porta1 and I have changed the clock speed to 4000000 in the config chip window. Previously I have tried this at all clock speeds. Another problem is that there is no explanation of how this program is supposed to work. I have assumed the temperature of sensor one will be displayed and then by pressing either of the switches you can get results for the other sensors. With various attempts I have got either 0.0 C or as now 0 DS18 App. stopped.
Re: One Wire example files.
Posted: Mon Jun 03, 2013 10:08 am
by Benj
Hello,
I can potentially see two issues.
First you say you are using the DS18S20 device, I originally wrote the code around the DS18B20 device and there seems to have been some minor changes to the device since then so it could be there is an issue with the component code. Saying this though there are users who have these devices working so let's investigate further.
Maybe because your running using a PIC at 4MHz (1MIPs) your processor is not running fast enough to be able to process the one wire bus correctly. Could you try changing the 4MHz oscillator with say 20MHz?
Also have you tried a simple 1 second flasher program on your hardware. Just as a sanity check that second delays are bang on what they should be on the hardware. If second delays are correct then all the other delays e.g. micro seconds as used by the 1 wire component should also be correct.
Re: One Wire example files.
Posted: Thu Jun 06, 2013 6:57 am
by andyduell
I have run a one second flasher and this works well at 20MHz on my hardware. I have then run the single onewire device file at 20MHz but still can't get a temperature reading. Following your post I have ordered some DS18B20+ sensors.
Re: One Wire example files.
Posted: Mon Jun 10, 2013 7:41 am
by andyduell
I have now tried the DS18B20+ sensors but still get the same result - no temperature reading.
Looking at the data sheets the difference between the DS18B20 and DS18S20 seems to be the thermometer resolution which is DS18B20 9 to 12 user selectable but the DS18S20 is 9 bits.
I am trying to get my head into the C file and noticed the following:-
//Global Variables
// Internal variables
MX_UINT8 ONEWIRE_2_oo_id[8];
MX_SINT8 ONEWIRE_2_oo_conflict;
MX_UINT8 ONEWIRE_2_oo_new_conflict;
// Device ID Variables
Sorry that I can't give you the line numbers but is this significant?
Re: One Wire example files.
Posted: Mon Jun 10, 2013 7:46 am
by andyduell
Ref the previous post I have now got line numbers by opening the C file in Open Office and they are 271 - 278
Re: One Wire example files.
Posted: Mon Jun 10, 2013 7:52 am
by jgu1
Hi!
Could you try this. It work by me..
Jorgen
Re: One Wire example files.
Posted: Wed Jun 12, 2013 6:41 am
by andyduell
jgu1 wrote:Hi!
Could you try this. It work by me..
Jorgen
Thanks Jorgen. My first attempts are not successful, I think that I need to get into the clock timings in some detail but I appreciate your post.
Re: One Wire example files.
Posted: Wed Jun 12, 2013 11:23 am
by jgu1
Hi again!
ok, it sounds strange, as mentioned it works fine with me.
as you probably have seen it is a PIC16F886 I use with only one sensor.
If you change to a 877A you of course change the configuration for this device and use the same input. If you are interested, I can try to change my program from a 887 to a 877A and test it, but only with one sensor
Best regard
Jorgen
Re: One Wire example files.
Posted: Wed Jun 12, 2013 9:51 pm
by andyduell
Hi,
Yes I am using the 16F877A and I realise that I need to change the configuration to get the clock settings correct but so far I haven't had a lot of time to get to grips with this. Thanks for your offer.
Re: One Wire example files.
Posted: Fri Jun 28, 2013 10:34 pm
by medelec35
Hi Jorgen,
I have just tried DS18B20+
For the first time with your Flowchart, which works really well.
Temperature is correctly displayed to 2dp
Thanks.

Re: One Wire example files.
Posted: Sun Jun 30, 2013 12:40 pm
by jgu1
Hi Martin!
Thank´s for reply. Yes It´s also work fine by me. Hope to Andyuell also get it to work.
Honestly, I think it's something I've picked up here at some point, but that's no matter it just works.
(maybe one of your nice exable Martin, can´t remember

).
Regard
Jorgen.

Re: One Wire example files.
Posted: Mon Jul 01, 2013 7:08 am
by andyduell
Hi,
I have now tried several things as follows. I am using the 877a chip and in all files set the config to 0x3F3A with a clock speed of 20000000Hz and the connections on the panel to Onewire porta0 and the LCD portb 0-5.
In the Single OneWire device file downloaded from Examples/Components/Onewire compiled to chip without ICD enabled I get 0.0 C
If I enable ICD with breakpoint 8 Callstack depth 8 and communication speed 100 and then step through I get zero values for the variables.
When I step through and edit Retval to 1 the program branches to No Device Found on the LCD at the first decision diamond.The same thing happens at the second decision diamond.
With Jorgens Virker file I deleted the C code with the Oscon and Ansel setting compiled to chip and get 0.0 C Get_Temp 0 on the LCD screen. When I enable ICD all variables values are 0, if I change Retval to 1 then the program branches as in the Single OneWire file.
With the Multipe OneWire file compiled to chip I get 0 DS18 App stopped on the LCD screen. When I enable ICD and edit varoius variables the I get the predicted results.
I would value anyones comments but I think I have a problem with the hardware? Any help would be appreciated.
Re: One Wire example files.
Posted: Sat Jul 06, 2013 8:22 am
by andyduell
Hi,
For those of you who have got a OneWire flowcode file to work can you tell me if you are using parasite power or not? If you are what mosfet are you using as I can see no specification for it anywhere.
Thanks in anticipation.
Re: One Wire example files.
Posted: Sat Jul 06, 2013 10:13 am
by medelec35
Hi Andy,
I have not used parasite power.
Just used two supply + data wire.
Here is a post by someone who has used parasite power.
http://mbed.org/users/snatch59/notebook ... itic-power
Martin