Show Posts
Pages: 1 ... 423 424 [425] 426 427 ... 586
6361  Using Arduino / Project Guidance / Re: 1khz frequency downsampling for phototransistor 40k RPM counter on: July 14, 2011, 09:23:06 am
The only interrupt running apart from yours is the millis() timer, I doubt this will have any serious affect on the timing and anyway you can calibrate the code.

I'd just use the code from reply #1, I see no reason that wouldn't do the job. And make sure your input is a clean waveform.

______
Rob
6362  Using Arduino / LEDs and Multiplexing / Re: sensor array time critical on: July 14, 2011, 08:50:01 am
Ok, another thought.

Use 50 (can you get by with 48, that's a much better number for hardware) photo transistors all wired open collector.

When Any one of them is triggered it interrupts the Arduino and at the same time latches all 50 inputs into 5 shift registers.

The Arduino notes the time then waits for the pulse from the second array which is wired the same.

On getting the second pulse you read the data from all 10 shift regs, By finding the 1-5 high bits you can determine the centre for your trajectory.

You can halve the number of shift regs needed by putting both arrays in parallel and making sure you scan the bits from the first pulse before you get the second.

So just thinking aloud, if you use a Mega (54 inputs) you can probably do the lot without the shift regs. You only need the trigger timestamp and the bits that were set at the time of the trigger.

You're ISR might look something like this


Code:
first_pulse = 0;
ISR xx () {
  if (first_pulse != 0)  {
   first_pulse = micros();
   bits[0] = PORTA;
   bits[1] = PORTB;
   bits[2] = PORTC;
   bits[3] = PORTD;
  } else {
   second_pulse = micros();
   bits[4] = PORTA;
   bits[5] = PORTB;
   bits[6] = PORTC;
   bits[7] = PORTD;
  }
 
}

When done scan the first 4 bytes looking for the set bits and use the middle one as your position then repeat for the second four bytes.
______
Rob
6363  Using Arduino / LEDs and Multiplexing / Re: sensor array time critical on: July 14, 2011, 08:30:34 am
Quote
How would I efficiently OR the sensors togther in terms of circuitry?
What are the sensors? Data sheet?

LDRs would be difficult to OR I think.

Transistors could all be wired open collector to produce a single INT pulse per array then run something like robtillaart's code to find the mid point.

_____
Rob
6364  Using Arduino / LEDs and Multiplexing / Re: sensor array time critical on: July 14, 2011, 08:02:58 am
Is there only one object at a time?

I ask because it will make a huge difference to what needs to be done. For example if that's the case you don't really need to poll the sensors at all, just OR them all together so you have a start pulse from one array and a stop pulse from the other.

I think LDRs are a bit slow to respond (might be wrong there), if so what about using photo transistors? 

______
Rob
6365  Using Arduino / Project Guidance / Re: Why are the photo interrupter not working? on: July 14, 2011, 04:48:58 am
The data sheet is quite unclear to me as to the pinout re long/short leads. It's quite possible the long lead is the cathode.

To find out do this.

 5V---RESISTOR---LONG PIN---SHORT PIN---GND

Now measure the voltage from long pin to short pin.

If the LED is conducting it will have about 1.5v across it so the reading will be something in this range. long pin = Anode, short pin = cathode.

If the LED is not conducting it will have 5v across it. short pin = Anode, long pin = cathode.

______
Rob
6366  Using Arduino / Project Guidance / Re: Why are the photo interrupter not working? on: July 14, 2011, 04:35:46 am
Quote
ASSUMING THAT THE LONG LEAD IS ANODE,
A reasonable assumption, but I can't verify from the data sheet.

Quote
Pin 1 goes to one end of a 120 ohm resistor, the other end of the resistor goes to  +5 volts.
     Pin 2 goes to ground.
Other way around. Pin 1 to GND, 2 to 5v. Resistor can be in series on either side of the LED.

Quote
10K resistor between 4 & gnd
You can do this two ways, the link you showed has the resistor from pin 4 to GND, the Arduino input on pin 4 and pin 3 to 5V.

OR

Pin 3 to 5v (through a resistor) and have the Arduino input on pin 3.

One way will invert the signal, the other will not.

______
Rob
6367  Using Arduino / Sensors / Re: Proper MOSFET to power DS18B20 in parasite mode on: July 14, 2011, 03:55:04 am
Is it not possible to start 5 readings, wait 500mS or whatever then get the results?

______
Rob
6368  Using Arduino / Programming Questions / Re: First project almost complete; RunningAverage not averaging on: July 13, 2011, 11:00:26 pm
Looking at the code I'd say that once the temp is over the threshold and you turn the buzzer on you are constantly resetting previousMillis so the

if(millis() - previousMillis > interval)

test is always true and the buzzer will never turn off. Try this

    if(millis() - previousMillis > interval)
    {
       
      // if the buzzer is off turn it on and vice-versa:
      if (buzzerState == LOW) {
        previousMillis = millis();   // only reset previousMillis if the buzzer is not already on
        buzzerState = HIGH;
      } else
        buzzerState = LOW;
    }
  }

______
Rob

6369  Using Arduino / Programming Questions / Re: First project almost complete; RunningAverage not averaging on: July 13, 2011, 10:53:06 pm
Quote
However, if I then close the monitor window, it instantly stops buzzing, and when I open monitor again, it shows the temperature in my mouth
Opening and closing the monitor will reset the Arduiono, so it seems tha what you are seeing is the temp reading working once after reset and never again.

______
Rob
6370  Using Arduino / Sensors / Re: Proper MOSFET to power DS18B20 in parasite mode on: July 13, 2011, 09:57:21 pm
Quote
An Arduino pin can supply that, can't it?
Yep, I guess you just have to disable I2C and turn the pin into an output for the duration, I haven't looked but presumably the library does this.

Quote
The pin you are using for 1-Wire communications is capable of becoming a "strong pullup" through the OneWire library.
As Coding Badly said.

______
Rob



6371  Using Arduino / Project Guidance / Re: Super Simple Bidirectional 5Volt & 3.3Volt Logic Level Converter Needed on: July 13, 2011, 08:15:58 pm
I don't think that diode setup will work as is.

I2C is an open-drain bus so it needs pullup resistors, that circuit doesn't have any.

Also, the 3v3 signal is being reduced to ~2v5 by the single diode, IIRC that is right on the edge of a valid logic high and will probably be unreliable.

I think something similar to what you have may work but without redrawing I can't get my head around it.

EDIT: I had a play with ideas but couldn't find anything that works with just diodes and resistors.

______
Rob
6372  Using Arduino / Sensors / Re: Proper MOSFET to power DS18B20 in parasite mode on: July 13, 2011, 08:05:19 pm
Quote
It's all greek to me
Normally the chip gets its power through the 4k7 resistor.

What that is saying is that under certain conditions (temp conversion and eprom writing) the chip needs more power than can be supplied through the resistor so you have to provide it some other way. The method they suggest is to basically short out the resistor with a FET, thus providing a hard power supply to the bus.
 
This means that no bus activity can occur while the FET is turned on.

Another thing to note about parasitic power is that it's not recommended over 100C temps.

______
Rob
6373  Using Arduino / Project Guidance / Re: 1khz frequency downsampling for phototransistor 40k RPM counter on: July 13, 2011, 07:40:51 pm
I don't see why you need an RTC, the Arduino clock should be well accurate enough for this.

______
Rob
6374  Community / Bar Sport / Re: If you post same question on multiple forums, are you cross-posting? on: July 13, 2011, 07:35:24 pm
What Rob said.

But why don't you ask the question on a few other forums and see what they say?

______
Rob
 
6375  Using Arduino / Programming Questions / Re: bitWrite() creates drifting bytes (reorganizing bytes and splitting up) on: July 13, 2011, 09:10:45 am
Not your problem but surely

Code:
bitWrite(count,0,bitRead(usl[j],0));
 bitWrite(count,1,bitRead(usl[j],1));
 bitWrite(count,2,bitRead(usl[j],2));
 bitWrite(count,3,bitRead(usl[j],3));
 bitWrite(count,4,bitRead(usl[j],4));
 bitWrite(count,5,bitRead(usl[j],5));
 bitWrite(count,6,bitRead(usl[j],6));
 bitWrite(count,7,bitRead(usl[j],7));
 bitWrite(count,8,bitRead(usl[j+1],0));
 bitWrite(count,9,bitRead(usl[j+1],1));
 bitWrite(count,10,bitRead(usl[j+1],2));
 bitWrite(count,11,bitRead(usl[j+1],3));

could be

Code:
count = usl[j] + (usl[j+1] << 8);

or did I miss some nuance of the code?

Also j is running from 0 to 7 and indexing into an array of 4 bytes (usl).

______
Rob
Pages: 1 ... 423 424 [425] 426 427 ... 586