MEDIATEK LinkIt Smart 7688 Developer's Manual page 62

Hide thumbs Also See for LinkIt Smart 7688:
Table of Contents

Advertisement

while(True):
time.sleep(1)
# simply wait for interrupt
PWM
PWM
Use
module to generate a pulse width modulated signal pattern. This is useful to
control actuator peripherals such as servo motors. To use PWM, initialize it on a certain pin
such as GPIO. Note that only
control the PWM pattern, several parameters are required, including:
Period
o
This defines the carrier frequency of the modulation. It's controlled
period
period_ms
by
,
Duty Cycle or Pulse Width
o
These two parameters are related to each other and usually you only need to set one
of them. Duty cycle is controlled by
0.0
where
is 0% of duty cycle and
the pattern in a different unit: the "uptime" of the signal in time units. This is defined
pulsewidth
by
The following example generates a 500Hz PWM signal with 25% duty cycle on
pin P26
.
import
mraa
pin = mraa.Pwm(18)
pin.period_ms(2)
pin.enable(True)
pin.write(0.25)
I2C
I2C (Inter-Integrated Circuit) is a widely used protocol among peripherals. It consists of 2
signal pins - usually named
GPIO4(P21)
on
and
The way I2Cs are initialized is slightly different from GPIO modules - instead of using pins,
I2Cs are initialized according to its device index. Since there is only 1 set of I2C master
device on LinkIt Smart 7688, you can simply pass 0 - and it is always on
pin GPIO4
GPIO5
and
import mraa
i2c = mraa.I2c(0)
I2C is capable of connecting multiple slave devices to a single I2C master. Each slave
device is identified by a 7-bit address. The following example scans for a Seeed Studio 3-
Axis Digital Accelerometer attached to LinkIt Smart 7688 by reading the device ID from its
registers.
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
MediaTek LinkIt™ Smart 7688 Developer's Guide
18, 19, 20, 21
period_us
and
write
1.0
pulsewidth_ms
pulsewidth_us
,
, and
# initialize on GPIO18 (pin P26)
# set PWM frequency to 500Hz (2ms period)
# enable PWM output
# set duty cycle to 25%
SDA
SCL
and
. LinkIt Smart 7688 comes with 1 set of I2C
GPIO5(P20)
SCL
as
and
.
© 2015, 2016 MediaTek Inc.
supports PWM on LinkIt Smart 7688. To
APIs.
API with a value range between
is 100% of duty cycle. Pulse width also defines
APIs.
SDA
respectively.
0.0
1.0
to
,
Page 62

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents