With
a small size, extremely low power consumption and great Linux support, arm
based boards are great for developing small projects. The Beagle Bone Black was
launched in 2008; Texas Instruments as an open source computer developed the
original Beagle Board. It featured a 720 MHz Cortex A8 arm chip and 256MB of
memory. The BeagleBoard-xm and Beagle Bone were released in subsequent years
leading to the Beagle Bone Black as the most recent release.
Setting up the Cluster
2x beagle bone blacks (Connected to
machines)
2x Ethernet cables
2x Ethernet cables
With ifconfig change the ip address
and Edit /etc/hostname and place the new
hostname in the file.
hostname beaglebone1
127.0.0.1 localhost
192.168.1.51 beaglebone1
(Example)
192.168.1.52 beaglebone2
(Example)
Creating a Compute Cluster
With MPI
MPI is a standardized system for passing messages
between machines on a network. It is powerful in that it distributes programs
across nodes so each instance has access to the local memory of its machine and
is supported by several languages such as C, Python and Java. There are many
versions of MPI available MPICH is one of them. As a root execute following
commands.
sudo apt-get update
sudo apt-get install gcc
sudo apt-get install libcr-dev mpich2 mpich2-doc
MPI works by using SSH to
communicate between nodes and using a shared folder to share data. The first
step to allowing this was to install NFS.
Install NFS server on first BBB1
using # apt-get install nfs-server
Install NFS client second
BBB2 using # apt-get install
nfs-client
Create a directory to be used for MPI on each BBB with mkdir
/hpcuser
Synchronise the folders by issuing the command on the master
node:
# echo "/hpcuser *(rw,sync)" | sudo tee -a
/etc/exports
Mount the master's node
on slave so they can see any files that
are added to the master node:
# mount beaglebone1:/hpcuser /hpcuser
create the hpcuser and assign it the shared folder:
# useradd -d /hpcuser hpcuser
To generate a key to use for the SSH communication.
# su - hpcuser
# sshkeygen -t rsa
Testing MPI
Once the machines were able to successfully connect to each
other, Write a simple program on the master node.
log in as hpcuser,
create a simple program in its root directory /hpcuser and call
it mpi1.c. MPI needs the program to exist in the shared folder so it can run on
each machine.
The program below simply displays the index number of the
current process, the total number of processes running and the name of the host
of the current process. Finally, the main node receives a sum of all the
process indexes from the other nodes and displays it:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int rank, size, total;
char hostname[1024];
gethostname(hostname,
1023);
MPI_Init(&argc,
&argv);
MPI_Comm_rank
(MPI_COMM_WORLD, &rank);
MPI_Comm_size
(MPI_COMM_WORLD, &size);
MPI_Reduce(&rank,
&total, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
printf("Testing
MPI index %d of %d on hostname %s\n", rank, size, hostname);
if (rank==0)
{
printf("Process sum is %d\n", total);
}
MPI_Finalize();
return 0;
}
Created a file called machines.txt in the same directory and
place the names of the nodes in the cluster inside, one per line. This file
tells MPI where it should run:
beaglebone1
beaglebone2
compile the program using
mpicc and the test it :
mpicc mpi1.c -o mpiprogram
mpiexec -n 8 -f machines.txt ./mpiprogram
TITLE
: INTERAFCING OF STEPPER mOTOR.
OBJECTIVE
:
Study of stepper motor interface with BBB.
S/W
AND H/W REQUIREMENT :
BBB ,Stepper motor driving circuitry and stepper motor
host .
REFERENCES
:
THEORY
:
A unique type f motor useful for
maving things in small increments is a stepper motor. Stepper motors rotate or
step from one fixed position to the next. Stepper motors are used in do matrix
printers, floppy disk( used to position the read and write head over the
desired track ) and to move the pen around on x-y plotters.
Common
step sizes for stepper motors range from 9 to 30 degrees.A stepper motor is
stepped from one position to the next by changing the currents through the
fields in the motor. The two common field connections are reffered to as two
phase and four phase
Step Switch
SW4 SW3
SW2 SW1
1 0 0
1 1
2 1 0
0 1
3 1 1
0 0
4 0 1
1 0
STEP
TO DO :
Stepper
motor PIO is connected to BBB board .
Connections are done using 4GPIOs on
header p9.
•
Send
a rotation patter for the stepper motor.
•
Observe
the rotation of the motor.
Interfacing
diagram
Program
in Python to rotate the stepper motor
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P9_11", GPIO.OUT)
GPIO.setup("P9_12", GPIO.OUT)
GPIO.setup("P9_13", GPIO.OUT)
GPIO.setup("P9_14", GPIO.OUT)
while True:
GPIO.output("P9_11", GPIO.HIGH)
GPIO.output("P9_12", GPIO.LOW)
GPIO.output("P9_13", GPIO.LOW)
GPIO.output("P9_14", GPIO.LOW)
time.sleep(0.25)
GPIO.output("P9_11", GPIO.LOW)
GPIO.output("P9_12", GPIO.HIGH)
GPIO.output("P9_13",
GPIO.LOW)
GPIO.output("P9_14", GPIO.LOW)
time.sleep(0.25)
GPIO.output("P9_11", GPIO.LOW)
GPIO.output("P9_12", GPIO.LOW)
GPIO.output("P9_13", GPIO.HIGH)
GPIO.output("P9_14", GPIO.LOW)
time.sleep(0.25)
GPIO.output("P9_11",
GPIO.LOW)
GPIO.output("P9_12", GPIO.LOW)
GPIO.output("P9_13", GPIO.LOW)
GPIO.output("P9_14", GPIO.HIGH)
time.sleep(0.25)
GPIO.cleanup()
No comments:
Post a Comment