project:medlab:gsr
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
project:medlab:gsr [2014/07/13 02:27] – created jenda | project:medlab:gsr [2015/03/30 17:08] (current) – data logging jenda | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | ====== Arduino GSR ====== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | {{ : | ||
+ | x-axis: time, 10px/s; y-axis: conductance, | ||
+ | |||
+ | ===== Schematics ===== | ||
+ | |||
+ | Adjustable current (~5μA) is passed through the subject and the voltage drop is read with AtMega ADC (as we have not found any other ADC). The ADC reference level is set by the second potentiometer. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Adding capacitors to AREF and ADC (A0) improves stability. We recommend something like 47 μF to AREF and 2.2 μF to ADC. | ||
+ | ===== Electrodes ===== | ||
+ | |||
+ | Electrodes are placed on two fingers of the same hand. | ||
+ | |||
+ | Using pieces of PCB (or other metal) as electrodes is really prone to motion and galvanic artifacts. Using 4x4cm TENS gel electrodes gives clean signal with no motion artifacts. The electrode is rolled around the finger and secured by [[https:// | ||
+ | |||
+ | {{ : | ||
+ | ===== Usage ===== | ||
+ | |||
+ | - Set OFFSET to maximum resistance | ||
+ | - Connect electrodes | ||
+ | - Adjust REF to get the signal approximately to the middle of the scope | ||
+ | - If this is impossible or the signal is very noisy, decrease resistance of REF | ||
+ | |||
+ | ===== Source ===== | ||
+ | |||
+ | |||
+ | |||
+ | <code c> | ||
+ | int sensorPin = A0; | ||
+ | int sensorValue = 0; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | analogReference(EXTERNAL); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | sensorValue = analogRead(sensorPin); | ||
+ | Serial.println(sensorValue, | ||
+ | delay(100); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | import pygame | ||
+ | import random | ||
+ | import time | ||
+ | import serial | ||
+ | import sys | ||
+ | |||
+ | SCREENSIZE = XSIZE, YSIZE = (1350, 514) | ||
+ | |||
+ | screen = pygame.display.set_mode(SCREENSIZE) | ||
+ | x = 4 | ||
+ | |||
+ | # background color | ||
+ | bg = (200, | ||
+ | |||
+ | # line color | ||
+ | fg = (0,0,0) | ||
+ | screen.fill(bg) | ||
+ | |||
+ | ser = serial.Serial(port="/ | ||
+ | |||
+ | yprev=0 | ||
+ | |||
+ | # grid color | ||
+ | gc = (150, 150, 150) | ||
+ | |||
+ | def grid(x): | ||
+ | ''' | ||
+ | for i in range(1, | ||
+ | pygame.draw.line(screen, | ||
+ | |||
+ | from datetime import datetime | ||
+ | from time import gmtime, strftime | ||
+ | |||
+ | wow=datetime.now().strftime(" | ||
+ | l=open(" | ||
+ | |||
+ | |||
+ | while True: | ||
+ | line = ser.readline() | ||
+ | sys.stdout.write(line.decode(" | ||
+ | l.write(line.decode(" | ||
+ | x = (x+1)%(XSIZE-2) | ||
+ | try: | ||
+ | y = int(line)/2 | ||
+ | except: | ||
+ | y=0 | ||
+ | |||
+ | # remove previous data | ||
+ | pygame.draw.line(screen, | ||
+ | # draw red line | ||
+ | pygame.draw.line(screen, | ||
+ | # draw grid | ||
+ | grid(x) | ||
+ | # draw data | ||
+ | pygame.draw.line(screen, | ||
+ | yprev=y | ||
+ | pygame.display.update() | ||
+ | |||
+ | |||
+ | </ |