Like the rest of science and engineering, electronics relies heavily on the International System of Units, which is abbreviated SI. The abbreviation SI comes from the French name Système International, and it’s basically the modern version of the metric system. Electronics also have measurements and quantities with some very large and small values. So, instead of a schematic with values like 1000 Ω or 1 x 103 Ω, you are likely to see 1 kΩ. In this example, k is the metric prefix for one-thousand, and the Greek letter omega Ω is symbol for ohm, the SI unit of resistance.
In this activity, you will:
The International System of Units is the modern metric system. It is abbreviated SI, from the original French "Le Système International d'Unités."
Here’s an example of one of the most commonplace SI units -length in meters:
How is this used? One example would be if you are taking notes while measuring distances, it’s a lot easier to write L = 50 m than it is to write “the length is fifty meters”.
Here is a table of some of the common time and electric quantities and units you will use in these lessons.
Quantity | Unit | Description | ||
---|---|---|---|---|
Name | Symbol | Name | Symbol | (non-technical version) |
Time | t | second | s | This is seconds, the familar time measurement |
Frequency | f | hertz | Hz | Repetitions per second |
Current | I | amps or amperes | A | Flow of electrons |
Voltage | e or V | volts | V | Electical pressure that makes current flow through circuits |
Resistance | R | ohm | Ω | Resistance to electrtic current, which reduces the rate current flows through a circuit at a given voltage |
Capacitance | C | farad | F | The amount of charge a device called a capacitor can store when boltage is applied to it |
Metric Prefixes are Multipliers
SI also simplifies numbers that are large and small with metric prefixes. These prefixes are multipliers for scaling the unit to which they are attached. Here are two examples:
scale for 1,000
scale for 0.001
Metric prefixes make it so that you can write 20 km instead of 20,000 m, and 3 mm instead of 0.003 m.
In these examples:
Here is a table with the common metric prefixes these lessons will use.
Quantity | Prefix | Decimal | ||
---|---|---|---|---|
English Name | Name | Symbol | Value | Scientific Notation |
Billion | giga | G | 1,000,000,000 | x 109 |
Million | mega | M | 1,000,000 | x 106 |
Thousand | kilo | k | 1,000 | x 103 |
Thousandth | milli | m | 0.001 | x 10-3 |
Millionth | micro | µ | 0.000001 | x 10-6 |
Billionth | nano | n | 0.000000001 | x 10-9 |
Trillionth | pico | p | 0.000000000001 | x 10-12 |
You may wish to bookmark this page in your browser so you can easily refer back to this table.
For the sake of making calculations, a common first step is to convert a measurement with a metric prefix to its decimal equivalent. So, instead of starting with 1 kΩ, you’d want to start with 1000 Ω. For this step, just replace the metric prefix with x metric-prefix-decimal-value. If you are not sure of the metric prefix’s decimal value, just look it up in the table.
Here is another example with 20 ms. Looking up m in the SI Metric Prefixes table, its decimal value is 0.001. So, replace m with x 0.001, and then calculate the result.
If you multiply some value by 1, the result is that same value. For example, 2 kΩ x 1 = 2 kΩ. The quantity is unchanged. The faction 1000 / k is also equal to the number 1. Remember from the SI Metric Prefix chart that kilo = 1000. So if you start with k = 1000 and divide both sides by k, you get 1000 / k = 1. Multiplying 2 kΩ by 1 (in the form of 1000/k), the k’s in the numerator and denominator cancel, and the result is 2000 Ω. It’s still the same value as 2 kΩ, but in this case, without the metric prefix.
(View full size: muam-multiply-by-one-prefix-to-val.mp4 [1])
This script converts quantities and metric prefixes to the numbers they represent.
Example Script: metric_prefixes_to_values
# metric_prefixes_to_values prefix_exponents = {'M':6, 'k':3, 'm':-3, 'u':-6} print("Enter quantity, metric prefix, and unit.") print("Result will be a decimal value.") print() while True: text = input("Enter quantity: ") quantity = float(text) prefix = input("Enter metric prefix: ") exponent = prefix_exponents[prefix] unit = input("Enter unit: ") value = quantity * (10 ** exponent) digits = str(abs(exponent) + 1) if value < 1: fstr = "%." + digits + "f" else: fstr = "%" + digits + ".0f" print("Value:", fstr %value, unit) print()
This script converts quantities and metric prefixes to the numbers they represent.
Here are some you will see in upcoming lessons.
The metric_prefixes_to_values script converts quantities and metric prefixes to the numbers they represent.
This script's first statement is called a dictionary. A dictionary has a name. (prefix_exponents) and key-value pairs (Like 'M':6 and 'k':3). The keys are 'M’, 'k', 'm', and 'u'. The value paired with 'M' is 6; the value paired with 'k' is 3, and so on… Later in the script, a statement will retrieve the value that’s paired with a given key and use it as an exponent. For example 3, will become 1 x 103. To learn more about dictionaries, try the Dictionary Primer [3].
prefix_exponents = {'M':6, 'k':3, 'm':-3, 'u':-6}
These are print statements. Each print statement contains a string object, the text between quotes. The one that’s just print() adds an empty line before the next print statement.
print("Enter quantity, metric prefix, and unit.") print("Result will be a decimal value.") print()
Inside the endless while True loop, text = input(“Enter quantity: “) displays Enter quantity: and then stores the value you type in a variable named text. quantity = float(text) converts the characters you typed into a floating-point number that the micro:bit can use in statements that make calculations.
while True: text = input("Enter quantity: ") quantity = float(text)
Another input statement stores the metric prefix you type (like M, k, m, or u) in a variable named prefix. Then, prefix_exponents[prefix] looks up the value that’s paired with that prefix in the dictionary at the beginning of the script. For example, if you typed M, the key is 'M', so the value that gets returned by prefix_multipliers[prefix] will be 6, and that’s the value that gets stored in the exponent variable. Another example, If you typed k, the key will be 'k', and the value that gets stored in exponent will be 3. Again, to learn more, try the Dictionary Primer [3].
prefix = input("Enter metric prefix: ") exponent = prefix_exponents[prefix]
This final input statement just stores a unit you type. Those should be SI units like A, F, Hz, and V. For Ω, substitute ohm.
unit = input("Enter unit: ")
The quantity and exponent variables were set earlier. Quantity is the number you typed in response to the "Enter quantity" prompt like 1 or 20. The exponent variable stores the value from the dictionary. So, when you typed k, it looked up 3 in the dictionary, or when you typed m, it looked up -3. So, if you typed a quantity of 1 and a prefix of k, this would multiply 1 by 1x103 for a result of 1000. If you typed a quantity of 20 and a prefix of m, it would multiply 20 by 1 x 10-3 for a result of 0.02, and so on…
value = quantity * (10 ** exponent)
The script will need a string with a character in it, like ‘4’ for k or m, or ‘7’ for m or u, to help format the value it displays. It starts by taking the absolute value of the exponent. So, regardless of whether the exponent is -3 or 3, the absolute value will be 3. Then, it adds 1 to that value. Then, the value (7 or 4) is converted to a string that contains ‘7’ or ‘4’. The resulting string with the character is stored in a variable named digits.
digits = str(abs(exponent) + 1)
Don’t worry too much about the details of this part; it’s a little more advanced. Scripts can use statements like print("value %3.2f", value) to display a total of 3 digits with 2 to the right of the decimal point. These lines in the script build a formatting string like “%3.2f”, but adjusted to the size of the value the script is about to display.
if value < 1: fstr = "%." + digits + "f" else: fstr = "%" + digits + ".0f"
This statement makes the result appear in the Serial Terminal. It prints "Value: " followed by the specially formatted string that represents the value, followed by the unit. For example, this is what makes 1000 ohm or 0.0200 s appear.
print("Value:", fstr %value, unit)
This prints an empty line before the while True loop repeats and asks you to enter your next quantity.
print()
If you use metric prefixes that are not in the dictionary, such as G, n or p, the script will display a message about an exception.
prefix_exponents = {'G':9, 'M':6, 'k':3, 'm':-3, 'u':-6, 'n':-9, 'p':-12}
Again, because of how the micro:bit module’s 32-bit floating point arithmetic works, the results will be slightly different from what you get with a calculator. It’ll be close, but not quite as precise. For example, if you expect 40000000000, you might get something like 39999995231. The result is still more than 99.9999% correct.
After making calculations with the decimal values, for example, you may need to convert back to metric prefixes. Let's look at how that works.
Step 1: Decide how many places to the left or right to shift the decimal point and select the corresponding metric prefix. For example, if you shift it left by 3, that’ll be k (kilo), or if you shift it left by 3 more (for a total of 6), that’ll be M (mega). For shifting to the right, 3 would be m (milli), 6 would be µ (micro), and so on… Tip: Make sure to use multiples of 3.
Step 2: Find the decimal value for the metric prefix in the SI Metric Prefixes table and make a fraction of metric prefix / decimal value.
Step 3: Multiply your quantity by the fraction.
Step 4: Calculate the result.
Example: Convert 38,000 Hz so that it has a metric prefix. Hint: In engineering notation, it’s usually preferable for the integer part of the quantity to be in the 1...999 range.
Here are examples of how metric prefixes change the schematics you’ve been working with. Again, shoot for an integer portion in the 1...999 range.
Remember from earlier, how if you multiply some quantity by 1, the result is that same quantity? The example started with 1000 = k and divided both sides of the equal sign by k for a result of 1 = 1000 / k. You could divide both sides by 1000 instead for 1 = k / 1000. Then, starting with 2000 Ω, you can multiply by k / 1000. The thousands cancel, and the result is 2 kΩ.
(View full size: muam-multiply-by-one-val-to-prefix.mp4 [4])
The scrip values_to_metric_prefixes converts decimal values to quantities with metric prefixes. It is similar to the previous example program, but there are two main differences. First, values_to_metric_prefixes is not using special formatting strings to ensure that the values display as decimal (instead of sometimes displaying exponential notation). Second, this conversion is the inverse of the previous conversion. In this script, the value-to-quantity conversion is done with division:
quantity = value / (10 ** exponent)
In the previous example, the quantity to value conversion was done with multiplication:
value = quantity * (10 ** exponent)
Since 1 x 103 is 1000, it can also be used in place of the prefix k. This same rule applies to all rows in the SI Metric Prefixes table on this page. [5]. Just remember to use the rules of scientific notation in your calculations!
(View full size: muam-multiply-by-one-sci-note.mp4 [6])
The values_to_metric_prefixes script converts values to quantities with metric prefixes.
# values_to_metric_prefixes prefix_exponents = {'M':6, 'k':3, 'm':-3, 'u':-6} print("Enter decimal value and metric prefix") print("Result will be quantity and prefix.") print() while True: text = input("Enter value: ") value = float(text) prefix = input("Enter metric prefix: ") exponent = prefix_exponents[prefix] quantity = value / (10 ** exponent) unit = input("Enter unit: ") prefix_unit = prefix + unit print("Value:", quantity, prefix_unit) print()
This script converts decimal values to quantities and metric prefixes.
Explain how to update the Ohmmeter Parts drawing so that it uses SI units and metric prefixes. Your goal is to keep any quantities in the 1 to 999 range.
Links
[1] https://learn.parallax.com/sites/default/files/content/Python/Elec/muam-multiply-by-one-prefix-to-val.mp4
[2] https://python.microbit.org/v/2
[3] https://learn.parallax.com/tutorials/robot/cyberbot/dictionary-primer
[4] https://learn.parallax.com/sites/default/files/content/Python/Elec/muam-multiply-by-one-val-to-prefix.mp4
[5] https://learn.parallax.com/node/2443
[6] https://learn.parallax.com/sites/default/files/content/Python/Elec/muam-multiply-by-one-sci-note.mp4
[7] https://learn.parallax.com/node/2444
[8] https://learn.parallax.com/node/2447