How to start with Microcontrollers

Microcontroller Topics
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to start with Microcontrollers

Post by Neo » Thu Jun 16, 2011 2:36 pm

i have made that line change and done another build however didn't fix the problem. is there any other information i can provide to make things easier?
Your photos are not very clear. I just noticed a small problem in the wiring.

I see pin 1 is connected to Vdd (supply +5V) through a 1K resistor. This is correct.
But, have you grounded the pin 1 as well (instead of grounding through a switch)? If you have done so, this will continually reset the CPU. Just remove that red cable that you used to ground pin 1.

Pin 1 must be always pulled up with a 1K resistor to work. Grounding it will reset the CPU. That's why we have used a switch there to reset the CPU whenever needed.
User avatar
DPX
Sergeant
Sergeant
Posts: 13
Joined: Tue Jun 14, 2011 5:28 pm
Location: Melbourne, Australia

Re: How to start with Microcontrollers

Post by DPX » Thu Jun 16, 2011 7:49 pm

hi. i have made that change to the circuit however it is still not working. i have attached a diagram of my circuit which hopefully shows clearly what everything is connected to.

Thanks.
diagram of current setup with notes.
diagram of current setup with notes.
bread3.jpg (196.75 KiB) Viewed 11818 times
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to start with Microcontrollers

Post by Neo » Fri Jun 17, 2011 1:14 am

Circuit is correct according to what I see. However I see a problem in the way you wired the PICKit3 to the micro.

I think you missed to provide power to 2 VDD and 2 VSS Pins. I see you have given power to pin 11 & 12 but not to pin 31 & 32.

I have added a little article on this. See How to connect PICKit3 to PIC16F877A.

Make sure that you have given external power using a 7805 regulator to the micro when you are programming. Don't expect to get it powered by the USB.

Lets see how it goes.
User avatar
DPX
Sergeant
Sergeant
Posts: 13
Joined: Tue Jun 14, 2011 5:28 pm
Location: Melbourne, Australia

Re: How to start with Microcontrollers

Post by DPX » Fri Jun 17, 2011 11:08 am

Neo wrote:Make sure that you have given external power using a 7805 regulator to the micro when you are programming. Don't expect to get it powered by the USB.
Can you explain a little more on this and how to use it within the circuit? Currently i was supplying 5v from external power supply to my circuit and connecting the pic kit to usb and circuit when programming. When testing i simply remove the pic kit and associated connections and test the circuit with the 5v power supply.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to start with Microcontrollers

Post by Neo » Fri Jun 17, 2011 11:40 am

Can you explain a little more on this and how to use it within the circuit? Currently i was supplying 5v from external power supply to my circuit and connecting the pic kit to usb and circuit when programming. When testing i simply remove the pic kit and associated connections and test the circuit with the 5v power supply.
The circuit under PIC Power Supply is mostly required to provide power to the micro. Most power adapters are not supplying a smooth current which makes the micro to restart unexpectedly. 7805 is a very good power regulator which manages that part. However, note that you have to provide 9 - 12V DC supply to that.

The reason I asked you to provide power is, I have seen you have wired a separate location in the project board for programming. That is okay if you connect the micro correctly according my diagram and connect the PICKit3 correctly.

If you are going to wire the PICKit3 to the same target circuit, there won't be any problems. If you can replace the 1K resistor connected to pin 1 (MLCR) and ground to 10K, it would be better (Just because the PICKit3 diagram says, it needs a resistor in the range 4.7 - 10K). Double check whether all 5 pins of PICKit3 are correctly connected to the micro. Just switch on power to microcontroller board and then connect to the device using PICKit3.

If it is still not working, can you take a picture (in macro mode if you have that in your camera) from above so I can see the wires clearly. If it is possible to program on another micro, it would be good. Micros are very sensitive devices. Even with a little mistake, they could blow off.
User avatar
DPX
Sergeant
Sergeant
Posts: 13
Joined: Tue Jun 14, 2011 5:28 pm
Location: Melbourne, Australia

Re: How to start with Microcontrollers

Post by DPX » Fri Jun 17, 2011 4:32 pm

Ok some good news and bad news. Good news i was able to achieve the LED blinking. Bad news i will lose the use of my left hand to keep this event occurring lol. Let me elaborate.

I reprogrammed the mcu with the new circuit following the tutorial you provided. Then when attempting to test the circuit i saw nothing happening. I looked at my circuit and tried to press down all wires in case something was not connected properly. I accidentally touched the 1k resistor connected to pin 2 and the LED. I noticed the LED turn on. So while keeping my thumb on that 1K resistor the LED blinks on and off (This is happening every second, not every few seconds as you state should happen). Without it the LED does not light up. What could be the problem? I also noticed directly after i disconnect the supply to the circuit the LED turns on for a second before power is cut off.

Thanks.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to start with Microcontrollers

Post by Neo » Fri Jun 17, 2011 5:19 pm

Okay.. Some good news at last ;)

Could you take a snapshot of the circuit board from top in macro mode (If your camera has macro mode). Make sure you resize it to fit on the forum screen.
User avatar
DPX
Sergeant
Sergeant
Posts: 13
Joined: Tue Jun 14, 2011 5:28 pm
Location: Melbourne, Australia

Re: How to start with Microcontrollers

Post by DPX » Fri Jun 17, 2011 6:20 pm

Ok my camera is not very good. I will list the connections which hopefully make it easier to follow.

Programming
top view when programming.
top view when programming.
program-circuit.jpg (96.29 KiB) Viewed 11807 times
Pin 1 (MCU) to pin 1 (ISCP).
10K Resistor from pin 1 (ISCP) to pin 2 (ISCPVdd).

0.1uf Ceramic Capacitor from pin 11 to pin 12.
Pin 11 to +5V.
Pin 12 to GND.

0.1uf Ceramic Capacitor from pin 31 to pin 32.
Pin 31 to GND.
Pin 32 to +5V.

10K resistor pin 38 to GND.
Pin 39 (MCU) to pin 5 (ISCPClk).
Pin 40 (MCU) to pin 4 (ISCPDat).

Pin 2 (ISCPVdd) to +5V.
Pin 3 (ISCPVss) to GND.
--
LED Circuit (Note: has been rearranged, Switched the network 1k resistor to 1K film resistor)
top view of led.
top view of led.
led-circuit.jpg (96.22 KiB) Viewed 11807 times
1K Resistor to pin 1 and +5V.
1K Resistor from pin 2 to positive end of LED, negative end of LED to GND.
0.1uf Capacitor from pin 11 to pin 12.
Pin 11 to +5V.
Pin 12 to GND.
20pf Capacitor from pin 12 to pin 13.
20pf Capacitor from pin 12 to pin 14.
4Mhz Crystal Oscillator from pin 13 to pin 14.

Pin 31 to negative end of 10uf Electrolytic Capacitor.
Pin 32 to positive end of 10uf Electrolytic Capacitor.
0.1uf Capacitor from positive end of 10uf Electrolytic Capacitor to negative end of 10uf Electrolytic Capacitor.
Positive end of 10uf Electrolytic Capacitor to +5V, negative end of 10uf Electrolytic Capacitor to GND.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to start with Microcontrollers

Post by Neo » Fri Jun 17, 2011 7:13 pm

Pin 1 (MCU) to pin 1 (ISCP).
10K Resistor from pin 1 (ISCP) to pin 2 (ISCPVdd).
1K Resistor to pin 1 and +5V.
These two are confusing. Can you remove both and put a 10K one from pin 1 (micro) to VDD (+5V). I guess you have added two here. Since the PICKit3 user manual recommends a 4.7K to 10K one, I thought it is safer to put a 10K one instead of 1K as in our circuit diagram.
10K resistor pin 38 to GND.
Should be pin 36 (PGM) right? This is not very important. But grounding pin 38 (RB5) has no use at all.

Rest of the pin connections are perfect for me.
User avatar
DPX
Sergeant
Sergeant
Posts: 13
Joined: Tue Jun 14, 2011 5:28 pm
Location: Melbourne, Australia

Re: How to start with Microcontrollers

Post by DPX » Fri Jun 17, 2011 7:46 pm

Please note i am programming in first circuit and then once i have programmed the chip i place it in the other circuit. So to answer your comments.

Pin 1 (MCU) to pin 1 (ISCP), 10K Resistor from pin 1 (ISCP) to pin 2 (ISCPVdd)
Used when programming. I followed your suggestion from the tutorial you added in How to connect PICKit3 to PIC16F877A.
Neo wrote:Note 1: It is good to add a 10K resistor between pin 1 (MLCR') and VDD as in the first image.
1K Resistor to pin 1 and +5V
Used in LED circuit and follows your original circuit diagram.

10K Resistor pin 38 to GND
Neo wrote:Should be pin 36 (PGM) right? This is not very important. But grounding pin 38 (RB5) has no use at all.
Used in programming. Again i followed your note in How to connect PICKit3 to PIC16F877A. Sorry i only looked at pin number and not description.
Neo wrote:Note 3: It is also good to put a 10K resistor between pin 38 (PGM) and ground (this could avoid programming-troubles.
Post Reply

Return to “Microcontrollers”