pic 16F684

Thread Starter

rp216

Joined Apr 5, 2013
20
hey guys!

i would like some help in my programming as i have been newly introduced to it.

well, my project is about LED DIMMING using pic 16F684

i have to program to show the following:
1) demonstration of PWM for brightness control
2) demonstration of PWM for flashing control
3) demonstration of ADC for single channel
4) demonstration of ADC for two channels
5) pic control of high power LED
6) use of interrupts

i have already build a simple hardware circuit to start with. please guide me further with programming as its my first time.
 

ErnieM

Joined Apr 24, 2011
8,377
Is this a school project? It sure sounds like one (not that there's anything wrong with that).

Get ready to post your schematic as we will need to see that as well.

Good luck and welcome to the forums.
 

tshuck

Joined Oct 18, 2012
3,534
Looking up samples of what you are trying will help you tremendously, just make sure they are the same compiler you are using. Always program a device with the datasheet readily available and read the thing if/when you get stuck. In fact, read it anyway, that how you know what to do when attempting something.

What language are you going to be programming in?
 

Thread Starter

rp216

Joined Apr 5, 2013
20
@ ERNIEM - ya its a college program. i am not in the field of electronics but i had an optional subject so had to pursue it - i will upload the schematic soon

@ tshuck- i was reading the data sheet but its too long. i tend to get confused - anyways thanks for the advice- its in assembly language
 

Thread Starter

rp216

Joined Apr 5, 2013
20
how do i attach a scanned image or a picture here? the text box shows only " insert url " option. please help me out!
 

tshuck

Joined Oct 18, 2012
3,534
how do i attach a scanned image or a picture here? the text box shows only " insert url " option. please help me out!
Attach the image, then, you can insert the image into the body of the post with the "Insert Image" button, after getting the attached image's URL.
 

Markd77

Joined Sep 7, 2009
2,806
You have to click the [Go Advanced] button and then click the paperclip icon.
<ed> OK, you figured it out while I was typing. </ed>
 

Markd77

Joined Sep 7, 2009
2,806
Please tell us if you are using assembler or C and if C which compiler.
I'd suggest:
Find a good code template for your PIC.
Get an LED to turn on on a normal pin as a test that everything is connected properly.
Read the datasheet and look at example code for hardware PWM, ADC and interrupts.
Add features one at a time and test.
Learn to use the simulator.
If anything isn't working as expected, post code and explanation of the problem.
 

ErnieM

Joined Apr 24, 2011
8,377
The schematic looks very good. If I were you I would get the software working in little stages:

get LED to light
get LED to blink
get LED to blink at defined rates for on and off
get analog to digital readings and use in previous blink (so you can SEE the analog conversion readings)

Now you have the pieces to make the final app. Of course, you may skip some steps if you have an in-circuit debugger (a PICkit works) and ain't afraid to use it.

BTW: if you short all 3 terminals of J1 then LEDs will alternately blink:
RC5 low turn on D1
RC5 high turn on Q1 & D2
 

tshuck

Joined Oct 18, 2012
3,534
OP is using assembly, see post # 6.

OP: I will second what both Ernie and Mark have said, except looking at someone else's assembly can be pretty daunting, if you do it, make sure you understand what the code is attempting to do and how it's done.
 

Thread Starter

rp216

Joined Apr 5, 2013
20
@ allen- yeah thanks for re drawing the circuit diagram- its 5v.

thanks guys- i think once i figure out the way to write the program of turning the LED i will paste it here. its already took me a day to figure out the ports and reading the data sheet
 

absf

Joined Dec 29, 2010
1,968
It's quite normal to start slow, at least for me. But once you get the hang of it, you will move on fast. It's just a hurdle you have to get over.

Did you have the breadboard and programmer ready or are you just doing it on a simulator like multisim or proteus?

Allen
 

tshuck

Joined Oct 18, 2012
3,534
@ allen- yeah thanks for re drawing the circuit diagram- its 5v.

thanks guys- i think once i figure out the way to write the program of turning the LED i will paste it here. its already took me a day to figure out the ports and reading the data sheet
There's nothing wrong with that!

You may want to find a tutorial online about how to use the microcontroller.
I liked this tutorial while learning PICs. It uses a different model, but the basics are there, and explained rather well...
 

Thread Starter

rp216

Joined Apr 5, 2013
20
@ tshuck - thanks for the tutorial guide- will have a look at it.

@ allen- i have already built the circuit on a copper board and now using the software " MPLAB IDE v8.70" for programming in assembly.
 

absf

Joined Dec 29, 2010
1,968
Yes, I also strongly recommend the Nigel's tutorial site. I started learning PIC from it and and I've made almost all the boards for that tutorial too.

I'll show some of them when I am free to take photos for them.

Allen
 

Thread Starter

rp216

Joined Apr 5, 2013
20
hello guys..i am now stuck after the following-

#INCLUDE <P16f684.INC>
__config _MCLRE_ON & _PWRTE_OFF & _WDT_OFF & _INTOSC & _CPD_OFF & _IESO_OFF & _CP_OFF & _BOD_OFF & _FCMEN_OFF

; ORG 0x000 ; processor reset

Initialise
bcf STATUS, RP0 ; activate BANK 0
clrf PORTA ; initialize PORT A
clrf PORTC ; initialize PORT C
movlw 0x07
movwf CMCON0 ; comparators OFF
bsf STATUS, RP0 ; change to BANK 1


how will i make my LED ON? should i create a delay?
and there is an instruction called Banksel? i dont know how to use it...please help me out!
 
Top