+ All Categories
Home > Documents > Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry...

Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry...

Date post: 14-Mar-2018
Category:
Upload: buitram
View: 306 times
Download: 13 times
Share this document with a friend
20
Hans-Petter Halvorsen, M.Sc. Raspberry Pi
Transcript
Page 1: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

Hans-PetterHalvorsen,M.Sc.

RaspberryPi

Page 2: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi

Hans-PetterHalvorsen,M.Sc.

https://www.raspberrypi.org https://dev.windows.com/iot

Page 3: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

A900MHzquad-coreARMCortex-A7CPU,1GBRAM

Windows10IoTCore

Small-ScaleComputer

RaspberryPi- OverviewTheRaspberryPi2isalowcost,credit-cardsizedcomputerthatplugsintoacomputermonitororTV,andusesastandardkeyboardandmouse.TheRaspberryPi2canrunWindows10IoTCore.

13x- GPIOpins2x- SPIbuses1x- I2Cbus2x- 5Vpowerpins2x- 3.3Vpowerpins8x- Groundpins

3.5mmaudiojack/compositevideo

Page 4: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi3TheRaspberryPi3isthethirdgenerationRaspberryPi.ItreplacedtheRaspberryPi2ModelBinFebruary2016.ComparedtotheRaspberryPi2ithas:• A1.2GHz64-bitquad-coreARMv8CPU• 802.11nWirelessLAN• Bluetooth4.1• BluetoothLowEnergy(BLE)

Page 5: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi- ConnectorsTheRaspberryPi2typeBrunsaquad-coreARMCortex-A7CPUand1GBRAM.ItoffersthefollowingConnectors:• 4xUSB2.0sockets• 10/100BaseTEthernetsocket• HDMIvideosocket• RCAcompositevideosocket• microSDcardsocket• PoweredfrommicroUSBsocket• 3.5mmaudiooutjack• HeaderforGPIOandserialbuses(I2CandSPI)• DisplaySerialInterface(DSI)15wayflatflexcableconnectorwithtwodata

lanesandaclocklane• Cameraconnector15-pinMIPICameraSerialInterface(CSI-2)

Page 6: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi- PinMappings

Page 7: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi– GPIO

using Windows.Devices.Gpio;

public void GPIO()

// Get the default GPIO controller on the systemGpioController gpio = GpioController.GetDefault();if (gpio == null)

return; // GPIO not available on this sytem

// Open GPIO 5using (GpioPin pin = gpio.OpenPin(5))

// Latch HIGH valuepin.Write(GpioPinValue.High);

// Set the IO direction as outputpin.SetDriveMode(GpioPinDriveMode.Output);

// Close pin - will revert to its power-on state

GPIO:GeneralPurposeInput/Output

ThesePinscanbeusedforDigitalInput/Output

ThisExampleopensGPIO5 asanoutputandwritesadigital‘1’outonthepin

Page 8: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

Hans-PetterHalvorsen,M.Sc.

RaspberryPiWindows10IoTCoreforRaspberryPi

Page 9: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

Windows10IoT Core• Windows10IoT CoreisasmallscaledversionofWindowsrunningonsmalldevicessuchasRaspberryPi2

• https://dev.windows.com/iot

IoT– InternetofThings

Page 10: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

Hans-PetterHalvorsen,M.Sc.

RaspberryPiCommunicationProtocols

Page 11: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

CommunicationProtocols• UART(UniversalAsynchronousReceiver/Transmitter,)• ...

– http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

• SPI(SerialPeripheralInterface)– ...– http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

• I2C(Inter-IntegratedCircuit)– ...– http://en.wikipedia.org/wiki/I2C

http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols

Page 12: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi– SPIBus• SerialPeripheralInterface(SPI)isasynchronousserialdataprotocolusedby

microcontrollersforcommunicatingwithoneormoreperipheraldevicesquicklyovershortdistances.

• WithanSPIconnectionthereisalwaysonemasterdevice(usuallyamicrocontroller)whichcontrolstheperipheraldevices.

• SPIdevicescommunicateinfullduplexmodeusingamaster-slavearchitecturewithasinglemaster.

• TheinterfacewasdevelopedbyMotorolaandhasbecomeadefactostandard.• Typicalapplicationsincludesensors,SecureDigitalcards,andliquidcrystaldisplays

(LCD).

http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

SCLK:SerialClock(outputfrommaster)MOSI:MasterOutput,SlaveInput(outputfrommaster)MISO:MasterInput,SlaveOutput(outputfromslave)SS(orSC):SlaveSelect(activelow,outputfrommaster)

https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi

Page 13: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi– SPIBusThereare2SPIbuscontrollersavailableontheRPi2:SPI0 andSPI1

SPI0:Pin19- SPI0MOSIPin21- SPI0MISOPin23- SPI0SCLKPin24- SPI0CS0Pin26- SPI0CS1

SPI1:Pin38- SPI1MOSIPin35- SPI1MISOPin40- SPI1SCLKPin11- SPI1CS0

using Windows.Devices.Enumeration;using Windows.Devices.Spi;

public async void SPI()

// Get a selector string for bus "SPI0"string aqs = SpiDevice.GetDeviceSelector("SPI0");

// Find the SPI bus controller device with our selector stringvar dis = await DeviceInformation.FindAllAsync(aqs);if (dis.Count == 0);

return; // "SPI0" not found on this system

// Use chip select line CS0var settings = new SpiConnectionSettings(0);

// Create an SpiDevice with our bus controller and SPI settingsusing (SpiDevice device = await SpiDevice.FromIdAsync(dis[0].Id, settings))

byte[] writeBuf = 0x01, 0x02, 0x03, 0x04 ;device.Write(writeBuf);

Page 14: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi- I2CBus

http://en.wikipedia.org/wiki/I2C

• I²C(Inter-IntegratedCircuit),isamulti-master,multi-slave,single-ended,serialcomputerbus

• Itistypicallyusedforattachinglower-speedperipheralICstoprocessorsandmicrocontrollers.

• I²CistypicallyspelledI2C(pronouncedI-two-C)• TheI²Cbuswasdevelopedin1982byPhilipsSemiconductor.• TheI²Cprotocolrequiresonly2wiresforconnectingalltheperipheraltoamicrocontroller.

https://learn.sparkfun.com/tutorials/i2c

Page 15: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPi- I2CBusThereisoneI2CcontrollerI2C1 exposedonthepinheaderwithtwolinesSDA andSCL.1.8KΩinternalpull-upresistorsarealreadyinstalledontheboardforthisbus.

Pin3- I2C1SDAPin5- I2C1SCL

using Windows.Devices.Enumeration;using Windows.Devices.I2c;

public async void I2C()

// Get a selector string for bus "I2C1"string aqs = I2cDevice.GetDeviceSelector("I2C1");

// Find the I2C bus controller with our selector stringvar dis = await DeviceInformation.FindAllAsync(aqs);if (dis.Count == 0)

return; // bus not found

// 0x40 is the I2C device addressvar settings = new I2cConnectionSettings(0x40);

// Create an I2cDevice with our selected bus controller and I2C settingsusing (I2cDevice device = await I2cDevice.FromIdAsync(dis[0].Id, settings))

byte[] writeBuf = 0x01, 0x02, 0x03, 0x04 ;device.Write(writeBuf);

SCL:SerialClockLine

SDA:SerialDataLine

Page 16: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

DigitalTemperatureSensorwithI²CInterface

http://home.hit.no/~hansha/documents/lab/Lab%20Equipment/iot_sensors.htm

Page 17: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

HoneywellHumiditySensorwithI²C/SPIInterface

HoneywellHIH-6120-021-0014-PinSIPTemperature&HumiditySensor

http://home.hit.no/~hansha/documents/lab/Lab%20Equipment/iot_sensors.htm

Page 18: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

Hans-PetterHalvorsen,M.Sc.

RaspberryPiRaspberryPiCamera

Page 19: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

RaspberryPiCameraTheRaspberryPiCameraisidealforHomeSecurityApplications

ConnectitdirectlytotheCameraInterfaceontheRaspberryPi

https://www.raspberrypi.org/help/camera-module-setup/

5megapixelresolutionStillimages2592x1944Video:1080p30

Note!Thismoduleisonlycapableoftakingpicturesandvideo,notsound

Page 20: Raspberry Pi - Telemark University Collegehome.hit.no/~hansha/documents/lab/Lab Equipment/Raspberry Pi... · Raspberry Pi 3 The Raspberry Pi 3 is the third generation Raspberry Pi.

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:[email protected]:http://home.hit.no/~hansha/


Recommended