Presentation is loading. Please wait.

Presentation is loading. Please wait.

Internet of Things with Intel Edison Servo motors with Pololu Controller Pierre Collet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com.

Similar presentations


Presentation on theme: "Internet of Things with Intel Edison Servo motors with Pololu Controller Pierre Collet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com."— Presentation transcript:

1 Internet of Things with Intel Edison Servo motors with Pololu Controller
Pierre Collet Intel Software

2 Objectives Objective Servo motors are controlled with a signal called PWM. To interact correctly with a PWM device, you need to generate a strict signal. Obvious for a basic microcontroller, not so much for a general purpose processor with a regular linux. Two solutions : Use a Real Time OS. On Edison the second processor is running a Real Time OS so we can do it on Edison itself. Use an external PWM card, connected with USB. A good example : Pololu Maestro card. Today, we’ll use the Pololu Maestro with 6 PWMs.

3 Setup

4 LibUSB LibUSB We are connected to the Pololu card with USB, using USB messages. We need libusb-1.0-dev and we’ll use a package for Yocto, the Linux by default on Edison. To install : echo "src/gz all  > /etc/opkg/base-feeds.conf echo "src/gz edison  >> /etc/opkg/base-feeds.conf echo "src/gz core2-32  >> /etc/opkg/base-feeds.conf echo "src mraa-upm  > /etc/opkg/mraa-upm.conf opkg update opkg install libusb-1.0-dev

5 Using the Master USB port
Master/Client When you plug Edison to your PC with a USB cable, you see Edison as a serial-over-USB device and a mass storage device. That’s the client mode of USB. Switch But Edison is also a PC, acting as master. To use the full size USB port on the board as a master, operate the switch. Remember to switch it back after this lab.

6 Hardware Connecting hardware Plug and boot your board.
Connect the Pololu card to Edison on USB host connector using a standard mini USB Cable. Connect a servo motor on Pololu channel #1. In the next slide we’ll see how to power the Pololu from a USB port.

7 Hardware – Power from USB
The Pololu has 2 power requirements : Very minimal for the microcontroller. This power comes from the USB cable. High for the servos. We need to get this power from an external source and connect it to the 2 power pins of the Pololu. Two methods Usually, we would get a 6V battery with the right connector. If you have one, use it. If you don’t, it’s possible to : cut a USB cable (it’s not reversible, obviously), separate wires get the 2 power wires (red and black) connect manually the 2 wires to the Pololu power pins

8 Hardware Regular USB cable DATA Modified USB cable POWER ONLY Vin #0
#5

9 Script

10 Shell script to control a servo
Binaries We provide you 3 binaries to control 3 parameters : The targeted position of the servo motor The speed of the servo motor (0 is max speed) The acceleration of the servo motor (0 is max acceleration) For each binary, the first argument is the channel number and the second parameter is the value. How to run this files # ./set_accel 0 0 # ./set_speed 0 0 # ./set_target The order is automatically sent to the Pololu card via USB. These binaries are C++ program using libusb-1.0.

11 Shell script to control a servo
A simple bash script to control a servo motor #! /bin/bash while : # infinite loop do ./set_target # channel 0 targeted position is set to 1000 sleep 1s # we wait a second ./set_target sleep 1s Done It’s just moving the servo from 1000 to 2000 and back, with 1s pauses.

12 C Code

13 Set_target source code
A C++ main function using libusb #include <iostream> #include <string> #include <libusb-1.0/libusb.h> #include <unistd.h> #include <stdlib.h> using namespace std; int main(int argc, char *argv[]){ if(argc < 3) cout << "Usage: binary servo_number target_value" << endl; int servo = atoi(argv[1]); int value = atoi(argv[2]);

14 Set_target source code
Creating libusb structures libusb_device **devs; libusb_context *ctx = NULL; libusb_device_descriptor descr; libusb_device *pololu; string idPololu ("137"); int r; int found = 0; ssize_t cnt, i; Initializing libusb r = libusb_init(&ctx); libusb_set_debug(ctx, 3); Seeking devices cnt = libusb_get_device_list(ctx, &devs);

15 Set_target source code
For each device found for(i = 0; i < cnt; i++) { r = libusb_get_device_descriptor(devs[i],&descr); //pololu id is 137, so let’s find it if(descr.idProduct == 137) { pololu = (devs[i]); found = 1; break; Stop looking for devices and don’t unreference the pololu } libusb_unref_device(devs[i]);

16 Set_target source code
Sending target command if(found) { libusb_device_handle **handle; r = libusb_open(pololu,handle); r = libusb_detach_kernel_driver(*handle,0); if(r < 0 && r != LIBUSB_ERROR_NOT_FOUND) { cout<<"Error: detach kernel driver failed"<<endl; return 1; } r = libusb_claim_interface(*handle,0); r = libusb_control_transfer( *handle,0x40,//request type 0x85, //request value, //value servo, //servo number NULL,0,5000);

17 Set_target source code
Closing USB connection r = libusb_release_interface(*handle,0); libusb_close(*handle); } libusb_free_device_list(devs, 1); libusb_exit(ctx); return 0;

18 Conclusion Conclusion Idea : Integrate Edison and Android ?
Edison being a PC, you can expect to find a lot of great USB solutions to all your problems. Same thing for webcams. For PWM, you could do without the Pololu Maestro, both are good solutions. Idea : Integrate Edison and Android ? An IoT project which need a remote ? Use your Android smartphone to control Edison ! We’ve seen how to create a web form with NodeJS, you can also create an Android app with a native look and feel.

19

20 License Creative Commons – By 3.0
You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work to make commercial use of the work Under the following conditions: Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). With the understanding that: Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. Other Rights — In no way are any of the following rights affected by the license: Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; The author's moral rights; Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.


Download ppt "Internet of Things with Intel Edison Servo motors with Pololu Controller Pierre Collet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com."

Similar presentations


Ads by Google