Arduino PWM without analogWrite() - Muppet 2 Project

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ธ.ค. 2024

ความคิดเห็น •

  • @foxabilo
    @foxabilo 2 ปีที่แล้ว

    Watching these vids after the event and I'm waiting for you to discover the joys of synchronous buck-boost shoot through and dead time implementation :D

  • @TheDefpom
    @TheDefpom 7 ปีที่แล้ว +3

    Please go into the detail of how the registers work in this case.

  • @AlexK-rg1qs
    @AlexK-rg1qs 7 ปีที่แล้ว +17

    Would love to see more on registers with arduino!

  • @martinj9268
    @martinj9268 7 ปีที่แล้ว +4

    You should do a video on arduino registers. Honestly I don't know the first thing about that sort of thing, but am definitely interested!

  • @TechGorilla1987
    @TechGorilla1987 7 ปีที่แล้ว +3

    Cheers Mr. I. Hope your day is going well, sir.

  • @RNA0ROGER
    @RNA0ROGER 7 ปีที่แล้ว

    This is beyond useful for a huge number of applications. Thank you Julian

  • @christostrauss7468
    @christostrauss7468 3 ปีที่แล้ว

    Excellent solution for my problem! Only question how could I change the 2 pwm channels in order to change motor direction?

  • @PhattyMo
    @PhattyMo 7 ปีที่แล้ว

    I don't recall having this issue with a similar buck/boost/synchronous rectification project I did one weekend..but my memory of it is a bit fuzzy,been a while since I needed a dual/inverted PWM output. I think I just used the map() function,to invert the PWM value. I'd have to see if I still have a copy of the code. I was using an Arduino Mega though,maybe that's the difference.

  • @atul2048
    @atul2048 2 ปีที่แล้ว

    Hello, how would you change the frequency?

  • @modellerdesign
    @modellerdesign 5 ปีที่แล้ว

    Julian Ilett
    Hello. Can you prompt the issue of arduino pwm controlling the mosfets. It goes from 0 to 4.5 volts on linear mode on voltage. But should it be a step from 0 to 4.5 with pwm without any linearity on a voltage, to controlling the applications?. Sorry for the noob and such a kind of question. I do the DIY motor controller, and if I add a gate driver to mosfet with say 12v of driving voltage, the arduino don't give a damn on a pwm and just ON and OFF full power, no matter what pwm cycle is applied.
    Thanks.

  • @sihlejako813
    @sihlejako813 3 ปีที่แล้ว

    how do you disable phase correct or how can one get controlled phase shift between pwm signals?

  • @carlossorondo5152
    @carlossorondo5152 5 ปีที่แล้ว

    what did you do to create the non overlap and create the space between the pulses..?

  • @carlossorondo5152
    @carlossorondo5152 5 ปีที่แล้ว

    what pins are you using besides where the pot is .. It may be a dumb question but i am a newbie sorry ..

  • @carlossorondo5152
    @carlossorondo5152 5 ปีที่แล้ว +1

    Julian thank you it is exactly what I was looking for.

  • @sigitpermana7330
    @sigitpermana7330 3 ปีที่แล้ว

    Hi julian! does this work for timer 2, what should be changed? Thx

  • @cmuller1441
    @cmuller1441 7 ปีที่แล้ว +2

    The flipping was not a bug but a misuse of the library. You must NEVER mix library accesses and direct register accesses. You either use one or the other but not both. Inverting was also quite simple: just call the library with (100-dutycycle%)...

  • @haz939
    @haz939 7 ปีที่แล้ว

    I've been trying to get complementary / none overlapping waveforms just using the 8 bit timer. There is inverted bits in the TCCR0A register for both OCR0A and OCR0B. it only works in CTC mode?

  • @grahamsutherland1106
    @grahamsutherland1106 7 ปีที่แล้ว +1

    Why not submit a pull request to fix this in the Arduino framework?

  • @carlossorondo5152
    @carlossorondo5152 5 ปีที่แล้ว

    Also how do you set the frequency out ?? I need the 30Khz

  • @LateralThinkerer
    @LateralThinkerer 7 ปีที่แล้ว

    This is ingenious - how is the frequency set?

  • @NickGaster
    @NickGaster 7 ปีที่แล้ว +3

    Did you order that flashlight custom or customise it yourself? Really enjoy your videos. Thanks

  • @agsolarpower5975
    @agsolarpower5975 7 ปีที่แล้ว

    Hi
    How much non overlapping time you get?
    And also is it sufficient for mosfets?

  • @haroldthibault9921
    @haroldthibault9921 7 ปีที่แล้ว +2

    Could you please link the previous video where the problem occurs

    • @JulianIlett
      @JulianIlett  7 ปีที่แล้ว

      Thanks Harold - I've done that now :)

  • @steveroberts1861
    @steveroberts1861 7 ปีที่แล้ว

    You are only dividing the analogue read value by 2? Shouldn't this be divided by 4? Is the assignment to the register just dropping that extra bit?

  • @pratikbhagat9028
    @pratikbhagat9028 5 ปีที่แล้ว

    julian , while using timer 2 8bit for generating noninverting and inverting pwm using direct register write i see that inverting pwm2 is little bit phase shifted in respect to pwm1. what can be the issue.
    pinMode(3, OUTPUT);
    pinMode(11, OUTPUT);
    TCCR2A = _BV(COM2A1) | _BV(COM2B1) |_BV(COM2B0) | _BV(WGM21) | _BV(WGM20);
    TCCR2B = _BV(CS22);
    OCR2A = 55;
    OCR2B = 55;

  • @JerryEricsson
    @JerryEricsson 7 ปีที่แล้ว

    Wow; you know years ago (way back when Christ was a Corporal!) I used to have a C=128 Commodore setup and subscribed to RUN magazine and a few others. They came with "FREE SOFTWARE!" in machine code, entered with a special assembler that you had to type in, or buy a floppy disk with it included. Of course you had no idea how the machine code worked because it was just a series of 8 bit numbers entered into the program, then assembled into a game or utility. I used to do them all! Had the wife read me the code, as I punched the numbers into the software, then we would play the games. Well at last, I can get a bit of understanding what all that was all about. Great to have a bit of education whilst I sit down here in our 35 foot Rexall Rexair Class A Motor Home with an old recliner sitting in the middle of the living room holding my aging body up in a rather comfortable position. We just returned from a walk around the block in the beautiful Arizona Sunshine! Oh by the way, did anyone ever tell you, we got your bridge from London? Yep, just 26 miles from where I sit, in Lake Havasu City, sits the London Bridge with a small imitation London community under it. We stop off for some of their wonderful Fish and Chips when we visit.
    By the way, have you tried that little Arduino with the extra pins yet? Just wondering, I use them all the time down here as I don't have a lot of room, and they are almost like having an Arduino and a breadboard in one. Oh for reference, it is 68 degrees F. here in Golden Shores Arizona, a bright and sunny day, so much nicer then it was when we left South Dakota a week ago, where it was 8 degrees F. with 5 inches of snow on the ground. --The nomadic snowbird---

  • @alischannel7206
    @alischannel7206 ปีที่แล้ว

    i need to contact you sir regarding my bidirectional converter

  • @vylbird8014
    @vylbird8014 7 ปีที่แล้ว

    This any help?
    const int pwmtop=128;
    void setup(){
    TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20); //Adjust timers.
    TCCR2B = _BV(WGM22) | _BV(CS20);
    OCR2A = pwmtop; //Go faster.
    pinMode(3, OUTPUT); //PWM drive
    }
    That'll crank up the PWM frequency as high as you reasonably can, at the expense of precision. You'll be down to 7-bit, not 8-bit. But if you're doing with a buck converter, the trade off is worthwhile to avoid needing an impractically huge inductor.

  • @Sariel2030
    @Sariel2030 6 ปีที่แล้ว

    JULIAN ILETT YOU SHOULD DEFINITELY MAKE A VIDEO EXPLAINING HOW TO BUILD A CIRCUIT, CODE, APP AND ZERO CROSSING CIRCUIT WHICH CAN CONTROL AT LEAST 5 AC LIGHT BULBS AND BE ABLE TO NOT ONLY TURN THEM ON/OFF BUT DIM EACH ONE OF THEM SEPARATELY VIA BLUETOOTH HC-06 AND ANDROID APP. THAT WILL BE A CHALLENGE!!!

  • @borayurt66
    @borayurt66 6 ปีที่แล้ว

    This is just what I am trying to do for a project at the moment, and you helped me a lot. Since you seem to have a better understanding of registers, and you said "I can make this work with whatever frequency I need." Can you please help me to bring it down to something like 3Hz?

    • @JulianIlett
      @JulianIlett  6 ปีที่แล้ว

      You can get 30Hz easily enough - 3Hz is more difficult.

  • @ammarsalha6533
    @ammarsalha6533 7 ปีที่แล้ว

    which pin should we use ,could you please help me
    I'm using arduino mega

    • @fezdetritus
      @fezdetritus 7 ปีที่แล้ว

      The mega is completely different, the program will have to be rewritten for it. It has different registers and semantics.

  • @fbach2100
    @fbach2100 7 ปีที่แล้ว

    Hi Julian. You may also like the new Atmega328PB with even more 16bits timers available (among plenty of other good stuff, like a second UART, more I2C, etc.)

    • @JulianIlett
      @JulianIlett  7 ปีที่แล้ว

      Oooh interesting. But will it work in the Arduino IDE?

  • @originalmianos
    @originalmianos 7 ปีที่แล้ว

    So many issues like this in Arduino. It's probably a result of crowd sourced software development where hardly anyone knows the big picture. Pros and cons. Was it you or Dave that did the vidyeo on how slow the pin toggle is using the Arduino code as opposed to using the registers? On the other hand you get the same function on the ESP8266 even though it's all software below it and the same on the ARM, even though it's completely different again.

  • @tengelgeer
    @tengelgeer 7 ปีที่แล้ว

    Fixing it in software would have been perfectly fine :) It keeps the abstraction layer intact :)
    Okay, it would have been even better if the Arduino PWM/analogWrite() library was a bit more capable. Aka, enable invert via the abstraction and act on it with a write.
    Or at least the fix should have included a -1 in the else state :) Good to remind me of that!

  • @janneraatikainen9453
    @janneraatikainen9453 3 ปีที่แล้ว

    Hei, fine. Could you kindly release a code for 1kHz and for digital PIN #5 (T1), please. Next how to manage PWM it self.

  • @TheLightningStalker
    @TheLightningStalker 7 ปีที่แล้ว

    I just copied your code into the IDE and ran it on a DIP 328P I bought in 2013 and the waveforms DO overlap. This might require some further investigation.

    • @TheLightningStalker
      @TheLightningStalker 7 ปีที่แล้ว

      Yeah I tried it on my Uno and Nano and it does not do that. There is no "dead time" at all. There is something different happening with your Nano. It's not supposed to do that.

  • @teletoon2884
    @teletoon2884 2 ปีที่แล้ว

    Please where's the code ?

  • @lezbriddon
    @lezbriddon 7 ปีที่แล้ว +1

    this is a way better way to fix it you have found, and i take no joy in seeing ide bugs....but if i was doing it quick and dirty then i would have ...(not a real language but very basic.....) (oh how did you get the guard time on the inverted signal?)
    if pwm=100 then pinX=1:pinY=0
    else
    if pwm=0 then pinX=0:pinY=1
    else
    analog write pinX
    endif
    endif
    Would have been a quick and dirty bodge, but no way as neat as just hitting the hardware

  • @NickFoxQuixand
    @NickFoxQuixand 7 ปีที่แล้ว

    Cool scope Jules

  • @km5405
    @km5405 7 ปีที่แล้ว

    Pwm with arduino ... Heh been some time since i saw that waveform on a screen (altough mine came from my soundcard ;D) .... I was changing the frequency for a 12V 150 watt pwm hot wire driver to a nicer frequency

  • @jamest.5001
    @jamest.5001 7 ปีที่แล้ว

    you should sell muppts. and have attachments you can call them muppt baby's! for blue tooth and all the monitoring stuff. just like the other controllers. I want to get in to the arduinos so badly. but I'd have to dig my computer stuff out and likely have to build one that works. there is some thing wrong with all of them. just to get one desk top that I can use. they aren't so old to be grandmas computer. just your parents PC. less than 10 years old but not much. and of course I'm not buying a new one! that's money I can spend on stuff more important!!! great video. I hope you are teaching me something!!! I'm trying to learn! its not do easy when you don't personally have one to work with! greatly informative video. thanks!!,,

  • @SuperLoops
    @SuperLoops 7 ปีที่แล้ว +3

    King Arduino was the king of Italy like 1000 years ago

  • @Hungarianscene
    @Hungarianscene 7 ปีที่แล้ว

    12:24 non overlapping section = it's called dead time ;)

    • @TheLightningStalker
      @TheLightningStalker 7 ปีที่แล้ว

      Someone has been reading PWM controller datasheets.

  • @retroelectrons2
    @retroelectrons2 7 ปีที่แล้ว

    Congratulations !

  • @Dunkelheit667
    @Dunkelheit667 7 ปีที่แล้ว

    256 likes when I watched the video and eight dislikes. Now it has 257 likes, I feel a little guilty, just having destroyed the good side of power of two. We should reach 512, please help!

  • @RWBHere
    @RWBHere 7 ปีที่แล้ว

    As usual, the first line of the code mystified me. The rest was gobbledygook. Thanks anyway.

    • @RWBHere
      @RWBHere 7 ปีที่แล้ว

      P.S. If this is simple, don't go into complicated without a health warning on the video! ;-p

  • @BillySugger1965
    @BillySugger1965 7 ปีที่แล้ว

    This is why I absolutely detest using other people's libraries, I much prefer to write low level drivers myself.

    • @JulianIlett
      @JulianIlett  7 ปีที่แล้ว

      With you there mate!

  • @agsolarpower5975
    @agsolarpower5975 7 ปีที่แล้ว

    Now I am able to get frequency of 31.12khz by changing top value to 0xFF 😋

  • @foxfyre3600
    @foxfyre3600 7 ปีที่แล้ว

    I prefer direct access to registers. I go into that hardware folder and look into the files. I like how the Arduino IDE still exposes the names and addresses, even though they can be quite cryptic. Many functions are written with a lot of error checking but if I wanna go fast, I can't have the cruft. It forces you to know what goes on below. I never use analog/digitalAnything in my loops, only in setup(). TL;DR, I like efficient code.