Soc ninja title

Construction

CONSTRUCTION

Author: Jordi Guerrero.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Creative Commons License

PROTECTING YOUR BEAGLEBONE BLACK

The Beaglebone Black board is known to be very fragile. I take no responsibility for any damages. Take all the precautions and always double-check the wiring through all the steps.

To protect your BBB I recommend:

  • Use a transparent case with access to all the GPIO connectors. Optionally, you can use a Stacking Header (2x23) to easily access the GPIOS like the picture below.

BBB_case

  • Careful! Don't remove your BBB from the case with your micro SD plugged!
  • Always use the power button or the shutdown/poweroff command to correctly power off your BBB.
  • Before connecting anything verify twice voltages and GPIO numberings.

Beaglebone GPIO:

bbb_gpio

READING ENCODERS

Goals:

  • Using magnetic quadrature encoders (better than analog ones) with TI eQEP.

I use the TI eQEP Linux kernel module from Nathiel Lewis (http://nathanielrlewis.com/?p=87) which is included in BeagleBoard.org Debian image for BBB since 2014-May-14.

Note: I don't recommended updating your BBB if it is not necessary.

To know your Beaglebone version connect to BeagleBone Black over USB.

~ $ ssh root@192.168.7.2

or just type the command:

# cat /etc/issue

It shows a message:

Debian GNU/Linux 7

BeagleBoard.org BeagleBone Debian Image 2014-04-23

Also We can know our Linux distribution with the command: cat /etc/issue

In this example you have to update the BB Debian Image. 

HOW TO UPGRADE THE SYSTEM IN EMMC:

  • Download from  the last Debian 7 image (I experienced problems with Debian 8).

Beaglebone Black:  http://beagleboard.org/latest-images
Beaglebone Green: http://www.seeed.cc/beaglebone_green/

  • Unzip the image: 
$ xz -d <debian-image>.img.xz
  • Identify your sdcard: sudo fdisk -l.
  • copy the image to tour sdcard

$ sudo dd if=<debian-image>.img of=/dev/<sdcard-disk> 

TRICK: If you want to monitor the progress of dd use:

 # pv <debian-image>.img | dd of=/dev/<sdcard-disk> 
  • Plug your sdcard in BBB and connect it over USB. It will show:
~ $ ssh root@192.168.7.2
Debian GNU/Linux 7
BeagleBoard.org Debian Image 2015-11-12
  • It means that you are booting from your sdcard.
  • In /boot/uEnv.txt uncomment the line: #cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh near the end of the file.
  • Restart the system. BBB blue LEDs will start to blink in order (like Kitt in Knight Rider). After some minutes the LEDs will stay on.
  • Unplug the sdcard.
  • You have your BBB updated!


INTERNET CONNECTION

Now we need Internet connection to download a git project. We have two options:

CONNECTING A USB WIFI DONGLE

1.- Edit /etc/network/internet in your BBB:

1.1- WiFi Example with DHCP

allow-hotplug wlan0 # this line allows BBB to connect automatically your wifi connection
iface wlan0 inet dhcp
    wpa-ssid "essid" ##Change essid with your essid
    wpa-psk  "password" ##Change password with your wifi password

1.2- WiFi Example with static IP

# WiFi Example
allow-hotplug wlan0
iface wlan0 inet static
    wpa-ssid "essid" ##Change essid with your essid
    wpa-psk  "password" ##Change password with your wifi password
    address 192.168.1.10
    netmask 255.255.255.0
    network 192.168.1.0
    gateway 192.168.1.1


2.- Plug your USB wifi Dongle

3.- Reboot the BBB.

SHARING INTERNET USING NETWORK OVER USB

We need to download a git project. One option is sharing Internet over USB connection. I just follow the next guide: 

https://elementztechblog.wordpress.com/2014/12/22/sharing-internet-using-network-over-usb-in-beaglebone-black/

HOW TO USE TI EQEP WITH LINUX KERNEL MODULE

1.- Disablinng HDMI case. It's not necessary on Beaglebone Green.

First, we have to disable the HDMI cape. In /boot/uEnv.txt remove the # in line: 

##Disable HDMI (v3.8.x)
cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN

Be careful, don't disable the eMMc or HDMI/eMMC cape!

Reboot the BBB. It took me a couple of reboots to make the ssh connection work again (I don't know why...).

Test that you have the HDMI cape disabled:

~# cat /sys/devices/bone_capemgr*/slots
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN

If HDMI capes are without L (P-O--), you have successfully disabled HDMI cape.  

ASSEMBLING MOTORS AND ENCODERS

This is the most difficult task because the difficulty in soldering the encoder to the motors.

First read the Pololu manual for this encoder:

https://www.pololu.com/product/2598

I used this images as a reference:

ref_encoder

Steps:

steps_encoder

  • Begin to solder M1 and M2 to motors. Be careful to not overheat the motor connections.
  • Assemble motors to 1-Floor.stl frame with the brackets as parallel as possible.
  • Attach the wheels to the motors.
  • Solder a ribbon cable to encoder. Try to use the same color configuration for the connections in both motors. In my case black is for GND ans lilac for VCC.
  • Plug the magnetic wheel in extended back shafts.
  • Crimp ribbon connector 18-20 cm from motor.

ASSEMBLING THE FRAME

Fit the nut in its hole. Use a metal screw and a screwdriver to fully screwed in.

nut_insert

Attach the bearing balls.

bottom_fresonbot

Use 4 nuts, 4 nylon spacers and 4 screw(M3) to join the two frames.

spacers

assembling_frame_v2

Connect the battery holders in series and test the polarity with a multimeter. Solder two pin headers. I attached holders with Kapton tape.

battery_holder

Use a spacer to hold the battery.

spacer_battery

Cut the breadboard in three and attach it to the BBB case:

cut_protoboard

Attach the breadboard parts to the BBB case ot the top. Make sure that Power, Reset and User buttons remain accessible.

attach_protoboard

WIRING ENCODERS

I'm working in a shied to avoid wire work. Link. It's working but not fully tested, I take no responsibility for any damages.

connections_v2

LEFT ENCODER

encoder_left_GND -- GND

encoder_left_OUTB -- 100 Ohms -- BBB_P8-35

encoder_left_OUTA -- 100 Ohms -- BBB_P8-33

encoder_left_VCC -- BBB_P9-3 (3V3)

encoder_left_M2 -- driver_BO1

encoder_left_M1 -- driver_BO2

RIGHT ENCODER

encoder_right_GND -- GND

encoder_right_OUTB -- 100 Ohms Resitor  -- BBB_P8-42

encoder_right_OUTA -- 100 Ohms Resitor  -- BBB_P8-41

encoder_right_VCC -- BBB_P9-4 (3V3)

encoder_right_M2 -- driver_AO2

encoder_right_M1 -- driver_AO1

DRIVER

driver_GND -- GND

driver_VCC -- Switch_1 (7.2-7.5V)

driver_VIN -- regulator_VOUT (5V)

driver_BIN2-EN -- BBB_P9-14

driver_BIN1-PH -- BBB_P9-12

driver_AIN2-EN -- BBB_P9-16

driver_AIN1-PH -- BBB_P9-23

driver_MODE --- 22k Ohms Resitor --- driver_VCC

REGULATOR

Regulator_VOUT (5V) -- driver_VIN

Regulator_GND -- GND

Regulator_VIN (7.2-7.5V) -- Switch_1

SWITCH

Switch_1 -- driver_VCC

Switch_2 -- Battery(6xAA)_VCC (7.2-7.5V)

BATTERY

Battery_GND -- GND

Battery(6xAA)_VCC (7.2-7.5V) -- Switch_2 

BeagleBone Black

BBB_P8-1 -- GND

BBB_P9-1 -- GND

In the next photographies you can see all the wiring done also the wiring of IR sensor (sorry, at this moment I don't have any photography without IR wires). I used a color code to help to clarify the cable work. In the first photograpy there is a mistake, I connected right encoder to P8_11 and P8_12, but it should be to P8_41(grey), P8_42(white).

Wire colors: 

Black: GND || Red: 7.2V || Orange: 5V || Yellow: 3V3

Encoder_OUTB: White || Encoder_OUTA: Grey || encoder_M2: Blue || encoder_M1: Green

Driver_IN2-EN: Violet || Driver_IN1-PH: Dark green

wiring_1

wiring_2

wiring_3

GND connections

I made lots of GND's connections instead of a ground plane... maybe too many :)

Note: I didn't find any Pololu component in fritzing. Therefore I used an ADXL345 instead of the desired Pololu Driver.

gnd_bbb_v2

TESTING ENCODERS

LEFT ENCODER

GPIOs:

P8-33

P8-35

# echo bone_eqep2 > /sys/devices/bone_capemgr.9/slots
# cat /sys/devices/ocp.3/48304000.epwmss/48304180.eqep/position

RIGHT ENCODER

GPIOs:

P8-41

P8-42

# echo bone_eqep1 > /sys/devices/bone_capemgr.9/slots
cat /sys/devices/ocp.3/48302000.epwmss/48302180.eqep/position


Just in case that you have problems with eqep1 or eqep2 use eqep0.

EQEP 0

GPIOs:

P9_42

P9_27

~# echo bone_eqep0 > /sys/devices/bone_capemgr.9/slots
~# cat /sys/devices/ocp.3/48300000.epwmss/48300180.eqep/position

Make sure that: 

  • Approximately they count 1200 ticks per revolution.
  • When you turn forward add ticks and when you turn backward subtract ticks. In opposite case, exchange GPIOs
Other option to test encoders is use my program test_encoders.sh.
~# cd fresonbot-HEAD-cf5faee/bashScripts/
~fresonbot-HEAD-cf5faee/bashScripts# ./test_encoders.sh

TESTING MOTORS

I programed in python a test code for motors. test_motors.py move the robot, forward, backward, turn left and finally turn right.

~# cd fresonbot-HEAD-cf5faee/
~fresonbot-HEAD-cf5faee/# python test_motors.py

If the robot turns crazy, use stop.py:

~fresonbot-HEAD-cf5faee/# python stop.py

ADDING IR SENSORS

I recommended to read the datasheet of the Sharp IR sensor. Link.

There are two important notes:

[...]

  • In order to decrease measuring error by moving direction of object, we recommend to mount the sensor like below drawing. 

datasheetir_1

  • In order to stabilize power supply line, we recommend to connect a by-pass capacitor of 10μF or more between Vcc and GND near this product.

[...]

The first note is the reason why I put the IR sensors in vertical orientation. Also I use a 10 µF capacitor across power and ground close to the sensor.

I use Beaglebone analog input to read IR sensors. The BeagleBone Black hardware has six analog-to-digital converter (ADC) modules associated with six analog input pins. You can use these pins to measure positive voltages in the range 0 V (GND_ADC) - 1.8 V (VDD_ADC).

Caution: Never connect a voltage greater than 1.8 across the ADC pins. Voltages greater than 1.8 V can damage the board.

We have to reduce output IR sensor voltage. The easy way is to use a voltage divider.

Although in Control of mobile robots use 10kΩ and 22kΩ to voltage divider, I found a link that recommend 1kΩ and 470Ω to avoid lots of  noise. I made my test to confirm this isue:

With 10kΩ-22kΩ

10k-22k


With 1kΩ-470Ω

1k-470

WIRING IR SENSORS

I'm working in a shied to avoid wire work. Link. It's working but not fully tested, I take no responsibility for any damages.

Make sure that your voltage divider is connected properly, otherwise you could broke your beaglebone.

              Ra              Rb
Vin(5V)--[== 1K ==]--+--[== 470 ==]----+
| |
| |
| |
Vout(BBB_AINX) Gnd

Compact wiring:

compact_irwire

#
# _2_
# 3/ \1
# | |
# | |
# 4| |0
#

IRsensor_Right_back_Yellow ---- BBB_AIN0
IRsensor_Right_front_Yellow ___ BBB_AIN1
IRsensor_Front_Yellow ---- BBB_AIN2
IRsensor_Left_front_Yellow ---- BBB_AIN3
IRsensor_Left_back_Yellow ---- BBB_AIN4

TESTING IR SENSORS:

First enable the ADC ports:

~# echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots

Read the IRSensor, use AIN0, AIN1, AIN2, AIN3, or AIN4:

~# cat /sys/devices/ocp.3/helper.12/AIN0
Other option to test encoders is use my program test_IR.py
~# cd fresonbot-HEAD-cf5faee/
~fresonbot-HEAD-cf5faee# python test_IR.py

COMMENTS

Please feel free to leave any comments. Any improvement would of course be very welcome!

SOURCES:

eqep:

Beaglebone GPIO:

Pololu Driver:

Pololu Encoder:

Pololu Regulator:

IR sensor datasheet:

IR Sensor voltage divider:




If you found anything useful enough and you want to thank us for that, please consider donating to people who need it, like the NGO OXFAM. Thank you !


Comments

Comments are manually approved. Just be a bit patient :-)

There are currently no comments

New Comment

required

required (not published)

optional

Recent Tweets