JLIRC

After having lirc working on the Raspberry Pi, I wanted a Java program that can talk with lirc and make it possible to intercept infrared signals from a remote control via java code.  That is were JLirc comes in.  JLirc is a java api for using lirc.  More information about can be found on JLirc

The installation instructions can be found on an install file which you can find in the sources zip.  You have to download the sources to your raspberry pi and extract the zip.  Than you need to do a build (Makefile).  Important note is that you have to use the option  -march=armv7-a instead of what was original in the Makefile.  It will not build if you don’t change it.Once built you have to first launch the lirc deamon :

sudo service lirc start

and than launch the test application which is in the sources :

java -cp . org.lirc.test.Irw

As a result when you hit a button on the remote control you should see something similar like this :

pi@raspberrypi ~/lirctest/build $ java -cp . org.lirc.test.Irw
0000000000fda857 00 KEY_5 /home/pi/lircd.conf.conf

Pretty simple isn’t it.

LIRC on Raspberry Pi

It is already a while that I have the feeling that the responsiveness of the raspberry controlled car is not really satisfying.  Always I have the feeling it responds a fraction later.  Last week I was changing the tv channel using the remote control.  I noticed buttons like forward, backward, up arrow, back arrow, ….  I was immediately thinking that this could be the solution to my problem.  Why not control my Raspberry controlled car with a simple remote control instead of a JavaFX application.  To be able to do that I need an infrared receiver and of course the software to glue everything together.  So I started looking on the internet for information.  Rapidly I found information about lirc (Linux Infrared Remote Control).  This is a Linux package that makes it possible to send and decode infrared signals.

As infra red receiver for example you can use a TSOP2136.  You can find the datasheet on TSOP2136  Make sure you do the wiring correct.  There are only 3 wires.  A data wire, supply voltage wire and a ground wire.  Depending on the sensor the order can be different so watch out.

Connect the sensor data pin to the GPIO 18 pin (or another but make sure this is also mentioned in the configs), connect the sensor ground pin to the ground pin and the sensor supply voltage pin to the 3.3V pin.

To get lirc installed use the following command
sudo apt-get install lirc
Some configurations need to be done.

Add the following to /etc/modules

lirc_dev
lirc_rpi gpio_in_pin=18

Important notice is that GIO pin 18  (BroadCom GPIO pin number-> not PI4J/WiringPi GPIO pin number) will serve as data input from the infrared sensor.

Create or modify the following file (/etc/lirc/hardware.conf) with the contents here under :
# /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=""

Restart Lirc to be sure the changes a described above are taken.
sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

Add the following line to /boot/config.txt :
dtoverlay=lirc-rpi,gpio_in_pin=18

When done reboot your raspberry pi and than launch the following commands :
sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

Now take your remote control and push any button.  You should see something similar like this :
pi@raspberrypi ~ $ sudo /etc/init.d/lirc stop
[ ok ] Stopping remote control daemon(s): LIRC:.
pi@raspberrypi ~ $ mode2 -d /dev/lirc0
space 16777215
pulse 9083
space 4459
pulse 615
space 520
pulse 645
space 493
pulse 613
space 525
pulse 610
space 510
pulse 621
space 539
pulse 628
space 486
pulse 637
space 510
pulse 626
space 494
pulse 635
space 1641

When you want to work with the remote control you will have to create or generate an lirc configuration file because you will need to configure what signal corresponds with what button (action) on the remote control.  To do this you can launch the following command :

irrecord -d /dev/lirc0 ~/lircd.conf
lircd.conf is the configuration file that will be generated.  Follow all steps when using irrecord.  In my case I got the following content in my config file.

# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Tue Feb 2 19:09:14 2016
#
# 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 9042 4488
one 593 1671
zero 593 537
ptrail 603
repeat 9047 2221
pre_data_bits 16
pre_data 0xFD
gap 108029
toggle_bit_mask 0x0

begin codes
KEY_0 0x30CF
KEY_1 0x08F7
KEY_2 0x8877
KEY_3 0x48B7
KEY_4 0x28D7
KEY_5 0xA857
KEY_6 0x6897
KEY_7 0x18E7
KEY_8 0x9867
KEY_9 0x58A7
KEY_UP 0x50AF
KEY_DOWN 0x10EF
KEY_VOLUMEUP 0x807F
KEY_VOLUMEDOWN 0x906F
KEY_FORWARD 0x609F
KEY_BACK 0x20DF
KEY_PAUSE 0xA05F
KEY_PLAY 0xA05F
KEY_CLOSE 0x00FF
end codes

end remote

RaspInLoop

Hello all,

I just came into something that might be interesting to simulate and debug applications using PI4J.  Have a look at RaspInLoop.  I am an IntelliJ user so I can’t test it.  Hopefully there will come something similar for IntelliJ.

Jan

New Car Chassis

Hello all,

first of all I want to wish you all a very happy 2016.  Hope all your dreams may come true and mine of course.

During the Winter holidays I took the opportunity to order a new chassis for the Raspberry Pi Controlled Car.  The one I got was not good.  Pieces were missing or incorrect and that made it not as expected.  The package came from China and was cheap so I won’t complain.  It’s sometimes a risk we have to take.  Anyway, I did use that chassis to do my first developments and tests so it was not a waste of money.  Once the new chassis was there, I directly started setting it up and and let it drive.  You can see some pictures here under.  I am pretty satisfied I got it working.  I made a little interface in JavaFX with a couple of buttons : Forward, Backward, Left, Right and a speed slider.  That’s all I need for the moment in the interface.  As I said.  Very simple.  The interface is running on my laptop and it communicates via RMI towards my developments installed on the Raspberry Pi.  It is working well although I notice sometimes a lack of responsiveness.  Question is if my choice for RMI is the reason for that or not.  I haven’t taken the time to investigate if I could use for example a light webservice (REST) to speed up.  Anyway, the goal was to let it move and turn …  Now I need to do the finetuning when I have time.

IMG_2220 IMG_2221 IMG_2219