Easy ADC to LCD

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 After the 400th time I wrote the same project to test something simple with the ADC and put the result on the LCD, I decided to make a component to simplify things.  This component does everything you would need to do to sample the ADC and display the result on the LCD, a standard practice when learning and debugging.

   

I added some common features:
1.) automatic sampling, just all Easy_ADCToLCD_Start() and you are done.  (blocking forever, great when you just want to do something really simple) 
2.) built in averaging (filtering) of the samples to smooth out any noise.  the size of the average is adjustable
3.) a "transfer function" that allows you to convert the voltage into another unit, say current or ohms.  you can specify any C equation to convert the voltage from the ADC into anything else, includes units.
4.) uses 32 or 16 bit get result API so it can be used with the DelSig or the SAR
5.) Just put in the name of the ADC and the LCD and the component takes care of the rest for you.

   

its a simple component, but I really like how it simplifies my life.  The concept could be extened to anything really, like sending the data out to a UART ...

39 Replies
Anonymous
Not applicable

Very handy 🙂

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I cannot get the testbench to work, what do I have to do to make it run? The component does not show up.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Found it! You had an archive archieved into an archive.

   

 

   

And I found a programming flaw ! You wrote in main() line 97

   

i = ++i %16;

   

which is flagged as a warning by GCC (Yes, I changed the devive to PSoC5)

   

Generally you should avoid having the same var as LValue and modified on the right side of the equal sign.

   

Have a look into a manual here http://publications.gbdirect.co.uk/c_book/chapter8/sequence_points.html

   

In your case the assignment would probably work, but this is a target for unpredictable result when altered.

   

 

   

Bob

0 Likes
EdUc_284901
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hi to all!:

   

How can I use it? I mean what files and where should I but them.

   

Thank you

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The very first post in this thread by Chris contains a link to a downloadable archive. There you get it from.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Made a small modifcation to split the I = ++i % FILTER_SIZE; into to lines.  New Archive posted here (hopefully the forum will allow me to attache a .cycomp file this time)

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Grrr.  Ok, its attached as a .zip file.  Extract the zip file to get the component archive.

0 Likes
EdUc_284901
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hi!

   

Can I use it with PSoC 5LP??

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

This is a pure software component, no reason why it should not run on any PSoC.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I am getting an error message of missing /Generated_Source/PSoC4/EasyADC_to_LCD_1.h:19:20: fatal error: device.h: No such file or directory I tried to add the .h file and it still will not complie.  I'll add the program so you can check it out.

0 Likes
Anonymous
Not applicable

 Hey!  Thanks for using the component.  The problem is that at some point they changed "device.h" to "project.h"  I need to update the component with that fix.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Give this one a try.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Still givning the error Unable to open the file for reading. Could not find file 'E:\Documents and Settings\bob\My Documents\cypress\New Folder\EasyADC_to_ADC\EasyADC_to_LCD.cylib\KEES_EasyADC_to_LCD_v1_00\API\EasyADC.h'. .  Where do I place the new file in the main library or some where else?

0 Likes
Anonymous
Not applicable

 Unzip the file and inside there should be a .cycomp file.  Open a new creator project, and go to the "components" tab (in the workspace explorer).  Right click on your project name and select "import component".  In the dialog box that pops up, select "import from archive" and navigate to the .cycomp file you extracted.  Click "OK" and you should now have a copy of the component in your project.  open you project schematic and place the component along with the ADC and LCD component.  Assign pins, write main.c and try to build.  Let me know what happens.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I moved the library to a new folder and downloaded it again.  blew away the old dep  and made a new dep and get this error again. ./Generated_Source/PSoC4/KEES_EasyADC_to_LCD_1.h:19:20: fatal error: device.h: No such file or directory

   

 

   

Thnaks Bobgoar.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Well i got the new component into the design but still complaining about the .h file here is the design and I'll send the lib dir also.

   

 

   

Bobboar

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I now am getting closer.  I just made a blank device .h file and that fixed  that error about the device h issue .  Now I am getting an error in EasyADC_to_LCD.c at line 91 Build error: too few arguments to function 'ADC_1_GetResult16' and line 97 operation on 'i' may be undefined [-Wsequence-point] and line 110 Build error: too few arguments to function 'ADC_1_CountsTo_Volts' I do not know if I need a math function turned on or what is the cause fo these errors.

   

 

   

Bobgoar

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Don't you need to have a #include project.h in that file ?

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You have got both components, the old and the new one. Remove the old version 1.00 and include the new version 1.1

   

When setting the properties, disable the transfer function, it contains references to math.h which you probably do not want.

   

 

   

Bob

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

 Did not seem to need the .h file  all the project .h file has all the includes but it would not compile with out the empty file.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I checked for the enable transfer function it is turned off.  Still getting error of Build error: too few arguments to function 'ADC_1_CountsTo_Volts' at line 104 in EasyDac_to_lcd.c file/

   

 

   

Bobgoar

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here is the latest program file and library still getting errors.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

CountsToVolts() needs the channel number as the first parameter and there is no GetResult32(), only a GetResult16().

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Bob is correct. 

   

The Easy ADC to LCD component was created before the SAR sequencer existed and so it is was not aware of the different parameters that need to be passed in order to get a result from the GetResult() API.  That is why it is complaining about too few arguments passed to GetResult() and CountsToVolts().  Its expecting a channel number and my component isn't providing one.

   

I went ahead and updated the component to work with these sequencing ADC's (new parameters added) as well as adding a few other feautres.

   

Remove all other versions of the component from you projects / libraries and use this one.  I have updated the revision number to v1.1 and updated the datasheet as well.

   
        
0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

 This part of program is generated by the easyadc_to_lcd library so where do I change it in the lib to get it to produce the  correct files in the program?

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

 This part of program I will try the new library.

0 Likes
Anonymous
Not applicable

 There is no need to modify it.  I posted an updated version of the component (see 3 posts up)

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I must be missing something here.  I added the component to the easy adc to lcd library and it appears to be the same one I had . I do not know how to get this new component into my design.  What am I missing?

0 Likes
Anonymous
Not applicable

 First, remove all previous versions of this component from your library.  Then, import the new component into your library.

   

 

   

When you place the component and open the customizer, do you see an "AutoSample" parameter?  If you do, then you have the latest version.  If you do not, create a new, blank project, and import the latest component into that project as I described earlier.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Chris

   

"This is the curse of every good deed". Just creating a new component, giving it to the public and then... new devices pop up, new Creator versions appear and the adaption of the old-fashioned component consumes the last bit of leisure time... 😉

   

 

   

Thank you!

   

Bob

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Thanks for your help Chris and Bob I finally got the item to compile and again Thanks so much.  Have a Merry Christmas and Happy New Year.

   

 

   

Bobgoar.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Bobgoar

   

Are you not working the next days? Early start of celebrating christmas?? Cool!!!

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I could not make the component to work. For some reason after  the function : 

   

   

sprintf(szBuffer,"%0.4f v ", ADC_SAR_Seq_CountsTo_Volts(0, temp));

       

   

is executed the value in szBuffer stays 0x20;

   

When I print out temp the value is right.

   

Could anybody help me with this problem.

0 Likes
Anonymous
Not applicable

 Are you using PSoC 5LP and the latest version of creator?  If so, it might be related to the heap size.  Check out the posts in this topic for more info: http://www.cypress.com/?app=forum&id=2492&rID=76890

   

 

   

" Just a note for making this work with Creator 3.1 for PSoC 5LP.

   

Add the linker flag -u _printf_float by going to Project -> Build Settings -> Linker -> Command line.  This will add floating point support for sprintf.

   

You will also need to increase the heap size in the .cydwr file under the Systems tab.  A size ov 0x0800 should be fine.  This gives the sprintf function room to work."

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

@kees: since this seems to be a common problem now: maybe the default heap size should be increased again (I even encountered it in the BLE project created from a template...)

0 Likes
Anonymous
Not applicable
        Hi Kees, Thanks a lot for your prompt response. Your suggestion worked. But I wonder how could have I found such a compiler problem without your expert help. Where should have I looked to find the answer to my problem?. By the way I was running the example on a PSoC4. I have enjoyed all your apps and writings since I got hooked on PSoC. I have literally become a PSoC zealot. Keep up the good work.   
0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Where is the system tab to change the heap size located?

0 Likes
Anonymous
Not applicable

 open the Cydwr file in your workspace explorer (this is where you normally set you pin locations) and along the bottom there are tabs.  This is where you find the system tab.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Thanks I was looking all over for the system tab and it was right in front of me all the time in the center of the Psoc creator screen.

0 Likes