Page 1 of 2
DS18B20 component not working on FC10?
Posted: Wed Apr 09, 2025 5:22 pm
by Carmelo
I have almost completely copied the example from the wiki, referring to the configuration and use of the Ds18B20 sensor blocks and when I run the program, the value 999 always seems to flash on the 7-segment displays.
What could be the solution to this problem to be able to see the temperature read from the sensor?
I attach the example file
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 8:17 am
by medelec35
Hello.
With the way the XC8 compiler works, the minimum frequency for pic8 for DS18B20 is about 19MHz.
There are plenty of devices that have a 32MHz+ internal oscillator, 64MHz in the newer devices.
DS18D20 does work with v10, just not at the 8MHz speed you have got your microcontroller running at.
The lower frequencies does not allow the critical timing required for OneWire devices.
This does not apply to AVR devices like Uno since there is no divide by 4 clock rate, so will work on the Uno/Mega etc
I have shown the temperature sensor working
here.
Therefore, I'm moving this topic from Bugs to General.
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 10:14 am
by Carmelo
Thank you very much for the response.
I'll see how to change the frequency.
C.
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 11:18 am
by medelec35
You're welcome.
If you need further assistance, then we are here to help
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 2:01 pm
by Carmelo
Pues siento decir que me sigue sin funcionar.
Cambie el oscilador interno a uno externo de 20MHz y en el fichero adjuntado de test en el otro apartado de este foro, deshabilite el bloque de configuración del oscilador interno.
El resultado de funcionamiento sigue siendo el mismo: parpadeo constante de los 3 displays con el valor siempre fijo de 999.
El fichero tiene la misma configuración que el ejemplo de la wiki, excepto el uso de la uart que no la uso.
La multiplexación para ver los valores la cree yo mismo y funciona a la perfección. Si deshabilito el bloque de lectura y pongo un bloque de cálculo con un valor fijo, este valor se ve perfecto en los displays.
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 3:35 pm
by medelec35
Hoy probé el DS18B20 para asegurarme y funcionó a 19,6608 MHz.
Puedes comprobarlo con un
flasher de 1 s. Si la frecuencia es correcta, comprueba que la resistencia pullup esté entre 4,7 kΩ y 10 kΩ. También revisa las conexiones de los pines.
I tested the DS18B20 today just to make sure, and it worked for me at 19.6608MHz.
You can check with a
1s flasher. If frequency is correct.
Then check the pullup resistor is 4.7K to 10K. Also check the connections going to the pins.
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 5:13 pm
by Carmelo
Pues a mí no me marca nada más que 999 de forma intermitente.
¿Te puedo adjuntar, está noche, por aquí el fichero y me miras a ver qué estoy haciendo mal?
C.
Re: DS18B20 component not working on FC10?
Posted: Thu Apr 10, 2025 9:54 pm
by Carmelo
Adjunto el fichero que me da el error de funcionamiento.
La lectura de los displays se ve de forma intermitente como dije en post anteriores.
Re: DS18B20 component not working on FC10?
Posted: Fri Apr 11, 2025 9:34 am
by medelec35
Con el cristal de 19 MHz, quité el DS18B20 y la lectura fue la misma: 999. ¿Tienes un analizador lógico o un osciloscopio para probar el sensor, ya que podría estar defectuoso?
Puedes probar la conexión quitando el sensor y conectando el pin A0 a 0 V. La lectura debería ser entonces de 0,00000.
With the 19MHz crystal, I removed the DS18B20 and the reading was the same 999. Do you have a logic analyser or a scope you can test the sensor with as it could be faulty?
You can test connection by removing the sensor and connecting pin A0 to 0V. the reading should then be 0.00000
Re: DS18B20 component not working on FC10?
Posted: Fri Apr 11, 2025 11:26 am
by Carmelo
Gracias por la respuesta.
He realizado lo que me ha comentado. Efectivamente el sensor estaba mal.
Lo he cambiado por uno nuevo y ahora sí se ve la lectura con el valor correcto, pero.....
El valor sigue parpadeando.
Es decir, veo bien el valor pero de forma parpadeante, he intentado ver porque pero no lo localizo. ¿ Puedes ser por el bloque que hay delante del bloque de lectura que provoca una espera?
¿Como podria conseguir que la lectura fuera estable?