BBBK Programming Notes

Download Report

Transcript BBBK Programming Notes

BBBK Programming Notes
Rudra Dutta
CSC 453-001, Fall, 2013
Beyond Hello LEDs

More general purpose programming on the
BBBK
 Communication with other platforms – sockets
 Compiling remotely and pushing
 Sensor reading
–


Using pins and modes
– General analog sensor strategy
General starting point:
 http://beagleboard.org/Getting%20Started
When all else fails, read the manual
–
https://github.com/CircuitCo/BeagleBoneBlack/blob/master/BBB_SRM.pdf?raw=true
Virtual Box, Ubuntu VM
Step1: Install Ubuntu 12.04 LTS on VirtualBox
( Ubuntu disk image and VirtualBox software from the following links has been tested by TA):
– VirtualBox: ( VirtualBox-4.2.16-86992-Win.exe) from
http://www.oracle.com/technetwork/serverstorage/virtualbox/downloads/index.html#vbox
– Ubuntu 12.04 LTS from:
http://www.ubuntu.com/download/desktop
Step2: Enable USB in Guest Machine
i.
Install Ubuntu GuestAdditions: (In Guest Machine: Devices->Install Guest Additions )
ii.
Install Install Virtualbox Extension Packs (Oracle_VM_VirtualBox_Extension_Pack4.2.16-86992) from
http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html
Download and save extension pack software in your computer(host machine)
In VirtualBox:
File->Preferences->Extensions
Then click the add package button and provide path
3
Socket programming on BBBK WiFi
–
Enable WiFi on BeagleBone Black
 Step1: Power the BBB with power supply that is able supply at least 2A and
ssh into it via usb or Ethernet
 Step2: On the BBB, Create a directory
named rtlwifi under /lib/firmware/ (go to the /lib/firmware/ directory and
type mkdir rtlwifi)
 Step 3: Go to http://nordicgroup.us/bbb/wireless/rtlwifi/ , you should be able
to see the following files
Download all of them(10 files ) to the folder created on
step2( /lib/firmware/rtlwifi/ )
4
Socket programming on BBBK WiFi
–
Enable WiFi on BeagleBone Black…cont
 Step 4: Plug in the Wi-Fi dongle
 Step 5: Enable WiFi in /var/lib/connman/settings
Example:
5
Socket programming on BBBK WiFi
–
Enable WiFi on BeagleBone Black…cont
 Step 6: Create /var/lib/connman/wifi.config and edit configuration file as
shown in the example below
Save and close file
6
Socket programming on BBBK WiFi
–
Enable WiFi on BeagleBone Black…cont
 Step 7: Restart connection manager service, using following command
systemctl restart connman.service
Example:

Step 8: Reboot the BBB, the LED on the WiFi dongle should light up. :
 Step 9 : The wired ssh connection to the beagle bone will get broken when
you reboot. Give it about a minute or so after the wifi dongle lights up and
ssh again using wired connection. Run ifconfig to see if the wireless
interface has been connected
If not connected, press the reset button on bbb and repeat step 9 above
again
Example:
7
Socket programming on BBBK WiFi
–
Enable WiFi on BeagleBone Black…cont

For more details,
–
–
http://nordicgroup.us/bbb/wireless/
http://learn.adafruit.com/beaglebone/wifi
8
BBBK programming – push from Ubuntu Eclipse

Video tutorial
http://www.youtube.com/watch?v=vFv_-ykLppo:
Additional Resource:
http://www.lvr.com/eclipse5.htm
9
BeagleBone Black Expansion Connectors

The BeagleBone Black
provides two 46-pin dual
row expansion
connectors “P9” and
“P8”, which are also
known as “Expansion
A” and “Expansion B”
respectively
 Location and pinout of
these connectors are as
shown
Pinout Tables for Expansion Headers

The pinout tables for P8 and P9 show functions
offered by each of the pins
 The functions vary based on the mode setting
for each pin. Pin modes can be changed if
required (this is an advanced task)
 The function associated with a pin and a mode
changes the maximum voltage at each pin
Be careful! If you send higher
voltage than the maximum
listed for that pin and mode,
you will damage the
BeagleBone Black!!
Pinout Tables for Expansion Headers



The PROC column is the pin number on the
processor
The PIN column is the pin number on the expansion
header
The MODE columns are the mode setting for each
pin
–
Setting each mode to align with the mode column will give
that function on that pin
Pinout tables can be found on the BeagleBone Black System
Reference Manual
Useful GitHub Resource:
https://github.com/bradfa/beaglebone_pinmux_tables
P8 Pinout
P9
Pinout
Power Limitations

Power limitations on the pins for different modes
Note that Analog Input (AIN) pins are 1.8V, while GPIO pins are 3.3V
Checking and Selecting Pin Modes

Check Pin Statuses
http://robotic-controls.com/node/68

To control digital input/output, and read values from
different pins, you can use facilities in the
/sys/class/gpio directory. For further details:
http://www.armhf.com/index.php/using-beaglebone-black-gpios/

Setting Pin Modes
–
In general, it should be possible to use default pin modes. For
some cases you may need to set the modes. You would have
to write and compile a Device Tree Overlay. Details can be
found at:
http://hipstercircuits.com/enable-serialuarttty-on-beaglebone-black/
Reading sensors : Alcohol Gas Sensor

Alcohol Gas Sensor:
Schematic diagram
For more details: https://www.sparkfun.com/products/8880
Reading sensors : Alcohol Gas Sensor

Wiring Diagram for connecting with BeagleBone
Black

Maximum voltage to AIN (analog input) in
BeagleBone Black is 1.8V, therefore values of
R1 and R2 must be selected to ensure that the
voltage at the AIN does not exceed 1.8V
Reading sensors : Alcohol Gas Sensor

Mapping to BBB pins and values of R1 and R2 used in
testing:
R1
10K
R2
4.7K
GND
Pin 1 of expansion header P9
5V
Pin 5 of expansion header P9
AIN0
Pin 39 of expansion header P9
For more options on pin mapping please refer to expansion header specifications from
BeagleBone Black Specifications Reference Manual. From
BeagleBone Black Wiki
(http://circuitco.com/support/index.php?title=BeagleBoneBlack)
Reading sensors : Alcohol Gas Sensor

After connecting the sensor to the BBBK, sensor
readings can be obtained by reading the
corresponding device files

Path to device files can be found
at:http://hipstercircuits.com/reading-analog-adcvalues-on-beaglebone-black/

Additional resources:
http://youtu.be/z6b4zlh0IrE
Note: This YouTube tutorial is for the BeagleBone (not “Black”), so
the path to the device files are different. But the general approach is
similar
Reading sensors :Triple Axis Accelerometer

Triple Axis Accelerometer Breakout MMA8452Q

Schematic diagram(from
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Accelerometers/MMA8452Q
-Breakout-v11-fixed.pdf):
Reading sensors :Triple Axis Accelerometer

Wiring
Pin 3 on P9 Header
Pin 20 on P9 Header
Pin 19 on P9 Header
Pin 1 on P9 Header
Reading sensors :Triple Axis Accelerometer

Testing:
–
Install IC2 tools , run the following commands
–
opkg update
– opkg install i2c-tools
–
detect or probe IC2 bus, run the following commands
–
ic2detect
– ic2detect –l
–
check functionalities ic2 bus, run the following commands
–
–
ic2detect -F 1
detect or probe devices on a particular bus, run the following
commands
–
ic2detect -r -n
Sample
output
before a
ic2 device
is
connected.
, where n the ic2 bus adapter number
Sample output after a ic2
device is connected.
=> Device is at address
40 now
Reading sensors :Triple Axis Accelerometer

Testing ..cont:
–
View data(readings) from the i2c device , run following
command
–
i2cdump n address
- where bus= i2c bus number, address HEX address of the
connected device, we get by running icmpdetect –r -n
Example: for the example in previous page, where n = 3 and
the device address in at x40, run :
Sample output :
i2cdump 3 0x40
When we move the sensor, we observe some
values of the displayed registers change.
Detailed description of register address maps
and content of those registers can be found
in the data sheet of MMA8452Q
accelerometer starting page 18.
Additional Resources
–
Using i2c-tools with Angstrom Linux on the
BeagleBone Black
http://minix-i2c.blogspot.com/2013/07/using-i2c-toolswith-angstrom-linux-on.html
–
Beaglebone: An I2C Tutorial:
http://www.youtube.com/watch?v=8C2zk6B-eLU