 Everybody have a plate of food. Don't fall asleep yet. That's the toughest time to talk. So, first speaker in the afternoon session is Deepak Karki, enabling cyber-physical system using Bigel Black and Bigel Bone Black and Python. And I will let him introduce himself because I think he'll do a better job. Hi guys, I'm Deepak. I am a hobby hardware hacker and a software developer. I'm currently interning with PayPal. I'm still a final year student at PES University in India. So, today I thought I'll give you guys a bit of an introduction on how to start hacking with the Bigel Bone Black and a couple of projects which I've done with Bigel Bone Black and Python. So, I was hoping this one would be under the open hardware track because it has a decent bit of Python but it also has some Node.js components. So, I hope none of you will be angry with me for using Node. So, yeah, I was a GSOC student, Google Summer of Code student last year. I interned with BigelBone.org. I was involved in building some real-time kernel drivers and this year I'm mentoring for the same organization. So, here's the agenda. So, I think I'll start with the introduction to the Bigel Bone Black specification, what it's capable of, followed by a PyBBIO. It's a Python library for Bigel Bone Black IO. Then, a bone script. It's something similar in Node.js, followed by PyBBIO. It's a Python library for getting real-time control over the co-processor on this board, followed by projects I got. It's an IoT framework which is under development. It's my thesis project for my final year. So, if you have more time, you can have a look at some cool projects built with the Bigel Bone Black. So, this is a Gigahertz Linux computer. It can run Debian off the shelf. So, all you have to do is take the Bigel Bone Black. They give you a USB connector. So, it exposes R and DIS interface or Ethernet over USB if you prefer to call it. So, you see it starts. So, these four LEDs, once they start blinking, you know it started. So, under a minute, you can have your board up and running. So, just remove the board from this package. You need time to start it back and you're plugged in and it started. So, it's really simple to...it started. Now, I can just SSH into it. It's got an IP address. I can just SSH into it and start using it. So, it gives me a Linux terminal control. So, it has a 4GB EMMC onboard flash which basically has the Linux image. Or, alternatively, you can use an SD card. So, you can build your custom OS, put it on an SD card and start hacking around. It has a 512MB RAM. Then it has...the most interesting part is this two, yeah, PRU 32-bit microcontrollers. So, these things are...they give you real-time I.O. in a Linux environment. You can think of them as a co-processor. PRU basically translates to programmable real-time units. So, they're remote processors which you can program and hack around with. So, these are the ways you can connect to your BeagleBone Black. You can use the USB host which works out of the box. Or, you can use Ethernet. You can use Wi-Fi. It takes less than half an hour to set it up. I've used Wi-Fi a lot of times. And, if you're trying to use Linux with graphical environment... So, you have an HDMI output, micro-HDMI which you can see over here. So, this is micro-HDMI. So, you can just connect it to your TV or any other HDMI monitor and start using it. So, as of now, it runs Debian. It comes with a pre-built image of Debian on the EMMC image. The EMMC card. There's also Android KitKat port available now. And Ubuntu plus Cloud9 IDE. So, why the BeagleBone Black as compared to the Raspberry Pi or Arminos? This is one completely open-source platform including the board files. Which gives you a huge lot of capabilities. So, you have a lot of IO ports starting from I2C, SPI, USB, MMC, PWM. Then, ECAP, MCSP, GPIO, a lot of GPIO pins. So, in case you're trying to build a robot or something along those lines, it can be very useful. The PRU which I talked about previously can be used to BitBang custom protocols. Which is separate from the Linux kernel. So, you won't have any scheduling or real-time problems. Which you would normally face if you try to program them in the Linux environment. So, getting started. Now, a fun thing about this is since it comes up as a network interface, it gets an IP address. The default one is 192.168.7.2. Yeah, 192. Yeah, here it is. So, you can just open the BeagleBoard.org website. It has certain apps that can run from the browser directly on the BeagleBoard using Bonescript. So, it uses web sockets and Node.js. And you can start executing simple code right over here. I'll show you guys a demo later on. So, when I'm explaining Bonescript, and you see the green thing over here, it basically says that it's connected and you can start playing with it. It gives you a nice web interface, graphical thing. There's a Bone101 app coming about, a cross-platform app which will let you graphically control all your IOPorts and things like that. So, BeagleBoard versus others. So, the main container over here is the Raspberry Pi. Now, you'd really want to know, well, most people have asked me, why not a Raspberry Pi? It's simpler to start off. So, yeah, even I definitely prefer Raspberry Pi when I'm building small hacks. So, if you're really trying to build a product or looking at some serious hacking, I would say BeagleBoard and Black because, one, it's completely open, including the board file schematics, everything, whereas Raspberry Pi is a rather closed environment when it comes down to the hardware level. And so, you have a lot of IOPins. So, I've made a point where when BeagleBoard and Black would win, and when Raspberry Pi. So, if you're trying to build something like Chromecast, or something along that line, you'd probably want to use a Raspberry Pi because it's more like a GPU. It's quite powerful when it comes to graphics, whereas if you want to learn or hack around, I'd say BeagleBoard and Black. So, now, extending the BeagleBoard, definitely you have a lot of IOPorts and you have interfaces for various protocols, but how would you actually extend it? Say, I wanted to build a home automation system, something that simple, or if I want to build the Internet of Things, how would I go about using a simple microprocessor board like this to actually making a talk to everything around? So, for that, how many of you guys have hacked around with the Arduino over here, or know about it? Okay, a few of you. So, Arduino is something known as shields, which you can stack upon, stack it on the Arduino, and it gives it additional features. So, something similar is available for the BeagleBoard. They're called games. So, this allows you to extend add functionality. It gives, for example, audio outputs. You can have a prototyping board where you can start sorting components on that and directly talk to the BeagleBoard Black so you won't require a breadboard. So, now, coming to PYBBIO, this is an excellent library available. It definitely beats the Raspberry Pi Python library hands down. So, it's designed by Alexander Hiam. I am also one of the key contributors there. Basically, it gives you an Arduino-style API for accessing BeagleBoard Black IO pins. So, now, if you actually look at it, the BeagleBoard Black controlling the IOs are not so simple. If you try from a basic level, because there's something known as device-tree overlays, which actually take care of the pin-muxing and stuff. So, kernel 3.8 has, you could say, it's made developers' life a bit harder. But PYBBIO nicely abstracts all of that complexity and gives you a very neat Python API to start off with. It doesn't have Python 3 support yet. So, it's still stuck on 2.7. We are trying to port it. Hopefully, we should be doing some work this summer. So, a simple hello world program in PYBBIO would look like this. So, you import the PYBBIO library, then you have the setup function, which is very similar to how it's there in the Arduino, followed by a loop. And then you start the loop. So, user 3 is one of the LEDs on the board. So, you have four LEDs you can start programming without buying any extra hardware. So, what you do is you initially, in the setup, you set the mode of user 3 LED to output, and then you set it to low. And in the loop, you toggle it every half a second. So, and then you run the loop. It's really that simple. So, you can actually control physical devices in such a simple manner. Now, if you want to look at something like controlling a servo motor, which would be, for those of you who don't know what it is, it's a simple motor which you can control degree to degree. So, 0 to 180 degrees. So, the idea is in robots and certain like humanoid robots, if you're making a miniature version, so you use this heavily. So, how simple is it to control those? So, you import the servo library, and then you say, okay, servo motors internally use PWM pins. That's pulse width modulation. You basically modulate a digital wave in such a way that it gives you an analog output. The mean voltage would be somewhere between 0 and 1. Now, so you're just declare saying, okay, I want to use PWM 1A as a servo pin. And then the servo, you basically initialize the servo object as such. And then in the loop, you say, from angle in 0 to 180 degrees, you keep writing it. So, it keeps moving the servo motor from 0 to 180. So, currently, what features does it support? The Beaglebone Black has a lot of features, and PyBBIO obviously does not support them at this point of time. So, it has complete support for GPIO, I2C, SPI, UART or the serial interface, pulse width modulation, analog to digital converter, and quadrature encoder pulse. So, these are the things it has support for out of the box. Quite a few more are coming on its way. So, other than just having libraries for protocols, do you have, people have asked me, like, do you have any libraries to directly talk to sensors? Say I have sensor X, just get X value or something like that. So, we've been adding that under the library section. So, you can see that quite a few things have been added. That includes ADC servos, digital to analog converters, temperature sensors, accelerometers, so on. And also, how many of you have developed web apps in Python? Okay, a couple of you. So, there's something interesting known as the BBIO server, which allows you to directly get the Beaglebone Black API and puts it into a Flask-based server. So, it gets it in the Flask environment, so you can create buttons and stuff. And the moment you click on it, you can trigger an IO event on the board. So, it's that amazing. So, this is one thing I worked on myself, and you have web streaming. So, you can just connect a webcam. So, if you're doing some basic home monitoring stuff and things like that, you're all powered up. How much time do I have left? So, it basically follows a do not repeat yourself philosophy. So, there are APIs, people who use PY serial, a serial API to talk to your Arduino and things like that. You know that there are already APIs available as such. So, there's PY SPI. What this does is it builds over that. I've written the IE2C user space library myself, and it internally grabs SMBus. So, the main reason why you need a separate PYBBIO API is because there are lots of things specific to the board, like device trees and certain ports can't be used or there'll be conflicts. It handles all those beautifully and gives you a nice generic API to use your ports. We are running out of time. So, this is a simple on an LCD, Hitachi LCD screen. I think 2 into 16, yeah. So, it's a tiny clock display. You have an API for this too. I'll give you the links to my slides later. We are running out of time. Next is bone script. It's a Node.js API to get started. It's just like the PYBBIO, but in Node.js. It's written by Jason, who also heads the BeagleBoard.org foundation. So, it gives you a very nice event-based IE. I think Node.js is probably the most suited language to build something like this because of its callback nature and eventiness, I would say. So, you can easily have attached callbacks on your devices. So, saying that if you get an interrupt on pin 1, then just execute this callback and stuff like that. So, these are, again, code to blink an onboard LED. So, you set the pin mode as out and then you set a timer on a function which digital writes. So, this is the one that does it. Digital writes the particular state to the LED. So, I'll come to the demo a bit later. So, it's not feature-rich as PYBBIO. It has a bit of digital IO, analog IO, UART, I2C. SPI should be on its way and then has quite a few system utility functions. So, as of now, it's the best available API for Node.js for the BeagleBone Black. So, another thing is you can execute code from your browser directly on the BeagleBone Black. So, what it does is it opens a web socket and listens for any requests and then does a RPC call. So, the Getting Started app has some code on the browser. You can click Run and it starts executing on the hardware. So, you can use any web-enabled IDE that can just connect to your BeagleBone Black. So, BeagleBone Black acts as a server, basically. So, the next project I want to talk about is PRU Speak. So, these are all the libraries available at your disposal to start hacking around with the BeagleBone Black. PRU Speak is one such library which does real-time IO control from Python. So, PRU is a coprocessor or a remote processor, you can say, which basically has a shared-memory architecture with the core ARM processor. So, it's on the SOC. Along with the core ARM architecture, core ARM processor, you have the real-time unit. It's a shared-memory architecture. So, this is generally used. People write firmware for the PRU and then they talk to some user space process via some kernel interfaces, which wasn't really clean. So, the main part of this project involved writing a decent bridge to talk between the PRU and the user space processes. So, you could just write some code in the user space process and ask the PRU to execute it. So, here is where the PRU is. So, they have... It's a master-slave architecture. There are two microcontrollers, basically, which run at 200 MHz, independent of the ARM core. And the ARM... The kernel can actually manipulate its states, like enable interrupts, disable interrupts, change register values, so on and so forth. So, it's modeled over BotSpeak. So, BotSpeak is a programming language of sorts from the Tufts University, where you have the BotSpeak code and a BotSpeak interpreter. So, any platform that supports a BotSpeak interpreter, like Raspberry Pi does it or Vino does it, you have many other open-source hardware platforms that do it. So, you can take the same code and start executing it there. So, you don't have to learn a language every other time. So, we thought this would be a nice way for people to get started with the PRU to write real-time scripts. So, this is how a sample script would look. So, you start the script, then you do, okay, set DIO0, that's digital IO0, high, then you wait for a second, then you set it low, and then you go back to the first instruction. Or you can start generating a triangular wave by using the PWM directive. It's like a high-level assembly, wherein you can easily access all your IO peripherals. So, this is the graph for copying input to output. It gives you a much better latency and delays as compared if you've done it on a Linux system. So, this is to copy input to output. You can see there is a slide, okay. You don't have that over here. And this is a PWM. So, you have a 10 nanoseconds jitter, which I will be taking care of, but it's much better than what you would have bought while playing with ARM. If you tried to do the same thing on Linux, it would have been much more terrible. And this is 10 kilohertz. This is 2 kilohertz, a PWM at 8 channels. And this is the internal working. You have the user space libraries. You have the Linux kernel. And then you have the PRU firmware. So, there's a tiny interpreter running on the firmware. I write some code on the user space. Then ask the kernel to stream it to the PRU via some standard CISFS interface. And then that in turn goes to the PRU and the PRU executes it. So, I can write stuff like ADC, sampling, getting data, everything on the PRU. And it can start executing. And it's a shared memory architecture, so you can add additional plugins to read the captured data and place it wherever you want. So, now we have Project Zygote. This is just a couple of slides. What we're trying to build is an IoT framework saying that, okay, the main idea is to abstract devices. So, into objects, which you can, into JavaScript objects. So, I can have probably a resource belonging, say, a sensor on some BeagleBone Black somewhere around the world. And I can have one in my house. I can have one in my neighbor's house. So, if you're all connected to the same Zygote server, is there some way I can just access all of them and probably take some sensor value and pump it to some actuator? Is there some way we can do that? A concept of a generic resource. So, say I create a resource one based on some RESTful URL. Then resource two is another RESTful URL where each RESTful URL represents a particular, say, a slash PWM slash sensor slash one, something like that. And then just read it from that and pump it to some other actuator. So, the ideas can be built something like that. So, the Zygote embed is what goes on to the hardware platform. So, let's say it's... the overall architecture is various embedded platforms, open a web socket and connect to the server. And then they tell the server saying, hey, I'm available at this location and I have XYZ features. So, I have, like, so-and-so sensors on me. So, the user can then use a web interface to see, okay, I have sensor XYZ on this board and across the network I have sensors ABC on another board. Or can I read from this sensor and maybe pump it to an actuator? So, this is how our dashboard will look. So, currently we had previously we had used freeboard.io's dashboarding. We're coming up with custom ones of our own. So, the idea is, okay, take it from the sensor and pump it onto your dashboard panel. Can we do something as simple as that? So, for people who don't want to sit in right front-end JavaScript code or back-end, you know, plucking out your sensor values, can we create, like, a uniform web interface for them? Like, okay, here's a block, here's a block. Can I just connect these two? Yeah, something like this. So, temperature, maybe you want to have a function to massage it and then a spark line. So, can we build something like this and the user just picks up blocks and then say, hey, this is the flow I want. You know, I want to go about it. So, yeah, that's a fine name. It's still under way. So, we're working on it right now. So, hopefully we can follow it at crest slash zygote on GitHub. K-R-E-S slash zygote on GitHub. So, hopefully we should come up with something nice pretty soon. Yeah. So, that's about it for my talk. Q&A. Okay, so it tells me where the board is connected now. So, this is, like, a getting started page of Beagleboard.org. And here I have some basic code running around, basic code lying about, which converts, which imports the bone script library and then sets user zero, which you can see over there, high. And over here, as you can see, it's gone high. So, it's really simple. Let's see if I can do the same thing and set it to low. And yeah, it's gone low. So, this is the web... What's happening is inside this bone script server running, and whatever calls you make over here gets executed over here. So, I can basically use the bone script API either directly on a JS file over here or in my web browser. So, that's the basic idea. Yeah, so that's it. Thank you.