Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Initialize_ADC help??? (http://www.chiefdelphi.com/forums/showthread.php?t=34062)

Splintercell 05-02-2005 18:56

Initialize_ADC help???
 
Hey, does anyone know if you can run 2 devices at once on different analog pins using the Initialize_ADC? If so can someone please point me in the right direction. Any help is greatly appreciated.

Astronouth7303 05-02-2005 19:02

Re: Initialize_ADC help???
 
Quote:

Originally Posted by Splintercell
Hey, does anyone know if you can run 2 devices at once on different analog pins using the Initialize_ADC? If so can someone please point me in the right direction. Any help is greatly appreciated.

Why are you calling Initialize_ADC? I can't even find it! (Please tell me this isn't some new thing I missed.)

To use multiple analog channels, just call Get_Analog_Value() using two different pins.

Splintercell 05-02-2005 19:05

Re: Initialize_ADC help???
 
I'm using Initialize_ADC from some of Kevin's code. I'll try working with that, thanks.

kjohnson 05-02-2005 19:16

Re: Initialize_ADC help???
 
Quote:

Originally Posted by Splintercell
I'm using Initializa_ADC from some of Kevin's code. I'll try working with that, thanks.

By Kevin he means Kevin Watson. You can reach his website here.

Robby 05-02-2005 23:41

Re: Initialize_ADC help???
 
Quote:

Originally Posted by Splintercell
Hey, does anyone know if you can run 2 devices at once on different analog pins using the Initialize_ADC? If so can someone please point me in the right direction. Any help is greatly appreciated.


i'm not absolutely sure on this, but i have two ideas

1) i would imagine that you would need to periodically switch which pin the adc is set to. In order to do this, i think all you need to do is just change the ADCON0bits.CHSx bit to reflect which analog input you wish you use

2) after looking through the default code i noticed how they get analog values. When you call Get_Analog_Value() it makes a call to OpenADC(), i imagine you could use the same code, i believe the function it refers to is in adc.h

i hope i adressed what you were looking for

Splintercell 06-02-2005 07:48

Re: Initialize_ADC help???
 
Thanks, I'm going to have to look around on this, but I hope it works. I have changed the ADCON0bits.CHSx to diferent pins, but I have yet to get two different pins to work in the same code. It either doesn't work or tells me the error I posted previously. I'll try the OenADC() and see if it works. Thanks again all.

Kevin Watson 06-02-2005 11:06

Re: Initialize_ADC help???
 
Quote:

Originally Posted by Splintercell
Thanks, I'm going to have to look around on this, but I hope it works. I have changed the ADCON0bits.CHSx to diferent pins, but I have yet to get two different pins to work in the same code. It either doesn't work or tells me the error I posted previously. I'll try the OenADC() and see if it works. Thanks again all.

What are you trying to do with your code? You mentioned that you wanted to do two simultaneous ADC conversions. This cannot be done because there is only one ADC on-board. You have to select the channel to convert (which automatically starts a conversion), wait for it to finish, grab the data, select new channel, wait for it to finish, ...

-Kevin

Splintercell 06-02-2005 13:22

Re: Initialize_ADC help???
 
Thanks a bunch Kevin, I'll get back to this code now. (almost got it ;) )

Splintercell 06-02-2005 13:47

Re: Initialize_ADC help???
 
Kevin,
What our goal is to initialize the ADC one time, but to activate 2 analog pins during the call. That way we can have 2 inputs ready for us to grab when we want them.

Is this possible and if so how ?

Robby 06-02-2005 16:46

Re: Initialize_ADC help???
 
Quote:

Originally Posted by Splintercell
Kevin,
What our goal is to initialize the ADC one time, but to activate 2 analog pins during the call. That way we can have 2 inputs ready for us to grab when we want them.

Is this possible and if so how ?


i had one more thought, if you want to use 2 analog pins i am assuming that you are using a gyro and accelerometer at the same time, i actually just considered doing this myself and here's my latest idea: set your timer to interrupt twice as frequently as needed for each device and then take the output from the adc for different pins each time. This may be too much of a burden on your system depending on what you are doing so you could just keep the same timer rate and alternate pins each time, but most likely this would be too slow for your purposes


All times are GMT -5. The time now is 23:58.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi