arduino plus delphi mobile apps - beyond basics

67
Arduino+Delphi Mobile Beyond Basics Victory Fernandes Embarcadero MVP-Brazil

Upload: vic-fernandes

Post on 26-Jan-2017

63 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Arduino plus Delphi Mobile Apps - Beyond Basics

Arduino+Delphi MobileBeyond Basics

Victory FernandesEmbarcadero MVP-Brazil

Page 2: Arduino plus Delphi Mobile Apps - Beyond Basics

@victoryjorge

Page 3: Arduino plus Delphi Mobile Apps - Beyond Basics

Victory Fernandes• I love Delphi since 1998! • Embarcadero MVP-Brazil• CTO at TKSSoftware.com• Electrical Engineer; Msc. Medicine Neuro-

Science• INDEVA Manipulators and AGVs representative

Page 4: Arduino plus Delphi Mobile Apps - Beyond Basics

How big is Brazil?

Page 5: Arduino plus Delphi Mobile Apps - Beyond Basics

How big is Brazil? ExtremeDelphi 2016 events so far we travelled +10.0000km

Page 6: Arduino plus Delphi Mobile Apps - Beyond Basics

Embarcadero Conference Brazil 2016

• Oct,26 – São Paulo – Brazil• 7 simultaneous rooms• 600+ attendees are expected

#ECON2015

www.embarcaderoconferece.com.br

Page 7: Arduino plus Delphi Mobile Apps - Beyond Basics

Factory floor weighing scales

Page 8: Arduino plus Delphi Mobile Apps - Beyond Basics

Factory floor weighing scales

Page 9: Arduino plus Delphi Mobile Apps - Beyond Basics

Truck weighing scales

Page 10: Arduino plus Delphi Mobile Apps - Beyond Basics

Production tracking

Page 11: Arduino plus Delphi Mobile Apps - Beyond Basics

Production tracking

Page 12: Arduino plus Delphi Mobile Apps - Beyond Basics

Production tracking as we found!

Page 13: Arduino plus Delphi Mobile Apps - Beyond Basics

Ethernet IO device

Page 14: Arduino plus Delphi Mobile Apps - Beyond Basics

Delphi Intraweb app on TV

Page 15: Arduino plus Delphi Mobile Apps - Beyond Basics

Delphi Intraweb app on Mobile + SMS

Page 16: Arduino plus Delphi Mobile Apps - Beyond Basics

Worked with microcontrollers before?

Page 17: Arduino plus Delphi Mobile Apps - Beyond Basics
Page 18: Arduino plus Delphi Mobile Apps - Beyond Basics

• First prototype used Arduino…

Page 19: Arduino plus Delphi Mobile Apps - Beyond Basics

•Why we ended up using ARM?

Page 20: Arduino plus Delphi Mobile Apps - Beyond Basics

•NYQUIST theorem

Page 21: Arduino plus Delphi Mobile Apps - Beyond Basics

• Learn about the signal to be sampled• Choose the right sensor• Dimentions, Weight, Voltage, other general limitations

• Sample rate vs. File size vs. Recording speed

• Prototype circuit dimentions, weight, power consumption, other general limitations etc…

• Battery usage• Prototype Housing

• "Microcontrollers for Dummies"

Page 22: Arduino plus Delphi Mobile Apps - Beyond Basics
Page 23: Arduino plus Delphi Mobile Apps - Beyond Basics

• Prototyping platforms• Open source Software and Hardware • Application? Size, power consumption…• 8bits, 32bits…• 16MHz, 95Mhz…• 32KB-512KB Flash; 2KB-32KB RAM, SRAM,

EEPROM…• 8051, PIC, AtMega, ARM…• Intel, Microchip, Atmel, Freescale, NXP…

• "Microcontrollers for Dummies"

Page 24: Arduino plus Delphi Mobile Apps - Beyond Basics

• Digital I/Os

Page 25: Arduino plus Delphi Mobile Apps - Beyond Basics

•Numbered pins 0 to 13•6 of them with suport for PWM

•0 (zero) = LOW = 0 Volts•1 (one) = HIGH = 5 Volts

•Max. current output 20mA

• Digital I/Os

Page 26: Arduino plus Delphi Mobile Apps - Beyond Basics

• PWM

Page 27: Arduino plus Delphi Mobile Apps - Beyond Basics

•Equivalent to analog output; Allows to control signal power output (Watts) and can be used to dimmers leds, control motor speed etc...

• PWM – Pulse Width Modulation

Page 28: Arduino plus Delphi Mobile Apps - Beyond Basics

• Analog Input

Page 29: Arduino plus Delphi Mobile Apps - Beyond Basics

•Numbered pins A0 to A5

•Voltage input from 0 to 5V is mapped to a Byte•Binary values from 0000-0000 to 1111-1111•Decimal values from 0 to 255

•Allows to read analog sensors for temperature, light, distance, etc...

• Analog Input

Page 30: Arduino plus Delphi Mobile Apps - Beyond Basics

• There is more…

SPI-Serial Peripherical Interface

I2C-inter-Integrated Circuit

Page 31: Arduino plus Delphi Mobile Apps - Beyond Basics

•RISC•Reduced Instruction Set Computer•131 Assembler instructions; 1 instruction per cycle

•At 16MHz its almost 16x106 lines of code per second!

• ATMega328P

Page 32: Arduino plus Delphi Mobile Apps - Beyond Basics

•EEPROM memory, once you record there is no need for a power supply in order to keep its contents.

•This is where your program code is stored after you download it to to the microcontroller...

• Flash memory - 32KB

Page 33: Arduino plus Delphi Mobile Apps - Beyond Basics

•Static Random Access Memory, will keep its contents as long as the power is available; Not need for refresh like DRAM.

•This is where the microcontroller executes our program... No power? All status and variable values are lost!

• SRAM Memory - 2KB

Page 34: Arduino plus Delphi Mobile Apps - Beyond Basics

•Electrically-Erasable Programmable Read-Only Memory

•This is where we record data that we do not want to lose after shutdown!

• EEPROM Memory - 1KB

Page 35: Arduino plus Delphi Mobile Apps - Beyond Basics

• Not that much?

Page 36: Arduino plus Delphi Mobile Apps - Beyond Basics
Page 37: Arduino plus Delphi Mobile Apps - Beyond Basics

• "Hello world”? Why the resistor?

Page 38: Arduino plus Delphi Mobile Apps - Beyond Basics

• Remember the 20mA max current?

•Ohm’s law•V[Volt]=R[ohm].i[Ampere]

•R = 5/0,020 = 250 ohm

• LED internal resistance is very low! In this case we considered it tends to zero

Page 39: Arduino plus Delphi Mobile Apps - Beyond Basics

• Voila!

Page 40: Arduino plus Delphi Mobile Apps - Beyond Basics

• The fun goes on…

Page 41: Arduino plus Delphi Mobile Apps - Beyond Basics

Can we trigger a relay like this?

Page 42: Arduino plus Delphi Mobile Apps - Beyond Basics

Voltage/Current output coupling

Transistors triggering

higher currents/v

oltage

ULN2001-2002-2003-20046-25V; up to 500mA

Page 43: Arduino plus Delphi Mobile Apps - Beyond Basics

• Voila!

Transistors are here!

Page 44: Arduino plus Delphi Mobile Apps - Beyond Basics

Now lets say I want to read a sensor…

Page 45: Arduino plus Delphi Mobile Apps - Beyond Basics

Now lets say I want to read a sensor…

Page 46: Arduino plus Delphi Mobile Apps - Beyond Basics

Now lets say I want to read a sensor…

Page 47: Arduino plus Delphi Mobile Apps - Beyond Basics

Can I do this?

Page 48: Arduino plus Delphi Mobile Apps - Beyond Basics

PULL DOWN resistor

Page 49: Arduino plus Delphi Mobile Apps - Beyond Basics

PULL DOWN resistor

when OPEN Vout = GND = 0V LOW is read

when CLOSED Vout = Vin = 5V HIGH is read

Usually high values around 10kOhm

Page 50: Arduino plus Delphi Mobile Apps - Beyond Basics

PULL UP resistor

Page 51: Arduino plus Delphi Mobile Apps - Beyond Basics

PULL UP resistor

when OPEN Vout = Vin = 5V HIGH is read

when CLOSED Vout = GND = 0V LOW is read

Usually low values around 300ohm

Page 52: Arduino plus Delphi Mobile Apps - Beyond Basics

Do we really need the resistors?

Page 53: Arduino plus Delphi Mobile Apps - Beyond Basics

What if I want to use industrial sensors?

Page 54: Arduino plus Delphi Mobile Apps - Beyond Basics

Optocoupler, Opto-Isolator or Photo-Coupler

Page 55: Arduino plus Delphi Mobile Apps - Beyond Basics
Page 56: Arduino plus Delphi Mobile Apps - Beyond Basics

Delphi Android/iOS app

ON

OFF

UDP Server192.168.1.177:8888

’H’ ’H’ ’H’=On’L’ ’L’ ’L’=Off

•We built our control protocol from scratch

Page 57: Arduino plus Delphi Mobile Apps - Beyond Basics

•Robocore Padawanwww.robocore.net/loja/produtos/arduino-shield-padawan.html

Temperaturesensor

Joystick

Potentiometer

RGB LEDGeneral connector supportsDigital inputDigital outout/PWM

7 segmentdiplay

Lightsensor

Page 58: Arduino plus Delphi Mobile Apps - Beyond Basics

•DFRobot accessory boardwww.dfrobot.com/index.php?route=product/product&path=35&product_id=1045

RGB LED

Joystick

Potentiometer

RelayBuzzer

LCD Display

Pressure/Humidity

Page 59: Arduino plus Delphi Mobile Apps - Beyond Basics

•But our protocol must be able

to control all the pins…

Page 60: Arduino plus Delphi Mobile Apps - Beyond Basics

•Its time to go a little deeper into the Arduino C Language

Page 61: Arduino plus Delphi Mobile Apps - Beyond Basics

•Supported string messages…

‘dw04h’ = digital write pin 4 high‘dr02’ = digital read pin 02

‘aw03255’ = analog write pin 3 value 255

‘ar02’ = analog read pin 2

Page 62: Arduino plus Delphi Mobile Apps - Beyond Basics
Page 63: Arduino plus Delphi Mobile Apps - Beyond Basics

• Coding the complete Arduino C code…

Page 64: Arduino plus Delphi Mobile Apps - Beyond Basics

• VCL demo

Page 65: Arduino plus Delphi Mobile Apps - Beyond Basics

• VCL demo

Page 66: Arduino plus Delphi Mobile Apps - Beyond Basics