Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Why isn't this working?

Status
Not open for further replies.
Nigel Goodwin said:
The nominal cell voltage of alkaline batteries is 1.5V the same as zinc-carbon - you are perhaps thinking of NiCd or NiMh where it's only 1.2V?.

Check my (very old) discharge graphs at:

Oh cr*p, I was over focussed on NiCad, Sorry Glacius, Thanks Nigel.
 
ericgibbs said:
Hi,
The problem with alkaline batteries is that a single cell gives about 1.2V, the older zinc-carbon batteries gave about 1.5.
For some reason the industry seems to be stuck with the older ZincCarbon designation, IMO the correct voltage should be printed on alkaline batteries.

If I am correct and you have CONFIG pin#5 as MCLRE, ie:ON, it means the PIC is not being RESET at power up.
If its set to OFF, so that you can use it as an I/O pin, then the PIC's internal Reset line is connected to Vdd, so its reset OK.
That means you can use RA5 as a I/O pin.

Look at the CONFIG Word on the PIC's datasheet.

Are you using a +5Vregulator between the battery and the PIC??

Does this make it clear?
EDIT: Disregard the section re-alkaline battery voltages.... its NiCd

Yes I am using a 5V regulator between the PIC and battery (LM7805C) and in my source, should I set MCLRE_ON to MCLRE_OFF? I always thought that pin 5 (ie VSS) was supposed to be connected to the ground terminal?
 
I think that pin number 4 is MCLRE; because thats how its connected on my programmers schematic, and all the LED's work off the programmer. So after a quick glance I'm assuming that I also need to connect pin number 4 to +5V but can anyone confirm this just in case? (By the way; how did you find out that pin 5 is MCLRE?)
 
Glacius said:
I think that pin number 4 is MCLRE; because thats how its connected on my programmers schematic, and all the LED's work off the programmer. So after a quick glance I'm assuming that I also need to connect pin number 4 to +5V but can anyone confirm this just in case? (By the way; how did you find out that pin 5 is MCLRE?)

hi,
Do you have the datasheet for your PIC?. if not download it from www.microchip.com

If look at the pin designations on the datasheet, you will see some pins are multi-function and have to be configured
to perform the function of your choice.

A quick look at pin#4, shows it as either RA5, MCLR [or Vpp], the configuration word CONFIG at the near the top of your program code sets the function of RA5.
Bit #5 of the Config word reg, if set high makes pin#4 the MCLR, if low it a inp/out pin RA5.

IIRC in your code Config bit#5 is ON [hi] which makes the RA5 pin MCLR.
Looking at your diagram, pin #4 goes to a connector and dosn't show any pullup to +Vdd. [unless its somewhere else off board??]

Your code runs OK in my sim, which it would do, even if MCLR was not connected, thats one of the shortcomings of simulators.

Ref: your 9Vbty, from what you say, you need a new battery.

Does this help?
This is your config word:
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _INTRC_OSC_NOCLKOUT
 
Last edited:
ericgibbs said:
hi,
Do you have the datasheet for your PIC?. if not download it from www.microchip.com

If look at the pin designations on the datasheet, you will see some pins are multi-function and have to be configured
to perform the function of your choice.

A quick look at pin#4, shows it as either RA5, MCLR [or Vpp], the configuration word CONFIG at the near the top of your program code sets the function of RA5.
Bit #5 of the Config word reg, if set high makes pin#4 the MCLR, if low it a inp/out pin RA5.

IIRC in your code Config bit#5 is ON [hi] which makes the RA5 pin MCLR.
Looking at your diagram, pin #4 goes to a connector and dosn't show any pullup to +Vdd. [unless its somewhere else off board??]

Your code runs OK in my sim, which it would do, even if MCLR was not connected, thats one of the shortcomings of simulators.

Ref: your 9Vbty, from what you say, you need a new battery.

Does this help?
This is your config word:
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _INTRC_OSC_NOCLKOUT

Ok, I have the data sheet and I see pin 4 as MCLRE or Vpp. So do I need to connect that Pin to a +5V (where my Vdd is connected to) to make my program work? (The schematic of the programmer and the way I've seen it run makes me assume it does) And I think I'll try it out tomorrow once I pickup a new 9v battery.

How do you see bit#5? Is it the hexidecimal H"005" or the 5th one down on the list? Could you please copy/paste what you were talking about, in the program, and explain it?
 
hi,
Do you have a picture of the schematic you are referring too?

This is your Config statement.
 
Last edited:
So would this new schematic fix my problem or should I add in a resistor somewhere between pin 4 and +5v?
 

Attachments

  • scalemainboard2.jpg
    scalemainboard2.jpg
    40.7 KB · Views: 128
hi,
There is no point is 'wasting' a pin, when you can use the Vdd internal MCLR by changing your config word.

Just change the config word as shown.
 
Last edited:
I don't really mind wasting a pin (although it's kinda too late now)... I've already kinda soldered my pic onto my board being sure it will work. >_> Anyway, do you htink my new schematic will make my program work?
 
Glacius said:
I don't really mind wasting a pin (although it's kinda too late now)... I've already kinda soldered my pic onto my board being sure it will work. >_> Anyway, do you htink my new schematic will make my program work?

hi,
Where else does pin#4 goto?

What are those two rectangles on your drawing?? 'red circle'

What will they be connected too?
 
Last edited:
The two red connectors I could potentially use on sensors or another board and for the particular use of this Microprocessor I don't really need Pin 4 anyway, so I guess it doesn't connect to anything else.
 
Glacius said:
The two red connectors I could potentially use on sensors or another board and for the particular use of this Microprocessor I don't really need Pin 4 anyway, so I guess it doesn't connect to anything else.

I would recommend that you modify the Config as I have shown and keep pin#4 connected as a port pin RA5.
 
ericgibbs said:
I would recommend that you modify the Config as I have shown and keep pin#4 connected as a port pin RA5.

ok, I'll try it, so does anyone have any good ideas on how to removed my solded my chip from a PCB? >_>
 
Glacius said:
ok, I'll try it, so does anyone have any good ideas on how to removed my solded my chip from a PCB? >_>
hi,
Do you have 'solder wick' or a solder 'sucker' in your toolkit?

Multi-pin ic's can be removed from a pcb, its not usually the ic that gets damaged its the pcb pads/tracks.

I prefer the solder sucker method for removing ic's and then clearing out the holes.
If you intend re-using the pcb, it would be a good idea to fit an ic socket after you have removed the ic.

Once you have removed your ic remember to protect it from ESD while handling.
To remove any 'drips' from the ic pin/legs use solder wick, dont overheat the ic.

If you have to remove an ic from a pcb and you know the ic is faulty and you need to reuse the pcb, you can cut thru each pin/leg of the ic [ leave as much pin as you can, cut as close as possible to the ic plastic]. Then remove the pin/legs one at a time.
Its important that you use small/sharp side cutters.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top