Modifying GADC example board file.

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 12:09 pm

was just trying to start by using the testhal adc example to read a voltage (3.3v) and display it on my lcd and then take it from there..

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Sun May 05, 2013 12:14 pm

How do you want to display it? You can use the ChibiOS/RT HAL to get the conversation value, calculate it into your voltage and then use something like sprintf() to convert it to a string and display it using the ChibiOS/GFX high level routines.

The goal of GADC is to provide a uniform ADC abstraction because the interface provideded by ChibiOS/RT is very platform dependend and we cannot create generic applications which run on all the platforms with that.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 12:25 pm

well yes thats exactly what i want to do just having a hard time figuring out how i get the conversion value.

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Sun May 05, 2013 12:42 pm

There are plenty of examples available showing how to use the ADC driver of the ChibiOS/RT HAL. I recommend you taking a look at the ./testhal example.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 12:52 pm

yes that is the example i am using but where do i get the result from i cannot see where the result is in the example?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Sun May 05, 2013 12:59 pm

The results are in the sample1 and sample2 buffers. They are of the type adcsample_t.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 3:16 pm

i know i probably sound stupid but how do i convert the buffers into strings i have tried and all i get is random characters on lcd

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Sun May 05, 2013 3:30 pm

The value in the adcsample_t buffers contain the converted ADC value. You first have to calculate the real voltage from it. This will be a float value. You can now use something like sprintf() to convert it to a string:

Code: Select all

#include <string.h>         // here we can find the prototype of sprintf()

float voltage = 2.42f;      // lets asume our measured voltage level is 2.42V.
char buffer[20];            // this will be our output string. Make sure it's long enough.

sprintf(buffer, "voltage: %fV", voltage);    // create the string containing the current voltage level

gdispDrawString(10, 10, buffer, font, Yellow);     // draw the string on the screen


Please note that sprintf() is a very memory intensive call. Make sure your stack size is big enough. You will also need to include the syscalls in your makefile. Furthermore, you need to include the stubs I attached into your project.
I hope that helps a bit.


~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 3:45 pm

what syscalls should i add?-- :oops:
ok i found syscalls.c and have added it to my makefile
Last edited by daviddawe1982 on Sun May 05, 2013 4:31 pm, edited 1 time in total.

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 4:25 pm

i cannot see the attached stubs either


Return to “LCD Driver and Graphic Framework”

Who is online

Users browsing this forum: No registered users and 5 guests