OUTDATED !!!! Pecking test computer configuration - theunissenlab/lab-documentation GitHub Wiki
Pecking test computers
The pecking test is currently set up on 4 boxes, controlled by 2 computers. The computers are both Intel NUCs - Product #BOXD34010WYKH1 - with 4 USB ports and headphone audio out. The two computers are:
- Chubbyninja
- Controls boxes 5 and 6
- IP Address: 192.168.0.112 (external) 10.42.0.1 (local)
- Connected to keyboard, mouse and monitor
- connected to 123E Wifi
- connected to pumpkin via ethernet cable
- Pumpkin
- Controls boxes 2 and 3
- IP Address: 192.168.0.102 (external) 10.42.0.23 (local)
- connected to 123E Wifi
- connected to chubbyninja via ethernet cable
Network
- NWAF network IP: 192.168.0.1
- WiFi SSID:
- WiFi Password:
- WiFi Router admin password:
Incoming data are redirected by the router on Chubbyninja (acting as a virtual server) for interpretation, using port 65454. The wifi router cannot itself interpret incoming commands.
The port must be enabled on chubbyninja in the file /etc/sshd_config. After adding the port the computer is listening to in this file, the ssh deamon must be restarted by typing
sudo ssh service restart
Data saving system
The data saving system is set up in the following way. On each computer, the drive folder contain the Pecking_test folder which is synced using insync with the bdrive Pecking_test folder (account [email protected]). Only part of the content of Pecking_test under bdrive is synced with the local computers:
125_Computers
PythonConfig/scripts
PythonConfig/Commands
PythonConfig/Configuration
PythonConfig/Start Session Data Form.gdform
PythonConfig/Shaping Protocol Python Config.gddoc
PythonConfig/Pecking data.gdsheet
PythonConfig/Pecking data links.gddoc
PythonConfig/Fasting Data Form.gdform
PythonConfig/Session Data Form.gdform
PythonConfig/To-do list.gddoc
PythonConfig/Pyoperant additions.gddoc
PythonConfig/Run an experiment.gdform
PythonConfig/Rules to feed the birds!.gddoc
PythonConfig/Seed consumption experiment.gdform
Then each computer chubbyninja and pumpkin are synced with their respective data folder:
PythonConfig/experiment_chubbyninja
or PythonConfig/experiment_pumpkin
When birds are done running one experiment then their data folder is transferred to PythonConfig/Projects under the corresponding project folder.
All the Pecking_test folder is entirely synced also using insync with tdrive: /auto/tdrive/julie/drive/Pecking_test
including the Projects folder that contains all the data from the pecking test archived.
Audio Config
To check all devices that can work as sound cards type cat /proc/asound/cards
To check the usb devices type lsusb
You should see the sound card in both of these and you can use that information to edit the two files below as needed.
To test the sound you can use: aplay - D speaker0 ~/test_song.wav
/etc/udev/rules.d/analog_audio.rules
KERNELS=="card[0-9]*", SUBSYSTEMS=="sound", ATTRS{id}=="PCH", ATTR{id}="Analog"
or
KERNELS=="card[0-9]*", SUBSYSTEMS=="sound", ATTRS{id}=="Juke", ATTR{id}="Analog"
The above rule tells udev
(the linux device manager) to locate the device with an id
matching PCH
(for the built-in soundcard) or Juke
(for the external USB soundcard we've been using after the internal soundcards broke down). It gives this device the fixed name Analog
, which will be used in the next step.
/etc/asound.conf
# Pieced together from
# http://alsa.opensrc.org/Asoundrc#Splitting_front_and_rear_outputs and
# http://stackoverflow.com/questions/14725257/alsa-python-capturing-multiple-mono-audio-inputs
pcm.split {
type dmix
ipc_key 2048
slave {
pcm "hw:Analog"
channels 2
}
}
pcm.speaker0 {
type plug
slave.pcm "split"
hint {
show on
description "Plays sound through the left channel only"
}
ttable.0.0 1
}
pcm.speaker1 {
type plug
slave.pcm "split"
hint {
show on
description "Plays sound through the right channel only"
}
ttable.0.1 1
}
Alsa is software that manages audio interfaces in linux. The above configuration creates three virtual devices: split
, which is a two channel device mirroring the device named Analog
which we configured with udev
, and speaker0
and speaker1
, which represent the left and right channels of split
. We can now play audio out of the left and right channels independently by playing sound to speaker0
and speaker1
, respectively. You might have to change the name of the device Analog
if it does not match what you find out typing lsusb
and cat /proc/asound/cards
Amplifier
Audio is run out of the headphone jack where it connects to an amplifier. The amplifier should be adjusted to provide the desired output sound level within its corresponding boxes. The left and right channels output from the amplifier are sent one to each box that the computer controls.
Controlling the boxes and collecting data
The boxes are interfaced with using an Arduino Uno hooked up to each chamber. The Arduino outputs 3 digital signals to control the pecking button light, the feeder, and the main house light (I don't think this one works though...). It has 1 digital input from the pecking button. The functioning of the chamber and programmatic interface to it should be discussed elsewhere, but there are a few things that are needed to make things work on the computers.
- The Arduino software must be installed
- Can be done through
sudo apt-get install arduino
- Can be done through
- User must be added to the "dialout" group. This is done automatically when the Arduino software is run for the first time. You must log out and log back in before this takes effect.
- Again, udev will initialize the Arduinos in arbitrary order, so custom rules should be applied. These rules will create a symbolic link in /dev that points from a consistent and interpretable name like "ttyArduino_box2" to the randomly given name like "ttyACM1".
### Box 2:
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Arduino (www.arduino.cc)", ATTRS{serial}=="95232343733351909201", SYMLINK+="ttyArduino_box2"
### Box 3:
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Arduino (www.arduino.cc)", ATTRS{serial}=="95232343733351403182", SYMLINK+="ttyArduino_box3"
### Box 5:
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Arduino (www.arduino.cc)", ATTRS{serial}=="9523234373335140A011", SYMLINK+="ttyArduino_box5"
### Box 6:
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Arduino (www.arduino.cc)", ATTRS{serial}=="952323437333518041A1", SYMLINK+="ttyArduino_box6"