SlideShare una empresa de Scribd logo
1 de 12
Descargar para leer sin conexión
OpenWrt ed elettronica
                    digitale




                         Licenza: http://creativecommons.org/licenses/by-sa/3.0/


Autore: Claudio Mignanti c.mignanti<at>gmail.com
Linux un po ovunque:
● modem/router

● NAS

● televisioni

● stampanti laser
                                   http://wiki.ninux.org/Hackalicegate
● ascensori

● LHC




Si mimetizzano intorno a noi....
User space
                    Dal sw all'hw
             /dev/gpio   /dev/i2c-N       /dev/spi-N



                             I2C             SPI              ...


                               GPIO
                                                          KERNEL


             PIOA                  PIOB                PIOC
                                                                SOC
PIOA

       PA0
  1          +5V
  0
  0
  0            0V
  0
  0
  0
       PA7
  0
GPIO
                  L'anello di congiunzione
echo 82 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio82/direction

echo 1 > /sys/class/gpio/gpio82/value
echo 0 > /sys/class/gpio/gpio82/value




                                              5
GPIO usando il C
  #include <stdio.h>
  #include <gpio_dev.h>

  int main (void) {
      fd = open (“/dev/gpio”);
      ioctl (fd, GPIO_REQUEST, 82);
      ioctl (fd, GPIO_DIR_OUT);
      ioctl (fd, GPIO_SET, 1);
      sleep(1);
      ioctl (fd, GPIO_SET, 0);
  }

                                                           6
trunk/target/linux/generic/files/include/linux/gpi_dev.h
Solo led?
●   Optoisolatori
●   Relè
●   Motori
●   Sensori di vario tipo
●   …. composizioni varie



                                7
… CNC




                                    8
http://wiki.ninux.org/cnc
GPIO e stepper motor
          PYTHON CLASS                                   USER SPACE
             STEPPER                                      PROGRAM


              /DEV/GPIO SYSFS /DEV/MOTORn
                                  STEPPER DRIVER
               GPIO API

                                      PWM


                                 CPU



                                                                                          9
http://sourceforge.net/apps/trac/acme-dev/browser/kernel-stuff/stepper-driver/stepper-drv.c
class stepper:
    """ This class allow you to drive a stepper motor using gpio pins.n
The stepper class use the follow paramethers for costructor:n
   (enable, direction, step, [limit], [low_pwr])n
    """
…
  def step (self, number=1, delay=0, recover_step=300):
        self.enable()
        time.sleep(0.001)
        for i in range(0, number):
             #check if at limit
             if (self.have_limit and self.limit_pin.get() == 0):
                      self.recover_end(recover_step)
                      self.disable()
                      return number - i + recover_step #missing steps
             self.step_pin.set(0)
             self.step_pin.set(1)
        time.sleep(0.001)
        self.disable()                                                  10
        return 0
Appuntamento fisso...

… alla Domenica nerd (17.30 alle 23.00).
         Associazione Fusolab
         Via Giorgio Pitacco 29
                 ●




                                           11
EOF




                                 ?
                                Claudio Mignanti c.mignanti<at>gmail.com
                                                                          12
                                              OpenWrt Hacker - Hardware designer
pub 1024D/0DFD7CBB C94D 759A 2EF0 172F 9673 65E4 C4C1 8627 0DFD 7CBB

Más contenido relacionado

Destacado (18)

Libro1nnn (1)
Libro1nnn (1)Libro1nnn (1)
Libro1nnn (1)
 
Grunt.js introduction
Grunt.js introductionGrunt.js introduction
Grunt.js introduction
 
El perfume
El perfumeEl perfume
El perfume
 
Mr Holdings car
Mr Holdings carMr Holdings car
Mr Holdings car
 
311
311311
311
 
Slideshare
SlideshareSlideshare
Slideshare
 
Picobgp - A simple deamon for routing advertising
Picobgp - A simple deamon for routing advertisingPicobgp - A simple deamon for routing advertising
Picobgp - A simple deamon for routing advertising
 
(1) siyasal tarih 1923-50
(1) siyasal tarih 1923-50(1) siyasal tarih 1923-50
(1) siyasal tarih 1923-50
 
Crackedpot
CrackedpotCrackedpot
Crackedpot
 
Trabjo de redes porcentaje
Trabjo de redes porcentajeTrabjo de redes porcentaje
Trabjo de redes porcentaje
 
Help and hoarding by Annette Conway, Psy.D.
Help and hoarding by Annette Conway, Psy.D.Help and hoarding by Annette Conway, Psy.D.
Help and hoarding by Annette Conway, Psy.D.
 
Computers
ComputersComputers
Computers
 
Happy Birthday MORGAN!!!
Happy Birthday MORGAN!!!Happy Birthday MORGAN!!!
Happy Birthday MORGAN!!!
 
мой город
мой городмой город
мой город
 
The wright brothers started with a glider before going to powered flight.
The wright brothers started with a glider before going to powered flight.The wright brothers started with a glider before going to powered flight.
The wright brothers started with a glider before going to powered flight.
 
AFP, Poliovirus, Enteroviruses,
AFP, Poliovirus, Enteroviruses, AFP, Poliovirus, Enteroviruses,
AFP, Poliovirus, Enteroviruses,
 
Mr holdins car
Mr holdins carMr holdins car
Mr holdins car
 
Jacques louis david2003
Jacques louis david2003Jacques louis david2003
Jacques louis david2003
 

Similar a Openwrt, linux e GPIO al LinuxDay 2010 Roma

Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4
Iulius Bors
 
Open CL For Haifa Linux Club
Open CL For Haifa Linux ClubOpen CL For Haifa Linux Club
Open CL For Haifa Linux Club
Ofer Rosenberg
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
Tom Paulus
 

Similar a Openwrt, linux e GPIO al LinuxDay 2010 Roma (20)

Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
 
Atomic pi Mini PC
Atomic pi Mini PCAtomic pi Mini PC
Atomic pi Mini PC
 
Atomic PI apug
Atomic PI apugAtomic PI apug
Atomic PI apug
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
 
IoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3BIoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3B
 
Innovation with pcDuino
Innovation with pcDuinoInnovation with pcDuino
Innovation with pcDuino
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 
Arduino Introduction by coopermaa
Arduino Introduction by coopermaaArduino Introduction by coopermaa
Arduino Introduction by coopermaa
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
 
Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4Raspberry pi lcd-shield20x4
Raspberry pi lcd-shield20x4
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Open CL For Haifa Linux Club
Open CL For Haifa Linux ClubOpen CL For Haifa Linux Club
Open CL For Haifa Linux Club
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
Developing a NodeBot using Intel XDK IoT Edition
Developing a NodeBot using Intel XDK IoT EditionDeveloping a NodeBot using Intel XDK IoT Edition
Developing a NodeBot using Intel XDK IoT Edition
 
Project ACRN GPIO mediator introduction
Project ACRN GPIO mediator introductionProject ACRN GPIO mediator introduction
Project ACRN GPIO mediator introduction
 
F9 microkernel app development part 2 gpio meets led
F9 microkernel app development part 2 gpio meets ledF9 microkernel app development part 2 gpio meets led
F9 microkernel app development part 2 gpio meets led
 
Начало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev KitНачало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev Kit
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Hands-on Labs: Raspberry Pi 2 + Windows 10 IoT Core
Hands-on Labs: Raspberry Pi 2 + Windows 10 IoT CoreHands-on Labs: Raspberry Pi 2 + Windows 10 IoT Core
Hands-on Labs: Raspberry Pi 2 + Windows 10 IoT Core
 

Más de Claudio Mignanti (7)

Pycon9 - Paas per tutti i gusti con Dokku and Kubernetes
Pycon9 - Paas per tutti i gusti con Dokku and KubernetesPycon9 - Paas per tutti i gusti con Dokku and Kubernetes
Pycon9 - Paas per tutti i gusti con Dokku and Kubernetes
 
Roma linuxday 2013 - nodejs
Roma linuxday 2013 - nodejsRoma linuxday 2013 - nodejs
Roma linuxday 2013 - nodejs
 
Presentazione tirocinio
Presentazione tirocinio Presentazione tirocinio
Presentazione tirocinio
 
TuxIsAlive
TuxIsAliveTuxIsAlive
TuxIsAlive
 
Elettronica digitale with Example
Elettronica digitale with ExampleElettronica digitale with Example
Elettronica digitale with Example
 
Git for dummies
Git for dummiesGit for dummies
Git for dummies
 
Presentazione Ninux al LinuxDay Roma 2012
Presentazione Ninux al LinuxDay Roma 2012Presentazione Ninux al LinuxDay Roma 2012
Presentazione Ninux al LinuxDay Roma 2012
 

Openwrt, linux e GPIO al LinuxDay 2010 Roma

  • 1. OpenWrt ed elettronica digitale Licenza: http://creativecommons.org/licenses/by-sa/3.0/ Autore: Claudio Mignanti c.mignanti<at>gmail.com
  • 2. Linux un po ovunque: ● modem/router ● NAS ● televisioni ● stampanti laser http://wiki.ninux.org/Hackalicegate ● ascensori ● LHC Si mimetizzano intorno a noi....
  • 3. User space Dal sw all'hw /dev/gpio /dev/i2c-N /dev/spi-N I2C SPI ... GPIO KERNEL PIOA PIOB PIOC SOC
  • 4. PIOA PA0 1 +5V 0 0 0 0V 0 0 0 PA7 0
  • 5. GPIO L'anello di congiunzione echo 82 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio82/direction echo 1 > /sys/class/gpio/gpio82/value echo 0 > /sys/class/gpio/gpio82/value 5
  • 6. GPIO usando il C #include <stdio.h> #include <gpio_dev.h> int main (void) { fd = open (“/dev/gpio”); ioctl (fd, GPIO_REQUEST, 82); ioctl (fd, GPIO_DIR_OUT); ioctl (fd, GPIO_SET, 1); sleep(1); ioctl (fd, GPIO_SET, 0); } 6 trunk/target/linux/generic/files/include/linux/gpi_dev.h
  • 7. Solo led? ● Optoisolatori ● Relè ● Motori ● Sensori di vario tipo ● …. composizioni varie 7
  • 8. … CNC 8 http://wiki.ninux.org/cnc
  • 9. GPIO e stepper motor PYTHON CLASS USER SPACE STEPPER PROGRAM /DEV/GPIO SYSFS /DEV/MOTORn STEPPER DRIVER GPIO API PWM CPU 9 http://sourceforge.net/apps/trac/acme-dev/browser/kernel-stuff/stepper-driver/stepper-drv.c
  • 10. class stepper: """ This class allow you to drive a stepper motor using gpio pins.n The stepper class use the follow paramethers for costructor:n (enable, direction, step, [limit], [low_pwr])n """ … def step (self, number=1, delay=0, recover_step=300): self.enable() time.sleep(0.001) for i in range(0, number): #check if at limit if (self.have_limit and self.limit_pin.get() == 0): self.recover_end(recover_step) self.disable() return number - i + recover_step #missing steps self.step_pin.set(0) self.step_pin.set(1) time.sleep(0.001) self.disable() 10 return 0
  • 11. Appuntamento fisso... … alla Domenica nerd (17.30 alle 23.00). Associazione Fusolab Via Giorgio Pitacco 29 ● 11
  • 12. EOF ? Claudio Mignanti c.mignanti<at>gmail.com 12 OpenWrt Hacker - Hardware designer pub 1024D/0DFD7CBB C94D 759A 2EF0 172F 9673 65E4 C4C1 8627 0DFD 7CBB