View previous topic :: View next topic |
Author |
Message |
Mrtgl
Joined: 15 Sep 2020 Posts: 6
|
charlieplexing leds problems |
Posted: Fri Mar 12, 2021 4:08 am |
|
|
Hello everyone, I designed a circuit in Charlieplexing method. I set only one led to light with software, but more than one led is on. The LEDs that should not be light are uninspired, what is the reason for this?
Code: | #include <18F24K20.h>
#device ADC=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(internal=16MHz)
#use fast_io (a)
#use fast_io (b)
int a=100;
void main()
{
setup_oscillator(OSC_16MHZ);
setup_timer_0(T0_OFF);
setup_timer_1(T1_DISABLED);
setup_timer_3(T3_DISABLED);
setup_ccp1(CCP_OFF);
setup_spi(SPI_DISABLED);
setup_wdt(WDT_OFF);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
set_tris_a(0x00);
set_tris_b(0x00);
output_a(0x00);
output_b(0x00);
while(TRUE)
{
//////////////////////18/////////////
set_tris_a(0b11111101);
set_tris_b(0b11101111);
output_high(pin_b4);
output_low(pin_a1);
delay_us(a);
output_low(pin_b4);
delay_us(200-a);
}
} |
[img]https://hizliresim.com/FbMJEC[/img]
[img]https://hizliresim.com/jfwgEv[/img] |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9228 Location: Greensville,Ontario
|
|
Posted: Fri Mar 12, 2021 6:17 am |
|
|
Try increasing your delays....
100 microseconds is really, really fast so your eyes won't see any change
POV, Persistance Of Vision.
For test purposes, I'd suggest a delay of 250 milliseconds (1/4 second) between changes, as a reasonable time for you to SEE what's happening.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19516
|
|
Posted: Fri Mar 12, 2021 7:11 am |
|
|
The high speed should not stop it working. The most likely thing
honestly is a wiring problem. Assuming you have a pair of LED's running
from B4 to A1, with one reversed, and suitable resistors, disconnect the
PIC, and verify that one lights when A4 is high and B1 low, and the
other lights when A4 is low and B1 high. I suspect you are going to find
either that the second LED is not reversed so they both come on with
the voltage the same way, or that there is some cross wiring somewhere
giving the same effect.
Pin A1 is set as an input, so is doing nothing at the moment.... |
|
|
Mrtgl
Joined: 15 Sep 2020 Posts: 6
|
|
Posted: Fri Mar 12, 2021 7:57 am |
|
|
temtronic wrote: | Try increasing your delays....
100 microseconds is really, really fast so your eyes won't see any change
POV, Persistance Of Vision.
For test purposes, I'd suggest a delay of 250 milliseconds (1/4 second) between changes, as a reasonable time for you to SEE what's happening.
Jay |
Thank you for your answer, but it has nothing to do with sure. I have tested. |
|
|
Mrtgl
Joined: 15 Sep 2020 Posts: 6
|
|
Posted: Fri Mar 12, 2021 8:00 am |
|
|
Ttelmah wrote: | The high speed should not stop it working. The most likely thing
honestly is a wiring problem. Assuming you have a pair of LED's running
from B4 to A1, with one reversed, and suitable resistors, disconnect the
PIC, and verify that one lights when A4 is high and B1 low, and the
other lights when A4 is low and B1 high. I suspect you are going to find
either that the second LED is not reversed so they both come on with
the voltage the same way, or that there is some cross wiring somewhere
giving the same effect.
Pin A1 is set as an input, so is doing nothing at the moment.... |
I checked the connection of the LEDs. all true. I have done a short circuit test and there is no short circuit. This problem does not happen with all LEDs. it only happens on some LEDs. Is there any special pin setting related to that? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9228 Location: Greensville,Ontario
|
|
Posted: Fri Mar 12, 2021 8:18 am |
|
|
You'll have to select each LED, one by one, turn it on and make a chart of all possible connections and what happens. This needs to be methodical and written down !
Only then can you see what might be wrong(probably a miswiring ??)
I thought about some other internal peripheral being on a pin, but you've disabled the ones I'm familiar with. ( I don't use that PIC).
I keep thinking about this...
'I checked the connection of the LEDs. all true'
Did you just look at the connections or electronically test with an external power source ?
If the PIC was removed from the PCB , you could test the LEDs with a battery and test probes to confirm all the LEDS do work as expected. If that is true, then it's possible the PIC has been damaged. You could perhaps test it 'on the bench' ? |
|
|
|