multi sample ADC (newbie question) - Cypress.com Forums http://www.cypress.com/? Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57777 Yeah! My highlight for the last 3 hous this year was:

Reading data from an ADC (Clocked with 500kHz) with a DMA-channel, transfering right into a low-pass-filter and using a second DMA-channel reading the data from that filter right into a memory - array! BANG!!!!

Wishing you all the best for the next year!

And may your DMAs never stall

Bob

 

]]>
Sat, 31 Dec 2011 13:31:27 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57774 Hi Bob,

 

Using DMA might not be intuitive for a beginner to PSoC.

Using the EOC to read the ADC values will be advantageous in this project and there is no necessity to poll in software for the conversion to complete.

I'm thinking of an easier solution for this.

 

Wish you a happy and prosperous new year !

]]>
Sat, 31 Dec 2011 08:00:05 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57768 Hi dasq,

do not torture a newbee with DMA (I'd like to put a smiley here, but the editor will crash). Right, WHEN it runs, it runs fast without CPU intervention and is looking very professional.

The MIN and MAX assignments just seem to set an interval for the values, I cannot see something wrong with those...

 

We have 9 and a half hours left this year

Bob

 

]]>
Sat, 31 Dec 2011 07:37:51 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57764 Hi reggler,

 

After looking at your code, I have made the following observations:

1) When hardware is used to trigger the SOC of ADC, it is not required to use the "ADC_IsEndConversion(ADC_WAIT_FOR_RESULT)" API. Instead the EOC, which is triggered once the conversion is done can be made use of. An array can be declared to store the values during the burst of conversion. Once the conversion burst is over (300us), you can do all the comparison at once.

 

2) Is the logic used in assigning the minimum and maximum count right?

When the ADC value obtained is less than the MIN_Count, you are assigning

IRfeedback = MIN_COUNT;

 

And similarly, when the ADC value is greater than MAX_COUNT, you are assigning

IRfeedback = MAX_COUNT;

I didn't understand the reason behind this operation.

 

As Bob has rectified, using PWM components to feed to the AND gate instead of Timer which signals the SOC is a right choice.

If DMA is used to transfer the converted ADC data to an array in SRAM using EOC as a source of trigger, the onus on CPU will greatly reduce.

]]>
Sat, 31 Dec 2011 06:52:21 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57743 Does this one work for you? (Remember to change the device to your chip 5568)

Bob

 

]]>
Fri, 30 Dec 2011 12:02:14 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57707 Well, you could use a compare output which can be set to something longer than the clock period. (take care, the timer-counter counts backwords)

The Pulse-counter tc-output is rather short as well, use the same technik here.

 

Going to bed now

Bob

]]>
Thu, 29 Dec 2011 17:21:21 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57705  I'm running on a Cypress Dev kit, the CYC8KIT-050 but I figured out what was wrong. Looks like the pulse from the ADCTimer is too short for the ADC, if I put a T-Flipflop in between, it seems to work fine - but I only get to measure every 2nd pulse...Do you have an idea how I could make that pulse from the timer a little longer otherwise?

 

Thanks  for sticking with me so far!

roN

]]>
Thu, 29 Dec 2011 17:15:01 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57704 This I don't have an eplanation for. Here it runs perfectly, although I had to change the device to cy8c5588-60. Are you using a Cypress-Kit or an own board?

Bob

]]>
Thu, 29 Dec 2011 17:03:01 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57703  No, it didn't work for me. When i set the hit count to 5 and let it run, the program never stops at the breakpoint (at Single Sample mode). It is stuck in "ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);" while the hit count is at 1 only - so one conversion got read only....

]]>
Thu, 29 Dec 2011 16:50:01 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57702 No, you are wrong, your design was working! But when you debug your program (Setting a brekpoint) what do you expect what your hardware does in the mean-time? it runs! It was only your program that has stopped!

Go to: Help-> Topics->Index   select "Breakpoints" and read what you may specify here.

Bob

 

]]>
Thu, 29 Dec 2011 16:10:09 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57701 Huh,  I don't get it,

 

Now I tried to set the ADC to multi sample and inserted this code just after the ADC_GetResult16(); line:

 

ConvCnt++;

/* Disable ADC after 5 conversions */

if (ConvCnt >= 4) {

ADC_Stop();

ConvCnt = 0;

}

UI thought I want to stop the adc after 5 samples and it would get restarted by hardware when it receives a pulse on the soc pin. But this doesn't seem to work either...

]]>
Thu, 29 Dec 2011 15:47:05 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57700 Set breakpoint at line

  if (IRfeedback < MIN_COUNT)

 

Click right on the breakpoint and select "Hit count" and in the pop-up window set the value to five. (works similar with the breakpoint-Window, which you must activate first)

Hope this helps

Bob

 

]]>
Thu, 29 Dec 2011 15:19:49 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57699  I'm not sure which if() you're setting the breakpoint to and why also i'm not sure what you mean by "hitc ount" - could you clarify please?
Thanks!

]]>
Thu, 29 Dec 2011 15:14:37 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57698 I see.

But when you set a breakpoint to the "if" and set the hit count to five, program stops after 5 ADC-conversions (on my system Kit001 CY8C5588-60 ES1)

Bob

By the way: if there are interrupts in a system the debugger behaves somtimes a bit queer and seems not to leve a breakpoint-line. removing a brekpoint and setting it to next line shows that

]]>
Thu, 29 Dec 2011 15:04:59 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57696  Yep, Single sample = once per pulse on soc - no?

I see 5 pulses (with 60uS distance to eachg other) on the scope...

]]>
Thu, 29 Dec 2011 14:54:07 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57695 Ha, you've set the ADC's conversion mode to single sample! So you can wait a fortnight for the nect sample to get ready! Question is: What did you see on your skope???

 

Bob

 

]]>
Thu, 29 Dec 2011 14:44:11 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57694 I think, here is a limit for uploads of 2MB and your Project has 11MB.

I'm working on it...

Bob

 

]]>
Thu, 29 Dec 2011 14:33:17 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57693  Didn't seem to work again - try this instead: http://dl.dropbox.com/u/15963911/MyLRB.zip

]]>
Thu, 29 Dec 2011 14:22:11 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57692  I don't see the attachment - retry.

]]>
Thu, 29 Dec 2011 14:18:15 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57691  Can do!
Please see attached!

 

Thank you!

roN
 

]]>
Thu, 29 Dec 2011 14:04:38 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57689 Would you mind to zip your project and upload it here so that we can check everything? (when you run a "Cleanup" before, the fil will get smaller)

Bob

]]>
Thu, 29 Dec 2011 13:38:19 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57683  Hi Dasq,

 

Okay,

 

I now hooked up my 300uS line to an AND gate, the other input is coming from a timer that kicks in every 60uS, then the output from that AND gate goes to the soc of my ADC which is configured to 10bits at a conversion rate of 17000 SPS in Single Sample mode. My code looks like this:

 

    while(1)

    {

LCD_Position(0, 0);

   LCD_PrintString("IRfeedback       ");

        /* Place your application code here. */

//for(i = 0; i<=2; i++){

        /* Wait for end of conversion */

        ADC_IsEndConversion(ADC_WAIT_FOR_RESULT); 

        IRfeedback = ADC_GetResult16();

if (IRfeedback < MIN_COUNT)

        {

            IRfeedback = MIN_COUNT;

        }

        /* Used to remove the count beyond 8 bit value, see resolution section

         * in DelSig ADC datasheet */

        else if(IRfeedback > MAX_COUNT)

        {

            IRfeedback = MAX_COUNT;

        }

        else

        {

            /* Continue */

        }

//}

AVGfeedback = IRfeedback;

LCD_Position(0, 11); 

        LCD_PrintNumber(AVGfeedback);

    }

 

 

It seems like it's reading the value once only and then it would get stuck in ADC_IsEndConversion(ADC_WAIT_FOR_RESULT) and not get out of there anymore but if I hook up a debug pin to the ADC's soc, I can clearly see 5 pulses with my scope. What am I doing wrong? 

Hints or suggestions appreciated!

Thank you!
roN
 

 

]]>
Thu, 29 Dec 2011 12:33:54 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57650 Hi reggler,

 

There are many suggestions already provided.

Another way of doing is by using a Timer/Counter to trigger the SOC when the 300us pulse is present (by ANDing the Timer/Counter output with the 300us pulse output).

If you intend to take, say 5 readings then you would require a conversion every 60us. Hence the conversion rate of the ADC should be greater than 16.7kSPS. Make sure that the resolution you have chosen allows you the required conversion rate.

 

The EOC can be used to read the converted values. The ADC will generate an EOC pulse only when the 300us pulse is active.

]]>
Wed, 28 Dec 2011 22:39:42 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57649  Apart from the methods lleung has suggested(DMA looks the cleanest),We can also use the existing ISR in the ADC.Have a pin state read there,which then calls StopConvert or Stop.

You could also add that change to the component itself,so you may re-use this functionality.

One thing we can try is modifying the schematic of the component and add an additional pin,and thats connected to an IRQ which calls the StopConvert or Stop functions,but then thats basically the same thing.

The stop convert function switches off power to a number of sub-blocks,by writing to various internal registers.Linking that to hardware schematics,is via an interrupt,the way I see it.

 

]]>
Wed, 28 Dec 2011 19:28:41 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57645 I can think of a few way to do this

1. use a counter of 5, start it at the edge of your 300uS by an interrupt signal,
the counter counts number of EOC from the ADC and when it reaches 5, generate an interrupt and in the ISR stop the ADC.

2. Same as you mentioned, stop the clock of the ADC, but I am not sure if that would have other side effects,
 so I would not do this.
 
3. I having try this but this should work. Similar to 1 but use DMA and make it perform 5 transaction and at the end of the transaction,
 generate an interrupt and stop the ADC in the ISR

]]>
Wed, 28 Dec 2011 18:00:55 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57644  As a hack i probably could juast select an external clock source and only have the clock source active while I wanna sample the feedback but that doesn't seem that "clean" to me. I'm wondering if i could do it differently, i.e. by reading the 300uS line state in software and have an interrupt fired every time it goes low...?

Thanks,

Ron

]]>
Wed, 28 Dec 2011 17:14:22 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57643  I have a timer that kicks in every 50Hz continously. That pulse again, resets another counter that will hold a line low for 300uS (in one shot mode). I invert that line to get a 300uS pulse every 20ms(50Hz). now that pulse goes into an AND gate with the PWM being on the other input and so i end up getting my 300uS PWM pulse every 20ms. Now what I wanr is, I want to take about 5 ADC measurments from a feedback line while the PWM is active. I am awaer that I can connect the ADC's soc line to the 300uS pulse to start the conversion but how do I signal it to stop again? There's no "enable" on the ADC.

Thanks for hints & suggestions!

roN

]]>
Wed, 28 Dec 2011 17:10:16 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57640 Can you tell us what is your requirment?

You mentioned ADC and PWM, What line changes your are referring to? The output of the pwm? When you said Sync, you mean sync of the ADC sampling and PWM operations?

]]>
Wed, 28 Dec 2011 16:32:46 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57639  Yep, I read this too, so if there's no possibility to stop it otherwise, can I then trigger an interrupt when one of my lines changes its state so that my program can keep sync?

Thanks,
roN

]]>
Wed, 28 Dec 2011 16:07:16 -0600
Re: multi sample ADC (newbie question) http://www.cypress.com/?rID=57636 The datasheet says "ADC conversions continue until either theADC_StopConvert() or ADC_Stop() functions are executed."

So it doesn't look like you can stop convering in hardware.

Regards, Bob

 

]]>
Wed, 28 Dec 2011 13:11:49 -0600