This document discusses using GPIO (general purpose input/output) pins with Linux to control electronic devices. It provides examples of using GPIO pins with C code and Python to control LEDs, motors, sensors and more. GPIO pins act as the connection between software and hardware, allowing control of physical devices from user space programs. The document also mentions OpenWrt, a Linux distribution commonly used in routers and embedded systems, and encourages attendance at a weekly "nerd Sunday" meetup to discuss electronics projects.
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
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