Need code for analog to digital !
I have four 12-bit analog to digital parallel converters connected to propeller.
I am using one dedicated cog to monitor/poll end-of -conversion (EOC) outputs of those four
ADCs via four i/o pins, one for each EOC.
I need one separate cog for each ADC.
The ADCs are not necessarilly synchronized, so the EOC signals are not changing at the same time.
My generic idea behind the code :
1)Poll the EOCs i/o pins -cog0
2)If any EOC active, determine which one it is and
which cog should be started to get the sample -cog0
3)Poll again -cog0 and at the same time read sample from ADC-cog1,2,3 or 4
How do I start and assign new cogs to process samples coming from each of the four ADCs ?
How will I let the other cogs (1,2,3,4) know that it is time to read sample from ADC latch ?
Please help, getting desperate.
Thanks.
I am using one dedicated cog to monitor/poll end-of -conversion (EOC) outputs of those four
ADCs via four i/o pins, one for each EOC.
I need one separate cog for each ADC.
The ADCs are not necessarilly synchronized, so the EOC signals are not changing at the same time.
My generic idea behind the code :
1)Poll the EOCs i/o pins -cog0
2)If any EOC active, determine which one it is and
which cog should be started to get the sample -cog0
3)Poll again -cog0 and at the same time read sample from ADC-cog1,2,3 or 4
How do I start and assign new cogs to process samples coming from each of the four ADCs ?
How will I let the other cogs (1,2,3,4) know that it is time to read sample from ADC latch ?
Please help, getting desperate.
Thanks.

Comments
VAR long ADCvalues[noparse][[/noparse] 4], ADCflags[noparse][[/noparse] 4], stack[noparse][[/noparse]64] PUB initialization | j repeat i from 0 to 3 ADCflags[noparse][[/noparse]j] := false COGNEW(ADCprocess(eocBase + j, adcBase * adcPinCount + j, j),@stack+j*64) ' Now all ADCs are running and each will set its ADCflags value to true when its ADCvalues is updated. ' After you look at each updated ADCvalue you're interested in, set its ADCflags value to false showing ' that you've used it. The false will get changed to true the next time the ADC finishes its conversion. PUB ADCprocess(eocPin, adcPin, valueIndex) | x ' Initialize the ADC on eocPin and adcPin repeat repeat until ina[noparse][[/noparse]eocPin] == 1 ' Wait until eocPin is high ' read adc value into local variable x ADCvalues[noparse][[/noparse]valueIndex] := x ' Makes value globally available ADCflags[noparse][[/noparse]valueIndex] := true ' Indicates that value is availablePost Edited (Mike Green) : 10/26/2006 1:58:46 AM GMT
that looks like a good way to go about it, I should have thought of that.
I hope I will have some schematics and code later on to share, though
it may take a while.