Electronics > Electronics

How to know if crystal working

<< < (2/5) > >>

dunk:
hi Polaris, if you want to confirm Militoy's first theory that the LED is blinking, just too fast to see (which sounds quite likely to me) you could try the following.
write initialisation code for your microcontroller. don't forget to initialize the pins the LEDs are connected to as output.
in your code, set the output of one pin to on and a 2nd pin to off.
put a loop as the main routine in your code but don't put any real commands in there for now.
program your microcontroller and power it up.

do the pins you configured as outputs have the high (on) and low (off) voltages you expect? if they do then it appears that your micro, other components and configuration section of code work ok. try re programming, swapping the high and low pins round just to confirm.

if the pins both sit at the same voltage as in your troublesome flashing LED example then the problem will be one of the following:
incorrect code. the smallest typo can break everything.
incorrect circuit. i have spent hours before trying to work out why a miswired circuit is not working.
faulty component. so it is probably the least likely explanation but still possible.

let us know a little more:
which microcontroller are you using?
can you draw us a quick diagram of your circuit?
post the code you are uploading to your microcontroller here.

dunk.

Militoy:
Dunk's comments sparked another idea on a way of measuring what the LED may be doing: Even though your meter's frequency range may be too slow to pick up the clock frequency, I'll bet it will be able to tell if the LED is just blinking fast. Try putting the ground (black) lead on ground, and the meter input (red) lead on the output pin with the LED (while it's supposed to be in a "while loop" blinking) - with the meter set on the Hz scale. Do you get any reading?

Admin:
another idea for measuring voltage from the frequency . . . if the above dont work . . . make a RC circuit! this smooths out the squarewave to an analog voltage that you can read with your multi-meter.

attach the output pin to a 10kohm resistor. then attach the other end of the resistor to a 10uF capacitor. next attach the other end of that capacitor to ground. finally, measure the voltage between the resistor and capacitor . . .

you may have to tweak the cap value though, depending on frequency . . .

Polaris:
sorri for this late reply as busy with other things.

my humble LED circuit.



will post my program later of the day.

As recommended, i had tried to program the Pin RA0, Pin RA1, Pin RA2, Pin RA3 as On, Off, On, Off. But seem like all of them when i attached the LED to each of the port, the LED was lit. My 2nd attempt was to experiment with only one Port, Pin RA1, which i modified the program to turn it off forever. The LED did not light.Setting the same port to on, the LED was lit. When i tried to put it more ports in as what i did previously, it did not output as expected. Got to try more of your proposed solution, but a bit tied up.

Polaris:
//helloled.c

#ifndef LED_TRIS
#define LED_TRIS  TRISAbits.TRISA1
#endif

#ifndef LED_LATA
#define LED_LATA  LATAbits.LATA0
#endif

#ifndef LED_PIN_RA0
#define LED_PIN_RA0 PORTAbits.RA0
#endif

#ifndef LED_PIN_RA1
#define LED_PIN_RA1 PORTAbits.RA1
#endif


#ifndef LED_PIN_RA2
#define LED_PIN_RA2 PORTAbits.RA2
#endif

#ifndef LED_PIN_RA3
#define LED_PIN_RA3 PORTAbits.RA3
#endif

#ifndef LED_PIN_RA4
#define LED_PIN_RA4 PORTAbits.RA4
#endif

#include <pic18f252.h>

void delay_ms(int ms)
{
int i ;

for(i=0;i <ms;i++);

}
void main()
{

  LED_LATA = 0;

  for(i
  LED_PIN_RA0=0;
  LED_PIN_RA1=0;
  LED_PIN_RA2=0;
  LED_PIN_RA3=0;

  LED_TRIS=0;


 while(1)
 {
   LED_PIN_RA1=0;
   delay_ms(10000);
   LED_PIN_RA1=1;
   delay_ms(10000);
   }

 }

Note:** LED_PIN_RA1 will always be off and never turn ON.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version