Excellent Darrel - many thanks....does it add much in the way of delay? (ie if I was sequencing 8 leds fast would this start slowing stuff up)
Excellent Darrel - many thanks....does it add much in the way of delay? (ie if I was sequencing 8 leds fast would this start slowing stuff up)
how fast human eye is btw? vport is nowhere near to be that slow
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
VirtualPort will be faster than using lists of HIGH/LOW since it doesn't set the TRIS bits each and every time.
That in itself may be a problem when running at 32Mhz and the old R-M-W issue may come into play.
Let me know if it does and I'll change it to use the LAT registers on the 16F1's.
The pin list macro can have multiple pins assigned to each bit.In a similar vein, can I group just two specific leds together for ease of handling? (I always will want two specific LEDS to light/extinguish together - but want to treat them as one entity vs having to duplicate the commands to each port/pin per LED)
In this example both RC6 and RB3 would turn on and off according to bit0 of the value passed to WritePort.
Code:MyPortPins macro ; these define which bits go with which pins Vpin 0, PORTC,6 Vpin 0, PORTB,3 Vpin 1, PORTB,6 Vpin 2, PORTB,5
DT
Hi Darrel,
That's fantastic (ie two pins handled as one virtual pin...I'm figuring that the maximum number of Virtual Port bits is 8? if so, wouldn't you just know that I have 9 LEDs!)
re VirtualPort and the TRISC settings ...hmm, maybe I can't use your funky routine after all - one thing I observed when using the HIGH/LOW command, was excessive audible clicking attributed to the port.pin switching state (I work with low level guitar signals, which often pass in close proximity to a PIC, guitar signals often get treated with enormous gain so I'm perhaps more aware/sensitive to such clicks than others!) The only way I was able to stop such clicking was to to use TRISC command instead of the high/low command, for example, this would result in clicking....
TRISC.6 = 0
HIGH PORTC.6
whereas this doesn't...
PortC.6 = 1
TRISC.6 = 0
....whacky. (so to turn an LED on/off, I don't use high/low, but just set the pin as output or input)
Last edited by HankMcSpank; - 1st September 2011 at 23:10.
Why not wire them in "anti-parallel" then? One is on when pin is low, the other when pin is high and both are off when TRIS is 1.In a similar vein, can I group just two specific leds together for ease of handling? (I always will want two specific LEDS to light/extinguish together - but want to treat them as one entity vs having to duplicate the commands to each port/pin per LED)
/Henrik.
Sorry, I misunderstood that. I thought you wanted one on when the other was off. I guess I kind of took that for granted because I can't really see the point in using more than one pin. Just wire the LEDs in parallel or, which is probably better, in series. Depends on the powersupply voltage and forward voltage drop of the particular LED.
Are these some high power blue LEDs? High current and high Vf? Is that the reason you need one pin for each LED? Please tell me what I'm missing :-)
/Henrik.
Yes, I'm using high brightness blue leds (fwd voltage 3.2V, my PSU is 4V) in parallel drawing about 20mA, therefore two = 40ma...too much for one PIC pin...hence wanting to treat two pins as one virtual pin in code. But it's no big deal....thought I'd ask - and as ever there is something that exists that can be brought into play, except that I need to control the pin on/off via TRISC to avoid clicking so I can't personally use it.
Last edited by HankMcSpank; - 2nd September 2011 at 10:17.
Bookmarks