[Company Logo Image]        CatsEyes Hints 

Home Up Contents Search Articles Caveat Purpose Notice                                                           

CatsEyes Hints and Tips

Division by Two

The division by two is just a right-shift by one bit position. To divide by multiples of two, just repeat the shift operation. Similarly, to multiply by two, left-shift by one bit position. One way to think of it is using the decimal system equivalent. To divide by 10, shift the digits in the number right by one position and to multiply by 10, shift it left.
 
The operation to do a right-shift in the PIC12F629/675 is RRF (rotate right through carry). You'll note that it shifts the bit in the carry flag into the left-most bit position. Since we want to make sure we shift a "0" into this position, we have to clear the carry flag first. We can do this with the BCF instruction, since the carry flag is part of the STATUS register.
 
So, assume you have a value from 0 to 255 in the variable TRIM that represents the position of your trimmer pot. You want to divide this by 8 (2 to the power of 3) to get a value from 0 to 31. So we can do three right-shifts (clearing the carry flag prior to each one):
 

 

bcf

STATUS, C

 

rrf

TRIM, f

 

bcf

STATUS, C

 

rrf

TRIM, f

 

bcf

STATUS, C

 

rrf

TRIM, f

 

Flashing LEDs

Circuit by CatsEyes

 

You can use flashing LEDs to enhance aircraft visibility and provide orientation cues. Flashing LEDs would be an advantage over continuously lit for three reasons:

* A flashing LED should inherently be more visible to the eye
* During the flash, the LED can be over-driven a bit, resulting in a brighter  flash
* The flashing LED (low duty cycle) will consume less current.
 

The LEDs I'm using are rated at 70mA. I've tried pulsing them at about double that, 150mA for a 50mS flash about once per second. Any more than 150mA seems to give diminishing returns in terms of light output. 50mS seems to be the shortest flash than appears as full brightness to the eye.


Another thing I was concerned about is RFI. The PIC pin obviously switches very fast. I noticed that Mr. RC-CAM's Landtastic uses 0.1uF capacitors on the output side of the MOSFET switches, between the LED and the resistor. I was thinking of putting the capacitor on the input side, so the FET would turn on slowly rather than suddenly (see below). With 10K and 0.1uF, the time constant is a millisecond which should eliminate any possibility of RFI. Or is this just overkill?


 

 

RC Groups Thread: http://www.rcgroups.com/forums/showthread.php?s=&postid=1832728#post1832728

 

What Type of Transistor and What Type of MOSFET to Use to Switch Loads with a PIC Pin
 
Diagram by CatsEyes

 

 

 

If the pin is "normally" low and you want to switch the load "on" by having the pin go high, use an NPN.

<<<<=========
 Diagram by CatsEyes

 

 

 

If the pin is "normally" high and you want to switch the load "on" by having the pin  go low, us a PNP.                                                                      ========>>>>

Diagram by CatsEyes

 

 

 
 
 
And for MOSFETS...
 
If the pin is "normally" low and you want to switch the load "on" by having the pin go high, use an N-Channel.
 <<<<=======
Diagram by CatsEyes

 

 

 

 
If the pin is "normally" high and you want to switch the load "on" by having the pin go low, us a P-Channel.                                                ========>>>>
 
 
 
 

 

 

 

 

Home ] Up ]                                                                                                                                               

Send mail to ironsidz@hotmail.com with questions or comments about this web site.
Copyright © 2003 
Last modified: March 18, 2004