TRISx = 1 is used to read an analog input, ex: A/D input. It turns the port into a high impedance input. So, if you want the port to sink in current just make that port low with TRISx = 0 like in the example in that thread.
TRISx = 1 is used to read an analog input, ex: A/D input. It turns the port into a high impedance input. So, if you want the port to sink in current just make that port low with TRISx = 0 like in the example in that thread.
"No one is completely worthless. They can always serve as a bad example."
Anonymous
I feel like a retard. So...
PIN --- DUAL LEDs --- RESISTOR --- 5VDC
PIN defined as output:
HIGH will source, turn on outgoing LED (like we always do)
LOW will sink, turn on incoming LED
I don't get how I'm to set ports/TRIS at both ends so neither LED will turn on. I've gone through that thread and a few others all evening but I can't see the forest through the trees apparently.
Even if my ports are defined as digital?
Robert
Last edited by Demon; - 12th January 2014 at 05:01. Reason: analog VS digital
Robert,
In your schematic at the top of the thread... the highlighted (green) LED's will be dark when GP 1&2 are BOTH High OR LOW. But the trick is to keep track of that interaction with the other LED's that are also tied to either of those two pins.
If GP1 is high and GP2 is low then the Yellow LED will be lit, and vice/versa for the Red one.
Seems like to me it's time to draw up a good ol'e fashioned truth table.
With 5 bits (pins) in use it will have 2 exp 5 = 32 possibilities. The truth table will also help you develop your code.
Is this what they call Charlieplexing?? I've never done one of those, but that is how it seems to my feeble mind.
good luck
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Hi Robert,
This is what Microchip did on their PICKIT1 demo board.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
"No one is completely worthless. They can always serve as a bad example."
Anonymous
"No one is completely worthless. They can always serve as a bad example."
Anonymous
It seems I'm getting denser every year.
"high impedance input mode" means nothing to me.
"meaning no current in or out for the LEDs" <--- this I understand
You only have to explain things once to me, but repeat yourself 12 times, post 3 sample programs, add 6 pictures, include 4 schematics, and I'm good to go.
I really appreciate the patience you guys have.
Robert
Found my answer to sinking the incoming LED.
http://www.picbasic.co.uk/forum/showthread.php?t=7638Do I set it as an output then set it's low state?
PIN --- DUAL LEDs --- RESISTOR --- PIN
Is it a simple matter of leaving both pins output LOW? That would mean both are connected to ground; no chance of leaking current.
Robert
In regard to the site mentioned in post #1:
Just to let you know I found the value of the current limiting resistors for the LEDs to be important. Set incorrectly they'd give me ghosting.
You also have to repeatedly set the TRISIO and the GPIO to get the specific LED or LEDs you want lit. Usually once wasn't good enough.
If you're in need of more than 20mA per pin I successfully used opto-isolators instead of the LEDs. I don't remember the specific part number but I think I posted that link somewhere. If needed I'll find it and reference it here.
I'd also suggest you put a switch in the ICSP clock and data lines to isolate the PIC for programming. It will save you alot of time and effort.
As always good luck and please post program here when finished.
I'm using Darrel's interrupts to control blinking; both on and off duration. Ghosting is not a problem.
I'm testing activating LEDs in bi-directionnal manner now. It's taking me a while 'cause I'm setting it up so the bytes RX from Master will line up with pin order. I'm also learning bit masking; never did that really.
I have MCT6 opto-isolators for now if needed. I don't know if I'll need faster, testing will show.
I simplified matters and dedicate MCLR, PGD, PGC, RX1 and TX1 pins.
Now I just have to figure my bits:
I made a truth table using an LCD to show how bitwise operators work. It's just setting up this particular syntax.Code:Port has: 10001001 Mask is: 10001111 Desired: 10000110 (bits 7-4 untouched, bits 3-0 reversed)
Robert
UPDATE: Have my bit masking working exsactly like I want it. Thanks everyone.
Last edited by Demon; - 13th January 2014 at 01:43.
Bookmarks