Menu

Two DS18B20 on differet pin

Help
jackjames
2018-01-30
2018-02-03
  • jackjames

    jackjames - 2018-01-30

    I should read the temperature two DS18B20 connected on two different pins of the micro.
    In order not to duplicate the reading routine, is it possible to indicate which pin to use for reading?

     
    • Anobium

      Anobium - 2018-01-30

      So, two devices on to two ports.
      Why not not two devices on port - a lot easier.

      Your demo folder shows how to read the devices ROM see \Temperature Sensor Solutions\DS18B20 Sensor Solutions\Sensor ROM Read to LCD. Then, use the call to read a specific device using the ROM addresses. A lot easier.

       
  • jackjames

    jackjames - 2018-01-30

    Thank you for your answer.
    This means that I need to know the code of each sensor and I will have to compile a program for each of the regulators that I will have to install. In case of replacing a sensor, I will have to change the regulator.
    Using a separate sensor for each input I avoid all these problems.
    I could write a separate reading routine for each input, but I find it a useless waste of memory.
    Is it possible to refer to a PORT by passing it as a datum instead of a #define?

     

    Last edit: jackjames 2018-01-30
    • Anobium

      Anobium - 2018-01-31

      I think we can but it will increase the code size - let me look at this at the weekend. This is doable - I will review the code size impact.

       
  • jackjames

    jackjames - 2018-01-31

    Thank you for your interest.
    Some compilers such as picbasic allow onewire dialog by switching ports and bits as parameters.

     
    • Anobium

      Anobium - 2018-01-31

      This may work, it may not, as I have not tested but it should. :-)

      DQ1 can be any valid ports. The demo attached shows the usage.

             ...
             do
                  readtempfromPort ( DQ1 )    'readTemp is now set
             loop while DS18B20DeviceReadBusy = true 'you ensure this IS NOT BLOCKING by adding a count or some other non-blocking test
      
          'Serial print temp
             ' Serial print the integer value of the sensor on the LCD
             hserprint readTemp
             'Serial print a special character
             hserprint chr(0xB0)+"C"
             HSerPrintCRLF
      

      So, the test library exposes a variable (not a function) called readTemp (maintain some level of backwards compatibility). Also exposes DSData for decimail extraction - this is not in the demo attached.

      Install the .h file to you C:\GCB@Syn\GreatCowBasic\Include\lowlevel directory. The demo can be any valid folder.

      Try, see what happens. I can only test this weekend.

      Anobium

       

      Last edit: Anobium 2018-01-31
  • jackjames

    jackjames - 2018-02-01

    Thanks.
    I'will try it.

     
  • jackjames

    jackjames - 2018-02-03

    The page in github is not present...

     
    • Anobium

      Anobium - 2018-02-03

      Reposted the demo URL

       
  • jackjames

    jackjames - 2018-02-03

    I wrote a test program for macros that work great.
    I have made some necessary changes to the program I'm writing to avoid waiting for the conversion, which in some cases could be too long.
    To do this I used a variable called 'Fase' and I made two calls in two different moments.
    The first to perform the conversion and the second to read the temperature.
    In this way, during the temperature conversion time, I can have other operations carried out by the program.
    I enclose the test program that uses a PIC16F1847 and the file with the macros modified for my use.
    Thanks to all the friends who have worked to achieve this result.

     
  • Anobium

    Anobium - 2018-02-03

    Excellent - I can see you use the very latest and it works. I will include in the next release.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.