IC3103学习笔记
课件引用于香港理工大学IC3103课程
Content
Spherical Robot
- Market Research
- Product design (Procreate/ Solidwork/ AutoCAD/ SketchUp)
- Eletronic: Arduino
Circuit
Ohm’s Law
V = I*R
where, V = Voltage (V); I = Current (A); R = Resistance (Ohms)
Electronic Signals
Signal which are continuous as time varying in nature are analog signals
.
Signal which are discrete are called digital signals
.
Analog signal
is a form of electrical energy (voltage, current or electromagnetic power) for which there is a linear relationship between electrical quantity and the value that the signal represents.
Analog Signals
– Voltage(e.g. 0-5V)
– Current(e.g. 0-20mA)
The signal, whose amplitude takes only limited values is called Digital signal
. Digital signal are discrete, they contain only distinct values.
Digital Signals
– I/O:1(High),0(Low),Pulse
– Bus (IO groups)
Input Devices
Sense the environment
• Digital Sensor
• Analog Sensor
Output Devices
Affect the surroundings
• Digital Actuators
• Analog Actuators
Process Module
Receiving input and controlling output
Digital System(Internal)
Analog to Digital Convert
• (e.g. 0~5V Signal)
0.0V 000
2.5V 050
5.0V 100
Big Arduino
Small Arduino
Electronic system Power
Power Adapter or Battery
• Power Adapter for hi power system.
• Battery for portable system.
• Rechargeable: NiMH/ Li-Ion/ Pb-Ac /SuperCap
• Non-Rechargeable: Alkaline Battery/ Li-ion*
Power Arduino Board
• From USB: DC5V, Max current 500mA
• From Ext DC PWR Jack: DC6-12V
• AAx4 Battery Box • USB Portable Power Supply
Procedure of build ELE system prototype
- Get an idea.
- Build minimize system as verify platform.
- Verify main function.
- Assemble ELE components into prototype.
- Test the full function prototype.
Arduino Basic Programming
Comments: created with // or /* and */
Operators: = is used to assign a value; == is used to compare values
And & Or: && is “and” || is “or”
Serial.begin() 1: Tx 0: Rx (Reserved for bluetooth transformation)
The serial communication is a simple scheme that uses the UART (Universal Asynchronous Receiver/Transmitter) on the Microcontroller. It uses,
5V for logic 1 (high)
0V for logic 0 (low)
For a 3.3V board, it uses
3V for logic 1 (high)
0V for logic 0 (low)
The messages sent to the computer from Arduino are sent from PIN 1 of the Arduino board, called Tx (Transmitter)
. The messages being sent to the Arduino from the computer are received on PIN 0, called Rx (Receiver)
.
There are five pins present on the USB-to serial adapter, including RX, TX, reset button, and GND (Ground).
void setup ( )
{
Serial.begin(4800);
}
void loop ( )
{
}
Serial.print()
Serial.print( value, format )
It specifies the base format and gives the output according to the specified format. It includes the formats Octal -OCT (base 8), Binary-BIN (base 2), Decimal-DEC (base 10), and Hexadecimal-HEX (base 16)
Serial.printIn()
Printed in a new line
void setup ( )
{
Serial.begin ( 4800);
}
void loop ( )
{
Serial.print(" Hello");
delay(1000);
Serial.println("Arduino"); // It will print Arduino followed by a new line.
delay ( 1500); // delay of 1.5 seconds between each printed line.
}
Serial.available()
Printed only when something statement has been fulfilled
int arrivingdatabyte = 0; // initializing the incoming serial byte
void setup( )
{
Serial.begin(9600); // 9600 is the data rate in bps (bits per second).
}
void loop( ) // loop function that executes repeatedly
{
if(Serial.available( ) > 0) // It will only send data when the received data is greater than 0.
{
arrivingdatabyte = Serial.read( ); // It will read the incoming or arriving data byte
Serial.print("data byte received:");
Serial.println(arrivingdatabyte, DEC); // here, DEC means Decimal
}
}
Serial.analogRead()
The analogRead( ) function reads the value from the specified analog pin present on the particular Arduino board.
// Below is an example for the better understanding of the analogRead( ) function
int AnaPin = A3; // Analog pin A3 is specified here
int value = 0; // variable declared to store the value read
void setup()
{
Serial.begin(9600); // It sets the serial rate at bps
}
void loop()
{
value = analogRead(AnaPin); // It reads the input pin
Serial.println(value);
}
setup()
Basic variable types:
Boolean (A boolean holds one of two values, true or false.)
void setup ( ) { }
// The setup function comes before the loop function and is necessary for all Arduino sketches]
void setup ( ) { pinMode (13, OUTPUT); }
// Outputs are declare in setup, this is done by using the pinMode function
void setup ( ) { Serial.begin(9600); }
// This particular example declares Serial communication at a baud rate of 960
Integer
Character
if()
if ( this is true ) { do this; }
if else
else { do this; }
loop: for while
void loop ( ) { }
for loop
for (int count = 0; count<10; count++) {
//for action code goes here
//this could be anything
}
while()
while ( count<10 ) {
//while action code goes here //should include a way to change count //variable so the computer is not stuck //inside the while loop forever
}
IO
Output
• Digital Write
digitalWrite ( pinNumber, value ) ;
// pinNumber can be any PWM pins (D0 to D13) value is either HIGH (ON/1) and LOW (OFF/0)
• Analog Write
analogWrite ( pinNumber, value ) ;
// pinNumber can be any PWM pins value is between 255 (100%) and 0 (0%)
3 6 9 10 11
Input
• Digital Read
digitalRead ( pinNumber) ;
// pinNumber can be any digital pins (D0 to D13) Return value is either HIGH (ON/1) or LOW (OFF/0)
pinMode (pinNumber, mode) ;
// pinNumber can be any digital pins (D0 to D13) mode: INPUT_PULLUP
• Analog Read
analogRead ( pinNumber) ;
// pinNumber can be any analog pins (A0 to A12) Return value is between 1023 (100%) and 0 (0%)
Delay Time
Delay milliseconds (1ms = 0.001s) delay( ms ) ;
ms type: unsigned long, range: 0 to 4,294,967,295
Delay microseconds (1us = 0.000001s) delayMicrosenconds( us ) ; us type: unsigned int, range: 0 to 16383
Electronic Component
Resistor
Capacitor
Diode (二極管)
Button (按鍵)
Transistor (晶體管)
IC – Integrated Circuit (集成電路)
Status of Connection
- Open Circuit
- Closed Circuit
- Short Circuit
Types of waveforms
DC Motor
DC Motor (Direct Current Motor)
• Continue Rotation
• Easy to drive
Speed Control
• DC Voltage
Output Torque
• Current
2 Type of DC Motor
Brush DC Motor
• 2 Pins: +/-
• Easy to drive
Brushless DC Motor
• 3 Pins: A/B/C
• High efficiency
Input IAx/IBx, Output OAx/Obx
Bluetooth
Soldering/Desoldering
Plastic Appreciation
UV (Inkjet) Printer Outlook
- Attached a paper on table
- Printed the image onto the paper
- Image Printed onto Object
Vacuum Former
- Place the forming mold on the former
- Put the plastic sheet on the frame
- Heat up the plastic sheet to soften
- Power on the vacuum pump for forming