programing

A catchall for PSoC3 discussions not captured by the other forums.

Moderator: ericb

programing

Postby jjpallipat » Wed Aug 28, 2013 12:27 am

i have written a program for reading adc values using a mux and adc converter
my main file include :-

#include <device.h>
#include <ADC.h>
uint8 det1val;
uint8 i;

void main()
{
for(;;)
{
/* Place your application code here. */
for(i=0;i<9;i++)
{

det1val = readadc(i);
}
}
}

ADC.c include
int32 readadc(uint8 channel)
{
uint8 trials=4;
int32 returnval;
//try 4 times to get non-zero values
while(trials)
{
AMux_1_Start();
AMux_1_Select(channel);
CyDelay(30);
ADC_Start();
ADC_StartConvert();
while(!ADC_IsEndConversion);
returnval = ADC_GetResult32();
if(returnval)
return returnval;
trials--;
}
return returnval;
}
ADC.h includes
extern int32 readadc(uint8 channel)


error is showing as require ANSI style prototype
can somebody help me
jjpallipat
Newbie
Newbie
 
Posts: 8
Joined: Tue Aug 27, 2013 8:19 pm

Re: programing

Postby bobmarlowe » Wed Aug 28, 2013 6:28 am

Better upload complete project here, use "Create Workspace Bundle" and attach file to post.

Main should be defined as
Code: Select all
void main(void)

There could be a name-conflict between component ADC and your files ADC.C and ADC.h
Do not start AMUX and ADC in a loop, just keep them runnning...


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: programing

Postby jjpallipat » Wed Aug 28, 2013 9:06 pm

Thanks bob

i have been expecting your replay

thanks for the support

i changed ADC to adc.c and adc.h

and included adc.h in adc.c
i feel the linking problem is over but now the error is coming as missing';'before readadc in adc .h file
on the line extern int32 readadc(uint8 channel);
Attachments
Design08.Bundle01.zip
(1.05 MiB) Downloaded 141 times
jjpallipat
Newbie
Newbie
 
Posts: 8
Joined: Tue Aug 27, 2013 8:19 pm

Re: programing

Postby bobmarlowe » Wed Aug 28, 2013 11:49 pm

The linking error was still there. I renamed your ADC.c and .h to Myadc and changed accordingly the code, some minor improvements :mrgreen:

Check the datasheet of the ADC for conversion-mode when using a MUX ! The required setting is different from yours.
Do you have got a Kit-030 or a Firsttouch? in the latter case remove the LCD I inserted.
Keep in mind that unterminated inputs will catch stray voltages and float to any value.
Connect the pin's terminals to real pins and lock them, so the fitter will not re-assingn another port/pin for a signal. This is made when opening the .cydwr-file.


Happy coding
Bob
Attachments
Design08.Bundle01.cywrk.Archive01.zip
(32.12 KiB) Downloaded 157 times
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: programing

Postby jjpallipat » Thu Aug 29, 2013 2:37 am

thanks bob

thanks a lot

i hope u meant to stop and start ADC converter whenever analog input is changed?

hope u could help me in future toooo :P
jjpallipat
Newbie
Newbie
 
Posts: 8
Joined: Tue Aug 27, 2013 8:19 pm

Re: programing

Postby danadak » Thu Aug 29, 2013 4:54 am

The approach, waiting for a conversion to complete, can be a waste of
MIPs, eg. use of the

Code: Select all
      while(!ADC_IsEndConversion);


Especially at higher sample rates. Consider using EOC and an ISR to invoke read
of data.

ADC with ISR.jpg
ADC with ISR.jpg (20.4 KiB) Viewed 3496 times


To determine settling time delay needed, you can make a calculation using classical
exponential RC charging time (stray R and ohmmeter tool measurement of analog route
for pin thru mux to A/D input ). The calculation would be settling to 16 bit LSB of full
scale, eg. a step of 0V to FS - 1/2 LSB, or whatever error criteria you choose. That may
allow you to cut delay wasted time down.

Code: Select all
      CyDelay(30);   


Lastly you have a 16 bit A/D as setup, translate that means LSB = 38 uV, in a board or
layout with digital noise in the 200 - 400 mV range. So layout, bypassing critical.

http://www.element14.com/community/docs/DOC-48016/l/cypress-an60263--application-note-for-accurate-adc-measurement-for-psoc-3and-psoc-5-family

http://www.cypress.com/?rID=82678

http://www.cypress.com/?rID=39677

Lastly lastly not all caps are equal, look at the f vs esr curves, polymer tantalums
excellent technology.



Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: programing

Postby danadak » Fri Aug 30, 2013 8:30 am

Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: programing

Postby jjpallipat » Thu Sep 12, 2013 3:55 am

thanks
haven't checked this post for some time
sorry for delay
jjpallipat
Newbie
Newbie
 
Posts: 8
Joined: Tue Aug 27, 2013 8:19 pm


Return to “%s” PSoC3 General

Who is online

Users browsing this forum: No registered users and 1 guest

cron