Showing posts with label USB. Show all posts
Showing posts with label USB. Show all posts

Saturday, August 16, 2014

Logic Supply’s Compact USB Wi-Fi Adapter for the Beaglebone Black

I wanted to put my Beaglebone Black onto my Wi-Fi network rather than running a network cable to it so I purchased Logic Supply’s USBWi-Fi adapter for the Beaglebone Black.   The only drawback I have found with the Wi-Fi adapter is the lack of instructions. This post will document how I setup the Wi-Fi adapter on my Beaglebone Black to hopefully assist others.

The package says that the latest release of the Beaglebone Black, with a Debian image, includes the drivers for the Wi-Fi module. I have been using the Angstrom distribution, mainly because the Bluetooth adapters work much better with it however if I have Wi-Fi I would not need the Bluetooth adapter.  So I decided to give the new Debian distribution another try with the Wi-Fi adapter.

Once I flashed the Debian image onto my Beaglebone Black (see instructions on how flashing the Beaglebone on the getting started page (http://beagleboard.org/getting-started)) I plugged the USB Wi-Fi adapter into the Belkin 7-Port USB Powered Hub that is connected to my BeagleBone Black.  Logic Supply strongly recommends that due to the Wi-Fi adapter’s power consumption, you use a 5 Volt AC adapter, rather than powering the Beaglebone Black from USB, when using this adapter.  I would say that is true with any USB Wi-Fi adapter, which is why connected the Wi-Fi adapter to the powered USB hub.

When I plugged the Wi-Fi adapter into the hub, I was hoping that the OS would detect the adapter and configure it then all I would have to do is to connect it to my Wi-Fi network.  Well I was a bit disappointed but that is OK because I like a good challenge and since there were no instructions (who actually reads instructions anyway) it was up to me to figure out how to get it working.

The first thing I did was to unplug the Wi-Fi adapter from the USB hub.  I then ran the following command to monitor any changes to the system log file and plugged the Wi-Fi adapter back in:

            tail –f /var/log/syslog

After plugging the Wi-Fi adapter back in, the log revealed that the OS setup the adapter with the device name ra0.  Once I had the device name, I open up the WICD Network Manager and went to the preferences to add the ra0 device name as the wireless interface.



I then clicked OK to go back to the main screen.  On the main screen I waited a couple of seconds and then clicked Refresh to refresh the list of networks.



I found my network and clicked Properties to set the network properties



And then I was on my Wi-Fi network.  I hope these instructions are able to assist others in configuring Logic Supply’s USB Wi-Fi adapter for the Beaglebone Black.


Sunday, June 15, 2014

LightZord - The Father's day robot

For Father’s day, I wanted to make a totally awesome robot but I did not know what a totally awesome robot would look like so I asked my daughters.  This post shows the robot that we came up with.  I also bought a second Beaglebone Black with a 7.0” LCD cape to make a remote controller unit for our totally awesome robot.  We named the new robot LightZord and below is his first video:


Here is another picture of LightZord wearing his Lei:



As you can see, he has a little bit of a weight issue that causes him to wobble a lot when he turns (at least I think that is the problem).  Not really sure how to solve this issue yet but if anyone has a suggestion please leave a comment below.

Here are a couple of pictures of the inside of LightZord:




The insides are wired exactly the same way as my previous robot and this is documented in the following posts:


What really makes LightZord different from my first robot is the remote controller unit.  To build this controller I purchased a second Beaglebone Black Rev C, 4D Systems 7.0”LCD Cape, second BluetoothUSB adapter and a second EasyACC battery charger. 






The new Beaglebone black Rev C comes with Debian preinstalled but I had a lot of issues trying to get the Bluetooth adapter to work with the preinstalled version of Debian so I put Angstrom on it.  Beaglebone.org’s getting started page documents how to install a new OS.

I then attached the Beaglebone Black to the 7.0” touchscreen cape as the documentation shows.  Once I powered up the Beaglebone, with the cape, the only issue I encountered was the touch screen calibration application did not automatically start.  Since the touch screen was unusable without the calibration, I connected the Beaglebone black to my network, SSH’d to the Beaglebone and ran the ts_calibrate command manually.  This did not actually solve the issue since it did not update the calibration so I copied the output of the ts_calibrate command to /etc/pointercal.  This forced the calibration utility to run the next time the Beaglebone started and correctly calibrated the touchscreen.

There is a virtual keyboard under the Universal Access menu option titled Florence Virtual Keyboard application.  This keyboard works really well with the touch screen but I would not recommend configuring your Beaglebone using that small keyboard.  It is a lot easier to connect your Beaglebone to your network and SSH in.

Now that I had my touch screen connected and calibrated, I configured the USB Bluetooth adapter as documented on in this post.  I then paired the controller with the LightZord robot and ran the Rover 5 rfcomm client application whose code is inthis post.  From here I could control LightZord buy typing in the following commands:
u – full speed
j – all stop
i – increase speed
k – decrease speed
o – set direction all forward
i – set direction all reverse
z – spin left
c – spin right

This was a pretty cool Father’s day project with my daughters.  There is still a couple of to-do’s left.  I want to eliminate the wobbling when LightZord turns, I want to add a GUI to the Rover 5 rfcomm client application and finally we still need to paint/decorate LightZord.  After all that is done, we can then add some sensors and create a robot that can move around by himself.


Sunday, May 11, 2014

I just got my BeagleBone Black, now what?

When I received my BeagleBone, I wanted to start build my Robot right away but I quickly realized that I needed to start off by setting up my BeagleBone and configuring the Linux Distribution.  You can install several different distributions on your BeagleBone but I would recommend starting with standardAngstrom distribution.  Once you are more familiar with your BeagleBone then you can try other distributions.  When you first login into the standard Angstrom distribution, you will login as the root user with no password.

A great place to start is BeagleBone’s Getting started page.  This page walks you though the initial setup, installation of the drivers on your local computer and flashing the latest software onto your BeagleBone.  This page documents these steps very well so I will not rehash them here but I did have one problem when I went though this page.   The problem was I have an Ubuntu laptop and a MacBook Pro but no Windows machine to write the image to the SD card as documented on the getting started page.  After a brief Google search, I found Adafruit’spage that walked me though using PiFiller to write the image to a SD card.  The total time for this setup was approximately two and a half hours for me so patience is needed. 

I connected my BeagleBone black to an old monitor I had lying around the house by using a micro HDMI to VGA converter.  I also bought a mini wireless keyboard with a trackpad so I was able to program my BeagleBone like a desktop computer.  While this is not necessary, it makes learning the BeagleBone a lot easer.  I used Cable Matters Active Micro HDMI to VGA Male to Female Adapter with 3 Feet USB Power Cable in Black  and Logitech Wireless Touch Keyboard K400 with Built-In Multi-Touch Touchpad  they both worked out of the box with no configuration.  I am also using a powered USB hub to connect and power USB devices.  I can also use the USB hub to power my BeagleBone.  The USB hub that I am using is the Belkin Ultra-Slim Series 7-Port USB 2.0 Hub .

Here is a picture of my rather messy setup.  

The USB hub is plugged into a wall outlet and the white cable from the hub goes into the USB port of the BeagleBone.   Below the white cable is the mini HDMI cable that is connected to the mini HDMI to VGA converted.  The USB hub also powers this converter.  The yellow cable, on the opposite side of the BeagleBone, is an Ethernet cable that connects the BeagleBone to my network (and the Internet).  The black cable next to the Ethernet cable goes from the USB client port to the USB hub to power the BeagleBone.  The USB client cable can also connect directly to your computer instead of the USB hub.  The dongle you see connected to the USB hub is for the Logitech keyboard.

If you do not want to connect your BeagleBone to a monitor and keyboard, you can access your board by connecting it to your computer’s USB port.  You could then use a SSH client to connect to your BeagleBone.  If you have a Windows machine you will need to download a SSH client like Putty.  If you have a Linux or Mac machine, you already have a SSH client installed.  If your BeagleBone is connected to the USB port on your local machine and the drivers are properly installed you can SSH to root@192.168.7.2 to access your BeagleBone.

Now lets spend a little bit of time setting up our Linux environment.  Note, To download and install new software you will need to connect your BeagleBone Black to the Internet using the Ethernet port or by adding a WIFI adapter.

Setting a root password:
By default, the root user on your BeagleBone Black does not have a password.  Obviously this is not good so lets set a password by running the following command:

passwd

Setting up NTP:
Now we will want to setup NTP (Network Time Protocol) because the BeagleBone Black does not contain a Real Time Clock therefore it loses its time/date settings each time it powers off. 

Lets begin by setting the timezone, for me this is the Eastern timezone.  We will then set the correct time so we can use the opkg utility to install the ntp software:

ln –s /usr/share/zoneinfo/America/New_York /etc/localtime
ntpdate –u pool.ntp.org

opkg update
opkg install ntp

Now we need to configure NTP.  We will start off by editing the /etc/ntp.conf file.  Since I live in the US, I use the US servers.  You can go to www.pool.ntp.org to find your local servers.  My ntp.conf file looks like this:

driftfile /etc/ntp.drift
logfile /var/log/ntp.log

server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
server 3.us.pool.ntp.org

# Defining a default security setting
restrict default

Now lets enable the NTP services but running the following commands:

systemctl enable ntpdate.service
systemctl enable ntpd.service

Finally we need to modify the /lib/system/system/ntpdate.service file.  My ntpdate.service file looks like this:
[Unit]
Description=Network Time Service (one-shot ntpdate mode)
Before=ntpd.service

[Service]
Type=oneshot
ExecStart=/usr/bin/ntpd -q -g -x
ExecStart=/sbin/hwclock --systohc
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Now your BeagleBone Black will have the correct time when you start it up, if it is connected to the Internet.

Setting the terminal prompt:
We will be doing a lot of work from the Linux terminal and the default terminal prompt does not tell you much.  Lets set the terminal prompt so it shows the logged in user, machine and the directory names.  To do this, edit the /etc/profile file and add the following line at the end of the file:

export PS1="\u@\h \w> "

Setup Python:
We will be making extensive use of Python and the Adafruit library.  Python is already installed and setup but we need to install the Adafruit library.  To do this, we need to first install some Python utilities:

opkg install python-pip python-setuptools python-smbus

Now we can use the Python package management tool to install the Adafruit library.

pip install Adafruit_BBIO

Browse Local Documentation:
If you installed the standard Angstrom image, your BeagleBone will have a local web server running that contains a lot of useful information.  I would recommend reviewing the information on this page and going though some of the basic demos.  I would also recommend printing out the Hardware Documentation section that contains the layout of the expansion headers.  The reason for this is you will want to power off the BeagleBone when you are connecting items to the expansion headers and will not have access to the images showing the layout.

To access the local documentation when the BeagleBone is connected to the USB port on your local machine, open a web browser and go to 192.168.7.2.

If your BeagleBone Black is connected to your local network, you can put the IP Address of your BeagleBone Black into your web browser to see the documentation.

Beginning some projects:
Your BeagleBone is now setup and ready to go.  As I mentioned earlier, you will probably want to try some of the demos in the local documentation.  My next few posts will show some basic projects that have helped me learn how to connect items to the expansion headers and how use the Adafruit library with Python.