Go Down

Topic: Saving I/O inputs and processing power (Read 756 times) previous topic - next topic

redcliffe

Hi. I'm working on an Pyranometer and UV Index meter. So far all I've done is interfaces the TAOS TSL230R sensor with my Arduino Uno as shown in the tutorial http://roamingdrone.wordpress.com/2008/11/13/arduino-and-the-taos-tsl230r-light-sensor-getting-started/#comment-310.

This method uses 5 Digital I/O pins. For my initial project I want to interface 2 of those sensors to the unit, plus for a later solar panel rotator project I'll have many other sensors and motor controllers. So I want to reduce the amount of I/O usage.

Here's my idea. I was going to jumper the various control pins manually high and low as required, and use pins 4 and 5 for the Fout data from the chips. Then in the main loop I was going to count pulses on each of those pins for 100m/s, instead of using the interupt method used in the tutorial.

Is this a good method, or are there better methods? Will this likely reduce the processor load for monitoring the chips? I've read that interrupt methods like the one in the tutorial don't leave much processor time for much else. Thanks,

David

Cylindric

That's sounds like what I'm planning on doing to count pulses from a set of PC fans' tachometer, rather than continuously count thousands of pulses
Current Projects: Rodentometer - Hamster Endurance Moni

Coding Badly

Quote
Is this a good method, or are there better methods?


It's your project (and you've described very little of it) so only you can answer that question.

Quote
Will this likely reduce the processor load for monitoring the chips?


Both methods count pulses over a time span.  The interrupt method runs "in the background" allowing your Sketch to do other work between pulses.  Your method blocks while counting so your Sketch will not be able to do other work between pulses.

In other words, neither method necessarily reduces the processor load.

Quote
I've read that interrupt methods like the one in the tutorial don't leave much processor time for much else.


That depends entirely on how the sensor is configured and the light intensity.  Obviously, in total darkness that statement is simply wrong.

I suggest you describe what you are trying to accomplish rather than giving implementation details.

redcliffe

What I'd like to achieve in project one is monitor two of those sensors, calculate light intensity, and output it via the ethernet shield in web and snmp formats. I also want to store a log on the sd card on the ethernet shield. So it will also need an NTP client to maintain time

The second project I want to do with these sensors is monitor two sensors, calculate the position of the sun and control a stepper motor to drive a solar array. It will need to monitor the position of the array, and also control a couple of linear actuators or solonoids. I'd also like to output data from this via ethernet. Thanks,

David

Coding Badly


Very nice description.

I suggest that you avoid interrupts.  Interrupts are appropriate when time is of the essence but none of what you've described is "time critical".  Interrupt driven code can be difficult to get correct and, if there is a problem, very difficult to debug.

redcliffe

Thanks, I guess the other thing with regard to doing it by blocking my program for a short time it means I'm choosing how long to block.

Chagrin

You'll be writing an SNMP server and NTP client from scratch if you try to implement it with the Arduino. SNMP is doable but NTP would be horribly un-fun. You'd have a lot fewer headaches using a real-time clock chip and you should be able to find these at most Arduino stores (Sparkfun, Pololu, etc.). Another alternative would be to perform an HTTP request to a web site to grab the time (found in the HTTP headers or potentially in the content of the page).

redcliffe

I've seen some code somewhere where someone implemented requesting time via NTP I think, not a full synchronisation, but just a once off set. I was considering using a real time clock, that was going to be my other question, do I need one to keep track of time? Sounds like I do.

David

Go Up