FAQ
TL;DR: Beginner wants MikroC temperature control on PIC16F877A; a veteran with 30+ years says, "it is bleeding difficult," so start small and master ADC/interrupt basics first. [Elektroda, Mark Harrington, post #21664757]
Quick Facts
- PIC16F877A temperature sensing uses ADCON0/ADCON1 and 10‑bit ADRESH:ADRESL result alignment. [Elektroda, Mark Harrington, post #21664759]
- MPLAB X IDE is a free Microchip toolchain for building and debugging PIC projects. [Elektroda, Steve Lawson, post #21664761]
- Official programmer: PICkit 3; PICkit 2 works for 16F877A but is legacy. [Elektroda, Steve Lawson, post #21664761]
- Starting in assembler teaches bank selection, interrupts, and peripheral control fundamentals. [Elektroda, Mark Harrington, post #21664759]
- CCP modules enable capture/compare/PWM features useful for fan or heater control. [Elektroda, Mark Harrington, post #21664765]
Who is this FAQ for, and what problem does it solve?
New MikroC users wiring a PIC16F877A for thermostat-style control. It condenses the thread into actionable steps, tool picks, and register tips so you can read a sensor, set limits, and switch a load safely. [Elektroda, syahrul Rizuan, post #21664754]
What’s the fastest way to get a "cookbook" start on PIC temperature control?
Use a known IDE and a supported programmer, then follow a minimal ADC read–compare–switch loop. Build, flash, and iterate. As one reply put it, "Google: 'pic programming tutorial'" to find stepwise guides and videos for the basics. [Elektroda, Steve Lawson, post #21664755]
Which IDE and programmer should I pick for a PIC16F877A project?
Install MPLAB X IDE and program with a PICkit 3. A PICkit 2 also works for 16F877A but limits upgrades to newer PICs. This combo keeps your toolchain stable and supported as you scale. [Elektroda, Steve Lawson, post #21664761]
Should I start with assembler or jump straight into C/MikroC?
Assembler first strengthens hardware skills: bank selection, PORT interrupts, and ADC configuration. You gain precise control and fewer hidden side effects. Later, move to C for speed and libraries. "Start with a simple processor first." [Elektroda, Mark Harrington, post #21664759]
Which ADC registers matter for reading temperature on 16F877A?
Set ADCON1 for analog channel configuration and references, use ADCON0 to select channel and start conversion, and read the 10‑bit result from ADRESH:ADRESL with chosen justification. Incorrect ADCON1 leaves pins in analog mode unexpectedly. [Elektroda, Mark Harrington, post #21664759]
How do I wire and read a common analog sensor in MikroC?
Connect the sensor output to an ANx pin, set Vref and ADCON1, start a conversion via ADCON0, then scale the 10‑bit ADRESH:ADRESL result. A 10‑bit converter yields 1024 codes for mapping to degrees. Keep wiring short and decoupled. [Microchip PIC16F877A Datasheet]
Can I simulate before buying hardware?
Yes. Use a PIC simulator to watch flags, FSR behavior, and instruction effects. One shared tool targets classic PICs and has known bugs, but it teaches core architecture concepts well enough to start. Validate on real hardware later. [Elektroda, Mark Harrington, post #21664762]
What are CCP modules and why might I need them here?
CCP provides Capture, Compare, and PWM. For temperature control, PWM can drive a fan or heater through a MOSFET for smoother control versus simple on/off. Capture and Compare assist in timing tasks around sampling. [Elektroda, Mark Harrington, post #21664765]
Is PICkit 2 still a viable choice for the 16F877A?
Yes, for this chip it works fine and is inexpensive on the used market. If you plan to adopt newer PICs soon, choose PICkit 3 to avoid support gaps and rework. [Elektroda, Steve Lawson, post #21664761]
Any gotchas with bank selection and interrupts on this project?
Yes. Wrong bank selection corrupts configuration and data reads. Mismanaged PORT change interrupts create erratic ADC timing. Always set STATUS bits before register access and mask unwanted interrupt sources during conversions. [Elektroda, Mark Harrington, post #21664759]
How do I build a simple thermostat loop in MikroC (3 steps)?
- Configure ADCON1/ADCON0; read ADRESH:ADRESL from your chosen AN channel.
- Convert ADC counts to temperature; compare against a setpoint and hysteresis.
- Drive a GPIO to control a relay or MOSFET; update every sample period. [Elektroda, Mark Harrington, post #21664759]
What is MPLAB X in one sentence?
MPLAB X is Microchip’s free, integrated environment for editing, building, simulating, and programming PIC projects with devices like PICkit. [Elektroda, Steve Lawson, post #21664761]
What learning path helps if I want deeper, long‑term skills?
Progress from HTML/JS logic thinking to VBA tables, then C/Java for types and math, and finally microcontroller architecture, LCDs, ADC, PWM, I²C, SPI, and serial. Expect a steep curve even for veterans. [Elektroda, Mark Harrington, post #21664757]
Where can I find extra notes on ADC and sample code style?
Review ADC notes discussing channel selection, conversion clocks, and data justification, then apply those in your MikroC project structure. Keep timing consistent for stable readings. [Elektroda, Mark Harrington, post #21664765]