PWM

download PWM

of 3

description

A primer on PWM.

Transcript of PWM

Setting up PWM:

From command line:ssh beaglebone.local -l root# ssh into beaglebone

Follow this website: http://digital-drive.com/?p=146more /sys/devices/bone_capemgr.8/slots # Cape Manager - checks overlaysConfigure pin 13 on header P8 for PWM by executing the following commands:echo am33xx_pwm > /sys/devices/bone_capemgr.8/slots echo bone_pwm_P8_13 > /sys/devices/bone_capemgr.8/slotsMake these overlays/adjustments load at startup:nano /media/BEAGLEBONE/uEnv.txt Add these to uEnv.txt: capemgr.enable_partno=am33xx_pwm,bone_pwm_P8_13 so that it looks like this:optargs=quiet drm.debug=7 capemgr.enable_partno=am33xx_pwm,bone_pwm_P8_13

cd into /sys/devices/ocp.2/pwm_test_P8_13.10 and then list files (ls)ls gives the following readout:driverduty modalias period polarity power run subsystem ueventThe important files are duty, period, and run.

Servo connections:black to P9_01 (Ground)red to P9_03(VDD 3.3V)white to P8_13 (PWM)

To tether internet to BBB:http://www.crashcourse.ca/wiki/index.php/BBB_networking_in_tethered_mode

On the BBB side, manually: route add default gw 192.168.7.1echo "nameserver 8.8.8.8" > /etc/resolv.confAnd on the server side: echo 1 > /proc/sys/net/ipv4/ip_forwardiptables -A POSTROUTING -t nat -j MASQUERADE

Seting-up a Node.js WebSocket server on the BBB in order to communicate with an HTML5 web client:cd /var/lib/cloud9mkdir websocket-servercd websocket-server/git initPull down code: git clone http://github.com/bparvizi/beaglebone-black.gitNow cd into beaglebone-black/bbb-pwm/ -- cd beaglebone-black/bbb-pwm/Use ls command to see files in folder bbb-pwm:README.md bbb-pwm.js node_modules package.json websocket-server.js

We only need to be concerned with the following in the above project folder: bbb-pwm.js- JavaScript file for controlling PWM and setting the period, run, and duty cycle. websocket-server.js- JavaScript file for running the Node.js WebSocket server. node_modules- Directory containing the project dependencies. Websocket-serber.js is the file that allows for PWM.Navigate to Cloud 9 IDE: http://192.168.7.2:3000/Open file: websocket-server/beaglebone-black/bbb-pwm/websocket-server.jsRun the file which gives this output on the console when run: PWM Configured...

Install node.js: sudo apt-get install nodejsStuck on Running the Web Client: http://digital-drive.com/?p=205Specifically: node web-server.js/var/lib/cloud9/websocket-server/beaglebone-black/websocket-client