Post Reply 
(41) LED Resistor Picker
02-20-2017, 12:39 PM (This post was last modified: 02-20-2017 12:43 PM by damaltor.)
Post: #1
(41) LED Resistor Picker
This program allows to pick a resistor for an LED. It uses the variables VCC (input voltage), U.F (forward voltage of the LED), R (resistor) and I (current through the LED) and can claculate any of the four after giving it the three others. It works similar to the TVM program of the advantage module: It uses USER mode and displays a menu which can be used like a softkey menu. Entering a number and pressing the corresponding key sets a variable to a value, and pressing a key without keying in a value before will calculate the selected variable. It is not the shortes possible program, but it works nicely and is easy to use.

Code:
VCC
 |
 R
 |
 +--U.F
 |
LED
 |
GND


Example 1: Finding a Resistor for a 2.2V LED with 5V input voltage and 20 mA
Code:
Input         Output
XEQ LEDR      VCC  U.F R I (Menu, can be shown anytime by pressing J)
5 A           VCC=5.000 (Set input voltage to 5V)
2.2 C         U.F=2.200 (Set LED forward voltage to 2.2V)
0.02 E        I=0.020 (Set desired current to 20 mA)
D             R=140.000 (perfect resistor value would be 140 Ohms)
150 D         R=150.000 (next standard resistor is 150 Ohms so we pick that)
E             I=0.019 (Current would be 19 mA with the selected resistor, which is probably fine)

Example 2: Find maximum allowed input voltage for an optocoupler which has a forward voltage of 1.5V and a max. current of 10 mA if a resistor of 1000 Ohms is used. Is 12V as input voltage ok?
Code:
Input         Output
XEQ LEDR      VCC  U.F R I (Menu, can be shown anytime by pressing J)
1.5 C         U.F=1.500 (set forward voltage to 1.5V)
0.01 E        I=0.010 (set current to 10 mA)
1 EEX 3 D     R=1,000.000 (set resistor to 1000 Ohms)
A             VCC=11.500 (Maximum voltage)
12 A          VCC=12.000 (if we would like to use 12V as input....)
D             R=1,050.000 (...the resistor should have been at least 1050 Ohms)

The program has 70 Steps in 20 registers and fits onto one magnetic card using both sides. It uses storage registers 01 to 04.
Code:
01 LBL "LEDR"
02 LBL J
03 SF 27
04 CF 22
05 "VCC  U.F R  I"
06 PROMPT
07 GTO J
08 LBL A
09 "VCC"
10 STO 01
11 FC?C 22
12 XEQ 11
13 GTO 99
14 LBL C
15 "U.F"
16 STO 02
17 FC?C 22
18 XEQ 22
19 GTO 99
20 LBL D
21 "R"
22 STO 03
23 FC?C 22
24 XEQ 33
25 GTO 99
26 LBL E
27 "I"
28 STO 04
29 FC?C 22
30 XEQ 44
31 GTO 99
32 LBL 11
33 RCL 03
34 RCL 04
35 *
36 RCL 02
37 +
38 STO 01
39 RTN
40 LBL 22
41 RCL 03
42 CHS
43 RCL 04
44 *
45 RCL 01
46 +
47 STO 02
48 RTN
49 LBL 33
50 RCL 01
51 RCL 02
52 -
53 RCL 04
54 /
55 STO 03
56 RTN
57 LBL 44
58 RCL 01
59 RCL 02
60 -
61 RCL 03
62 /
63 STO 04
64 RTN
65 LBL 99
66 ęś”"=" (append =)
67 ARCL X
68 PROMPT
69 GTO J
70 END
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)