One Wire example files.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

One Wire example files.

Post 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?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: One Wire example files.

Post by kersing »

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

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post by andyduell »

Close up.jpg
Close up.jpg (70.9 KiB) Viewed 11093 times
Overall layout.jpg
Overall layout.jpg (72.5 KiB) Viewed 11093 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.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: One Wire example files.

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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.
Attachments
Multiple OneWire test file.fcf
(45.24 KiB) Downloaded 448 times

User avatar
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.

Post 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.

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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.

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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?

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: One Wire example files.

Post by jgu1 »

Hi!


Could you try this. It work by me..

Jorgen
Attachments
1. Single OneWire_DS18B20_886_Virker.fcf
(15.5 KiB) Downloaded 529 times

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: One Wire example files.

Post by jgu1 »

Hi again!

ok, it sounds strange, as mentioned it works fine with me. :roll:
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

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: One Wire example files.

Post 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. :)
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: One Wire example files.

Post 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 :lol: ).

Regard

Jorgen. :D

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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.

andyduell
Posts: 17
Joined: Mon Feb 25, 2013 8:52 am
Contact:

Re: One Wire example files.

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: One Wire example files.

Post 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
Martin

Post Reply