Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question about RA0-RA3 connected to DIPs

Status
Not open for further replies.

HeiFelix

Member level 1
Joined
Apr 1, 2004
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
357
RA0-RA3

Hi members:

I have set the PORTA RA0-RA3 to be the input in a 16F877 and connected them to DIPs. The another ends of DIPs are tied to ground via a resistor. When DIP is ON, the PORTA RA is read as "0", How can I get it to be "1" when the DIP is OFF?
The fact are as following:
1. I can not use the resistors to pull them up because the PCB was done.
2. I can not move the DIP to PORTB because the PORTB is occupied by other DIPs.

Thanks
 

Re: RA0-RA3

That is bad news but it will not work the way you have done it.

You definitly need pullup resistors to get it working.

Maybe you can solder a resistor network 4*10K with common pin to +5V (using a wire) and soldering the other 4 pins to RA0 ... RA3.

If your MCLR pin is directly connected to +5V you could solder the common pin of the network there :)

This is the way I would correct this ...

best regards
 

Re: RA0-RA3

C-Man said:
You definitly need pullup resistors to get it working.
It is a bad news. I can not do it in your way because I have no place for resisters.
But I really looking at the product which is doing on the way that is described by me before. I really can not understand how it works but it works. I must copy it. Any solution?

Thanks
 

Re: RA0-RA3

There are few ways:

If you have one free PIC pin you can make it as output and connect DIP to it instead of ground - then you will make few reads on RA0-RA3, with changing this output - you will detect changing in inputs by program.

You can connect DIP to ground not directly, but through one capacitor - make RA0 as output with "1", then change it to input read it, next change to output with "0", change to input and read it. Make so for every pin RA0-RA4.
 

Re: RA0-RA3

You could try to read the analog value of RA0 ... RA3 using the built in ADC but I am afraid this will also give bad results without a pullup but it is worth a try.

You can also check out tips and tricks for the 12F629 processor here:

https://ww1.microchip.com/downloads/en/DeviceDoc/40040b.pdf

some good ideas can be found in this document

best regards
 

Re: RA0-RA3

Maybe you can try with smd resistors, they are very small so you can solder them on bottom of pcb between two rows of pic pins and connect other side of resistors to V+.


Mr.Cube
 

Re: RA0-RA3

Hi:

First, thanks all your guys. the fact is that I am copying a interesting product. The diagram of the product is as my description. It does work very well. One end of 4 DIPs are connected to RA0-RA3 seperately and another end of 4 DIPS are connected to ground with an 1K resister. How does it work? I do not want to change the PCB design.
klug is right. I do believe it works under your suggestion. C-Man had a good suggestion to learn from 12F629 tips. But it needs a change on hardware which was the last decision if so solutions for unchanging the hardware.
Please give me more solutions. I believe there is a better solution.

HeiFlix
 

Re: RA0-RA3

I can imagine it could work like this:

Program RA0 to RA2 as input, set RA3 as output H, read RA0 to RA2, if any of these reads H DIPSW on RA3 and X is closed.

Repeat above 3 times setting only RA2, RA1, RA0 as output H and the remaining pins as input.

If you did not get any H all DIPS are open :)

Only problem is that it does not work if only one DIP is closed :-(

Any other ideas??
 

Re: RA0-RA3

C-Man:

Geart idea! How to solve "One DIP connected" problem? :cry:
 

Re: RA0-RA3

I can not do it in your way because I have no place for resisters.

Why not use PORTB, which I think should have internal pull-up resistor?
 

Re: RA0-RA3

I need Help! :cry: :x
 

Re: RA0-RA3

It is simple - replace you resistor by capacitor and make output-input as I described above. Use capacitor as one-bit memory. To avoid possible error reading in not connected free-state pin, make this cycle 5 times for every pin - that will be enough.
 

Re: RA0-RA3

Have you tried:

1. make RA0-3 all outputs, set them to 1
2. (quickly) make them inputs, read level

The ones with pull-down will quickly go to 0, the floating inputs will (if you're lucky) float at 1 long enough to read back as 1.

HTH
Barny
 

Re: RA0-RA3

barny451:
I have tested yestoday. It can not work but I think it should work. I want to know why?
 

Re: RA0-RA3

Some more things to try:
1.Have you tried looking at the lines with a scope during the make-output/set-to-1/make-input/read cycle? Be aware that the scope probe capacitance might affect how the ports read. You need to make sure the ports are actually getting up to near the positive supply before the ports are made inputs.
2. Come to think of it, can you set the ports to output 1 BEFORE you make them outputs? So that they can't possibly output a zero which might affect how high they get when set to 1?
3. Try making the resistors a larger value, 10k, 100k, 1M? they shouldn't need to be as low as 1k to pull the ports down.
4. Code the routine in assembler rather than C, so there is the absolute minimum time between making them inputs and reading the values?

HTH
Barny
 

Re: RA0-RA3

barny451:

Still can not work.
Someone could test it on your own PIC?just try it on a free pin. I think it must work but mine can not work.
 

Re: RA0-RA3

Klug:

At last, In the midnight of the weekend, I begin to understand your great idea of "replacing the resistor by a capacitor". I am quite sure it is going to work. I will test it on next monday.

Thanks a lot.
HeiFelix
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top