- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there,
I am having PSOCEVAL 1 CY3210 Kit with me. I need to measure the max and min voltages for the ac input signal that i am giving. The signal is a sinusoidal with pk to pk of 3 volts, oscillating in 0.5 to 3.5 volts at frequency 500 Hz. I am using a signal generator to give the input so i am at liberty to set the frequency. I have varied the DC offset as for the voltage input to be only in positive.
I need to calculate the Vmax and Vmin peak values of the signal. Then Vpeak= (Vmax- Vmin)/2
Vrms=Vpk*0.7071
This what i am aiming to acheive. I am now using a voltmeter project that i got form the cypress and i am trying to edit the program to be suitable to my need.
The project is using the input to go through a PGA with 1 gain. Then it is sent through ADCINCVR with 12 bit resolution.
I am using a simple method to get Vmax and Vmin as follows. I am trying to display both on the LCD.
if(fVolts>temp1){
temp1=fVolts; //Vmax
}
else if(fVolts<temp2){ //Vmin
temp2=fVolts;
}
The problem is that both values shown are DC bias values and both are same.
I am attaching the project here. Please help me with this.
Regards
Shravan
Solved! Go to Solution.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Shravan,
The function ftoa uses the same static buffer for every call. Hence, it would contain the latest conversion result. You can declare two separate buffers for minimum and maximum. After calling ftoa, you can copy the ftoa buffer to the buffer you have declared for minimum and maximum,
Thanks,
Sampath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Shravan,
The function ftoa uses the same static buffer for every call. Hence, it would contain the latest conversion result. You can declare two separate buffers for minimum and maximum. After calling ftoa, you can copy the ftoa buffer to the buffer you have declared for minimum and maximum,
Thanks,
Sampath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the reply Sampath.
I am a novice at coding and stuff. Can you tell me as to how to declare and use different buffers for the ftoa command ?
Regards
Shravan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can declare buffers like this
char strMaximum[8];
char strMinimum[8];
// Copy ftoa buffer to the declared buffers.
pResult1 = ftoa(temp1,&iStatus1);
strcpy(strMaximum, pResult1);
pResult2 = ftoa(temp1,&iStatus2);
strcpy(strMinimum, pResult2);