EML 4840 Robot Design Department of Mechanical and Materials Engineering Florida International University Spring 2018

Microcontrollers, Embedded Computers and Operating Systems

An operating system (OS) is system software that controls, manages, and synchronizes computer hardware and software resources and provides common services for computer programs. Following is a diagram showing some relevant operating systems.

A is a small computer on a single integrated circuit (IC) containing a processor core, memory and programmable input/output (IO) peripherals. are designed for embedded applications, in contrast to the microprocessors used in personal computers (PC) or other general purpose applications.

A single-board computer (SBC) is a complete computer built on a single circuit board, with microprocessor(s), memory, input/output (I/O) and other features required of a functional computer. Single-board computers were made as demonstration or development systems, for educational systems, or for use as embedded computer controllers.

0.2 W

In an Uno, if you draw too much current (40mA or more) from an I/O pin, it will damage the pin. There are no fuses on the I/O pins.

Model GPIO per pin Power Clock Core RAM Price Arduino Uno 5 v 40 mA 9 - 12 v 45 mA* 500 mA 16 MHz 1 2 KB $25 Arduino Pro Mini 5 V 5 v 40 mA 5 - 12 v 20 mA* 500 mA 16 MHz 1 2 KB $10 Arduino Pro Mini 3.3 V 3.3 v 40 mA 3.35 - 12 v 20 mA* 500 mA 8 MHz 1 2 KB $10 ESP32 3.3 v 12 mA 2.3 - 3.6 v 250 mA 240 MHz 2 520 KB $10 Raspberry Pi 3 3.3 v 16 mA 5 v 400 mA* 2.5 A 1.2 GHz 4 1 GB $35** Raspberry Zero W 3.3 v 16 mA 5 v 150 mA* 1.2 A 1 GHz 1 512 MB $10** ODROID-XU4 1.8 v 10 mA 5 v 4 A* 6 A 15 GHz 8 2 GB $60** * idling. ** not including memory card and power supply.

GPIO reading Watch out for floating grounds or undetermined voltages!!!

That same GPIO leg of the button connects through a pull-down resistor (here 10K ohm) to ground. The other leg of the button connects to the 5 v supply. GPIO-controlled switching

BJT (bipolar junction transistor) vs MOSFET (metal–oxide–semiconductor field-effect transistor) vs Relay by Simon Monk, “Electronics Cookbook: Practical Electronic Recipes with Arduino and Raspberry Pi”. O'Reilly, 2017.

Amperage Technology Examples < 100 mA BJT or MOSFET 2N3904 or 2N7000 < 200 mA MOSFET < 500 mA Darlington or MOSFET MPSA14 or FQP30N06L < 3 A Darlington or MOSFET TIP120 or FQP30N06L < 20 A MOSFET FQP30N06L

When it comes to switching small loads (say under 100 mA) a small BJT (like the 2N3904) and a small MOSFET (like the 2N7000) are pretty much interchangeable. In fact, their pinouts mean that they are in the same transistor package and are pin compatible.

Above 100 mA but below 200 mA I would usually select a 2N7000 because its low on resistance means that it will not get as hot as a BJT.

Between 200 mA and 500 mA, I would either use a Darlington MPSA14 to save space over a FQP30N06L MOSFET (in a larger package), but only if I could afford the l.5 V or more voltage drop of the MPSA14.

Between 500 mA and 3A you are definitely in large- transistor territory in a TO-220 package. If you can afford the voltage drop of a Darlington then the TIP120 is a good choice; otherwise, a FQP30N06L will serve you well.

For powers over 3A use a FQP30N06L with a heatsink.

Use a relay for AC current.

Motors

Optical Switches

Tachometers (Speed and Position)

Quadrature Encoders (Speed, Position and Direction)

Absolute Encoders

Communication Protocols and Bus Networks

#define LED 13

void setup() { pinMode(LED, OUTPUT); }

void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); }

Protocol Wires Max Distance Nodes Communication Name TTL 1 1 Mbps 25 ft Single Asynchronous Transistor Transistor Logic UART 2 8 Mbps 50 ft Single Asynchronous Universal Asynchronous Receiver Transmitter I2C 2 400 kbps 80 ft Multiple Synchronous Inter-Integrated Circuit SPI 3 (4) 20 Mbps 10 ft Single* Synchronous Serial Peripheral Interface CAN Bus 2 1 Mbps 230 ft Multiple Asynchronous Controller Area Network USB 2.0/3.0 4 480/5,000 Mbps 16 ft Multiple Synchronous Universal Serial Bus Ethernet 4 (8) 10/100/1,000 Mbps 100 ft Multiple Asynchronous TCP/IP * multiple using mutplexers. Sensor, the blind men and the elephant

Controller

On-off controller

Proportional controller

setpoint = 4000 Kp = 0.85 previous_error = 0 Start: input = feedbackSensor() error = setpoint – input output = Kp*error actionActuator( output ) previous_error = error wait( dt ) Goto Start

Keep a certain “steady-state error” (signal too small to produce action in the actuators).

Proportional Integral Controller setpoint = 4000 Kp = 0.2 Ki = 0.05 previous_error = 0 integral = 0 Start: input = feedbackSensor() error = setpoint – input integral = integral + error*dt output = Kp*error + Ki*integral actionActuator( output ) previous_error = error wait (dt) Goto Start

Reduce the “steady-state error”.

Proportional Derivative Controller setpoint = 4000 Kp = 0.2 Kd = 0.3 previous_error = 0 integral = 0 Start: input = feedbackSensor() error = setpoint – input derivative = (error – previous_error)/dt output = Kp*error + Kd*derivative actionActuator( output ) previous_error = error wait (dt) Goto Start

Speed up “the response”.

Proportional Integral Derivative (PID) Controller setpoint = 4000 Kp = 0.2 Ki = 0.05 Kd = 0.3 previous_error = 0 integral = 0 Start: input = feedbackSensor() error = setpoint – input integral = integral + error*dt derivative = (error – previous_error)/dt output = Kp*error + Ki*integral + Kd*derivative actionActuator( output ) previous_error = error wait (dt) Goto Start

Combines the advantages of PI and PD, fast response and no steady-state error.

Response Rise time Overshoot Settling time Stead-state error Kp Decrease Increase Small Change Decrease Ki Decrease Increase Increase Decrease Kd Small Change Decrease Decrease No change