Reading the Voltage

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

cross mob
abho_4730071
Level 4
Level 4
First like received

Hi Team,

How to read a voltage from psoc and viceversa. so that i can able to see in any available host.

Please help me to provide the steps.

0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi ,

Kindly check the PSoC Code examples available in PSoC Creator. In PSoC Creator, Go to FIle -> Code example. Inside that check for CE195277(ADC and UART) example available .

Best Regards,
Vasanth

View solution in original post

0 Likes
4 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

The project with serial number 12 named Pioneer Board oscilloscope from the link below may help you. This code example is for PSoC 4.

https://www.element14.com/community/thread/23736/l/100-projects-in-100-days#Projects%20Released

If you are using PSoC 3/5 the following code example might help you.

https://www.cypress.com/documentation/application-notes/an84783-accurate-measurement-using-psoc-3-an...

Kindly update if you need more information after going through the above documentation.

Thanks

Ganesh

0 Likes

Hi Ganesh,

I am using CY8CKIT-050 PSOC 5LP. In this kit How to read a voltage from psoc and viceversa.

Please share a psoc project which will use USBUART style of project.

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi ,

Kindly check the PSoC Code examples available in PSoC Creator. In PSoC Creator, Go to FIle -> Code example. Inside that check for CE195277(ADC and UART) example available .

Best Regards,
Vasanth

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Please note that the community is not a place where you can order any programs free.

But you are required to learn from the helps/suggestions of others.

IMHO, you are supposed to be provided enough information to handle USBFS-UART from previous discussions,

and you should be able to learn from the sample code about how to use ADC.

Having said above, here is my simple trial/sample with CY8CKIT-050.

I connected a POT to P3_0.

schematic

002-schematic.JPG

pins

003-pins.JPG

maiin.c

==========================

#include "project.h"

#include "stdio.h"

#define STR_LEN 32

#define USBFS_DEVICE    (0u)

int16_t measure(void)

{

    int16_t adc_raw_count ;

    int16_t adc_mv ;

    int     ch = 0 ;

   

    ADC_StartConvert() ;

    ADC_IsEndConversion(ADC_WAIT_FOR_RESULT) ;

    adc_raw_count = ADC_GetResult16(ch) ;

    adc_mv = ADC_CountsTo_mVolts(adc_raw_count) ;

   

    return(adc_mv) ;

}

int main(void)

{

    uint16 count;

    int16_t adc_mv ;

    char str[STR_LEN+1] ;

  

    CyGlobalIntEnable; /* Enable global interrupts. */

    /* Start USBFS operation with 5-V operation. */

    USBUART_Start(USBFS_DEVICE, USBUART_5V_OPERATION);

   

    ADC_Start() ;

    for(;;)

    { 

        /* Host can send double SET_INTERFACE request. */

        if (0u != USBUART_IsConfigurationChanged())

        {

            /* Initialize IN endpoints when device is configured. */

            if (0u != USBUART_GetConfiguration())

            {

                /* Enumeration is done, enable OUT endpoint to receive data

                 * from host. */

                USBUART_CDC_Init();

            }

        }

        /* Service USB CDC when device is configured. */

        if (0u != USBUART_GetConfiguration())

        {

            adc_mv = measure() ;

       

            if (adc_mv < 0) {

                adc_mv = -adc_mv ;

                snprintf(str, STR_LEN, "-%d.%03dV\n\r", adc_mv/1000, adc_mv %1000) ;

            } else {

                snprintf(str, STR_LEN, "%d.%03dV\n\r", adc_mv/1000, adc_mv %1000) ;

            }

            count = strlen(str) ;               

            if (0u != count)

            {

                /* Wait until component is ready to send data to host. */

                while (0u == USBUART_CDCIsReady())

                {

                }

                USBUART_PutData((uint8_t *)str, count) ;

                CyDelay(1000) ; /* interval for measurement */

            }

        }

    }

}

==========================

Tera Term log

001-TeraTerm-log.JPG

moto