Very OLD Error in one-wire example in the library manager

Beta Testing discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Very OLD Error in one-wire example in the library manager

#1 Post by Dany » 11 Nov 2013 21:36

Already a very OLD one, signalled lightyears (yes, I know that is a distance) ago I think:

Code: Select all

      //--- Perform temperature reading
      Ow_Reset(PORTE, 2);                                    // Onewire reset signal
      Ow_Write(PORTE, 2, 0xCC);                              // Issue command SKIP_ROM
      Ow_Write(PORTE, 2, 0x44);                              // Issue command CONVERT_T
      Delay_us(120);

      Ow_Reset(PORTE, 2);
      Ow_Write(PORTE, 2, 0xCC);                              // Issue command SKIP_ROM
      Ow_Write(PORTE, 2, 0xBE);                              // Issue command READ_SCRATCHPAD
The time needed between the CONVERT_T command and the READ_SCRATCHPAD command has to be at least 750 millisecs (can be shorter if using a D18B20 type with resolutions < 12 bits). In the above example it is 120 microseconds!!!!!
This means that the scratcpad will be read before the tempconversion finished, at least the first and probably also the second loop. Eventually the readings will be OK because the first temp conversion will be finished.

Come on guys, so many starting people (will) have problems with this!!!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
milos.vicentijevic
Posts: 965
Joined: 23 Apr 2013 08:09

Re: Very OLD Error in one-wire example in the library manage

#2 Post by milos.vicentijevic » 14 Nov 2013 16:39

Hello Dany,

thank you for pointing this out.

I have send this to software development department so they can consider proper change of this example.

Best Regards,
Milos Vicentijevic

Post Reply

Return to “mikroPascal PRO for PIC Beta Testing”