Show Posts
Pages: 1 ... 34 35 [36] 37 38 ... 40
526  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with a CO2 sensor on: May 07, 2010, 10:35:47 am
btw:
1.
do u know where pin 14 is?
i think it is analog pin 0...

2.
after a reset all analog pins r configured as inputs...
so that u can be quite sure, that the sensor isnt damaged by them...
but maybe u want to put a resistor (2kOhm or so) between the arduino pin and the sensor PWM output... just to be sure... :-)

-arne
527  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with a CO2 sensor on: May 07, 2010, 09:30:31 am
1.
the co2 sensor and the arduino need to share a common ground voltage level...
how does ur power supply look like?

2.
the PWM output varies between 0V and V+ of the CO2 sensor...
the arduino needs below 30% of its supply voltage for a digital LOW...
the arduino needs above 70% of its supply voltage for a digital HIGH...
but the arduino doesnt like voltages below 0V or above its supply voltage...
maybe u need a voltage divider if the PWM output voltage can be higher than the arduino supply voltage...?

3.
i would use the following method to convert the PWM into the ppmCO2 value, because it doesnt depend on an accurate time (on my arduino i have an error of +0.3% IIRC... 0.3% of 1004ms (~=~3ms) corresponds to 6ppmCO2):
Code:
uint16_t pwm2ppm(uint8_t pin) {
  while (digitalRead(pin) == HIGH);
  while (digitalRead(pin) == LOW);
  uint32_t h,l;
  for (h=0; digitalRead(pin) == HIGH; h++);
  for (l=0; digitalRead(pin) == LOW; l++);
  // h+l <=> 1004msec
  // 1004*h/(h+l) <=> duty cycle D in msec
  // (D-177)/0.5 + 350 = ppmCO2
  return ((2*1004*h+1004)/(h+l)-2*177) + 350; // +1004 for proper rounding...(?)
}

maybe u should even disable interrupts...
http://arduino.cc/en/Reference/noInterrupts

-arne
528  Forum 2005-2010 (read only) / Interfacing / Re: Problem with k'nex motor and arduino on: June 05, 2010, 09:58:00 am
u should use a transistor..

1.
BJT: amplifies its base current... so with a 2N4401 u can use 500uA via a 10k Ohm resistor to give that motor 150mA(max)...
http://en.wikipedia.org/wiki/BJT

2.
MOSFET: with a IRLML2502 u can use a 5V/0V voltage to turn on/off the ground connection of that motor... there will be almost only the charge current for the gate capacitance...
http://en.wikipedia.org/wiki/Mosfet

-arne
529  Forum 2005-2010 (read only) / Interfacing / Re: beginner ?with stepper motor driver (Allegro 2916) on: June 06, 2010, 04:45:52 am
i dont know...

i cannot c the picture that u want to show...
can u show us a schematic of ur planned circuit?

while u r not sure, if u connected everything right, u should limit the current to 100mA somehow...

-arne
530  Forum 2005-2010 (read only) / Interfacing / Re: beginner ?with stepper motor driver (Allegro 2916) on: June 05, 2010, 10:00:29 am
have u seen this:
http://www.allegromicro.com/en/Products/Part_Numbers/2916/2916.pdf
?

-arne
531  Forum 2005-2010 (read only) / Interfacing / Re: 12V led strip to arduino on: May 30, 2010, 11:27:20 am
here is a schematic:
NPN-Switch

in ur case the switch is always closed,
but the resistor is connected to an output pin of the arduino instead of the power supply...

the transistor needs a current through its base pin that is 100 to 300 times lower, than the current through its collector pin... that is what the resistor is good for... the base pin cannot take very high currents btw... :-)

-arne
532  Forum 2005-2010 (read only) / Interfacing / Re: Help with CO2 sensor hookup on: May 18, 2010, 01:50:04 pm
how do u measure those 3.25V?
i thought it cant go higher than 50mV?
 [smiley=beer.gif]
-arne
533  Forum 2005-2010 (read only) / Interfacing / Re: Help with CO2 sensor hookup on: May 10, 2010, 09:23:04 am
if u want to use that MG thingy,
1.
u need a 5V/400mA power source
that u connect to the H pins (polarity does not matter)...
u should make sure
that the current is clearly below 200mA (use a "multi fuse 200mA" and an ampere-meter for that)...
2.
u need a voltage meter with very high input resistance (at least 10 G Ohm = 10,000 Mega Ohm)...
normal voltage meter (e. g. my "multimeter") have 1 M Ohm (1 Mega Ohm)...
the arduino pins (configured as _input_) have several 100ths of Mega Ohm...
that TLC271 Op Amp seems to have about 30 G Ohm...
the datasheet contains apropriate circuits...
this is a general circuit:
http://en.wikipedia.org/wiki/Operational_amplifier#Non-inverting_amplifier
3.
u need a place that cannot burn, even when u r not there...
because: the sensor needs a day to get its chemistry right...
maybe u should check with ur local fire department...?
maybe an empty garage would do?

-arne
534  Forum 2005-2010 (read only) / Interfacing / Re: Help with CO2 sensor hookup on: May 10, 2010, 03:43:58 am
the TLC271 (OpAmp) seems to be a good choice, 2...

if u dont like to make a complicated circuit, u might like these:
http://www.mb-systemtechnik.de/produkte_co2_messung_co2_sensor_modul.htm
http://www.senseair.se/oem.php
but they r more expensive, IIRC...

-arne
535  Forum 2005-2010 (read only) / Interfacing / Re: serial interface of the arduino at 1Mbps? on: May 11, 2010, 09:32:36 am
even 2Mbit/sec... :-)

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254424833

-arne
536  Forum 2005-2010 (read only) / Interfacing / Re: How to generate heat (36 - 43 degree)? on: April 30, 2010, 07:04:55 am
i would use 36Ohm 600mW resistors with a current of less than 90mA...

a good heat insulation around the circuit helps to distribute the heat evenly...

-arne
537  Forum 2005-2010 (read only) / Interfacing / Re: Indoor Air Quality Sensor on: April 22, 2010, 05:46:22 pm
oh - i forgot to check this thread again...
i hope i m still in time...

it is very unlikely that u check at the right microsecond, because all those things can take several microseconds...
so u should write "if (duration < x*1e6)"...

the while-condition looks suspicious, too...
it should be "while (duration < x*1e6);"...

btw: why do u want to use floating point arithmetics?
u could use "if (duration < x*1000000UL)", too...
"UL" means "unsigned long"... an "unsigned long" is a "uint32_t"...

and u should reset "pulseLow" to "0" in the "else" branch...

pulseIn delivers a value in "milli seconds"... so u should devide it by 30e3 (not 30e6)...

the rest looks good...
but just for 1.19hrs... :-) then or about then micros() starts at 0 again...

why dont u do it without the "x"?

Code:
void loop() {
  // 1. phase: pulseIn for 30 seconds
  const uint32_t howlong = 30000UL;
  const uint32_t sts = millis(); // start time stamp
  uint32_t ls = 0;
  while (millis() - sts < howlong)
    ls += pulseIn(...);
  percentage = ls/(howlong/100);
  // 2. phase: interpret the result
  ... like the else-branch
}

NB: in unsigned integer arithmetics a single overflow is well tolerated in the "millis() - sts" subtraction above...
e. g.: we use a 3 bit integer and howlong is 2:
Quote
sts=6 millis()=7 --> 7-6 = 1 < 2
sts=6 millis()=0 (overflow occurred) -> -6 mod 8 = (-6+8) mod 8 = 2 mod 8

-arne
538  Forum 2005-2010 (read only) / Interfacing / Re: Indoor Air Quality Sensor on: April 16, 2010, 04:49:24 am
Hi!

The pulse length is between 10msec and 90msec according to that datasheet...

For connections to arduino u should use a resistor... so that in case of a mistake u cant fry ur arduino or ur sensor... 10kR should suffice...  smiley-razz

U could try to use digitalRead() like this (due to interrupt activity the readings might be inaccurate):
Code:
// wait for end of pulse cycle
while (digitalRead(air_pin) == HIGH);
while (digitalRead(air_pin) == LOW);
// now do the timing
const uint32_t t0 = micros();
while (digitalRead(air_pin) == HIGH);
const uint32_t t1 = micros();
while (digitalRead(air_pin) == LOW);
const uint32_t t2 = micros();
// send out the duty cycle (HIGH percentage) via UART (maybe u need the LOW percentage)
Serial.print((t1-t0)*1e2/(t2-t0));
Serial.println('%');
There r more accurate methods by counting loop cycles (without micros() and with noInterrupts()):
http://arduino.cc/en/Reference/PortManipulation
and less accurate methods:
http://arduino.cc/en/Reference/PulseIn

or a RC-lowpass with analogRead()...

Cheers, Arne
539  Forum 2005-2010 (read only) / Interfacing / Re: couple of questions on: April 22, 2010, 06:09:35 am
SPI: http://www.arduino.cc/playground/Code/Spi

reading from a microphone:
maybe u need an amplifier?

just try it... :-)

e. g.: capacitor between mic amplifier (plus voltage divider) is connected to analog pin #0...
Code:
void setup() { Serial.begin(115200); }
void loop() { Serial.println(analogRead(0)); }
then u should c numbers that hop around the middle of the voltage divider...

Maybe u want to use this, 2 (in order to get a better resolution):
http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF
but that needs a change in the voltage divider...

-arne
540  Forum 2005-2010 (read only) / Interfacing / Re: couple of questions on: April 21, 2010, 05:37:55 pm
yup - u can use that capacitor + voltage divider trick from grumpy's url...

and my little formula... i dont know if that kind of average has already a name... i call it quick&dirty average...  smiley-razz

oh - u should transform the sample value to a signed integer and then use the absolute value of it, because u just care for the amount of deviation from silence ("0" depends on the voltage divider)...

-arne
Pages: 1 ... 34 35 [36] 37 38 ... 40