NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Everything Else » Multitasking ADC input pins
March 05, 2011 by amartinez |
Unless I'm missing something, I have not found anything in this forum on multitasking so I thought I'd ask this question. I am looking to symulataneously measure 2 variable voltages less than 3V from 2 separate ADC pins. The sample rates on each input pin could be as low as 100 Hz or even less, however, I also need the chip to show two separate LED indicators relative to the voltage levels detected. What I'm going after is basically 2 simple volt meters who work symultaneously off the same chip. Is this possible? Am I asking the chip to do too much? Thanks Al |
---|---|
March 05, 2011 by Ralphxyz |
On a single core processor you can only do one thing at a time, though those things are done so quickly they might as well and often are considered simultaneous i.e. multitasking, be that as it may this might help get you started it is a thread on using multisensors (including my multi sensor code) with a good explanation by Mike on what is possible. So you get your "simultaneous" reading of two variable voltages from 2 separate ADC pins (my code does 4 or 5). Using PWM you "should" be able show two separate LED indicators or you might need a DAC (Digital to Analog Converter) for the LED indicators. Possible the ATmega mcu will do it all for you, I am not sure, but getting the two voltages definitely will work. Ralph |
March 07, 2011 by amartinez |
Ralph, Thank you for your help but I was amiss in my wording. The code would probably be very simple in comparison as the LED indicators I was referring to were simple LED lights. I should have been more specific. No LCD needed for this project. 2 rows of 3 LED lights each. One row of LED lights would represent a voltage range from PC0 and one row from PC1. For example, if PC1 reads a voltage of 1 to 2V, then the first LED goes on. As the voltage increases more LED light up in the row light. It's a simple way to visually monitor two separate voltage inputs. Kind of like Humberto's LED sound meter but much simpler. One question. Is the code you posted the full code? I'm not very astute in C but I think there are variables missing and a main as well. I added the libraries and an int main statement, I ran the code through and I get the following message from the compiler. I indented the DOS compiler output as codeblock to reduce word wrapping.
Simply put, I'm just trying to light 3 LED lights relative to voltage input. Here my addition to the code before yours
Thank you for your time, looking forward to any ideas. Al |
March 07, 2011 by Ralphxyz |
amartinez, You are correct, the code I posted was just the modification to the tempsensor project code enabling multisensors. It just fits in place of the equivalent tempsenor code. It just replaces the while(1) loop I believe (I have not looked at it recently). That with the the additional variable declaration should give you working multi-sensor code. Essentially the Switch(mux) statement just literally switches between mux settings enabling multiple pins for ADC input. You could probable use a if > < statement to sense the voltage and light the appropriate led. Ralph |
Please log in to post a reply.
Did you know that you can follow NerdKits on Facebook, YouTube, and Twitter? Learn more...
|