One Wire example files.
Moderator: Benj
One Wire example files.
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?
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: One Wire example files.
Have you added the mandatory pull-up on the signal pin? (Recommended 1K to 4K7)
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
Re: One Wire example files.
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.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: One Wire example files.
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.
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.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
Re: One Wire example files.
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.
- Attachments
-
- Multiple OneWire test file.fcf
- (45.24 KiB) Downloaded 509 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: One Wire example files.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: One Wire example files.
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.
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?
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.
Ref the previous post I have now got line numbers by opening the C file in Open Office and they are 271 - 278
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
Re: One Wire example files.
Hi!
Could you try this. It work by me..
Jorgen
Could you try this. It work by me..
Jorgen
- Attachments
-
- 1. Single OneWire_DS18B20_886_Virker.fcf
- (15.5 KiB) Downloaded 582 times
Re: One Wire example files.
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.jgu1 wrote:Hi!
Could you try this. It work by me..
Jorgen
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
Re: One Wire example files.
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
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.
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.
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.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: One Wire example files.
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.
I have just tried DS18B20+
For the first time with your Flowchart, which works really well.
Temperature is correctly displayed to 2dp
Thanks.

Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
Re: One Wire example files.
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.
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.
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.
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.
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.
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.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: One Wire example files.
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
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
Martin