Toggle shoutbox Hyundai Aftermarket Shoutbox
|
The ER keeps complaining to my Biomed shop that they're having a problem with a ECG (electrocardiograph). You know, the thing in the movie hospitals that go beep..... beep..... beep.... Anyways, it's been showing artifacts in the signal and displaying a 60hz interference on-screen.
I decided to make an attempt to isolate the cause of the electromagnetic disturbance. So I built an Electric Field meter with my Arduino.
Here you can see it in action:
Looks like it might be a problem with the charging circuit of that emergency lamp.
The ECGs use very long leads, and intense signal processing to analyze waveforms. My arduino's digital input pins are not nearly as sensitive to 60hz interference as the ECG. Also, the antenna is only about 4 inches long, the ECGs leads are subjected to about 6 foot of "antenna" wires.
Here is the code I wrote to drive this meter.
I decided to make an attempt to isolate the cause of the electromagnetic disturbance. So I built an Electric Field meter with my Arduino.
Here you can see it in action:
Looks like it might be a problem with the charging circuit of that emergency lamp.
The ECGs use very long leads, and intense signal processing to analyze waveforms. My arduino's digital input pins are not nearly as sensitive to 60hz interference as the ECG. Also, the antenna is only about 4 inches long, the ECGs leads are subjected to about 6 foot of "antenna" wires.
Here is the code I wrote to drive this meter.
/*
Copyright 2010 Adam N. Outler Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */
//A note on HZ, if you notice meter oscillations on a known steady
// signal increase or decrease hertz by 1. The oscillations are
// caused when the signals are in near-perfect resonance.
float FrequencyToMonitor=59; //hertz
//setup pins
#define ANTENNA 31 //antenna pin
//16 LEDs on 16 different pins
int LEDPin[]={ 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 } ;
int LEDCount=16; //number of LEDs
//setup initial global values
int LEDCounter=0; //initial value of LEDs to display
int HalfPeriodMicroseconds=0;// initial value of halfwavelength
/*
SETUP defines pins and performs POT(Power On Test) on LEDs
*/
void setup() {
double HalfPeriod=((1/FrequencyToMonitor)*.5); //Half-period in seconds from frequency
HalfPeriodMicroseconds=int(1000000*HalfPeriod); //Convert period seconds to microseconds integer
pinMode(ANTENNA, INPUT); //set antenna pin
for (int Pin=0; Pin < LEDCount; Pin++) { //initialize each LED
pinMode(LEDPin[Pin], OUTPUT);
digitalWrite(LEDPin[Pin], HIGH); //Turn the LED on
delay(50);
digitalWrite(LEDPin[Pin], LOW); //Turn the LED back off
}
swingLEDs(); //perform LED check to verify LED functionality
}
/*
LOOP checks for value of antenna to go high and then low
if change is seen, then 2 LEDs are lit, otherwise total number
of LEDS are decreased. This allows for a magentic effect when
near the field.
*/
void loop(){
int ANTENNAValue=0; //sets and resets ANTENNAValue
int OldANTENNAValue=0; // as well as OldANTENNAValue
for ( int Pass=0; Pass < 4; Pass++ ) {//take 4 readings
ANTENNAValue=digitalRead(ANTENNA); // from the antenna
if ( ( ANTENNAValue == HIGH ) && ( OldANTENNAValue == LOW ) ) {
incrementLED(); //If a change is detected increase twice
incrementLED(); // 4 passes means 3 changes total
} else if ( ( ANTENNAValue == LOW ) && ( OldANTENNAValue == HIGH ) ) {
incrementLED(); // This makes the meter rise by
incrementLED(); // a total factor of 2 and
} else {
decrementLED(); // if there is no change it falls by 1
}
OldANTENNAValue=ANTENNAValue; //Log old value for next pass
delayMicroseconds(HalfPeriodMicroseconds); // half-wave pause before next reading
}
delayMicroseconds(HalfPeriodMicroseconds); //visual delay between reading passes
delayMicroseconds(HalfPeriodMicroseconds); //twice to avoid extremely long numbers
}
/*
FUNCTION swingLEDs tests the LEDs by lighting
them up sequentially. Each LED is brought high
then low twice.
*/
void swingLEDs(){
for (int Pin=0; Pin < LEDCount; Pin++) {
digitalWrite(LEDPin[Pin], HIGH); // instantanious full brightness
}
for (int Pin=0; Pin < LEDCount; Pin++) {
digitalWrite(LEDPin[Pin], LOW); // clear LEDs from left to right
delay(20);
}
for (int Pin=LEDCount; Pin > -1; Pin--) {
digitalWrite(LEDPin[Pin], HIGH); // light LEDs from right to left
delay(20);
}
for (int Pin=LEDCount; Pin > -1; Pin--) {
digitalWrite(LEDPin[Pin], LOW); // clear LEDs from right to left
delay(20);
}
}
/*
FUNCTION incrementLED increases the number
of LEDs lit by 1.
*/
void incrementLED(){
if ( LEDCounter < LEDCount - 1 ){ LEDCounter++;} //if not max increase
digitalWrite(LEDPin[LEDCounter], HIGH); //light new LED
}
/*
FUNCTION decrementLED decreases the number
of LEDs lit by 1.
*/
void decrementLED(){
digitalWrite(LEDPin[LEDCounter], LOW); //turn off current LED
if ( LEDCounter >= 0 ){ LEDCounter-- ;} // if not zero, decrease}
5 Comments On This Entry
Page 1 of 1
theresidenttechie
31 December 2010 - 01:17 PM
This is pretty cool, I like the concept. Very useful, I was wondering if you could post how you have your LEDs wired up. I would like to duplicate this, for use in my shop.
toddfun
31 December 2010 - 04:42 PM
the “if” and “else if” tests in the main loop are the identical tests. That is not of much use if you ask me.
theresidenttechie
02 January 2011 - 01:51 PM
thanks, very nice operation. I built it last night, and it works like a charm.
Page 1 of 1
Help


5 Comments







