Skip to content

BeagleBone Black for Servo Motor

Wissam Halimi edited this page Jul 7, 2014 · 3 revisions

Setting up BeagleBone Black on the Computer

First, there are 2 drivers needed to be installed:

  1. Network Driver
  2. Serial Driver

Needed installation packages having the suitable distributions for the lab owner’s system can be found on this website: https://learn.adafruit.com/ssh-to-beaglebone-black-over-usb/overview

Once the BeagleBone Black shows as a connection in your Network settings, you can proceed to ssh-ing your BBB. To do so, you simply need to type the following in your terminal: ssh 192.186.7.2 -l root

Configure Header Pins for PWM

A second step is to configure the pins of the headers present on the BeagleBone Black (BBB) to accept PWM controls. This is done by executing the following in the terminal:
echo am33xx_pwm > /sys/devices/bone_capemgr.8/slots
echo bone_pwm_P8_13 > /sys/devices/bone_capemgr.8/slots

At this stage, the pin 13 of header P8 (the pin to which is connected the control of the servo motor) is configured for PWM. However, this configuration isn’t saved once BBB is turned off. If the lab owner wished to remember this configuration, they should add this to the file “uEnv.txt”:

  • Open the file: more /media/BEAGLEBONE/uEnv.txt
  • Add this: capemgr.enable_partno=am33xx_pwm,bone_pwm_P8_13 so the file looks like that:
    optargs=quiet drm.debug=7 capemgr.enable_partno=am33xx_pwm,bone_pwm_P8_13

Sharing an Internet Connection with BeagleBone Black

We will refer to this video tutorial for setting up the internet connection in the BBB: http://www.youtube.com/watch?v=Cf9hnscbSK8

Those are the steps to follow:

  1. Connect you BBB to your computer using the USB cable coming with the board. To know to which socket on the board you need to plug the cable, refer to the one-page catalogue coming with the board. Once your BBB is recognized by the system, and is present on the network, eject it from the Finder; but keep the board connected to the computer with the cable.
  2. Go to System Preferences -> Sharing. On the left column in the window, check "Internet Sharing" and in the right column, check BeagleBoneBlack. This should allow sharing the internet of your computer with the BeagleBone Black.
  3. Open the terminal and:
    screen /dev/tty.usb* 115200
    If you are using a BBB shippped after November 2013. Otherwise:
    screen /dev/tty.usb*B 115200
    Your BBB's USB might not be connected to tty.usb. Go to the /dev directory and check which tty.usbXXX is corresponding the connection with your BBB. For example, in my case it was tty.usb133.
  4. Use root for the login to the beaglebone
    Next you need to: udhcpc -i usb0
    After this step, if all is alright, you should be able to ping www.google.com for example.
  5. Next you need to:
    ifconfig
  6. Kill the screen. The shortcut is Ctrl+a+\

At this stage, you are connected to the internet and you are able to do whatever you wish to do over the internet. To have access again to the memory of you beaglebone, you need to:
ssh [email protected]

Setting up the Smart Device Repository on BeagleBone Black

A third step is to download the code that is meant to run on the BeagleBone Black. Since the code is hosted on github, it is needed to get internet connection on the board. For this please refer to Sharing an Internet Connection with BeagleBone Black

The code can be found on this link: https://github.com/go-lab/smart-device The lab owner has to create a directory in which s/he wishes to host the code. So first s/he creates a directory on the BBB:
mkdir smart_device
cd smart_device
And now, s/he clones the repo into the directory:
git clone https://github.com/go-lab/smart-device
Next comes starting the websocket server:
cd BeagleBoneBlack/servo-beaglebone-black/bbb-pwm
npm install #needed only once to install the project dependencies
node websocket-server.js

Setting up the Client Web Server

On the computer, the lab owner also clones the same repo following the same steps detailed in , and:
cd BeagleBoneBlack/servo-beaglebone-black/websocket-client
node web-server.js

And the lab is ready to be used!

For how to access the lab through a web page, please refer to Access to the Web Page

Access to the Web Page

To connect to the Smart Device and control the Servo Motor lab, there are 2 cases:

  1. If the user is on the computer of the lab owner, they go to: www.localhost:8000/index.html
  2. If not s/he just needs to replace “localhost” by the IP of the machine where the web server is running

On the web page, the users:

  • Know the status of the lab:
  • Is PWM configured or not
  • Is lab On of OFF
  • Know at which position the arm of the motor is, by looking at the position of the scroll bar and the number provided next to it
  • Can control the servo motor by scrolling right and left to make the arm of the servo move clockwise and counterclockwise respectively