RP not generating negative DC output
-
- Posts: 27
- Joined: Thu Apr 14, 2016 3:14 pm
RP not generating negative DC output
I noticed that I cannot output a negative DC signal from the fast analog outputs of my Red Pitaya. Whenever I use the API function rp_GenAmp in combination with rp_GenWaveform (..., RP_WAVEFORM_DC) with a negative amplitude, my board outputs a constant DC signal of 1V. I have had a look at the source code and I suspect this is due to the fact that amplitudeScale in the ch_properties_t struct (in generate.h file) is an unsigned integer, so cannot be negative. Is this correct and is there any way to achieve negative DC output without changing the API?
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: RP not generating negative DC output
From a cursory examination of the code I can find no reason why it shouldn't be possible to generate negative DC output with the api.
That is a misinterpretation of the code, the way this bitfield is written to is consistent with 14bit signed numbers, even if the declared type in the struct is unsigned. 14bit signed is how the value is evaluated in the FPGA.amplitudeScale in the ch_properties_t struct (in generate.h file) is an unsigned integer, so cannot be negative
-
- Posts: 27
- Joined: Thu Apr 14, 2016 3:14 pm
Re: RP not generating negative DC output
The code I use is below. Whenever I call rp_GenAmp(...) with a negative voltage, for example rp_GenAmp(RP_CH_1, -0.5) and check the output of the RP with an external oscilloscope, I get a constant DC signal of about 1.08 V. If it's not the software, something must be wrong with my board. However, positive DC voltages work without problems and (after calibration) accurately. Any ideas where the problem might lie?
Code: Select all
//This is a program to output a constant DC voltage
//#include <iostream>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <sys/param.h>
#include "redpitaya/rp.h"
#include "main.h"
double time_diff(struct timeval x , struct timeval y); //to check execution times of different parts of the program
int main()
{
if(rp_Init() != 0){
fprintf(stderr, "RP API init failed\n");
}
//struct timeval start, now;
//double microseconds;
rp_GenReset();
rp_GenAmp(RP_CH_1, -0.5); //Generate negative voltage
rp_GenWaveform(RP_CH_1, RP_WAVEFORM_DC);
while(1){
rp_GenOutEnable(RP_CH_1);
}
rp_Release();
return 0;
}
double time_diff(struct timeval x , struct timeval y)
{
double x_ms , y_ms , diff;
x_ms = (double)x.tv_sec*1000000 + (double)x.tv_usec;
y_ms = (double)y.tv_sec*1000000 + (double)y.tv_usec;
diff = (double)y_ms - (double)x_ms;
return diff;
}
-
- Posts: 8
- Joined: Wed Feb 17, 2016 10:18 am
Re: RP not generating negative DC output
Hi,
Try this :
Try this :
Code: Select all
int main() {
if(rp_Init() != 0) {
fprintf(stderr, "RP API init failed\n");
}
rp_GenReset();
rp_GenWaveform(RP_CH_1, RP_WAVEFORM_DC);
rp_GenAmp(RP_CH_1,0); //Set to 0 V
rp_GenOffset(RP_CH_1,-0.5); //Use offset instead amplitude
rp_GenOutEnable(RP_CH_1);
while(1) {
//do something
usleep(10000);
}
rp_Release();
return 0;
}
-
- Posts: 31
- Joined: Mon Mar 28, 2016 1:10 pm
Re: RP not generating negative DC output
Have you tried if an AC waveform works OK (having a positive and negative swing) ?
Does Red Pitaya have a charge pump that can sustain a negative DC output at all?
Does Red Pitaya have a charge pump that can sustain a negative DC output at all?
-
- Posts: 27
- Joined: Thu Apr 14, 2016 3:14 pm
Re: RP not generating negative DC output
Thanks a lot, I tried using the rp_GenOffset function and it works, generating output of up to -1 V, as expected. I'm still not quite sure, however, why the rp_GenAmp function cannot be used in combination with RP_WAVEFORM_DC to produce negative voltage outputs.
-
- Posts: 8
- Joined: Wed Feb 17, 2016 10:18 am
Re: RP not generating negative DC output
I think that amp value behave like a scaling parameter.
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie
Who is online
Users browsing this forum: No registered users and 22 guests