arduino plus delphi mobile apps - beyond basics
Post on 26-Jan-2017
58 Views
Preview:
TRANSCRIPT
Arduino+Delphi MobileBeyond Basics
Victory FernandesEmbarcadero MVP-Brazil
@victoryjorge
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
How big is Brazil?
How big is Brazil? ExtremeDelphi 2016 events so far we travelled +10.0000km
Embarcadero Conference Brazil 2016
• Oct,26 – São Paulo – Brazil• 7 simultaneous rooms• 600+ attendees are expected
#ECON2015
www.embarcaderoconferece.com.br
Factory floor weighing scales
Factory floor weighing scales
Truck weighing scales
Production tracking
Production tracking
Production tracking as we found!
Ethernet IO device
Delphi Intraweb app on TV
Delphi Intraweb app on Mobile + SMS
Worked with microcontrollers before?
• First prototype used Arduino…
•Why we ended up using ARM?
•NYQUIST theorem
• 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"
• 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"
• Digital I/Os
•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
• PWM
•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
• Analog Input
•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
• There is more…
SPI-Serial Peripherical Interface
I2C-inter-Integrated Circuit
•RISC•Reduced Instruction Set Computer•131 Assembler instructions; 1 instruction per cycle
•At 16MHz its almost 16x106 lines of code per second!
• ATMega328P
•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
•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
•Electrically-Erasable Programmable Read-Only Memory
•This is where we record data that we do not want to lose after shutdown!
• EEPROM Memory - 1KB
• Not that much?
• "Hello world”? Why the resistor?
• 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
• Voila!
• The fun goes on…
Can we trigger a relay like this?
Voltage/Current output coupling
Transistors triggering
higher currents/v
oltage
ULN2001-2002-2003-20046-25V; up to 500mA
• Voila!
Transistors are here!
Now lets say I want to read a sensor…
Now lets say I want to read a sensor…
Now lets say I want to read a sensor…
Can I do this?
PULL DOWN resistor
PULL DOWN resistor
when OPEN Vout = GND = 0V LOW is read
when CLOSED Vout = Vin = 5V HIGH is read
Usually high values around 10kOhm
PULL UP resistor
PULL UP resistor
when OPEN Vout = Vin = 5V HIGH is read
when CLOSED Vout = GND = 0V LOW is read
Usually low values around 300ohm
Do we really need the resistors?
What if I want to use industrial sensors?
Optocoupler, Opto-Isolator or Photo-Coupler
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
•Robocore Padawanwww.robocore.net/loja/produtos/arduino-shield-padawan.html
Temperaturesensor
Joystick
Potentiometer
RGB LEDGeneral connector supportsDigital inputDigital outout/PWM
7 segmentdiplay
Lightsensor
•DFRobot accessory boardwww.dfrobot.com/index.php?route=product/product&path=35&product_id=1045
RGB LED
Joystick
Potentiometer
RelayBuzzer
LCD Display
Pressure/Humidity
•But our protocol must be able
to control all the pins…
•Its time to go a little deeper into the Arduino C Language
•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
• Coding the complete Arduino C code…
• VCL demo
• VCL demo
victoryfernandes@yahoo.com.brwww.youtube.com/user/
victoryfernandes @victoryjorge
Thank you! Grazie! Obrigado!
top related