Page 1 of 1

Problem reading 10-bit ADC on 12F675 PIC

Posted: Sat Oct 05, 2019 4:56 pm
by Oderlando
765/5000
Hello. I set up the code for a triac thermostat controlled by a 12F675 PIC, but some error is occurring. The thermostat works as follows: a zero crossing detector sends a high level signal to the microcontroller and after that, the microcontroller varies the triac drive actuation delay time until the desired temperature is reached. The longer the delay time on the drive (lag in the triac firing angle) the lower the output power of the triac. I used the code on a 16F88 pic and it worked very well. I can't read the ADC for 10 bits. I did not find the error. The problem is reading the ADC. Could someone check the code for me and try to find the fault?

Re: Problem reading 10-bit ADC on 12F675 PIC

Posted: Sun Oct 06, 2019 12:15 am
by medelec35
Hi Oderlando.
You have got:

Code: Select all

Count_Interrupt = 1953
Yet, Count_Interrupt has been assigned as a Bool which can only be 0 or 1:
Count_Interrupt Variable.png
(4.31 KiB) Downloaded 1513 times
Therefore ADC will never be read.

Also the interrupt assign must only be activated once, so it needs to be placed before the main loop.

Re: Problem reading 10-bit ADC on 12F675 PIC

Posted: Sun Oct 06, 2019 11:01 pm
by Oderlando
I modified the flowchart and applied some minor improvements. For 8-bit ADC reading, everything goes perfectly fine. I am sending the flowchart that works. But, something still leaves me in doubt ... When I try to read the 10-bit ADC, an error message is displayed during compilation. I tried in every way possible and all my options were exhausted. I am sending a print of the error screen. If possible, I would like you to help me read ADC through "GetInt".

Re: Problem reading 10-bit ADC on 12F675 PIC

Posted: Mon Oct 07, 2019 5:12 pm
by Benj
Hello,

You have ran out of RAM on the device.

To increase the available RAM you can remove the string manipulation variables from the project.

Open the following file in a text editor, maybe make a backup so you can easily go back when you need to.

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c

Near the top of the file find these lines.

Code: Select all

	#if !defined(MX_10F_TRIS) && !defined(MX_16F5x_TRIS)
		unsigned char FCI_TMP_STR[20];
		int FCI_TMP_INT;
	#else
		#warning "String temporary variables not defined to save on limited RAM space on your current target device"
	#endif
comment out the two variables and this should give you more RAM space to use for your own variables and allow the program to compile correctly again.

Code: Select all

	#if !defined(MX_10F_TRIS) && !defined(MX_16F5x_TRIS)
		//unsigned char FCI_TMP_STR[20];
		//int FCI_TMP_INT;
	#else
		#warning "String temporary variables not defined to save on limited RAM space on your current target device"
	#endif