Oct 18, 2016 - Ultra low power mc-Air⢠wireless technology with integrated ..... The three things that define a PWM si
www.mcThings.com
mcDemo205 Product Specification REVISION 0.2 OCTOBER 18, 2016
©2016 mc-Things Inc.
Page | 1
www.mcThings.com
Disclaimer Examples written in mcScript™ are for illustrative purposes only and subject to change. For the most up to date examples please refer to mcStudio™.
©2016 mc-Things Inc.
Page | 2
www.mcThings.com
Contents 1.
DEVICE OVERVIEW ................................................................................................................................ 5
2.
DEVICE VIEWS AND PIN ASSIGNMENTS ................................................................................................ 7 2.1 TOP VIEW ............................................................................................................................................ 7 2.2 BOTTOM VIEW .................................................................................................................................... 8 2.3 TEST CONNECTOR ............................................................................................................................... 9
3.
PRODUCT FEATURES ........................................................................................................................... 10 3.1 mc-Air™ LPLAN™ ............................................................................................................................... 10 3.2 ARM Cortex-M4F Processor .............................................................................................................. 10 3.3 Sigfox™ Transceiver .......................................................................................................................... 11 3.4 GNSS Receiver ................................................................................................................................... 12 3.5 Accelerometer................................................................................................................................... 13 3.6 Temperature Sensor ......................................................................................................................... 14 3.7 Buttons .............................................................................................................................................. 15 3.8 LEDs ................................................................................................................................................... 15 3.9 GPIOs ................................................................................................................................................. 16 3.9.1 Digital Inputs .............................................................................................................................. 16 3.9.2 Digital Outputs ........................................................................................................................... 17 3.9.3 Analog Inputs ............................................................................................................................. 17 3.10 SPI Interface .................................................................................................................................... 18 3.11 UART Interface ................................................................................................................................ 19 3.12 I2C Interface .................................................................................................................................... 20 3.13 PWM ............................................................................................................................................... 21 3.14 Power .............................................................................................................................................. 22 3.15 Battery Measurement ..................................................................................................................... 22
4.
ELECTRICAL SPECIFICATIONS .............................................................................................................. 24 4.1 Absolute Maximum Ratings .............................................................................................................. 24 4.2 Recommended Operating Conditions............................................................................................... 24 4.3 Power Consumption.......................................................................................................................... 24
©2016 mc-Things Inc.
Page | 3
www.mcThings.com
List of Figures Figure 1-1: mcDemo205 Block Diagram ....................................................................................................... 5 Figure 2-1: mcDemo205 Top View................................................................................................................ 7 Figure 2-2: mcDemo205 Bottom View.......................................................................................................... 8 Figure 3-1: Sigfox mc-Script ........................................................................................................................ 11 Figure 3-2: GNSS mc-Script ......................................................................................................................... 12 Figure 3-3: Accelerometer Schematic ......................................................................................................... 13 Figure 3-4: Temperature Sensor Schematic................................................................................................ 14 Figure 3-5: TMP102 mc-Script..................................................................................................................... 15 Figure 3-6: Button mc-Script ....................................................................................................................... 15 Figure 3-7: LED mc-Script ............................................................................................................................ 16 Figure 3-8: Input Pin mc-Script ................................................................................................................... 17 Figure 3-9: Output Pin mc-Script ................................................................................................................ 17 Figure 3-10: Analog Input mc-Script ........................................................................................................... 18 Figure 3-11: SPI Interface mc-Script............................................................................................................ 19 Figure 3-12: UART mc-Script ....................................................................................................................... 20 Figure 3-13: I2C mc-Script ........................................................................................................................... 21 Figure 3-14: PWM Example......................................................................................................................... 22 Figure 3-15: Power Jumper ......................................................................................................................... 22 Figure 3-16: Battery measurement mc-Script ............................................................................................ 23
List of Tables Table 1-1: Key Components .......................................................................................................................... 6 Table 1-2: External Interfaces ....................................................................................................................... 6 Table 2-1: Test Connector Pin Assignment ................................................................................................... 9 Table 3-1: GPIO Pins .................................................................................................................................... 16 Table 3-2: GPIO Pin Modes ......................................................................................................................... 16 Table 3-3: Input Pin Configurations ............................................................................................................ 16 Table 3-4: Analog Pins ................................................................................................................................. 17 Table 3-5: SPI Parameters ........................................................................................................................... 18 Table 3-6: UART Parameters ....................................................................................................................... 20 Table 3-7: I2C Parameters ........................................................................................................................... 21 Table 3-8: PWM Parameters ....................................................................................................................... 21 Table 4-1: Absolute Maximum Ratings ....................................................................................................... 24 Table 4-2: Recommended Operating Conditions........................................................................................ 24 Table 4-3: Power Consumption .................................................................................................................. 24
©2016 mc-Things Inc.
Page | 4
www.mcThings.com
1. DEVICE OVERVIEW The mcDemo205 is a technology demonstration platform which combines mc-Air™, Sigfox™, GNSS receiver, and various sensors to allow users to quickly develop IoT solutions. The device integrates an ARM Cortex-M4F processor, Sigfox radio, GNSS receiver, accelerometer, temperature sensor, mc-Air™ antenna, Sigfox™ antenna, GNSS antenna, buttons, LEDs, and various I/Os. Communication using the mc-Air™ Low Power LAN protocol allows distances up to 200m* to the mcGateway™ while the integrated Sigfox™ radio enables long range data transmission in Sigfox™ coverage areas. The integrated multi constellation GNSS receiver allows precision location acquisition anywhere in the world. A high level block diagram is shown in Figure 1-1 and key components in Table 1-1. Integration with mc-Studio™ ensures the fastest and most reliable IoT application development and deployment. Multiple sensors, interfaces, and I/Os provide measurement and control capabilities to solve any IoT problem.
GNSS Antenna
mcAir Antenna
Sigfox Antenna
GNSS
ARM M4
Sigfox mcDemo205
Figure 1-1: mcDemo205 Block Diagram
©2016 mc-Things Inc.
Page | 5
Battery (4xAAA)
Power Supply
USB PWR
USB
UART to USB
UART
High Accuracy Temp Sensor
SPI
LEDs
GPIO
8Mbit Flash Memory
ADC
3 Axis Accel
I2C
Buttons
www.mcThings.com
Table 1-1: Key Components
Key Components Application Processor
32-bit ARM Cortex M4F processor
mc-Air™ Wireless LPLAN
Ultra low power mc-Air™ wireless technology with integrated antenna over 2.4GHz
Operating System
mc-OS™ (specifically designed for IoT applications)
Sigfox™ Radio
Sigfox™ transceiver with integrated high performance PCB antenna allows connection to the Low-Power Wide-Area Sigfox™ network.
GNSS Receiver
Multi constellation (GPS, GLONASS, Beidou, Galileo) GNSS receiver with onboard high performance ceramic patch antenna.
Accelerometer
Low power 12-bit Digital accelerometer with onboard motion processor.
Temperature sensor
Low power temperature sensor with 0.0625°C resolution over -40C to +85C
8Mbit Flash Memory
8Mbit Flash for local data collection and firmware updates.
Table 1-2: External Interfaces
External Interfaces GPIO
7 GPIOs (shared with analog inputs)
ADC
4 Analog Inputs (shared with GPIO pins)
SPI
SPI Interface
I2C
I2C interface
PWM
Hardware PWM
USB UART
USB connection power the device and also provides a USB to UART bridge
©2016 mc-Things Inc.
Page | 6
www.mcThings.com
2. DEVICE VIEWS AND PIN ASSIGNMENTS 2.1 TOP VIEW
Figure 2-1: mcDemo205 Top View
©2016 mc-Things Inc.
Page | 7
www.mcThings.com
2.2 BOTTOM VIEW
Figure 2-2: mcDemo205 Bottom View
©2016 mc-Things Inc.
Page | 8
www.mcThings.com
2.3 TEST CONNECTOR The pin assignment of the test connector is shown in Table 2-1. Table 2-1: Test Connector Pin Assignment
Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Name GND GND SCLK MISO PIN8 MOSI SCL PIN3 PIN7 SDA PIN6 PIN2 PIN5 PIN1 3V3 PIN0 3V3 RF_3V3 PIN4 NC UART_RXD UART_TXD GND GND
©2016 mc-Things Inc.
Type G G O I I/O O O I/O I/O I/O I/O I/O I/O I/O P I/O P P I/O NC I O G G
Function Ground Ground SPI Clock SPI MISO Battery Voltage Monitor (VBAT_MON) SPI MOSI I2C SCL Battery Monitor Enable (EN_VIN_SW) LED2 (May also be used as GPIO if LED2 removed) I2C SDA Button 2 (May also be used as GPIO) LED3 (May also be used as GPIO if LED3 removed) GPIO/Analog Input Button 1 (May also be used as GPIO/Analog Input) 3.3V Power GPIO/Analog Input 3.3V Power 3.3V RF Power GPIO/Analog Input No Connect UART Receive UART Transmit Ground Ground
Page | 9
www.mcThings.com
3. PRODUCT FEATURES 3.1 mc-Air™ LPLAN™ The mc-Air™ LPLAN™ (Low Power Local Area Network) is a new protocol specifically designed for the Internet of Things. Using a high performance 2.4GHz onboard PCB antenna with a gain of +3.3dB allows distances of up to 200m* between the mc-Modules™ and mc-Gateway™ using very little power.
3.2 ARM Cortex-M4F Processor The ARM Cortex-M4F Processor runs the mc-OS™ operating system. This operating system was designed to run natively on the ARM Cortex-M4F with ultra low power consumption. Features include:
< 2.0 µA sleep current 2.4 GHz transceiver UART, SPI, I2C, PWM
The datasheet for this device can be found here: http://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.0.pdf
©2016 mc-Things Inc.
Page | 10
www.mcThings.com
3.3 Sigfox™ Transceiver The Sigfox™ transceiver with integrated high performance PCB antenna allows connection to the LowPower Wide-Area Sigfox™ network. The Sigfox™ network is a global cellular network specifically designed for ultra low power IoT devices. Direct integration into mc-Studio™ makes it very simple to send a Sigfox™ message as shown in Figure 3-1. 01 Class SigfoxDemo 02 03 Shared Event Boot() 04 'set Sigfox radio zone (default is US) 05 Lplan.SigfoxRadioZone(sigfoxradiozone.US) 06 End Event 07 08 Shared Event SigfoxStartHook() 09 'Do things before sending Sigfox Message 10 Lplan.SigfoxStartHookDone() 11 End Event 12 13 Shared Event SigfoxStopHook() 14 'Do things after sending Sigfox Message 15 Lplan.SigfoxStopHookDone() 16 End Event 17 18 'send sigfox message on button 1 press 19 Shared Event Button1FallingEdge() 20 'turn on LED2 to indicate Sigfox transmission started 21 LED2 = True 22 'sleep 500ms 23 Thread.Sleep(500000) 24 Dim sfData As ListOfByte = New ListOfByte 25 'Add data to Sigfox message (up to 12 bytes) 26 sfData.Add(0x40) 27 sfData.Add(0x87) 28 sfData.Add(0x1A) 29 sfData.Add(0x54) 30 'Send Sigfox message 31 Lplan.Sigfox(sfData) 32 'turn off LED2 to indicate Sigfox transmission complete 33 LED2 = False 34 End Event 35 36 End Class Figure 3-1: Sigfox mc-Script
©2016 mc-Things Inc.
Page | 11
www.mcThings.com
3.4 GNSS Receiver The multi-constellation (GPS, GLONASS, Beidou, Galileo) GNSS Receiver with integrated high performance ceramic patch antenna allows precision location acquisition. Direct integration into mcStudio™ makes it very simple to acquire a GNSS location as shown in Figure 3-2. 01 Class GNSSDemo 02 03 'GNSS Configuration Constants 04 Const GNSS_TIMEOUT_uS As Integer = 120000000 'GNSS Timeout = 120s 05 Const GNSS_MIN_SAT_COUNT As Integer = 3 'GNSS minimum sats = 3 06 07 'initiate GNSS acquisition on Button 1 press 08 Shared Event SW1FallingEdge() 09 'turn on LED2 to indicate GNSS acquisition started 10 LED2 = True 11 Device.StartGPS(GNSS_TIMEOUT_uS, GNSS_MIN_SAT_COUNT) 12 End Event 13 14 Shared Event LocationDelivery() 15 'Called when GNSS location acquired or timeout occurred 16 17 'Get latitude 18 Dim Lat As Float = Device.GetLatitude() 19 20 'Get longitude 21 Dim Lon As Float = Device.GetLongitude() 22 23 'Get GNSS fix time 24 Dim Time As Integer = Device.GetGpsFixTime() 25 26 'Do something with GNSS data (send over Sigfox, etc) 27 28 'turn off LED2 to indicate GNSS acquisition complete 29 LED2 = False 30 End Event 31 32 End Class Figure 3-2: GNSS mc-Script
©2016 mc-Things Inc.
Page | 12
www.mcThings.com
3.5 Accelerometer The low power I2C 12-bit 3-axis accelerometer (ST LIS2DH12) with configurable interrupt generation enables motion, freefall, and orientation detection. Features include:
±2 g, ±4 g, ±8 g, and ±16 g dynamically selectable full-scale ranges Output Data Rates (ODR) from 1 Hz to 5.3 kHz 12-bit digital output Configurable motion detection (Freefall, Motion, Pulse, Transient) Ultra Low power (3 µA in 10Hz low power 8 bit mode) 2 programmable interrupts
The datasheet for this device can be found here: http://www.st.com/content/ccc/resource/technical/document/datasheet/12/c0/5c/36/b9/58/46/f2/D M00091513.pdf/files/DM00091513.pdf/jcr:content/translations/en.DM00091513.pdf The accelerometer communicates via I2C (address 0x19) and also routes two (2) separate interrupt pins which allow the accelerometer to wake the processor on predefined acceleration events. It is setup as shown in Figure 3-3.
Figure 3-3: Accelerometer Schematic
Refer to the example project in mc-Studio™ for proper usage of the accelerometer.
©2016 mc-Things Inc.
Page | 13
www.mcThings.com
3.6 Temperature Sensor The low power I2C digital temperature sensor (Texas Instruments TMP102) is ideal where high accuracy is required. Power to the device is controlled by the processor to ensure the absolute lowest power consumption. Features include:
Accuracy Without Calibration: o ±0.5°C (typical) from -25°C to +85°C o ±1.0° (typical) from -40°C to +125°C 12-bit resolution (0.0625°C) Very low current active current (10 µA max) NIST Traceable
The datasheet for this device can be found here: http://www.ti.com/lit/ds/symlink/tmp102.pdf The temperature sensor communicates via I2C (address 0x48) and is setup as shown in Figure 3-4.
Figure 3-4: Temperature Sensor Schematic
An example of reading the temperature from the TMP102 is shown in Figure 3-5.
©2016 mc-Things Inc.
Page | 14
www.mcThings.com
01 Class Temperature 02 Shared Function GetTemp() As Float 03 Dim sensor As I2c 04 sensor = I2c.Create(250000, Pin.SCL, Pin.SDA, 0x48) 05 Device.EnableTempSensor() 06 Thread.Sleep(40000) // See page 13 of the datasheet 07 Dim res As ListOfByte = sensor.Read(2) 08 Dim temp As Float = Float.NaN 09 If res Nothing Then 10 Dim part As Float = res(1) >> 4 11 part = part / 16 12 temp = res(0).SignExtend() + part 13 End If 14 Device.DisableTempSensor() 15 Return temp 16 End Function 17 End Class Figure 3-5: TMP102 mc-Script
3.7 Buttons There are two (2) buttons available for user input. These buttons are shared with two (2) of the GPIO pins (PIN1 for Button 1 and PIN6 for Button 2). The buttons are NO (Normally Open) and the processor enables an internal pullup so the buttons are active low devices. Note: If the buttons are not being used than these pins may be used as GPIOs. Monitoring of the buttons is built into mc-Studio™ as shown in Figure 3-6. 01 02 03 04 05 06 07 08 09
Shared Event SW1Changed() If SW1 = True Then //button pressed Led2 = True //turn on LED2 if button pressed Else //button released Led2 = False //turn off LED2 if button released End If End Event Figure 3-6: Button mc-Script
3.8 LEDs There are three (3) red LEDs on the mcDemo205, LED1 is connected to the USB to UART bridge and will indicate when traffic is flowing on the UART, LED2 and LED3 are active high LEDs controllable in mcStudio™ for visual indication. These two LEDs are shared with GPIO pins (PIN7 for LED2 and PIN2 for LED3). Note: In order for PIN2 and PIN7 to be used as GPIO pins, LED2 and LED3 should be removed from the board. Control of the LEDs is built into mc-Studio™ as shown in Figure 3-7.
©2016 mc-Things Inc.
Page | 15
www.mcThings.com
01 02 03 04
Shared Event blinkLEDs() RaiseEvent Every 500 milliSeconds Led2 = Not Led2 //toggle LED2 Led3 = Not Led3 //toggle LED3 End Event Figure 3-7: LED mc-Script
3.9 GPIOs There are 7 General Purpose Input/Output pins available on the mcDemo205 as shown in Table 3-1. These pins are configurable as digital inputs, digital outputs, and analog inputs as shown in Table 3-2. Table 3-1: GPIO Pins
GPIO Pin PIN0 PIN1 PIN2 PIN3 PIN4 PIN5 PIN6 PIN7 PIN8
Description GPIO (ADC) GPIO Shared with Button 1 (ADC) (CAN BE USED AS GPIO IF BUTTON 1 IS UNUSED) GPIO Shared with LED3 (CAN ONLY BE USED AS GPIO IF LED3 IS REMOVED) Hardwired to battery measure enable (CAN NOT BE USED AS GPIO) * GPIO (ADC) GPIO (ADC) GPIO Shared with Button 2 (CAN BE USED AS GPIO IF BUTTON 2 IS UNUSED) GPIO Shared with LED2 (CAN ONLY BE USED AS GPIO IF LED2 IS REMOVED) Hardwired to battery voltage (CAN NOT BE USED AS GPIO) *
Table 3-2: GPIO Pin Modes
PinMode Not Used DigitalInput DigitalInputPullDown DigitalInputPullUp DigitalOutput AnalogInput
PIN0 Y Y Y Y Y Y
PIN1 Y Y Y Y Y Y
PIN2 Y Y Y Y Y N
PIN4 Y Y Y Y Y Y
PIN5 Y Y Y Y Y Y
PIN6 Y Y Y Y Y N
PIN7 Y Y Y Y Y N
3.9.1 Digital Inputs Any of the 7 GPIOs may be configured as digital inputs. There are three different input configurations as shown in Table 3-3. Table 3-3: Input Pin Configurations
Input Pin Configuration DigitalInput DigitalInputPullDown DigitalInputPullUp
©2016 mc-Things Inc.
Description Configure as high impedance (floating) Configure with internal pull-down to GND Configure with internal pull-up to VDD
Page | 16
www.mcThings.com
A GPIO digital input example is shown in Figure 3-8. 01 Define PinMode Pin0 As DigitalInputPullUp 02 Class InputPinTest() 03 Shared Event Pin0FallingEdge() 04 // pin0 has gone low, turn on LED for 100ms 05 Led2 = True // Turn on LED2 06 Thread.Sleep(100000) // Sleep for 100 ms 07 Led2 = False // Turn off LED2 08 End Event 09 End Class Figure 3-8: Input Pin mc-Script
3.9.2 Digital Outputs Any of the 7 GPIOs may be configured as digital outputs. A GPIO digital output example is shown in Figure 3-9. 01 Define PinMode Pin1 As DigitalOutput 02 Class OutputPinTest() 03 Shared Event TogglePin1() RaiseEvent Every 500 milliSeconds 04 // toggle Pin1 every 500 milliseconds 05 Pin1 = Not Pin1 // Toggle Pin1 06 End Event 07 End Class Figure 3-9: Output Pin mc-Script
3.9.3 Analog Inputs There are 4 pins that may be configured as analog inputs as shown in Table 3-4. Table 3-4: Analog Pins
Parameter ADC Pin ADC Voltage Range
Value PIN0, PIN1(Shared with Button 1), PIN4, PIN5 0V –3.6V Max
Figure 3-10 shows an example of reading the analog inputs.
©2016 mc-Things Inc.
Page | 17
www.mcThings.com
01 02 03 04 05 06 07 08
Define PinMode Pin0 As AnalogInput Public Function GetPin1Analog() As Short Dim value As Short value = Pin0 // Read the pin. This activates the ADC Return value // Return value in millivolts End Function
Figure 3-10: Analog Input mc-Script
3.10 SPI Interface The SPI Master interface enables synchronous communication between the mcDemo205 and peripheral devices. The parameters of the SPI interface are shown in Table 3-5. Table 3-5: SPI Parameters
Parameter SCK Pin MISO Pin MOSI Pin CS Pin Data Rates SPI Modes Master/Slave
Value SPI CLK MISO MOSI Any GPIO 125kHz, 250kHz, 500kHz, 1Mhz, 2MHz, 4MHz, 8 MHz 0, 1, 2, 3 Master ONLY
An example of SPI communications is shown in Figure 3-11.
©2016 mc-Things Inc.
Page | 18
www.mcThings.com
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
// // See datasheet at // http://ww1.microchip.com/downloads/en/DeviceDoc/20005119G.pdf // Class ExternalFlash Shared Mem1 As Spi Shared Mem2 As Spi Public Sub New() Mem1 = Spi.Create(8000000, 0, Pin.Pin0, Pin.Pin1, Pin.Pin3, Pin.Pin5) Mem2 = Spi.Create(8000000, 0, Pin.Pin0, Pin.Pin1, Pin.Pin3, Pin.Pin6) End Sub Public Function Read(adr As Integer, size As Integer) As ListOfByte Dim data As ListOfByte = New ListOfByte data.Add(3) ' Read command data.Add3Bytes(adr, Endianness.Big) ' Address data.AddElements(size) 'Size to read Dim mem As Spi If adr >= 0x00800000 Then mem = Mem2 Else mem = Mem1 End If data = mem.Transfer(data) Return data.GetRange(4) End Function
Public Sub Write(adr As Integer, toWrite As ListOfByte) Dim data As ListOfByte = New ListOfByte data.Add(2) ' Write command data.Add3Bytes(adr, Endianness.Big) ' Address data.AddRange(toWrite) 'Data to write Dim mem As Spi If adr = 0x00800000 Then mem = Mem1 Else mem = Mem2 End If mem.Transfer(data) End Sub End Class Figure 3-11: SPI Interface mc-Script
3.11 UART Interface There UART interface can be set on any of the GPIO pins. The parameters of the UART interface are shown in Table 3-6.
©2016 mc-Things Inc.
Page | 19
www.mcThings.com
Table 3-6: UART Parameters
Parameter RX Pin TX Pin Flow Control Supported Baud rates
Value Any GPIO pin, RXD Any GPIO pin, TXD Not Supported 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200, 230400, 250000, 460800, 921600, 1000000
An example of UART communications is shown in Figure 3-12. 01 Class Display 02 Shared Disp As Uart 03 Public Sub New() 04 Disp = Uart.Create(9600, Pin.Pin0, Pin.Pin1) 05 End Sub 06 Shared Event Uart0Receive() 07 Dim chr As Integer = Disp.Read() 08 While chr >= 0 09 // Process Character and do something 10 // .... 11 // .... 12 chr = Disp.Read() 13 End While 14 End Event 15 Public Sub DisplayText(row As Byte, col As Byte, str As String) 16 If row >= 0 Then 17 Disp.Write(0xff) 18 Disp.Write(row) 19 Disp.Write(col) 20 Disp.Write(str.Length.ToByte) 21 Disp.Write(str) 22 Else 23 Disp.Write(0xfe) 24 Disp.Write(str.Length.ToByte) 25 Disp.Write(str) 26 End If 27 End Sub 27 End Class Figure 3-12: UART mc-Script
3.12 I2C Interface There is a dedicated I2C communications interface on pins SCL and SDA. This interface bus is shared with the accelerometer (Address 0x19) and temperature sensor (Address 0x48). There are 10kΩ pull-ups on included on the demonstrator. The parameters of the I2C interface are shown in Table 3-7.
©2016 mc-Things Inc.
Page | 20
www.mcThings.com
Table 3-7: I2C Parameters
Parameter SCL Pin SDA PIN Data Rates Pull-ups (On Module) Unavailable Addresses
Value SCL SDA 100kHz & 250kHz 10kΩ 0x19, 0x48
An example of I2C communications is shown in Figure 3-13. 01 Class Temperature 02 Shared Function GetTemp() As Float 03 Dim sensor As I2c 04 sensor = I2c.Create(250000, Pin.SCL, Pin.SDA, 0x48) 05 Device.EnableTempSensor() 06 Thread.Sleep(40000) // See page 13 of the datasheet 07 Dim res As ListOfByte = sensor.Read(2) 08 Dim temp As Float = Float.NaN 09 If res Nothing Then 10 Dim part As Float = res(1) >> 4 11 part = part / 16 12 temp = res(0).SignExtend() + part 13 End If 14 Device.DisableTempSensor() 15 Return temp 16 End Function 17 End Class Figure 3-13: I2C mc-Script
3.13 PWM The demonstrator contains a hardware PWM (Pulse Width Modulation) peripheral with the parameters specified in Table 3-8. There are 3 PWM modules each with 4 channels per module. All channels using the same PWM module MUST be the same frequency but their polarity and duty cycle may be changed. The three things that define a PWM signal are the Pin, Period and Duty cycle. The pin specifies where the PWM signal is sent to, the Period is the amount of time between the rising edges of the signal in µSec and the duty cycle is the time that the pulse is active in µSec. So to create a pulse of 1Khz and a duty cycle of 20% the user has to specify a 1000 µSec Period and a 200 µSec Duty Cycle. If the duty cycle is 0 or negative the signal is always low and if the duty cycle is equal or larger than the period, the signal is always high. Table 3-8: PWM Parameters
Parameter PWM Pin Duty Cycle ©2016 mc-Things Inc.
Value Any GPIO Pin 0-100% (resolution based on frequency) Page | 21
www.mcThings.com
Frequency PWM Modules Channels per Module
3.8Hz to 5.333 MHz 3 4 (each channel on same module must be same frequency)
An example using PWM is shown in Figure 3-14. 01 02 03 04 05 06 07 08
Define PinMode Pin0 As PwmOutput Public Sub SetPwm() Dim pwm1kHz As Pwm pwm1kHz = Pwm.Create(1000) // create PWM with 1000µs period pwm1kHz.SetDutyCycle(Pin0, 200) // set PWM to 20% duty cycle on Pin0 pwm1kHz.Start() // start PWM End Sub
Figure 3-14: PWM Example
3.14 Power The mcDemo205 can be powered via USB or 4xAAA batteries. A jumper across J8 determines the power source as shown in Figure 3-15.
Figure 3-15: Power Jumper
3.15 Battery Measurement The mcDemo205 features built in battery voltage measurement. An mc-Script™ example of measuring the battery voltage is shown in Figure 3-16.
©2016 mc-Things Inc.
Page | 22
www.mcThings.com
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Define PinMode Pin3 As DigitalOutput Alias EnableBatteryMeasurement Define PinMode Pin8 As AnalogInput Alias BatteryVoltage Class BatteryDemo 'Battery voltage scaler based on mcDemo205 hardware Const BATT_VOLTAGE_SCALER As Float = 3.546 Private Function GetBatteryVoltage() As Float 'Enable battery voltage measurement resistor divider EnableBatteryMeasurement = True 'Sleep 20ms for voltage to stabilize Thread.Sleep(20000) 'Read battery voltage Dim voltgeMv As Integer = BatteryVoltage 'Disable battery voltage measurement resistor divider EnableBatteryMeasurement = False 'Convert measured voltage to actual battery voltage Dim batVoltage As Float = voltgeMv * BATT_VOLTAGE_SCALER 'Return converted battery voltage as float Return batVoltage End Function End Class Figure 3-16: Battery measurement mc-Script
©2016 mc-Things Inc.
Page | 23
www.mcThings.com
4. ELECTRICAL SPECIFICATIONS 4.1 Absolute Maximum Ratings Table 4-1: Absolute Maximum Ratings
Absolute Maximum Ratings Battery Input Voltage
+3.4V to +7.0V
USB Input Voltage
+4.5V to +5.5V
I/O Pin Voltage
-0.3V to +3.6V
Storage Temperature
-40°C to +125°C
NOTE: Exposure to the absolute maximum ratings for prolonged periods of time may affect long term reliability of the device.
4.2 Recommended Operating Conditions Table 4-2: Recommended Operating Conditions
Recommended Operating Conditions Battery Input Voltage
+3.6V to +6.5V (+6.0V Typical, 4xAAA 1.5V cells)
USB Input Voltage
+5.0V
Operating Temperature
-40°C to +85°C (depending on battery technology)
4.3 Power Consumption Table 4-3: Power Consumption
Power Consumption Sleep Current