+ All Categories
Home > Technology > Introduction to pcDuino

Introduction to pcDuino

Date post: 28-Jan-2015
Category:
Upload: jingfeng-liu
View: 117 times
Download: 1 times
Share this document with a friend
Description:
Overview of pcDuino
Popular Tags:
67
pcDuino A New Way To Innovate www.pcduino.com learn.linksprite.com
Transcript
Page 1: Introduction to pcDuino

pcDuinoA New Way To Innovate

www.pcduino.comlearn.linksprite.com

Page 2: Introduction to pcDuino

Agenda pcDuino: a platform open source software meets open source

hardware Programming under Ubuntu (linux)

Arduino style programming ( C ) for pcDuino Python programming for pcDuino Java programming for pcDuino Cloud 9 IDE

Programming under Android ICS Command line programming QT GUI

Friends help Friends Program Friends help Friends - PCB Friends help Friends - Assembly Friends help Friends -Distribution

Page 3: Introduction to pcDuino

pcDuino: where open software meets open hardware

pcDuino = mini PC + Arduino pcDuino is a kind of super Arduino with the brain

power of a mini PC. Existing Arduino shield can work on pcDuino. pcDuino can run Ubuntu. The desktop outputs

from HDMI. User can remotely access its desktop via VNC (Network or OTG-USB).

pcDuino has built-in Arduino style IDE environment. It also supports programming in Python, Cloud 9 IDE, Java, Go-lang, Scratch, etc.

pcDuino can run full Android ICS, and support Arduino style hardware programming under Android.

pcDuino is a server, a WiFi router, a printer server, a IP-PBX, and more.

pcDuino is a platform where open software meets open hardware.

Page 4: Introduction to pcDuino

pcDuino FamilypcDuino Lite pcDuino Lite WiFi pcDuino v1 pcDuino v2 pcDuino v3

CPU Allwinner A101GHz ARM Cortex A8

Allwinner A101GHz ARM Cortex A8

 Allwinner A101GHz ARM Cortex A8

 Allwinner A101GHz ARM Cortex A8

GPU OpenGL ES2.0OpenVG 1.1 Mali 400 core

OpenGL ES2.0OpenVG 1.1 Mali 400 core

OpenGL ES2.0OpenVG 1.1 Mali 400 core

OpenGL ES2.0OpenVG 1.1 Mali 400 core

DRAM  512MB 256MB  1GB   1GB

Storage NO FlashmicroSD card (TF) slot for up to 32GB

2GB FlashmicroSD card (TF) slot for up to 32GB

 2GB Flash (4GB after 2/1/2014)microSD card (TF) slot for up to 32GB

 2GB Flash (4GB after 2/1/2014)microSD card (TF) slot for up to 32GB

Video  HDMI HDMI  HDMI  HDMI

OS Support• Lbuntu 12.04•Android

•Lbuntu 12.04•Doesn’t support Android

•Lbuntu 12.04•Android

•Lbuntu 12.04•Android

ExtensionInterface  2.54mm headers Arduino (TM) Headers  2.54mm headers  Arduino (TM) Headers

NetworkInterface•10/100Mbps RJ45•USB WiFi extension (not included)

WiFi, No Ethernet•10/100Mbps RJ45•USB WiFi extension (not included)

•10/100Mbps RJ45•WiFi

Power  5V, 2000mA 5V, 2000mA  5V, 2000mA  5V, 2000mA

     

Page 5: Introduction to pcDuino

pcDuino hardware interfaces

Page 6: Introduction to pcDuino

pcDuino boot modes Default to boot from SD If there is no bootable image in SD, it will try to boot

from NAND. For Ubuntu OS, the system and data in NAND can be

copied to SD seamlessly.

Page 7: Introduction to pcDuino

Programming under Ubuntu (linux)

Page 8: Introduction to pcDuino

VNC to pcDuino through its USB-OTG

Page 9: Introduction to pcDuino

Two flavors Command line IDE

Arduino style programming ( C )

Page 10: Introduction to pcDuino

C Command lineSetup (one time) If not already done, set up git. Do this using the command: ubuntu@ubuntu:~$ sudo apt-get install git  Make sure you’re in your home folder by typing ubuntu@ubuntu:~$ cdubuntu@ubuntu:~$ pwd/home/Ubuntu Now download the distribution from github by typingubuntu@ubuntu:~$ git clone https://github.com/pcduino/c_enviroment

Page 11: Introduction to pcDuino

C Command line

Page 12: Introduction to pcDuino

C Command lineChange into the c_enviroment folder: ubuntu@ubuntu:~$ cd c_enviromentubuntu@ubuntu:~/c_enviroment$ lsMakefile hardware libraries output sample Now run make to make the libraries and the examples with the following command: ubuntu@ubuntu:~/c_enviroment$ make

Make[1]: Leaving directory `/home/ubuntu/c_enviroment/sample'The resulting binary files are found in the output/test folderubuntu@ubuntu:~/c_enviroment$ cd output/testubuntu@ubuntu:~/c_enviroment/output/test$ lltotal 660drwxrwxr-x 2 ubuntu ubuntu 4096 Apr 27 06:59 ./drwxrwxr-x 3 ubuntu ubuntu 4096 Apr 27 06:49 ../-rwxrwxr-x 1 ubuntu ubuntu 13868 Apr 27 06:58 adc_test*-rwxrwxr-x 1 ubuntu ubuntu 28284 Apr 27 06:58 adxl345_test*-rwxrwxr-x 1 ubuntu ubuntu 14209 Apr 27 06:58 interrupt_test*-rwxrwxr-x 1 ubuntu ubuntu 13726 Apr 27 06:58 io_test*-rwxrwxr-x 1 ubuntu ubuntu 13712 Apr 27 06:59 linker_button_test*-rwxrwxr-x 1 ubuntu ubuntu 13907 Apr 27 06:59 linker_buzzer_test*-rwxrwxr-x 1 ubuntu ubuntu 13689 Apr 27 06:59 linker_hall_sensor_test*-rwxrwxr-x 1 ubuntu ubuntu 13760 Apr 27 06:59 linker_joystick_test*-rwxrwxr-x 1 ubuntu ubuntu 13769 Apr 27 06:59 linker_led_bar_test*-rwxrwxr-x 1 ubuntu ubuntu 13690 Apr 27 06:59 linker_led_test*-rwxrwxr-x 1 ubuntu ubuntu 14290 Apr 27 06:59 linker_light_sensor_test*……

Page 13: Introduction to pcDuino

C Command lineTo view the contents of a sample sketch, (this example we’ll look at the contents of linker_led_test.c) type: ubuntu@ubuntu:~/c_enviroment/sample$ cat

linker_led_test.c/** LED test program*/#include <core.h>int led_pin = 1; void setup(){if(argc != 2){goto _help;}led_pin = atoi(argv[1]);if((led_pin < 0) || (led_pin > 13)){goto _help;}pinMode(led_pin, OUTPUT);return; _help:printf("Usage %s LED_PIN_NUM(0-13)n", argv[0]);exit(-1);}

void loop(){digitalWrite(led_pin, HIGH); // set the LED ondelay(1000); // wait for a seconddigitalWrite(led_pin, LOW); // set the LED offdelay(1000); // wait for a second} 

Page 14: Introduction to pcDuino

Creating Your Own Sketchubuntu@ubuntu:~/c_enviroment/sample$ nano button_led.c An empty nano screen should appear.Copy and paste the following code into it. (Remember to paste in nano at the cursor,

just right click the mouse button). #include <core.h> // Required first line to run on pcDuinoint ledPin = 8;int buttonPin = 7;// variables will change:int buttonState = 0; // variable for reading the pushbutton status void setup() {// initialize the LED pin as an output:pinMode(ledPin, OUTPUT);// initialize the pushbutton pin as an input:pinMode(buttonPin, INPUT);} 

Page 15: Introduction to pcDuino

Creating Your Own Sketchvoid loop(){// read the state of the pushbutton value:buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed.// if it is, the buttonState is HIGH:if (buttonState == HIGH) {// turn LED on:digitalWrite(ledPin, HIGH);}else {// turn LED off:digitalWrite(ledPin, LOW);}}

Page 16: Introduction to pcDuino

Creating Your Own SketchModify the Makefile and Compileubuntu@ubuntu:~/c_enviroment/sample$ nano Makefile You will see a section that lists all the OBJS something like: OBJS = io_test adc_test pwm_test spi_test adxl345_test serial_test liquidcrystal_i2c liquidcrystal_spi

interrupt_test tone_testOBJS += linker_led_test linker_potentiometer_test linker_tilt_test linker_light_sensor_test

linker_button_testOBJS += linker_touch_sensor_test linker_magnetic_sensor_test linker_temperature_sensor_test

linker_joystick_testOBJS += linker_rtc_test linker_sound_sensor_test linker_buzzer_test linker_hall_sensor_test

linker_led_bar_test linker_relay_testOBJS += pn532_readAllMemoryBlocks pn532readMifareMemory pn532readMifareTargetID

pn532writeMifareMemory 

Page 17: Introduction to pcDuino

Creating Your Own SketchWe’re going to add a line to the end of this with the name of the scketch we just created: OBJS += button_led Save the file and exit nano using <CTRL>X with a y and <enter>. We now run make by typing: ubuntu@ubuntu:~/c_enviroment/sample$ make You should see a whole bunch of text with the end being: button_led.c -o ../output/test/button_led ../libarduino.a If all went well, you can go to the output/test folder and find your executable you have created: ubuntu@ubuntu:~/c_enviroment/sample$ cd ../output/test/ubuntu@ubuntu:~/c_enviroment/output/test$ lltotal 676drwxrwxr-x 2 ubuntu ubuntu 4096 Apr 27 07:51 ./drwxrwxr-x 3 ubuntu ubuntu 4096 Apr 27 06:49 ../-rwxrwxr-x 1 ubuntu ubuntu 13868 Apr 27 07:51 adc_test*-rwxrwxr-x 1 ubuntu ubuntu 28284 Apr 27 07:51 adxl345_test*-rwxrwxr-x 1 ubuntu ubuntu 13668 Apr 27 07:51 button_led*…..(not showing rest of listing here)  

Page 18: Introduction to pcDuino

Creating Your Own SketchRun Your Sketch To run it, once you have wired up a switch and led to the right pins, type: ubuntu@ubuntu:~/c_enviroment/output/test$ ./button_led To stop the program, <Ctrl>C A Quick Re-Cap 

Add #include <core.h> to the top of your sketch.Create your sketch in the samples folder (if your familiar with linux,

makefiles, and compiling code, you could set up your own)Add the filename to the Makefile in the samples folder in the OBJS section

without the .cRun makeRun the executable from the output/test folder.You can introduce command line arguments into your sketch to make it

more transportable. 

Page 19: Introduction to pcDuino

Arduino IDE

Page 20: Introduction to pcDuino

Arduino IDE

Page 21: Introduction to pcDuino

Arduino IDE

Page 22: Introduction to pcDuino

Arduino IDE

Page 23: Introduction to pcDuino

Arduino IDE

Page 24: Introduction to pcDuino

ArduBlock

Page 25: Introduction to pcDuino

pcDuino Hardware Experiments

Page 26: Introduction to pcDuino

Potentiometer

Page 27: Introduction to pcDuino

LED Dimmer (PWM)

Page 28: Introduction to pcDuino

7-seg LED

Page 29: Introduction to pcDuino

8x8 LED Matrix

Page 30: Introduction to pcDuino

Analog Temperature Sensor

Page 31: Introduction to pcDuino

4 Digits 7-segment LEDs

Page 32: Introduction to pcDuino

16x02 Character LCD

Page 33: Introduction to pcDuino

Digital Humidity and Temperature Sensor

Page 34: Introduction to pcDuino

LED controlled by LDR

Page 35: Introduction to pcDuino

Serial Port of pcDuino

Page 36: Introduction to pcDuino

Extends to 4 UARTS

http://jbvsblog.blogspot.com/2013/09/pcduino-extends-to-4-uarts.html

Page 37: Introduction to pcDuino

Ultrasonic Sensor

Page 38: Introduction to pcDuino

Stepper

Page 39: Introduction to pcDuino

RF Servo

Page 40: Introduction to pcDuino

Relay

Page 41: Introduction to pcDuino

NFC Shield

Page 42: Introduction to pcDuino

Cottonwood:UHF ultra-distance RFID Reader

Page 43: Introduction to pcDuino

GPS Shield

Page 44: Introduction to pcDuino

Cellular Shield

Page 45: Introduction to pcDuino

Powerline Communication

Page 46: Introduction to pcDuino

Python

ubuntu@ubuntu:~/python-pcduino/Samples/blink_led$ more blink_led.py #!/usr/bin/env python# blink_led.py# gpio test code for pcduino ( http://www.pcduino.com )#import gpioimport timeled_pin = "gpio2"def delay(ms): time.sleep(1.0*ms/1000)def setup(): gpio.pinMode(led_pin, gpio.OUTPUT)def loop(): while(1): gpio.digitalWrite(led_pin, gpio.HIGH) delay(200)

Page 47: Introduction to pcDuino

OpenCV

Page 48: Introduction to pcDuino

OpenCVdef process(infile): image = cv.LoadImage(infile); if image: faces = detect_object(image) im = Image.open(infile) path = os.path.abspath(infile) save_path = os.path.splitext(path)[0]+"_face" try: os.mkdir(save_path) except: pass if faces: draw = ImageDraw.Draw(im) count = 0 for f in faces: count += 1 draw.rectangle(f, outline=(255, 0, 0)) a = im.crop(f) file_name = os.path.join(save_path,str(count)+".jpg") # print file_name a.save(file_name) drow_save_path = os.path.join(save_path,"out.jpg") im.save(drow_save_path, "JPEG", quality=80) else: print "Error: cannot detect faces on %s" % infile if __name__ == "__main__":process("./opencv_in.jpg")

Page 49: Introduction to pcDuino

OpenCV#!/usr/bin/env python#coding=utf-8import osfrom PIL import Image, ImageDrawimport cv def detect_object(image): grayscale = cv.CreateImage((image.width, image.height), 8, 1) cv.CvtColor(image, grayscale, cv.CV_BGR2GRAY) cascade = cv.Load("/usr/share/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml") rect = cv.HaarDetectObjects(grayscale, cascade, cv.CreateMemStorage(), 1.1, 2, cv.CV_HAAR_DO_CANNY_PRUNING, (20,20)) result = [] for r in rect: result.append((r[0][0], r[0][1], r[0][0]+r[0][2], r[0][1]+r[0][3])) return result  

Page 50: Introduction to pcDuino

Cloud 9 IDE Cloud9 IDE is an online development

environment for Javascript and Node.js applications as well as HTML, CSS, PHP, Java, Ruby and 23 other languages.

You're programming for the web, on the web. Teams can collaborate on projects and run them within the browser. When you're finished, deploy it—and you're done!

Page 51: Introduction to pcDuino

Cloud 9 IDE

Page 52: Introduction to pcDuino

QT on pcDuino

Page 53: Introduction to pcDuino

QT on pcDuino

Page 54: Introduction to pcDuino

Scratch

$sudo apt-get install pcduino-scratch

Page 55: Introduction to pcDuino

Go Langpackage main import ("fmt""./gpio""time") func main() { g, err := gpio.NewGPIOLine(7,gpio.OUT)if err != nil {fmt.Printf("Error setting up GPIO %v: %v", 18, err)return} blink(g, 100)g.Close()} func blink(g *gpio.GPIOLine, n uint) {fmt.Printf("blinking %v time(s)\n", n)for i := uint(0); i &lt; n; i++ {g.SetState(true)time.Sleep(time.Duration(1000) * time.Millisecond)g.SetState(false)time.Sleep(time.Duration(1000) * time.Millisecond)}}

Page 56: Introduction to pcDuino

Home Automation: IP controllable LED

Many users are asking if the hardware part can be programmed together with the Ubuntu linux?

Sure. This is the beauty of pcDuino. The Arduino compatible hardware is a native part of the OS.

pcDuino includes Ethernet port, USB Wifi dongle, so there is no need for Ethernet shield, Ethernet shield , USB host shield, MP3 shields and so on.

Now, we are going to implement a TCP/IP socket server on pcDuino to listen to the data coming from client.

When it receives character ’O', it will turn on the LED, and when it receives ‘F”, it will turn on the LED. No actions if receive something else.

Page 57: Introduction to pcDuino

Home Automation: IP controllable LED

#include “sys/socket.h”#include “netinet/in.h”#include “arpa/inet.h”#include “sys/types.h” int led_pin = 2; int listenfd = 0, connfd = 0;int n;struct sockaddr_in serv_addr;  char sendBuff[1025];time_t ticks;  

 void loop(){ n = read(connfd, sendBuff, strlen(sendBuff) );  if(n>0){if(sendBuff[0]=='O') digitalWrite(led_pin, HIGH); // set the LED onif(sendBuff[0]=='F') digitalWrite(led_pin,LOW); // set the LED off}}

void setup(){ led_pin = 2; pinMode(led_pin, OUTPUT); listenfd = socket(AF_INET, SOCK_STREAM, 0);memset(serv_addr, '0', sizeof(serv_addr));memset(sendBuff, '0', sizeof(sendBuff));  serv_addr.sin_family = AF_INET;serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);serv_addr.sin_port = htons(5000);  bind(listenfd, (struct sockaddr*) serv_addr, sizeof(serv_addr));  listen(listenfd, 10);  connfd = accept(listenfd, (struct sockaddr*)NULL, NULL);  }

Page 58: Introduction to pcDuino

Home Automation by Z-wave

Page 59: Introduction to pcDuino

pcDuino as 3D printer control console

Page 60: Introduction to pcDuino

pcDuino as banaba piano

Page 61: Introduction to pcDuino

Programming under Android ICS

Page 62: Introduction to pcDuino

Two flavors to program under Android There are two flavors to program under

Android: Command line QT5 GUI

Page 63: Introduction to pcDuino

Command line

Page 64: Introduction to pcDuino

QT5 GUI

We can copy the apk though pcDuino OTG or SD card to pcDunio and install it there.

Page 65: Introduction to pcDuino
Page 66: Introduction to pcDuino

Friends help Friends Friends help Friends - PCB Friends help Friends - Assembly Friends help Friends -Distribution

Leverage LinkSprite Manufacturing Facility in Shenzhen, China, and distribution channel worldwide.

Page 67: Introduction to pcDuino

Connect with pcDuino

Facebook.com/linksprite


Recommended