One Wire Example - Failure on linking

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

One Wire Example - Failure on linking

Post by gggwww »

Hello,

Im using the One Wire example from the Flowcode webpage for DS1820
Changed the chip to PIC16F88
Clock speed is 1MHz Internal - Added the following C block osccon=0x40;//1Mhz

Simulates fine
Compiles fine
Wont link - multiple failures
No other changes to the example .FCF than above

Suggestions?

Thanks !!
Attachments
1. Single OneWire device.fcf
(9 KiB) Downloaded 513 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 - Failure on linking

Post by Benj »

Hello

Look at the properties of the custom component and you will see that you are referencing portd as your one wire port.

You are also using a 16F88 as a target which does not have a portd.

Change the portd to porta and the trisd to trisa and your program should then compile correctly.

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Thanks - made the changes from Port D and TrisD to PortA and TrisA and still having issues - getting a return value of 1
Also - is AO the data port for the DS1820?

Thanks
Attachments
1. Single OneWire device.fcf
(9 KiB) Downloaded 391 times

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Update - as a point of reference I used the original example from my V4 install - this was written for the 16F877a - no changes made and would not compile - looks like the custom blocks have issues. I would very much like to try out using the DS1820 - any other examples available that use the DS1820?
Thanks!!

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 - Failure on linking

Post by Benj »

Hello

Please try this. It uses the Flowcode OneWire component and not the old custom version. It should now be compiling correctly.
Attachments
1. Single OneWire device.fcf
(12 KiB) Downloaded 646 times

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,
Thanks -
Compiled / Downloaded to 16F88 - went fine

LCD displays 0.0 C won't change from this value

Tried DS18B20 using both VDD connected to +5V and parasitic power option with VDD tied to GND and 4.7K pullup on data line tied to VDD

Greatly appreciate the help - If I can get this example working then should provide a nice basis to start customizing from

Regards,

George

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Additional Info

Post by gggwww »

Ben,

I disconnected the DS18B20 data line from AN0 on the 16F88 and the LCD continues to read 0.0C. None of the error checks are being picked up. From looking at the code, with a disconnected DS, the LCD should have read "no device found" - instead just a fixed 0.0C on the LCD.

Hope this helps

Thanks,

George

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 - Failure on linking

Post by Benj »

Hello George

You will currently need to restart the program to allow the device to detect that there is no device present.

I use the DS18S20 from Farnell with product code 972-4761, These are tested and working fine.

It looks like there are some fundemental differences between the DS18S20 and the DS18B20 which are covered here.
http://pdfserv.maxim-ic.com/en/an/AN4377.pdf

When I get some time I will have a look into this to see if we can properly support the DS18B20 devices with our OneWire component.

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Thanks Ben - appreciate the help

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,

Just received some 18S20's and plugged one into the circuit - same result - just 0.0C - no change -

Any suggestions?

Thanks !!

George
Attachments
1. Single OneWire device.fcf
(12 KiB) Downloaded 438 times

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,

Sent an earlier post but not sure it posted

Additionally Im getting a delay problem with your code when I try to build the download file

Please see attachment

Really would like to get this one working

Thanks,
George
Attachments
delayissue.JPG
(249.45 KiB) Downloaded 6225 times

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Additional detail

Program sets internal OSC to 1MHz - Ox40

Set Project options to 1Mhz - yours had 10Mhz

Thanks

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 - Failure on linking

Post by Benj »

Hello

The message you showed in your screen shot is meerly saying that at your clock speed of 1MHz the closest the 10us delay can come is 36us. This should be fine and shouldn't cause any problems.

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,

Thanks - any way for you to test your program on your side

I have everything wired properly and the LCD display continues to show a fixed 0.0C - wont change

Using the DS18S20 as suggested but still no luck

THanks

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 - Failure on linking

Post by Benj »

Hello

I noticed that you are using the internal oscillator set to 1MHz however in your project options the clock speed is set to 10MHz. This could explain why the 1Wire is not working. If this does not solve your problem then let me know and I will have another go here with the hardware.

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,
Thanks -

When I set the Project Options to 1Mhz to line up with the Internal Chip freq of 1Mhz the timing warnings appear - I disregarded the warnings and downloaded anyway - still fixed at 0.0C

I would greatly appreciate if you could try the hardware test

My hardware config:
PIC16F88 powered at 5VDC
DS18S20 powered by +5VDC ( not using parasite mode - although tried it and same result)
Output of DS18S20 pulled up by 4.7K Ohm resistor to 5V rail - as detailed in the DS18S20 MAXIM datasheet
Pin 17 of 16F88 (Port AO) used as input for DS18S20

Thanks again for the continued help

George

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 - Failure on linking

Post by Benj »

Hello George

Ok this afternoon I have ordered one of each of the following types of one wire sensor from Farnell.

DS1821+ 9726330
DS18B20+ 1187948
DS18S20+ 9724761

When these arrive I will test them all with your program and the V4 examples to see if I can tailor the component to work with all 3 devices. Please bear with me and I will let you know how I got on.

If you have any progress in the mean time then please let me know.

Also if there are any other requests for one wire devices not on the list above then now is a good time to let me know.

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,

Thanks for your efforts.

List looks good

I will keep you posted on my progress.

Hopefully this effort will greatly benefit the entire community

Best Regards

George

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Ben,
Upon review of the OneWire specification, it looks like the V4 macro for One Wire does not give the user access to all the required functions to get OneWire to work. If I review the C code from the OneWire DS1820 Example you sent me it has all the proper defines, but again, but some of the key ones are not in the UI popup for the OneWire Macro.

C Code from the example:
char oo_scratchpad[9];
// Scratchpad contents
// 0 Temperature LSB
// 1 Temperature MSB
// 2 Hi alarm temperature
// 3 Lo alarm temperature
// 4 Reserved, 0xFF
// 5 Reserved, 0xFF
// 6 Remainder register
// 7 Nr of counts per degree
// 8 CRC of pad contents


// Commands for the OO
// 1. ROM function commands
#define OO_READROM 0x33
#define OO_MATCHROM 0x55
#define OO_SKIPROM 0xCC
#define OO_SEARCHROM 0xF0
#define OO_ALARMSEARCH 0xEC
// 2. Memory Command Functions
#define OO_WRITEPAD 0x4E
#define OO_READPAD 0xBE
#define OO_COPYPAD 0x48
#define OO_CONVERTT 0x44
#define OO_RECALLE2 0xB8
#define OO_READSUPPLY 0xB4

MAXIM states that the following functions must be called in the correct order or the DS18s20 will not function
TRANSACTION SEQUENCE
The transaction sequence for accessing the DS18S20 is as follows:
Step 1. Initialization
Step 2. ROM Command (followed by any required data exchange)
Step 3. DS18S20 Function Command (followed by any required data exchange)
It is very important to follow this sequence every time the DS18S20 is accessed, as the DS18S20 will not
respond if any steps in the sequence are missing or out of order. Exceptions to this rule are the Search
ROM [F0h] and Alarm Search [ECh] commands. After issuing either of these ROM commands, the
master must return to Step 1 in the sequence.

Here is the transaction sequence for a single device on the bus

MASTER MODE DATA (LSB FIRST) COMMENTS
Tx Reset Master issues reset pulse.
Tx Presence DS18S20 responds with presence pulse.
Tx CCh Master issues Skip ROM command.
Tx 44h Master issues Convert T command.
Tx DQ line held high by
strong pullup
Master applies strong pullup to DQ for the duration of the
conversion (tCONV).
Tx Reset Master issues reset pulse.
Rx Presence DS18S20 responds with presence pulse.
Tx CCh Master issues Skip ROM command.
Tx BEh Master issues Read Scratchpad command.
Rx 9 data bytes
Master reads entire scratchpad including CRC. The master
then recalculates the CRC of the first eight data bytes from the
scratchpad and compares the calculated CRC with the read
CRC (byte 9). If they match, the master continues; if not, the
read operation is repeated. The master also calculates the
TEMP_READ value and stores the contents of the COUNT
REMAIN and COUNT PER Β°C registers.
Tx Reset Master issues reset pulse.
Rx Presence DS18S20 responds with presence pulse.

Unless I am missing something, I dont see some of the key functions in the OneWire Macro Define function in V4

Hope this helps

Regards,
George

Jan Middel
Posts: 7
Joined: Sun Nov 18, 2007 11:23 am
Contact:

Re: One Wire Example - Failure on linking

Post by Jan Middel »

Hello

Im using the One Wire example from the Flowcode webpage for DS1820
Only it works not by me there is only some stange symbols omn my lcd schreen
When i look at the data output on de DS 1820 there is no communication
I have put de code in to a program that i hve made.
Then it works a litte bit no srange symbols but no readings...
And i have data communication on de data output on the DS 1820

Can somboy help my??

I put on de file so that you can see what i meen.

Ps i hope you can read this im not so good to write in Engels :lol:

Groeten Jan Middel
Attachments
Test_ds1820_versie_2.fcf
(34.75 KiB) Downloaded 428 times

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by Eric »

Hello,

I am succesfully using the one-wire protocol of Flowcode V4 in a central heating controller.
My one-wire bus is 18 meters long and has 6 sensors DS18B20 attached to it.
It took me considerable study and effort to make it work reliable.
But it is perfectly possible to use the protocol of V4.
However: the configuration and the topology of the network is extremely critical.
Also the sequence of one-wire commands is critical.
I attach my network testprogram as a guideline.
Please read the comments at the beginning.
I hope this can help.

Rgds,

Eric
Attachments
DS18X20_Get_Temp_Multiple_Device.fcf
(30.15 KiB) Downloaded 677 times

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Eric,

Thanks - I will give the program a try

Best Regards,
George

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by Eric »

Please remember: the program will not simulate because there is no one-wire simulation in Flowcode.
You need at least 1 real sensor DS18S20 or DS18B20 connected to port A0.
You will see something like this on real hardware : 8 sensors ( 5 DS18S20 and 3 DS18B20 ) and display_res of 3 digits :
snap0206.jpg
snap0206.jpg (14.35 KiB) Viewed 16538 times

gggwww
Posts: 54
Joined: Wed Sep 09, 2009 12:50 am
Has thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by gggwww »

Eric,
Thanks

Can I run your program on a 16F877a? If possible, what crystal frequency - any special considerations? thanks for the help!

George

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time
Contact:

Re: One Wire Example - Failure on linking

Post by Eric »

George,

I haven't tested it on PIC16F877 but I see no reason why not.
I use a crystal of 8 Mhz

Regards,

Eric

Post Reply