#220

Sdílet
Vložit
  • čas přidán 28. 06. 2024
  • Using the PIO feature on the Raspberry Pi PICO is really, really difficult, right? Nope.
    JLCPCB Only $2 for PCB Prototype any colour jlcpcb.com/cyt including aluminium PCBs
    Let's explore the simple world of the PICO's PIO which sounds a lot more complicated than it really is. No, really. I mean, how complicated can 9 instructions be? And just 32 bytes of memory to work with?
    Even if you a total beginner in programming you will still understand this simple demo where I show how you can offload the burden of setting GPIO pins on and off way from the microcontroller and onto the PIO mini-brain instead. Simples.
    Please do take a moment just to visit my sponsor who make some wonderful PCBs, and now in aluminium too.
    JLCPCB Only $2 for PCB Prototype any colour jlcpcb.com/cyt including aluminium
    ========================
    PRODUCTS FROM THE VIDEO
    ========================
    Original JYETech DSO-SHELL DSO150 15001K DIY Digital Oscilloscope Unassembled Kit With Housing
    About $34 including VAT (for UK/EU customers)
    www.banggood.com/custlink/G33...
    ==========
    RESOURCES
    ==========
    Der Nulleffekt (The Null Effect) from Wolgang Spahn)
    Paspberry Pi Pico - Programmable I/O
    dernulleffekt.de/doku.php?id=...
    Life with David (CZcams)
    Raspberry Pio Pico - Programmable Input/Output
    • Raspberry Pi Pico PIO ...
    Raspberry Pi DataSheet with PIO examples (advanced)
    datasheets.raspberrypi.org/rp...
    Digikey PIO Info (and video)
    www.digikey.at/en/maker/proje...
    ==============
    CODE EXAMPLES
    ==============
    From the horses mouth (so to speak) Raspberry Pi
    github.com/raspberrypi/pico-m...
    PIO in C++ - if you really want a challenge
    www.cnx-software.com/2021/01/...
    List of all my videos
    (Special thanks to Michael Kurt Vogel for compiling this)
    bit.ly/CZcamsVideoList-RalphB...
    If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite (and other μControllers) journey
    My channel, GitHub and blog are here:
    ------------------------------------------------------------------
    / ralphbacon
    ralphbacon.blog
    github.com/RalphBacon
    ------------------------------------------------------------------
  • Věda a technologie

Komentáře • 157

  • @RamjetX
    @RamjetX Před 2 lety +4

    Life with David is a brilliant channel... Very clever fella, and really enjoyed his series on the Pico. I lost a whole Sunday to it infact...

  • @Cptnbond
    @Cptnbond Před 2 lety +2

    Hi Ralph, there are always useful take-aways from your episodes, thanks for that. Cheers.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Take away? Ooh, nearly Saturday, definitely a take away. Oh. I guess you were not talking about your local Indian Restaurant then. But this PICO is fun too!

  • @BerndFelsche
    @BerndFelsche Před 2 lety +3

    Nice to see a comprehensible introduction into otherwise inscrutable features.

  • @peoplethesedaysberetarded

    It always makes me so pleased to see one of your videos, friend. Also, I am so, so, glad that you put a countdown timer on your ads. I stuck around to listen and watch it, but that's a nice thing you've done there. :)

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Yes, the countdown timer was to show that it was only (usually) about 1 minute and not to skip ahead; glad you appreciated it! I just hope everyone visits my sponsor who pays my bills.

  • @YTbxg
    @YTbxg Před 2 lety +2

    That was a really useful intro to PIO. When I saw the Pico PIO was programmed in assembly I thought that would be too complicated to get into and looked no further. But now you have done the research I cant wait to have a play :-). I do like all this micropython code as well.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Glad you liked it! As I said, "Easier than you think!"

  • @mytechnotalent
    @mytechnotalent Před 2 lety +2

    You, Ralph, are the only one that made PIO understandable. Thank you.

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      Wow, "the only one" you say, Kevin. Well, I can't believe that's true but it's nice to know you understood my video. Thanks for the feedback, appreciated.

    • @mytechnotalent
      @mytechnotalent Před 2 lety

      @@RalphBacon most welcome and thank you Ralph!

    • @mytechnotalent
      @mytechnotalent Před 2 lety

      @@RalphBacon I would LOVE to see if you would make a detailed and I mean detailed video on how to write a device driver in C or MicroPython for the Pico. That would be so helpful. Device driver dev they say should use the PIO but I have no idea how to do such.

  • @lambert0259
    @lambert0259 Před 2 lety +1

    Thanks Ralph. Like you I've been playing with the Programable PIO and watched David's Tutorials on the programable PIO, I've managed to use a BME280 and a LCD display using I2C to display temperature etc, While the PIO output's parallel data On the PIO Pins, This is a lot different than programming Arduino and Stm32 Micro controllers. Keep up the good work.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      I'm pretty sure I could write much of what the PIO does on the PICO for the Arduino (using non-Arduino speak) but it would be much harder work.

  • @prlombaard
    @prlombaard Před 2 lety +1

    Thanks @Ralph S Bacon for the video. You have sparked my interest. I’ve known about PIO. The way you explain it was so easy I’ll go and play with it myself.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Go play! Plenty of examples on the official Raspberry Pi GitHub (link in my video description).

  • @duncanmarks1590
    @duncanmarks1590 Před 11 měsíci

    Hi, A very useful presentation, thank you for the time spent on this. Duncan

  • @csbluechip
    @csbluechip Před rokem +5

    I think you'll find there are TWO groups of FOUR State machines (rather than eight - the grouping is critical), and each group has 32 WORDS (64 bytes) of memory.

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Quite likely. But this was an academic exercise really. I wonder how many Real World uses these pins have found so far (especially with relatively inexperienced programmers of the PICO)?

    • @csbluechip
      @csbluechip Před rokem +2

      @@RalphBacon There is so much bad/misguided information being published on the Pico. And few have the integrity to say: My video is quite likely wrong.
      I expect that when accurate tutorials become available, the inexperienced will have an opportunity to learn how to use the Pico

  • @aryeguetta8592
    @aryeguetta8592 Před 2 lety

    Great video Ralph!!! thanks a lot, video well made and you have given so many information on the table that makes life with Pico easier. As for the Blinking NeoPixel board that project I would also be happy to see how it is done. if that is OK by you, Maybe next week :) - Keep it up and thank you so much.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Glad you enjoyed it! The NeoPixel code is available from the Raspberry Pi GitHub (link in the video description) but it's not simple - hence why I abandoned talking it through. But others have done it, see if anyone in these comments has posted something to GitHub.

  • @neildarlow
    @neildarlow Před 2 lety +1

    You could also use the Output Shift Register to output a repeating 0110 (or 1001) pattern to the two pins.
    This would also afford you the ability to use the 16.8 clock prescaler to have some control of the frequency.
    There's lots of tricks you can play with PIO. 😉

    • @RalphBacon
      @RalphBacon  Před 2 lety

      I'm going to have to re-read this a few times, Neil, and Google what you are telling me because I don't know how to do this (yes) - but I'm keen to know how to do this, so thanks for the heads up. 😉

  • @jj74qformerlyjailbreak3

    Thank you Sir.
    Yes I find your vids useful.
    I should have learned mc’s When I was a lad.
    Remember. “Those who can control time, Control”
    God bless.

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      Right on! But it's _never_ too late to learn new stuff, even my mum learned how to use the Internet using a tablet in her 90s. If she can do it, anyone can!

    • @jj74qformerlyjailbreak3
      @jj74qformerlyjailbreak3 Před 2 lety

      @@RalphBacon Indeed, Time to me is determined by my capacity to love ❤️
      I’m learning so much.
      ❤️ Hz 0101 ❤️ Hz
      Be a Resistor.
      🥂

  • @skf957
    @skf957 Před 2 lety

    Nicely done Ralph. Looking forward to a possible follow-up with that neopixel stick.
    I've used PIO on my Pico from a C++ program. Not recommended. I could not have worked out how to do it, and even after cutting and pasting all of the various header and helper (?) files, I still struggle to see what's going on!

    • @RalphBacon
      @RalphBacon  Před 2 lety

      For now, I'm sticking to putting the PIO code into MicroPython!

  • @JonMcPhalen
    @JonMcPhalen Před 2 lety +1

    If you like the PR2040 PIOs, you might love the Parallax Propeller 2 "Smart Pins."

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Here's a link for others to Part 1 of that series of articles:
      www.elektormagazine.com/magazine/elektor-167/59256

  • @followthetrawler
    @followthetrawler Před 2 lety

    Nice video Ralph, are you thinking of using PIO with Interrupts for you fridge door project - would be very interested in a video describing how to enable the state machine from an interrupt request

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      "PIO with Interrupts for you fridge door project" - are you crazy, Stuart! Oh, you're being serious. I hadn't thought of that approach but now that you've mentioned it I will have to see what advantage that might bring.

  • @MUHAMMADYAWARIFRAHEEM
    @MUHAMMADYAWARIFRAHEEM Před 2 lety +1

    Very informative video Sir

  • @flemmingchristiansen2462
    @flemmingchristiansen2462 Před 2 lety +1

    This is probably discussed earlier but i just have to comment on this.
    With pico setup, the speaker cone will never go negative. Please check your reference points.
    You are measuring the 2 output pins separately, out to ground but what do the speaker see. You put 1 side of the peaker to one pin and the other side, of the speaker, to another pin. The speaker "see" the difference between the 2 output pins. There is nothing to pull the speaker negative.

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      There is no negative voltage, for sure, but the speaker cone could never be in a certain position if the poles were not reversed - thus _giving the effect_ of a negative voltage. As my video stated.

    • @flemmingchristiansen2462
      @flemmingchristiansen2462 Před 2 lety +1

      @@RalphBacon That is not right. You are not reversing anything and you don't need to. Like me, you might need to read up on simple electronics. You are simply moving you ground point, therefore bigger amplitude. "giving the effect of negative voltage" is nonsense.Put your scope across the speaker, check your ground level and watch how the signal goes negative -or not.

    • @YTbxg
      @YTbxg Před 2 lety +3

      @@flemmingchristiansen2462 'giving the effect of negative voltage' does not mean there is negative voltage. If one was driving a speaker with +3v to -3v square wave what would you get. One could say this would "in effect" produce the same results as that of the video.

  • @mandelbro777
    @mandelbro777 Před rokem

    These 8 PIO state machines are game changing for hobbyists.
    I don't think many people understand how useful they are.
    Offloading of up to 8 custom peripheral processes, leaving the two main cores which can perform maths and logic totally free from having to interfere with their operation is such a simple idea, I can't think of why AVR didn't adopt this years ago. The fact these 8 state machines can also achieve timing accuracy not possible on the main cores that lose available clock cycles sometimes due to overheads, will make bit banging so much easier and more efficient.
    Thanks for this video .... it's good to see more people adopting micropython rather than whining about it because they're fixated on C/C++ due to psychological Arduino imprinting.

    • @RalphBacon
      @RalphBacon  Před rokem

      Certainly powerful, that's for sure. MicroPython or C++, choose whatever works for you, is what I say!

    • @1over137
      @1over137 Před rokem

      In my case it's not "Arduino imprinting". You talk about clock cycles and overheads. You won't like micro-python if you want low overheads. Even simple python instructions, to interpret and then execute and return back up the stack takes 100s of clock cycles. I mean things like a = b + c takes 100s of cycles.
      If you do something python-esk like append to filtered lists together that's going to take about 2 milliseconds per list entry.
      From python, I highly doubt you would be able to bit bang anything. It's probably the main driving reason for having hardware statemachines in the first place, if they were targetting MP.
      Look I use Python in my day job on "non-commodity" hardware. We are talking blade racks with 192 x 4Ghz Zeon cores and 4 terrabytes of RAM and python is still too slow.
      Using it on a MCU at 130Mhz is lunacy. It will work for "play school" style stuff where timing and performance are not a consideration and response times of milliseconds is acceptible.
      Once you move to hardware control, unless you hare using underlying native library code you will not be able to achieve the timing.
      Try bit banging a NeoPixel strip without using the NeoPixel native routines buried under the library, but just using the Python GPIO libs.

  • @andymouse
    @andymouse Před 2 lety

    Hi Ralph, keep going ! your beginning to peak my interest, I'm probally not alone either....cheers.

  • @Bianchi77
    @Bianchi77 Před 2 lety

    Nice video, thanks :)

  • @MrEdwardhartmann
    @MrEdwardhartmann Před 2 lety

    Thanks - I ask in your other comments and you delivered. (I can pretend that it was my comment and not the other few thousand who ask the same think!)

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist Před 2 lety

    By forming a bridge output then you and expect to get 4 x the power on the speaker. e.g 2.5V in to 10 ohms, power = V2/R (2.5)2 / 10 = 0.625W (5)2 / 10 = 2.5W 2.5W/0.625W = 4 Sp one extra pin and 4 times the power out.

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      Well, I'm not sure this is a true bridge output, as there is no actual negative voltage swing. And the correlation between power out and perceived volume is not linear; I can remember in my dim and distant younger days when I was a DJ (yes, really) being pretty disappointed at the increase in volume from a 100W amp from a 50W amp. To get double the volume (10dB) from the same set of speakers you need to increase power by ten! Yikes!

  • @mahudson3547
    @mahudson3547 Před 2 lety +2

    I think that ‘not very square’ wave on your scope is because you are using x10 probe and you haven’t adjusted the trimmer!

    • @RalphBacon
      @RalphBacon  Před 2 lety +3

      Spot on! Ironically, there was no reason for them to be on the 10x setting, I had just left them in that setting from another project. Anyway, I took the opportunity to calibrate both the probes, now very square indeed! You've earned a Gold Star!

  • @Chriva
    @Chriva Před 2 lety +1

    Welcome back! :)

    • @RalphBacon
      @RalphBacon  Před 2 lety +2

      Yay, thank you!

    • @Chriva
      @Chriva Před 2 lety

      On a slightly less joking note. Have you played anything with eTPU or the old TPU?
      It's remarkably similar in that you can precisely control pin toggling but it also has some additional branching and maths capabilities. Fun little marvels to play with :)

  • @markday3145
    @markday3145 Před 2 lety +1

    Note that you could have done your two-pin output with two set pins (using .set()), or two side-set pins (using .side()). The side-set pins tend to be useful for control pins that you are setting to a known, constant value; and the input/output pins can transfer data to/from the microcontroller memory. For example, the side-set pins might be for handshaking, clock, data direction, etc.
    The set and output pins can be the same pin(s). That's handy when you need to mix constant and data-driven values on the same pin (like for NeoPixels...).
    The PIO support in MicroPython is pretty darn good. Documentation and examples could use a little fleshing out. Until then, it may help to take a look at the C/C++ documentation and examples. I was surprised how easy it was to come up with my own NeoPixel implementation via PIO.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      If you got the NeoPixels up and running then you already are an expert regarding PIO capabilities, Mark! I shall look into what you said although at the moment you've just confused.com me!

    • @markday3145
      @markday3145 Před 2 lety

      @@RalphBacon I just pushed a couple of examples of things I was experimenting with up to GitHub:
      github.com/mday64/pio_experiments
      It's got a NeoPixel implementation (works differently from the official Raspberry Pi examples), and an 8-bit parallel output port with clock. Maybe it will help, or maybe it will just add to the confusion.

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      You've been busy, Mark!
      Given the comment from @Andrew Toogood above, I just wonder how many PICOlites will ever reach the standard of code you just published, or will they just download yours and say "Look what I did!" without understanding more than a line or two?

  • @DrexProjects
    @DrexProjects Před rokem +1

    I just got 2 of those in the mail to play with.

    • @RalphBacon
      @RalphBacon  Před rokem

      I hope you have fun playing with them.

  • @DRI1966
    @DRI1966 Před 2 lety

    Hello Ralph, any plans to make a video on the Attiny 202/402 ?
    Thank you for making this nice an understandable videos 👍
    Best Regards,
    Didier

    • @RalphBacon
      @RalphBacon  Před 2 lety

      I haven't got plans to look at these; the question for me (and my viewers) is: what are the advantages of these chips that makes them more suitable than others that we already have?

    • @DRI1966
      @DRI1966 Před 2 lety

      @@RalphBacon Hello Ralph, you do not find on CZcams too many video’s on how to program this chip’s.
      UDPI(One Pin Programming) seems to be the way Microchip / Atmel are going. Explained by you will be easy to understand 👍👌

    • @BenHeckHacks
      @BenHeckHacks Před 10 měsíci

      ​@@RalphBaconOne pin programming & debug, also has way better peripherals than legacy ATTINYs

  • @JimMaz
    @JimMaz Před rokem

    I would love to see some PIO communication between Picos.

    • @RalphBacon
      @RalphBacon  Před rokem

      It seems an unlikely topic for me to cover but I'm sure others out there have already done it.

  • @1over137
    @1over137 Před rokem

    Interesting approach to push/pull the speaker. I still can't figure out what the reference voltage would be. I mean normally you would see -3V +3V but thats only what the speaker sees. The MCU still sees 0-3V. I suppose what that is, is a differential pair and there is no static "reference". I hate analogue electronics :)

    • @RalphBacon
      @RalphBacon  Před rokem +2

      There's no magic, nor smoke and mirrors. It's still only VCC and GND.
      The "magic" (even though I said there was none) is in having the speaker cone move forward with the positive pulse in the normal way.
      BUT, when the polarity is _reversed_ it's still only VCC and GND but the speaker cone is now in a starting position that could only be achieved (normally) with a +VCC / -VCC and it moves the full distance backwards thus giving a much bigger sound wave than by normal means. 😲

    • @1over137
      @1over137 Před rokem

      @@RalphBacon i wonder .... if using PIO could you bit bang a PWM fast enough to make a class D amp out of a GPIO pin!

    • @RalphBacon
      @RalphBacon  Před rokem

      Yeah... good luck with that one!

    • @Henry-sv3wv
      @Henry-sv3wv Před rokem

      RP2040: IOVDD is Power supply for digital GPIOs, nominal voltage 1.8V to 3.3V
      Let's say we have 3.3V from the Pico board here.
      In IO output Mode you can switch the RP2040 IO Port pins between physical IOVDD pin (digital High logic state.) and its physical GND pin. (digital Low logic state).
      Let's say you have two Ports in output Mode and call them A and B.
      if you switch A to IOVDD and B to GND
      and after a 2 second waiting time switch
      A to GND and B to IOVDD
      and after waiting two seconds repeat
      then a multimeter connected beween those two IOs will see it's probes are alternatiting
      connection between IOVDD and GND. because the switching transistors in the ports are told by the software to do that.
      So the Multimeter will show alternating between: 3V and -3V
      if you measure any port to GND when it is LOW the port itself is a GND, so you measure GND to GND which shows 0V
      if you measure any port to GND when it is High, you measure GND to IOVDD which should be around 3.3V GPIO Power supply voltage on the Pico board.

  • @1over137
    @1over137 Před rokem

    Tip: To make breadboard buzzers tolerable, remove the label and stick a bit of blue-tac or putty in the hole.

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Your definition of "tolerable" is slightly different to mine! 🤣😂 Terrible, piercing sound and I've got too many in my workshop now (in finished projects). Seemed like a good idea at the time, of course...

  • @1over137
    @1over137 Před rokem

    Technically the PIO runs without intervention from the CPU core in the MCU. If you deal with other types of MCU you might find that your PIO isn't really special at all. Consider the approach taken on almost all MCUs today (if they have it available) for NeoPixel arrays.... DMA. You generate a bit pattern which creates the PWM square wave on the output pin.... call Transmit DMA and send the CPU to sleep. If the DMA is set to loop the buffer, you have nothing more to do and could potentially halt the CPU.
    Beyond DMA advanced MCUs like the STM32 et. al. have many, many concurrently running systems inside them, handling IO without the CPU intervention. I believe on something like the STM32F411 (Black Pill board), the MCU has about 16 different clocks, running 16 different parts of the MCU asynchronously on one of several buses.
    Usually those components are used for specific standard peripherals, like hardware UART, SPI, I2c etc, so the protocol aspects are very often taken care of entirely by the peripheral in hardware and the CPU is only "woken" up to process data that has arrived or when it's needed to make a decision.
    Stretched out to it's potential, you can have a DMA transfer reading audio off an SDCard triggering a DMA transfer to send that data over I2S for a DAC and the CPU would be asleep or maybe just waiting on UI button interupts to change track. Potentially even further with the FPU DSP extensions, as you can send floating point calculations to the FPU and off load that processing and receive an interrupt when it's done. So you could even potentially have an IIR filter or two running on the audio stream and the CPU would STILL be idle a lot of the time. Although, when you get that level of power you might find the CPU is entirely busy answering real time interrupts to orchestrate everything.
    The PIOs certainly sound interesting to play with and I'm sure some of the bus hardware in other MCUs could be used that way if you wanted to get down into the hardware control registers and start messing with their internal configs.

    • @RalphBacon
      @RalphBacon  Před rokem

      Ideal for NeoPixels, for sure, with no CPU involvement. I bet someone has already done this!

    • @1over137
      @1over137 Před rokem

      @@RalphBacon Having just done it with DMA->PWM on the STM and finding an even better way with SPI to try yet, I expect the greatest advantage of the PIO processors will be in converting the "bits" to sequences of 100 and 110 at 3 times the frequency. ;)

    • @1over137
      @1over137 Před rokem

      That would allow you to write raw 24bit RGB/BGR data to the port.

  • @lizardofoz5329
    @lizardofoz5329 Před 2 lety

    That is an interesting breadboard.
    Looks to be of higher quality than
    the usual fare. Source?

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      It's this one (UK supplier):
      coolcomponents.co.uk/products/ad-11-advanced-solderless-breadboard

    • @lizardofoz5329
      @lizardofoz5329 Před 2 lety +1

      @@RalphBacon Thank You for the link. I have
      one on the way. 6x6 configuration is going to
      make the 8266 boards I bought a lot easier to
      work with. In a crazy world a sane man such as
      yourself is much missed. So glad you are back.

  • @MisterkeTube
    @MisterkeTube Před 2 lety +1

    Hey Ralph, I can't unhear it anymore ... no, not the actual audio of it, but the name you gave it: the Pizza-electric buzzer ... I think the guy of that effect had his name pronounced like pee-a-tzo, no? Don't know whether he was somehow linked to that crooked tower or loved to eat some Italian circular bread with tomatoes smashed on top, but I don't think he deserves being turned into such a dish ...
    On a more useful note: I think you can add an additional command doing nothing (useful) with extra wait-states to get lower frequency. And I have a little worry: if you have a 4ohm speaker, is driving it directly from a gpio not risking over-current on that gpio (same for running between 2 gpio pins)?

    • @RalphBacon
      @RalphBacon  Před 2 lety

      You say tomayto, I say tomahto... Google says I should say pee-ay-zo which sounds very British English. I'm trying to say Peezo! I don't think it's a name: French physicists Jacques and Pierre Curie discovered piezoelectricity in 1880. And possibly the pizza too, with peperoni, of course.

    • @MisterkeTube
      @MisterkeTube Před 2 lety

      @@RalphBacon Well, I would actually say "Tomaat" as I'm not a native English speaker, but since the term piezo is derived from (ancient) Greek, perhaps someone speaking Greek in your audience (there's bound to be someone, right?), could tell us how it would sound in Greek and enlighten us both ;-) They also have great tomatoes in Greece, right? So maybe we should also ask them to clear up the tomayto / tomahto mess ;-)

    • @RalphBacon
      @RalphBacon  Před 2 lety

      😂 😁🤣 Good answer! I'll ask: Μιλάει κανείς εδώ ελληνικά;

  • @1over137
    @1over137 Před rokem

    My first experience with the Pico was managing to get a PicoW (hens teeth). I ran a very quick MQTT subscribe and it worked. Then I did "Blinky", couldn't be bothered to google the right delay function so did this instead. Fully expecting (having just come from STM32 world) for 1 million to not be enough iterations to produce a sensible blinky.
    In python I used this for delay:
    for( i in range(0,1000000)):
    pass
    The LED had about 1 Hz blink frequency. That's only 2 million iterations per second. On a 130Mhz core. Wow. I thought Arduino framework was wasteful.
    Circuit/Micro python is fiercely slow.

    • @RalphBacon
      @RalphBacon  Před rokem

      It's all down to interpreted vs compiled code, I guess. If Arduino had used μPython on the original Arduino it would never have found the success it has had, far too slow!

    • @wayland7150
      @wayland7150 Před rokem

      Rapid Electronics have loads of PicoW.

  • @fredflintstone1
    @fredflintstone1 Před 2 lety

    Damn do I now have to buy more stuff, CPC have now posted the extra 2 picos :-) I guess this is for the fridge alarm, I guess I will have to buy a fridge as well:-)

    • @RalphBacon
      @RalphBacon  Před 2 lety +1

      And beer to put in the fridge!

    • @fredflintstone1
      @fredflintstone1 Před 2 lety

      @@RalphBacon if only I could afford it instead of buying PICO's:-)

    • @RalphBacon
      @RalphBacon  Před 2 lety

      😁 🍺🍺🍺🍺

  • @gedtoon6451
    @gedtoon6451 Před rokem

    Do Raspberry Pi Ltd have an ARM licence, or did they use a third party to design and manufacture the RP2040?

    • @RalphBacon
      @RalphBacon  Před rokem +1

      All home grown from what I hear, and yes, they have a fully licenced ARM set up.

  • @allinclusive5762
    @allinclusive5762 Před 2 lety

    👍

  • @kentswanson2807
    @kentswanson2807 Před 2 lety

    GPIO co-processor!

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Well, a very limited coprocessor but, yes, I suppose it is!

  • @mrtom64
    @mrtom64 Před 2 lety

    Errr....[blood boiling] CZcams are saying 'Nobody clicks the bell anymore', well of course not, CZcams stopped email notifications months ago so whats the point? Yeah, I know it works for some users of certain browsers and mobile devices but for the majority of youtube users, nah. I have to use a third party to inform me of any new uploads otherwise I'd miss everything. It doesn't work for 'live' events though and if there isn't a 'reminder' set by the creator then I miss those too. Just my small rant, sorry....great vid, thanks.[/blood boiling]

    • @RalphBacon
      @RalphBacon  Před 2 lety

      What did Elton John say? Don't Shoot Me I'm only the Piano Player great album! But seriously, I've never really understood the "subscribe but also do something else to get notifications" anyway.

    • @NormanNodDunbar
      @NormanNodDunbar Před 2 lety

      @@RalphBacon Indeed he did. (Ticking is the best track in my opinion, tells astory.)
      Cheers,
      Norm.

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Hmm, I seem to remember that Ticking was on Caribou not Don't Shoot Me, but as this was a gazillion years ago I could be wrong. I liked Teacher I Need You as I liked my Spanish Teacher of the time! Jeez, that's unsettling, she would be nearly 80 now... if she's still here. Thanks Norman, now I feel really depressed. 😢 And old.

    • @mrtom64
      @mrtom64 Před 2 lety

      @@RalphBacon Sorry Ralph, you unkowingly lit the fuse and I kind of went off on one.

    • @NormanNodDunbar
      @NormanNodDunbar Před 2 lety +1

      @@RalphBacon So, I had to check and Ticking was indeed on Caribou. My mistke and as punishment, I will be listening to the album on repeat for at least a day! I always thought the Teacher... was a tad risque, even as a teenager, but then again, I know what you are saying!
      Yes, I'm old too. 61 back in April. Still, I'd hate to be a kid these days the way we humans are buggering everything up.
      Take care.
      Cheers,
      Norm.

  • @andrewtoogood1429
    @andrewtoogood1429 Před 2 lety +2

    This has been my favorite channel for a couple of years now, BUT I have to say I am losing interest, I can't think of anything I would use A Pico for that and Atmel or STM or ESP would not do better. And for me Micro python is pointless why learn a new language so my solutions can go slower and have less memory... Went to the end to see if you had an update in the bin sensor but alas :(

    • @RalphBacon
      @RalphBacon  Před 2 lety +2

      Hmm, I knew this would be a potential issue for my viewers, Andrew. After all, what _can_ the PICO do that the others cannot (and more quickly too)? I'm only covering the PICO because it's out there, in your face, inescapable, by virtue of being launched by Raspberry Pi. If another (much smaller) manufacturer had launched this it would not have had so much traction.
      I'm not sure MicroPython is pointless (harsh, Andrew, harsh) as beginners probably pick up the rudiments quite quickly (then get lost in spaghetti code). And no compilation stage leads to faster development time of that blinking LED, as you saw!
      But don't give up! And don't leave! My ATMega328P bin lid monitor is (slowly) coming along, talking using its nRF24L01 to a dumb receiver (at this stage), I have my fridge door alarm to complete albeit possibly with the PICO (maybe, I'm having doubts now) and I have my... oh, you'll just have to tune in and find out.
      (Remember, I'm an Arduinite at heart but don't tell anyone else).

    • @noweare1
      @noweare1 Před 2 lety

      I feel the same way.

  • @duncanx99
    @duncanx99 Před 2 lety

    Sorry, but I don't see how you get your claimed 'negative pulse'.
    A GPIO can only switch between OV and Vcc, so the maximum possible offset is surely only the same as The Vcc value, so with a Vcc of 3.3V its impossible to obtain the quoted 6.6V...
    In terms of Forward and Backward movement of a loudspeaker cone it makes sense but, as explained, it's incredibly misleading.

    • @hopje01
      @hopje01 Před 2 lety

      With this ‘trick’ you can double the voltage, but you need some kind of external reservoir. In this case the reservoir is a mechanical item. The coil movement is the double of the gnd-pin config. You can do the same with a little circuit with a capacitor as reservoir. The cap will charge to 2x the pin voltage. Handy if e.g. you want to use a led with a Vf greater than 3V on that output pin.

    • @duncanx99
      @duncanx99 Před 2 lety +1

      @@hopje01 No capacitors were used in the given example.
      As, I mentioned, I can see how the Forward and Reverse action of the loudspeaker cone provides double the volume but, at no point is there ' double the voltage', as stated in the video, for the setup shown. That's what will mislead anyone who doesn't understand what's going on and it's compounded by the dual trace oscilloscope display not having a common baseline.

    • @zyghom
      @zyghom Před 2 lety

      100%

    • @zyghom
      @zyghom Před 2 lety +1

      @@hopje01 there is a big difference between + and - 3V vs GND and 0 to 3V. That is why there is no 6V amplitude on Pico ;-)

    • @duncanx99
      @duncanx99 Před 2 lety

      @@zyghom Exactly...

  • @nweston5070
    @nweston5070 Před 2 lety +1

    Interesting! I didn’t know pushing an pulling pins for a sounder made such a difference.
    I think you can do a live-set-able number of delay cycles (I’ve not checked this but I hope you get the idea) - this uses side set for both bits so the pins have to be adjacent. I’ve also missed out the wrap target and wrap labels because I think the assembler assumes these if they are the first and last instructions:
    @rp2.asm_pio(sideset_init = (rp2.PIO.OUT_HIGH, rp2.PIO.OUT_LOW))
    def beep():
    mov(x, y)
    label(“loop1”)
    jmp(x_dec, “loop1”) .side(0b01)
    mov(x, y)
    label(“loop2”)
    jmp(x_dec, “loop2”) .side(0b10)
    Delays are caused by looping round and decrementing X, and when X gets to zero the code drops through. The minimum delay is zero, so the the minimum clock cycles for the whole lot is 4, or up to 2^32+2 if you set Y as 0xFFFF. This should give you pretty good pitch control if you use a fast PIO clock!
    You would set the number of wait cycles by setting Y in your Python WHILE loop using:
    sm.put(number_of_wait_cycles)
    sm.exec(“pull()”)
    sm.exec(“mov(y, osr)”)

    • @RalphBacon
      @RalphBacon  Před 2 lety +2

      A nice example, Mr Weston, (I'll call you Nick) and shows how tight loops can be implemented in the PIO arena as well as passing values to the PIO code. Cool stuff.