0
$\begingroup$

I would like to sample an analog 5kHz signal with a 50MHz sample rate. I want to do this with python so I can see if this sort of sample rate is enough for my needs. But I couldn't wrap my head around the problem.

I am so used to Simulink where I can have a continuous signal which I can move to the workspace and sample easily. Now in python, what I am struggling with is producing an "analog" signal. I need to have the analog signal so that I can sample it at 50 Megs to see the performance of the digitization.

What am I missing?

Edit: I have a capacitor discharge that takes 200 usecs. I will be acquiring this signal with hardware. But before selecting the hardware I wanted to see if 50 Msps is a sufficient sampling rate for my requirements.

$\endgroup$
4
  • $\begingroup$ Could be, of course. I am struggling to replicate that analog signal that is available in Simulink. I couldn't find a way to produce an analog signal, or even if it is possible. Do you have any recommendations for me? $\endgroup$
    – Guarneer
    Commented Aug 22, 2022 at 12:14
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Commented Aug 22, 2022 at 12:27
  • $\begingroup$ Please edit your question with an example continuous-time signal that you wish to sample -- i.e. if you just want $sin(2 \pi 5\mathrm{kHz} t)$, then there it is. Note that Simulink doesn't generate continuous-time signals -- it just generates a function of time, then calculates that function for the time intervals it's decided it needs to sample. $\endgroup$
    – TimWescott
    Commented Aug 22, 2022 at 13:30
  • $\begingroup$ Edited the question. sin(2π5kHzt) this is what I tried as well. $\endgroup$
    – Guarneer
    Commented Aug 22, 2022 at 14:05

1 Answer 1

0
$\begingroup$

and welcome to SE.SP!

You need to learn the difference between analog and digital signals. You can google this of course.
In a nutshell, an analog signal is a continuous signal representing some other quantity, i.e., analogous to another quantity (source: wikipedia). You could coarsely say that analog signals only exist in the physical world. Sound, light, voltage, temperature: these are signals that are continuous in time.

When we want to analyze an analog signal with digital devices such as computers, that can only represent signals as a set of discrete (the opposite of continuous) numbers, we need to sample this signal through the use of an ADC (Analog to Digital Converter), the result being a sequence of samples that the computer can store.

What you're asking is therefore impossible. Once the signal is in computer memory, it's already sampled. It's not continuous anymore, it's digital.

As such, in your case, the 5KHz signal you mention is either already sampled at some sampling frequency defined by whatever ADC was used to convert the analog representation of its physical quantity into a digital representation through sampling, or it has been generated by software (see @Tim Wescott's comment on your OP).

What you might be trying to do is to resample your signal, i.e modifying the sampling rate, but I won't go further into this since you really need to understand the absolute basics first.

Let me know if you need more explanation.

EDIT: Sampling rate requirements You need a sampling rate that's AT LEAST twice your signal's bandwidth of interest (Nyquist-Shannon theorem). So if you're interested in a 5KHz signal, 50MHz is overkill. In fact, the theory would tell you that a sampling rate of 10KHz is enough. Of course that's the theory, in practice you'd want to sample at a rate higher than that. Not sure what sampling rates your ADC supports, but 16KHz is a typical one, and in your case would do the trick.

$\endgroup$
5
  • $\begingroup$ Thanks for the answer. I may have used incorrect terms. I have edited the question now. I mainly have a 200 usec discharge I want to capture. I am trying to decide on a sampling rate for hardware. I wanted to do some simulations in this regard $\endgroup$
    – Guarneer
    Commented Aug 22, 2022 at 14:07
  • $\begingroup$ @Guarneer Edited my answer in this regard $\endgroup$
    – Jdip
    Commented Aug 22, 2022 at 14:41
  • $\begingroup$ Yes I am aware of the Nyquist rule but I have strict requirements so I need to know many data point during the discharge. $\endgroup$
    – Guarneer
    Commented Aug 22, 2022 at 14:43
  • $\begingroup$ what are your "strict requirements"? The answer to your original question as stated is just a resounding YES, 50MHz sample rate is ENOUGH to capture a 5KHz signal. But I don't think that's what you actually mean to ask. A discharge of $200\mu s$ would only contain one period of a 5KHz signal. Your question needs to be re-written. As it is, there's not much we can help you with. $\endgroup$
    – Jdip
    Commented Aug 22, 2022 at 14:48
  • $\begingroup$ If you know your signal's bandwidth, and you know the nyquist rule, then what else do you need? $\endgroup$
    – Jdip
    Commented Aug 22, 2022 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.