Welcome! Log In Create A New Profile

Advanced

Add infrared remote control your printer.

Posted by tatubias 
Add infrared remote control your printer.
January 26, 2015 09:02AM
Original post: [forums.reprap.org]

In this tutorial i will explain how to add a remote control to your printer.

what is needed:
  • raspberry
  • rasbian running / updated
  • infrared receiver
  • infrared control
  • octoprint
  • octorprint touch interface






install lirc

sudo apt-get install lirc


Connect your IR receiver to raspi pin 18 Data ground and 3.3v pin1 for vcc



edit: /etc/modules

Command: sudo nano /etc/modules

Add the following lines.
lirc_dev

lirc_rpi gpio_in_pin=18


edit sudo nano etc/lirc/hardware.conf
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"

# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false

# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false

# Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################

rebot the raspi

sudo reboot

check if you are receivin signals from your remote control

sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

when you press some buttons of your remote you will see somthing like this in your console.
space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903

now we need to configure lirc to recognize remote control buttons.

first stop lirc
sudo /etc/init.d/lirc stop

we need to generate the config file running the following command.

if you dont know the name of the buttons as is required during the configruatation run the following comand before conifguring and get the names.
irrecord --list-namespace

irrecord -d /dev/lirc0 ~/lircd.conf


As an example my configuration file looks like:
# Please make this file available to others
# by sending it to 
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan 18 14:59:06 2015
#
# contributed by
#
# brand:                       /home/pi/lircd.conf.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  /home/pi/lircd.conf.conf
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9006  4447
  one           594  1648
  zero          594   526
  ptrail        587
  repeat       9006  2210
  pre_data_bits   16
  pre_data       0xFF
  gap          107633
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0xB24D
          KEY_GOTO                 0x2AD5
          KEY_MUTE                 0x6897
          KEY_RECORD               0x32CD
          KEY_UP                   0xA05F
          KEY_TIME                 0x30CF
          KEY_LEFT                 0x50AF
          KEY_ENTER                0x02FD
          KEY_RIGHT                0x7887
          KEY_0                    0x48B7
          KEY_DOWN                 0x40BF
          KEY_BACK                 0x38C7
          KEY_1                    0x906F
          KEY_2                    0xB847
          KEY_3                    0xF807
          KEY_4                    0xB04F
          KEY_5                    0x9867
          KEY_6                    0xD827
          KEY_7                    0x8877
          KEY_8                    0xA857
          KEY_9                    0xE817
      end codes

end remote

Lest do back up of the original hardware configuration file.
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf


copy the new version
sudo cp ~/lircd.conf /etc/lirc/lircd.conf


restart lirc
sudo /etc/init.d/lirc start

now we will teach what to do with each button that we press. in this case we will make lirc run commands from the console.
sudo nano /etc/lirc/lircrc


My lircrc looks like this.

begin
    remote /etc/lircd/lircd.conf
    prog = irexec
    button = KEY_ENTER
    config = /var/www/post_api_printhead_xy-home.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_DOWN
    config = /var/www/post_api_printhead_down_10.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_LEFT
    config = /var/www/post_api_printhead_left_10.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_UP
    config = /var/www/post_api_printhead_up_10.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_RIGHT
    config = /var/www/post_api_printhead_right_10.sh
    repeat = 1
end

begin
    remote /etc/lircd/lircd.conf
    prog = irexec
    button = KEY_POWER 
    config = /var/www/post_api_printer_fans_on_M106.sh
    config = /var/www/post_api_printer_fans_off_M106-S0.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_1
    config = /var/www/post_api_printer_extruder_temp_0.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_4
    config = /var/www/post_api_printer_extruder_temp_190.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_7
    config = /var/www/post_api_printer_extruder_temp_220.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_RECORD
    config = /var/www/post_api_printer_motors_off_M18.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_MUTE
    config = /var/www/post_api_printhead_z-home.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_GOTO
    config = /var/www/post_api_printhead_z-up_10.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_RECORD
    config = /var/www/post_api_printhead_z-down_10.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_2
    config = /var/www/post_api_printer_bed_temp_0.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_5
    config = /var/www/post_api_printer_bed_temp_50.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_8
    config = /var/www/post_api_printer_bed_temp_100.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_9
    config = /var/www/post_api_printhead_extrude_5.sh
    repeat = 1
end

begin
    prog = irexec
    button = KEY_3
    config = /var/www/post_api_printhead_retract_5.sh
    repeat = 1
end

Here it is a you tube video.
[www.youtube.com]

read the original post.
[forums.reprap.org]
Sorry, only registered users may post in this forum.

Click here to login