DS18B20 with PIC18F26K22

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
Corto
Posts: 28
Joined: Thu Sep 04, 2014 7:01 am
Has thanked: 7 times
Been thanked: 6 times
Contact:

DS18B20 with PIC18F26K22

Post by Corto »

Hello everyone,
I have a big problem with the operation of the DS18B20 and the PIC18F26K22. Usually I use a PIC 16F1829 with an OSCCON F0 configuration (32MHz) PLL enable and clock Flowcode at 32MHz and it works fine.
Now I changed Pic for reasons of use of additional inputs and outputs, but here it does not work.
I made a small program that includes a display, an LED, and DS18B20. I tried everything (at least it seems to me, in configuration).
First of all, and you will give me your opinion, according to this configuration: OSCCON 76 PLL enable and clock Flowcode to 64MHz (see program attached), the LED flashes but with a very very long time and then I display Error CRC.
other configuration: OSCCON 76 PLL Enable and Clock Flowcode 16 (16x4 = 64 MHz), the LED flashes, it seems to me, 1s, so everything seems normal, except that I display a temperature at 0 °.
I always display a T ° at 0 ° whatever the configuration of OSCCON (without changing the PLL and clock Flowcode).
Initially the entry DQ was on A5, I changed to C2 and I always display 0 °.
I tried OSCCON 0x76; 0x66; 0x72; 0x7c; 0x78; 0xf8 and I still do not display the temperature correctly.
Maybe there is a huge problem that I have not seen, but I think I will go crazy
Can you please help me
Essai_ds18b20.fcfx
(14.7 KiB) Downloaded 360 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: DS18B20 with PIC18F26K22

Post by Benj »

Hello,

Do you have any tools available to look at and compare the signals of the working device and none working device. This will hopefully provide an insight into what's going wrong.

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: DS18B20 with PIC18F26K22

Post by Benj »

I was thinking on this last night and was wondering if simply installing the XC8 compiler from Microchip and activating the 60-day free trial might simply be enough to allow the program to work correctly. The free version of XC8 we ship with Flowcode PIC is known to be a bit inefficient and so this could be adding problems that are stopping the code from running on the micro running at 16MHz.

If simply installing XC8 and starting the free 60-day trial is not enough for Flowcode to use the pro mode then you may have to point Flowcode at the new compiler installation using the Build -> Compiler Options menu. Just look at the compiler messages to see what mode the compiler is in.

Hope this helps.

Corto
Posts: 28
Joined: Thu Sep 04, 2014 7:01 am
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: DS18B20 with PIC18F26K22

Post by Corto »

Hello Benj,
Thank you very much for your answers.
I am sorry for this delay, I prepared, and now I am on an exhibition to present my products. It is very tiring !

I bought the XC8 compiler, 2 years ago and I use it every time.
I tried to change the config 0x1; 0x2 and the OSCCON parameter.
I calculate and re-calculate all the configs with FOSC<3:0>; 2 etc; all seems good
but always I display 0°
I tried the OSCCON with 7E; 78; 70; F0; F8; F6; 72; 76;74; 75 and of course I adapt the 0x1 and 0x2 accordingly.
I lose my Latin (French expression to say that I still have not understood)
I was convinced that the problem was related to the speed and a specific configuration of the 18F, but frankly I think the problem comes from Flowcode's OneWire. I have multiplexed the combinations and I still get either a conversion problem or a communication problem.
I know the OneWire works with a 16F and there is no reason it does not work with an 18F, but what else is there?
The worst thing is that I develop another version using an 18F46K22 which is the same in bigger (Inputs / Outputs) and I will encounter exactly the same problem.
the compilation works in simulation under Proteus, but not in real life.
I suspected the PCB, I changed the DQ input from A5 to C2 in hard, cut track and solder wire, the same. I connected the DS in "parasite" mode the same
I re-made a much smaller test program to try to highlight a problem of speed, same
I modified the latencies, by the tempos, the same.
here, I have a lot of fun on this problem.
Sorry, Benj, again for this late response.
If someone have an idea and or use the DS with a 18F which run at 64MHz, I'll take it.
Thanks All

Post Reply