Cypress技术论坛
直播中

彭玉林

8年用户 191经验值
私信 关注
[问答]

交流输入的RMS电压计算

你好,
我和我一起拥有PSoCalEVE 1 CY32 10工具包。我需要测量我输入的交流输入信号的最大和最小电压。信号是正弦的PK到3伏的PK,在频率为500赫兹的频率下振荡0.5到3.5伏。我用信号发生器给输入所以我随意设定频率。我有不同的偏移量为输入电压是正的直流。
我需要计算Vmax和Vmin峰值信号。然后Vpeak =(Vmax -Vmin)/ 2
VRMS=VPK*0.7071
这就是我的目标。我现在用的电压表的项目,我得到的柏树和我正在编辑的程序是适合我的需要。
该项目是利用输入经过PGA增益1。然后通过12位分辨率的ADCcNVR发送。
我用一个简单的方法来获得Vmax和Vmin如下。我想显示在LCD上。
如果(fvvts & gt;TEMP1){
Tunv1=fVoTs;// Vmax
}
如果(fvolts <;temp2){ // Vmin
tim2=fVoTS;
}
问题是,这两个值显示的是直流偏置值都是相同的。
我附上的项目在这里。请帮帮我。
当做
谢拉万
CE5687.CaseV1.ZIP
348.3 K

以上来自于百度翻译


     以下为原文
  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=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


回帖(3)

李凯

2018-9-6 16:05:47
你好,夏拉文,
函数ftoa为每个调用使用相同的静态缓冲区。因此,它将包含最新的转换结果。您可以声明两个单独的缓冲区,以达到最小和最大值。在调用FTOA之后,您可以将FTA缓冲区复制到您声明的最小和最大缓冲区,
谢谢,
萨姆普斯

以上来自于百度翻译


     以下为原文
  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
举报

彭玉林

2018-9-6 16:24:32
引用: clslda 发表于 2018-9-6 08:43
你好,夏拉文,
函数ftoa为每个调用使用相同的静态缓冲区。因此,它将包含最新的转换结果。您可以声明两个单独的缓冲区,以达到最小和最大值。在调用FTOA之后,您可以将FTA缓冲区复制到您声明的最小和最大缓冲区,
谢谢,

谢谢你的回复Sampath。
我是一个新手,擅长编码。你能告诉我如何为FTA命令声明和使用不同的缓冲区吗?
当做
谢拉万

以上来自于百度翻译


     以下为原文
  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
举报

李凯

2018-9-6 16:41:33
引用: nc***iantai01 发表于 2018-9-6 09:02
谢谢你的回复Sampath。
我是一个新手,擅长编码。你能告诉我如何为FTA命令声明和使用不同的缓冲区吗?
当做

您可以像这样声明缓冲区
Char Stimax〔8〕;
Char Srimo〔8〕;
//复制FTOA缓冲区到声明的缓冲区。
Primult1=FTOA(TEMP1,和ISTATSU1);
STRCPY(STRMOST,PRELUT1);
Primult2=FTOA(TEMP1,和ISTATSU2);
SrcPy(Srimult,Primult2);

以上来自于百度翻译


     以下为原文
  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);
举报

更多回帖

发帖
×
20
完善资料,
赚取积分