Showing posts with label olfactometer. Show all posts
Showing posts with label olfactometer. Show all posts

Saturday, May 12, 2012

Open-Source Arduino-Based Olfactometer Shields

We just put together a set of shields to allow Arduino-based olfactometer control.  I am including the linked schematics here.  To make these shields, we are using a program called ExpressPCB, which is linked to a printing service.  I will not go through the details of what component goes where on the PCB, but I assume anyone with some electronics know-how should be able to figure them out.

ArduinoShieldBasic.pcb - Template we use for designing shields for Arduino Mega

rs232shield2.pcb - A module we use to communicate with Alicat MFCs

This module converts from Arduino's TTL serial to RS232 serial.  It also has a pwm signal filter and unity gain to allow analog output from two channels on the Arduino for control using an analog voltage.

valvedriver3.pcb - The valve-driver module for controlling odor valves

The module has optocouplers to switch solenoids on or off and status LEDs to view valve state.

valvedriverSMT.pcb - Another valve driver module with ribbon cable breakout (below)
ValveBreakout.pcb - the breakout with indicator LEDs


Valve - breakout












Valve - driver

Wednesday, April 25, 2012

Measuring Olfactometer Output in Odor Port

Odors are hard to measure and typical humans have little intuition for how they behave.  However, there are now ways to [relatively] easily measure the concentration of odors in clean air.  These devices are called photoionization detectors (PIDs) and they are used heavily in industry to detect specific volatiles.  Many of these devices are good at quantifying a stable odor source, but lack temporal resolution.  Some companies, however, have elected to make particularly fast PIDs.  One of these is the minPID from Aurora Scientific.  This device gives a measure of odor concentration in clean air with millisecond precision.

We use it routinely to calibrate our odor presentation and it is really the only reason we have solid idea about what odor concentration is being presented to the animal in our odor port.

Routine testing: miniPID (bottom) inserted into one of the odor ports.

Wednesday, April 11, 2012

Tubing and odors, a non-ideal combination

In olfactometry, one is constantly fighting to produce temporally precise and stable concentration outputs.  This is especially critical when you want to make detailed measurements of perception or neural activity.  Unfortunately, investigators are constantly confounded by artifacts that can distort the temporal properties and concentration profile of odor output.  On this blog, I hope to eventually cover several issues that typically come up in calibrating olfactometers.  In this first installment, I will deal with the issue of tubing after the jump.

Friday, April 6, 2012

Human Olfactometer in Action

Today was a day of putting the new Alicat MFC powered human olfactometer through its paces.

We tested:

1. Onset Latency (NResearch final valve)
2. Concentration steps via flow dilution (Alicat MFC)
3. Concentration waveforms (Alicat MFC)
4. Odor sampling by human subject (YBS)

Here are pictures of our setup:

Olfactometer Test Setup 1: Kinetics.  The PID (photoionization detector) is sampling directly from  the nose port.  The scope is displaying PID output and flow from the flow sensor (below).  Scope is being triggered on final valve onset.
Closeup of nose port (Nasal Ranger) connected to our teflon odor injector (right top) and then Honeywell flow meter at exhaust (bottom).  Here the PID is sampling from the exhaust.

Wednesday, March 21, 2012

Nose Poke Circuit

Just finished my nose poke circuit.  It consists of a beam break that triggers an notification LED to come on and toggles output state.

UPDATE:

Turns out that the transistor for the Poke Notify LED sucked current away from the output, reducing the "high" signal voltage sometimes to below TTL levels.  Replacing the transistor with a mosfet (in this case an AND gate) solved the issue.  Here is the new circuit which uses the AND gate to drive both the TTL output and the Poke Notify LED.


Monday, March 19, 2012

MFC Control Complete

Today I finished implementing control over my mass flow controllers from Alicat.  I now have the capacity to drive two MFCs via analog voltage or serial from our custom Arduino shield.  Everything works directly from MATLAB.

This is our Arduino-based olfactometer control module connected to two Alicat MFCs.
The output works at high frequencies with the MFCs being able to follow up to 3 Hz well.  I doubt that this performance will be maintained with long downstream tubing, but I hope to be able to do at least 1 Hz at output.

I had to work out a kink to get switching between serial and analog control to work.  The Alicat documentation says that A$$W20=16384 should enable analog set point. However, I found that this does not work.  Reading register 20 after setting analog set point from the front panel, however, showed that the correct value is actually 17408.

The Arduino will start by default in analog control mode. To switch modes:

[mode] = {0: SERIAL_OUT, 1: ANALOG_OUT}
olf.funcALIMode([mode]);

I tested the whole setup using my handy dandy flowmeter and things work very well so far.  Here is the code I used for my current test setup:


olf = OlfactometerDriver_SerialInterface('COM10'); pause(12);


% proportional control var
olf.funcALIMessage('A$$W21=500')
% differential control var
olf.funcALIMessage('A$$W22=10')


olf.funcALISin(1,1,0.5);
olf.funcALISin(0,1,0.5);


Next step: connect the MFCs to the olfactometer, determine the right parameters for sinusoids, and verify output via PID.


Thursday, March 15, 2012

My Awesome Test Setup

Here's a picture of my setup.  On top of the Arduino is our custom valve driver shield.  Attached to the shield DB9 port is my hastily soldered inverter.  That connects to the Alicat MFC.  The Arduino is also connected to the PC by its USB port.

PC (MATLAB) --> Arduino --> MFC


Below is what interacting with the MFC looks like from MATLAB.


Outputting Functions to MFC

One of the thing I want to be able to do is to output arbitrary odor waveforms with my MFCs.  As a start, I implemented a Sin function to be output to the MFC (i.e. changing the flow rate at some set frequency).  I am hoping to put my MFCs into the setup to verify that they are working properly.

What I did was put a function that gets called on each loop of the Arduino which updates the flow rate at 100 msec intervals.

void loop()                     
{
  ...
  ALI.makeSin(); // ALI is my AlicatMFC object
}


void AlicatMFC::makeSin()

{
  float flow;
  unsigned int uiflow, flow_out;
  
  if (!_on) return;
  if ((millis()-_tL)<100) return;
  
  _tL = millis();
  
  flow = _mean + _ampl / 2.0 * sin( (float) (_tL - _t0) * 2.0 * 3.1415926536 * _freq / 1000.0 );


  if (flow > 1.0) flow = 1.0;
  if (flow < 0.0) flow = 0.0;
  
  uiflow = (unsigned int) ((float) ALI_MULTIPLIER * flow);
  
  setFlow('A',uiflow,&flow_out);  
}



Tuesday, March 13, 2012

RS 232 Voltages

I managed to get some serial input from the MFC to the Arduino, however, the input was garbled!  One cause of this could be that the RS 232 voltage levels sent by the Alicat MFCs are inappropriate for the Arduino to handle directly.  I will call tech support tomorrow to determine their exact specs to see if all could be fixed with a simple resistor or if I will need some more serious circuitry.

However, I measured the output signal on my oscilloscope and I see that it indeed is 0-5V, which should be fine as far as the Arduino is concerned.  Strange behavior.

Setting Up Serial Comm with MFC via Arduino

I am now working on linking our Arduino to the Alicat MFCs.  I am connecting Serial port 3 on the arduino to the Alicat via a DB9 on our custom made Arduino shield.  As far as the software goes, I am first just forwarding strings sent to the Arduino from MATLAB on the PC to the Alicat and strings sent from the Alicat back to MATLAB.

One of the things I want to be able to do is to produce different odor concentration waveforms by manipulating the MFCs.  For example sine curves.

To do this more interesting and faster control, I will implement direct functions in the Arduino that will manipulate the MFC flow rate in real time.

Monday, March 12, 2012

Never Trust a Cable Just Because It Has The Right Connectors

I got some DB9 to mini DIN cables to connect to my Alicat MFC and... no luck.  After 1/2 hour of making sure I connected to the right PC serial port, I realized that the cables I got were designed for some other use.  They connected the wrong pins (only 3) from the DB9 to the DIN.  However, lucky for me, the DB9 connector on the cable was easily open-able and the cable had all the strands I needed!

The necessary connector layout is as follows:

DB9 --------------> 8 Pin Mini-DIN
5 ----- Ground ---- 8                                                             
3 ------ TX ------- 3
2 ------ RX ------- 5

Serial Port Support

Our Arduino powered valve driver makes control of solenoid valves from the PC easy.  We gave one of our valve drivers to a neighboring lab that is setting up some basic olfactometry.  They are trying to integrate it with existing software.  However, I realized that I wrote the whole library for our Arduino to specifically communicate with MATLAB through a custom object.  To make the system compatible with their software, I added simple serial port text parsing so now the Arduino can be controlled by several methods!

It should now be possible to turn on valve 0 by typing:

S valve 0 1

Our Home Made Olfactometer

In the lab, we are doing both human and rodent olfactometry.  What does that mean?  Well, to study olfaction we need to present controlled odor concentrations.  This is achieved via a device called an olfactometer.  Instead of buying one, we decided to make our own.  This device is a teflon/glass olfactometer controlled by an Arduino running custom code controlling solenoid valves.  This device lets us present steady odor concentrations to our subjects and rapidly switch between odors.  The olfactometer air delivery is currently controlled by simple flow meters.  However, we are now switching to mass flow controllers to enable rapid alterations in odor flow.  My next technical part will be to write a control interface for the Alicat MFCs we got in the mail last week.