Problem reading 10-bit ADC on 12F675 PIC

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Oderlando
Posts: 37
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Problem reading 10-bit ADC on 12F675 PIC

Post 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?
Attachments
Triac_Interrupt_12F675.JPG
Triac_Interrupt_12F675.JPG (171.74 KiB) Viewed 3580 times
Triac_Interrup_12F675.fcfx
(17.22 KiB) Downloaded 230 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

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

Post 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.
Martin

Oderlando
Posts: 37
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

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

Post 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".
Attachments
Fail.JPG
Fail.JPG (75.38 KiB) Viewed 3538 times
Triac_Interrup_12F675_2.fcfx
(17.15 KiB) Downloaded 228 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: Problem reading 10-bit ADC on 12F675 PIC

Post 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

Post Reply