Data Types.

Slides:



Advertisements
Similar presentations
temperature system wiring
Advertisements

Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2012 David Hall.
Waterproofing a thermistor ENGR 121 living with the lab © 2013 David Hall.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
Using Your Arduino, Breadboard and Multimeter Work in teams of two! living with the lab 1 © 2012 David Hall.
Assembly of conductivity flow loop living with the lab (in preparation for calibrating conductivity sensor)
Switches & whiskers on the Arduino living with the lab lever arm switches mounted to Arduino © 2012 David Hall.
Using fixed-cell references and built-in functions in Excel living with the lab © 2012 David Hall.
220  470  Gnd5V Currents Through Parallel Resistors 1 living with the lab © 2012 David Hall.
Introduction to Microsoft Excel living with the lab © 2012 David Hall.
Kirchoff’s Current Law (KCL) living with the lab University of Pennsylvania Library and Wikipedia Gustav Kirchoff (left) and Robert Bunsen (right) Bunsen.
Using for loops to control LEDs living with the lab 1 1 arduino.cc the for statement allows us to repeat a block of commands a limited number of times.
Building Circuits.
Measuring & Drawing a Barbed Fitting
Pump Fabrication Day Group A will draw their pump
Controlling Servos with the Arduino
Connecting Switches.
Series and Parallel Resistors
Pump Project Requirements
Pump Efficiency Fluid Energy Out + - Electrical Energy In.
Introduction to the Arduino
Why Won’t My Arduino Work?
Robot Challenge Introduction
Troubleshooting Your Multimeter
Line Following Tips photoresistor circuits
What’s in your kit?.
Pump Project Overview.
How to Use Dial Calipers
Controlling a Motor with Cascading Switches
Introduction to Transistors
Introduction to the Fishtank
Conservation of Mass
RGB LEDs.
Conservation of Mass Problem
Conductivity Sensor.
Introduction to Transistors
Troubleshooting Your Multimeter
a few of my favorite sensors
Relays.
using for loops to control LEDs
using the Arduino to make LEDs flash
Acquiring Data from an ADXL335 Accelerometer
Using Photoresistors with an Arduino
Introduction to Mathcad
Line Following Tips photoresistor circuit
Torque and RPM of Gears
Conservation of Mass Problem
analog and digital measurements
Finishing your Project
Using “if” statements.
Controlling the Heater
Conservation of Mass
Design Project Forecast
Digital Input from Switches
Measuring & Drawing a Barbed Fitting
Cash Flow Diagrams <in> <out> $200 $300 $150 $100
Implementing Switches Using Interrupts
Arduino: For Loops.
Non-Concurrent Force Systems
IR Object Detection IR detector IR LED IR light reflected off object
Radio Frequency Transmitter and Receiver
Interfacing a Rotary Encoder with an Arduino
Conservation of Mass Problem
Non-Concurrent Force Systems
Evaluating Design Alternatives
Counting Servo Gear Teeth (FS90R Servos)
Static Equilibrium Problem
Reservoir Loop.
Freshman Design Expo Presentations
Gearmotor Efficiency W table top gearmotor pulley string.
Presentation transcript:

Data Types

DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms

How do computers work? Use digital electronics Computer memory and chips keep track of large numbers of on/off “switches” A switch that is off is associated with a binary number of 0 A switch that is on is associated with a binary number 1 Patterns of “on” and “off” stored inside a computer are used to encode ordinary numbers Computer processors that use strings of 64 binary numbers to keep track of things are called 64-bit systems

What is binary? Base 10 is the most commonly used number system (10 digits): 0 1 2 3 4 5 6 7 8 9 Binary number system uses base 2 (2 digits): 0 1 A single unit of information is called a bit. In binary a bit can be a 0 or a 1 How many combinations can a 4-bit register represent? 1 1 1 1 Total number of bits being represented 24 =16 1 Each bit can be 2 options: 0 or 1

What are all the possible combinations of zeros and ones that a 4-bit register can represent? = 0 1 = 6 1 = 12 Number the bits starting with 0 1 1 = 1 1 = 13 = 7 1 2 3 1 1 = ? = 3 = 2 1 = 14 1 = ? = 2 1 = 8 1 1 = ? = 3 1 = 15 = 9 21=2 20=1 2+1=3 1 1 = 4 = 10 1 = 5 1 = 11 If there is a 1 in the bit, set 2 as the base and raise it to the bit number. If there is more than one bit with a 1 add their values together.

Successive Division by 2 for Decimal to Binary Conversion Convert the decimal value 47 to binary using successive division by 2 Divided by 2, because binary is base 2 LSB – Least Significant Bit 47 ÷2 =23 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 23 ÷2 =11 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 11 ÷2 =5 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 47 to binary is 101111 5÷2 =2 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 2÷2 =1 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 0 1÷2 =0 𝑤𝑖𝑡ℎ 𝑎 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 1 MSB – Most Significant Bit

Data Types Variables store information in the form of bits Predefined data types allow you to choose the best form for a variable Do you know of any data types? int float Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 byte 0 to 255 An unsigned 8 bit number (28=256) int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type long 32 -2,147,483,648 to 2,147,483,647 Frequently used data type, number with many digits, signed float -3.4028235x1038 to 3.4028235x1038 Includes decimal point, total precision is 6 to 7 digits Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 byte 0 to 255 An unsigned 8 bit number (28=256) int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type long 32 -2,147,483,648 to 2,147,483,647 Frequently used data type, number with many digits, signed float -3.4028235x1038 to 3.4028235x1038 Includes decimal point, total precision is 6 to 7 digits char One 8-bit ASCII character Alphanumeric characters, multiple characters called strings Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 byte 0 to 255 An unsigned 8 bit number (28=256) int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type float 32 -3.4028235x1038 to 3.4028235x1038 Includes decimal point, total precision is 6 to 7 digits Data Type # of Bits Range Comments int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type Data Type # of Bits Range Comments int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type float 32 -3.4028235x1038 to 3.4028235x1038 Includes decimal point, total precision is 6 to 7 digits Data Type # of Bits Range Comments boolean 8 True or false True ≠ 0 and False = 0 int 16 -32,768 to 32,767 Whole number, signed (+ or -), most common data type float 32 -3.4028235x1038 to 3.4028235x1038 Includes decimal point, total precision is 6 to 7 digits

Experimenting with Data Types 5V analog input 5 thermistor 10kW Build the thermistor circuit on your breadboard Activity 1: Collect 100 temperature values and take the average of the values. Provide the average value in Degrees Celsius Print information collected and calculated on the serial monitor Hint: Adapt the program from Question 1 from Homework 1 Truncation is the cutting off of values after the decimal place which can give you errors Using the proper Data Types and including decimals within the equation being calculated can help fix this issue Using the serial monitor to print values is a great troubleshooting tool. Always check your values! Activity 2: Collect 100 temperature values and find the minimum. Provide the minimum in Degrees Celsius

Experimenting with Data Types Activity 3: Collect 100 temperature values and find the min and subtract it from the data set. Then find the average of the remaining values. Provide both min and average in Degrees Celsius Tips for Programming Use the appropriate data type Print out everything you calculate Start with small pieces that build towards the larger program Comment the lines of code to help you remember their purpose

Additional Activities analog input 5 thermistor 10kW Collect 100 temperature values and find the maximum Collect 100 temperature values and find the min, max, and average Collect 100 temperature values and find the min, max, subtract out the min and the max values then find the average of the remaining values. Write a sketch that reads values from the thermistor circuit and prints the analog values, degrees in Celsius, and degrees in Fahrenheit. Beware of truncation and use the right data types.