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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
...
doreadtempfromPort(DQ1)'readTemp is now setloopwhileDS18B20DeviceReadBusy=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.
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.
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?
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.
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
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.
Thank you for your interest.
Some compilers such as picbasic allow onewire dialog by switching ports and bits as parameters.
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.
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
Thanks.
I'will try it.
I tried and the code works perfectly.
To save memory I call it through a routine that I send data to several times.
THANKS ANOBIUM !
@Jamejames
You are kidding. I did zero testing - all theortical!
Can you post you code? Have you sorted the DSDATA for decimal values, or, are you happy with the integer values?
Also, can you test the following? https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/tree/master/Temperature%20Sensor%20Solutions/DS18B20%20Sensor%20Solutions/MultiPort%20Sensors%20to%20Hardware%20Serial%20Terminal I need a reference piece of code - most grateful.
Anobium
**POST SCRIPT: ** I have tested and I have now verified all is ok. I could not make work when using an 18F. All ok now. Please use https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/DS18B20MulltiPort.h?format=raw as the library and the use the demo . If you chip is PPS then you may have to update the PPS, and, if not PPS please remove the PPS code.
Last edit: Anobium 2018-02-03
The page in github is not present...
Reposted the demo URL
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.
Excellent - I can see you use the very latest and it works. I will include in the next release.