Raspberry Pi Pico PIO - Ep. 15 - Faster Arbitrary Waveform Generator

Поділитися
Вставка
  • Опубліковано 25 сер 2024

КОМЕНТАРІ • 43

  • @miguelestrada2011
    @miguelestrada2011 Рік тому

    Hi david, It is so nice to see you here in a new video! Great video!

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Thank you very much. Once winter hits our area, I’ll be able to spend more time on the bench.

  • @goowatch
    @goowatch Рік тому

    Thanks for share your experiments. I'll try!

  • @23lkjdfjsdlfj
    @23lkjdfjsdlfj 8 місяців тому

    Excellent video!

  • @rgco2266
    @rgco2266 Рік тому

    Great job. To avoid jitter I use only integer divisors and adapt the buffer size for precise frequencies. Because of the FIFO there is no need to stick to memory aligned buffers. You can find it on instructables, user rgco

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Thanks for the info! I changed the buffer size in my follow-up video (Ep. 16); but I kept to memory aligned buffers. I'll check out your instructables. Thanks for watching!

  • @HufiVideo
    @HufiVideo Рік тому +1

    According to the sampling theorem, you can produce a perfect sine wave as long as you have more than two samples per period. However, this requires a low pass filter at the output of the DAC. So with a sampling frequency of 125 MHz, in theory, a perfect sine wave of 62.5 MHz is achievable. In practice, the limit will be about 50 MHz. Concerning the jitter problem, it would be much better to use a DDS (direct digital synthesizer), also known as NCO (numerically controlled oscillator). Those work with a constant sampling frequency but can achieve a very good frequency resolution.

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Those are good points. Perhaps an NCO could be simulated on the Pico by creating a series of wavetables when strung together and sampled at 125 MHz could synthesize many more stable waves. i.e. two wavetables each with 7 1/2 cycles (total of 15 cycles) output one after another would give a stable waveform of 3662109. Thanks for watching!

  • @unclemil
    @unclemil Рік тому

    Great video, just stumbled upon it - will watch the rest of them. Btw. as of writing Canakit seems to have Pico W in stock.

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Thanks for watching. I've been waiting for MicroCenter to get them in; I can get them locally with no shipping charge. But now that I'm back doing more projects; I might have to check out Canakit. Thanks!

  • @Otakunopodcast
    @Otakunopodcast Рік тому

    Thank you so much for these great Pi Pico videos. Been working my way through them and have been learning a lot.
    Just a quick note though, at 8:56 lines 60 and 77, the statement "if polarity = -1" is an assignment statement, NOT an equality statement (which, in C, is "==" (double equals.)) So, not only are you clobbering whatever value is in "polarity" , but since assignment operators always evaluate to Boolean true, the "else" clauses of those "if" statements will never run. (Yeah, this has tripped me up too. I've lost count of how many times.)

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Ahhh. Forgot about the "==". That's the problem in working with multiple languages. I'm so old that FORTRAN is my native language. Thanks, I'll check it out!

  • @Andreasonline3
    @Andreasonline3 Рік тому +1

    perfecto video

  • @EETechStuff
    @EETechStuff Рік тому

    Wow, I'm jealous. I just stumbed onto your channel, and first thing I notice is the Heathkit scope over your shoulder. It brought back memories of when I built one of those after I graduated from engineering school back in the 80's. And around the same time I built one of their H89 computers. Groovy. :)

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Fantastic. Hope you still have it. However with only a 5mHz bandwidth, it is limited to slow speed stuff. But mine still works great. Thanks for watching.

  • @ashrafatteya
    @ashrafatteya Рік тому +1

    Great video
    Try to overclock pico it can run at 250mhz up to 400mhz
    So you can push sm clock and your awg freq

    • @LifewithDavid1
      @LifewithDavid1  Рік тому +1

      Thanks for the suggestion! My next step is to see if I can get rid of the jitter. Overclocking might help; I haven’t tried that yet.

    • @LifewithDavid1
      @LifewithDavid1  Рік тому +1

      Thanks for the suggestion! My next step is to get rid of the jitter. Overclocking might help; I haven’t tried that yet.

  • @donprefontaine3237
    @donprefontaine3237 Рік тому

    David, I and a few others would like to see you build a W65C02 base system with an expansion connector for a bus. Bus expansion boards would include Adafruit 8-bit TFT LCD and an I2C-based SD card (using the NXP PCA9564 I2C to 8-bit parallel converter chip).

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Interesting. I’ll take a look at that. I was also considering turning a Pico into a 6502 system on a board that would emulate my TIM system. Both are going to take a little head scratching time. Thanks for the suggestion!

    • @donprefontaine3237
      @donprefontaine3237 Рік тому

      Keep your eyes open for a new 6502 IDE from Oshonsoft in the coming days. I use the Z80 one and it works great.

  • @simpletech2016
    @simpletech2016 Рік тому

    Great Demonstration. Is it not possible to use a frequency multiplier to get higher frequencies?

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      I think that's about the limit using the Pico. I think in the next video; I explore the limits of waveshape vs. speed. Much faster and you probably would be better with analog.

  • @haryoulimohamed3891
    @haryoulimohamed3891 2 місяці тому

    thank you david. When I use SM_CLK_FREQ=10,000 Hz, I get a distorted sine waveform. When I increase it to 125 MHz, I get an undistorted sine waveform. Could you please explain why this happens? knowing that in my case I did not add the capacitor and the amplifier.

    • @LifewithDavid1
      @LifewithDavid1  2 місяці тому

      When the state machine runs slowly (10 KHz); it can only output at the speed of the 10 KHz/the length of the PIO output loop. The faster the state machine runs, the faster you can output the data. The faster the data, the smoother the curve.

    • @haryoulimohamed3891
      @haryoulimohamed3891 2 місяці тому

      @@LifewithDavid1 Thank you for your answer. In ou PIO program we have just one instruction, tha means the output rate is 10Khz when the SM runs at 10 KH.But In your example, the state machine runs at 10 kHz, ensuring that the sine wave is not deformed in my example i get a deformed sine wave.

    • @LifewithDavid1
      @LifewithDavid1  2 місяці тому

      @@haryoulimohamed3891 In the video, I suggested that you run the state machine as fast as possible. Let's assume that you want to output a 10 KHz sine wave. You should have at least 16 samples per wave cycle (32 or 64 is much better). That means you need to run the state machine at least 160 KHz (16 * 10 KHz).

  • @haryoulimohamed3891
    @haryoulimohamed3891 2 місяці тому

    thank you david. i have a project real time signal processing(audio) with pio and DAC 8 bits. can you suggest me what can i do please

    • @LifewithDavid1
      @LifewithDavid1  2 місяці тому +1

      I added a DAC to the Pico in my DOOM video. I think that should work well for your application. You could use both cores; one for the signal processing, and one to handle the interface between memory and the PIO. DMA can help. My most recent video does a bare metal DMA. Good luck!

    • @haryoulimohamed3891
      @haryoulimohamed3891 2 місяці тому

      @@LifewithDavid1 Thank you. i want to use ADC with PIO and DAC 8 bits for data processing in real time .And don't know what i must do?? Can I use PIO for sampling analog signal??

    • @LifewithDavid1
      @LifewithDavid1  2 місяці тому

      @@haryoulimohamed3891 I would try using DMA to move the ADC data to a PIO FIFO. See section 4.9.2.5 of the RP2040 datasheet. Although this is not a beginner's project, if you have enough time to play, you should be able get the DMA to grab the ADC sample, then send it to PIO. You can use DREQ_ADC to control the pace of the DMA (500ksps) (see my most recent video and Table 119 of the datasheet). However, I don't know where you are going to do the signal processing. If it is one of the cores; then you may want to send it to a memory location directly instead of PIO. Then you can modify the data-steam as desired and then send it to PIO to output to a DAC. Although I haven't addressed this problem specifically, hopefully there is enough information in my 36+ videos on the RP2040 to give you some help. Good luck!

    • @haryoulimohamed3891
      @haryoulimohamed3891 2 місяці тому

      @@LifewithDavid1 "Thank you for your answer. Can I use PIO for data processing to reduce the latency, such as implementing a low-pass filter with PIO? Is that feasible?

    • @LifewithDavid1
      @LifewithDavid1  2 місяці тому

      @@haryoulimohamed3891 Probably not; but it depends how clever you are. Check out The PIO Chronicles, Episode 1-5. There are only 9 instructions, and none of them are logical (except a version of the jump command). No arithmetic. PIO is used to move data between the RP2040 and the outside world. But you should have no problem keeping up with the ADC (500ksps max speed) with the main core. It will work if you can do your filtering in under 250 clock cycles on one of the cores. Program in C (if you've got a lot of slop) or assembly (if timing is tight). Use DMA to move data from the ADC to the core. Manipulate the data in the core, and then use PIO to send the manipulated data from the core to the DAC, Check out my PIO and bare metal videos. That should bring you up to speed.

  • @samhutchins3061
    @samhutchins3061 Рік тому

    Great videos and explanations. I am trying to use an ADC to vary the frequency. However, I found that after the first setup, the Pico seems to panic when trying to reset/restart the DMAs or PIO in a 'while()' loop. The 'reset/unreset block commands are seemingly not the answer. So for now, I am using a simple 'reset' button on pin 30 to start the Pico over for each frequency change via the serial port program. Any suggestions on how to do it elegantly? BTW, your explanations on each important step are extremely useful.

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      Not sure without some testing; but I would make a second wave table with the new frequency and then switch to it with the DMA. Perhaps the exact timing can be made using interrupts which will interrupt the while loop.

    • @samhutchins3061
      @samhutchins3061 Рік тому

      What I am currently trying is placing the entire setup procedure in a function, then accessing that for even the first time and subsequent times through the while () loop. However, even with the block set/reset at the beginning of that loop, it's still only works the first time. Keeping in mind my lack of knowledge on dma, I'm still mystified!

    • @LifewithDavid1
      @LifewithDavid1  Рік тому

      @@samhutchins3061 I had a little problem with the DMA in my homebrew video (Ep. 12) because (I believe) DMA and the main core were butting heads when addressing the main bus. If you ask the core to do too much (like continuously redefining the setup function) then you might have some interference. Check out all my DMA related videos, that might help. Sounds like a cool project, Good luck!

    • @samhutchins3061
      @samhutchins3061 Рік тому

      Good insight. However for my function it is only rerun after manually entering different parameters such as wave type and frequency, so it's not doing that all the time. Thank you for the responses and helpful comments. Keep up the great videos!