ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

#175

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2020
  • Dig down below the Arduino-friendly functions to the underlying C++ code.
    JLCPCB Prototype for $2 & Free SMT assembly: jlcpcb.com/
    Free coupons for SMT assembly - just pay for the components
    All this info and more in my GitHub:
    github.com/Ral...
    Trying to cram Arduino code into a Attiny13/85 is quite a challenge so today we look at ways to drop down below the Arduino language and manipulate the port on the Attiny13 directly and what the equivalent code is using an Arduino. It's pretty straightforward and gets you closer to the "Bare Metal" programming.
    Additionally I have a small ATTinyXX programming board that fits onto a breadboard and connects to an Arduino ICSP programmer, joy!
    List of all my videos
    (Special thanks to Michael Kurt Vogel for compiling this)
    bit.ly/TH-camV...
    PRODUCTS
    Progamming shields for the price of a cup of coffee
    www.aliexpress...
    ATtiny13 Development Board (still waiting for mine to arrive)
    www.banggood.c...
    All this info and more in my GitHub:
    github.com/Ral...
    RESOURCES
    TinyTouchLib
    github.com/cpl...
    ATTiny13 Datasheet
    ww1.microchip.c...
    Advanced! AVR Libc Reference Manual Inline Assembler Cookbook
    www.microchip....
    100+ Projects on the ATTiny13 - Lukasz Marcin Podkalicki
    blog.podkalick...
    blog.podkalick...
    ATTiny13 MicroCore MCUDude
    github.com/MCU...
    Arduino Programming Shields (incl. OPEN SMART version)
    www.aliexpress...
    AVR: Configuring and Using Ports in C
    www.idc-online....
    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 journey
    All this info and more in my GitHub:
    github.com/Ral...
    My channel, GitHub and blog are here:
    ------------------------------------------------------------------
    / ralphbacon
    ralphbacon.blog
    github.com/Ral...
    ------------------------------------------------------------------

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

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

    Ralph, great video. I had a customer using ATTINY13A as an interface for a PV regulator port(battery charger). I was amazed at the small amount of coding used and the efficiency of it all. Thanks again for the awesome channel.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Yes, I'm amazed at what I've crammed into one for my Fridge Door Alarm sketch. I'll reveal all in due course!

  • @Roy_Tellason
    @Roy_Tellason 4 ปีที่แล้ว +1

    I really like the fact that that little board accomodates both the surface-mount and the through-hole versions of the chip!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Thanks Roy! Took me a while to get it all designed but I use these all the time now on my (new) breadboard and it really speeds up the research and development time, for sure.

  • @kevinnicholls1017
    @kevinnicholls1017 4 ปีที่แล้ว +1

    Thank you for your beautifully simple and well considered little board which is ridiculously cheap at JLCPCB at the moment.
    It makes it so easy to programme the Attiny via USBasp, whilst not adding unnecessary power regulators, LEDs, etc that get in the way of measuring the current with my other breakout boards.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Glad you like it, Kevin!

  • @ManfredAckermann
    @ManfredAckermann 4 ปีที่แล้ว +1

    Good video.
    Even if it may sound rude, I have to say: taking the effort to understand the underlying stuff and not having some high level abstraction doing the thinking for you, lets you leave the playground and make some real something. Mastering that barrier gives you the chance to be independent from whatever library doing what you are not capable of now, because you learn to RTFM of whatever chip and do it on your own. The journey I made got me so much forward in writing better code because I had to. Just do it.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +3

      Yes, I'm now familiar with quite a few datasheets for the AVR chips - and it makes me wonder at the brain power of the people who put them together in the first place. But most people just want to "do stuff", even if it is just some fancy NeoPixel displays, so Arduino-speak is good enough for them.
      But does a car driver NEED to understand how the clutch and fuel injection system works to drive the car? Of course not, but if you _do_ understand that then it might make you a better driver. Of course, just driving up the road to buy a newspaper is never going to stretch your driving skills anyway! Good to hear from you Manfred, thanks for posting.

    • @noweare1
      @noweare1 4 ปีที่แล้ว

      The power of Arduino is it gives people an entry point to the world of physical computing. Something the embedded world has been lacking since forever. There is a lot of EE's out there that bad mouth arduino because of it.

  • @scottstevens7569
    @scottstevens7569 4 ปีที่แล้ว +1

    Great video and information Ralph. It really shakes the cobwebs off C courses taken 20 years ago and helps tie together some AVR programming I've recently looked at and been overwhelmed by. Applying this to the ATTiny 85 is very helpful as well, as I thought I was just asking it to do too many things, but there is hope.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      You can't ask it to do "too many things", Scott, it all runs single threaded so it just "runs". but you could make the code more efficient so it runs _less code_ which would make it faster to execute stuff, that's for sure. Why not download the sketch and try it out?

  • @jensschroder8214
    @jensschroder8214 4 ปีที่แล้ว +2

    use the RESET pin of an Tiny13 / Tiny85 (T25, T45) as a INPUT. The Tiny13/85 has ADC0 on the reset pin. If there is an voltage divider higher than VCC*0.9 (4.5 at 5V VCC) the tiny will NOT reset, but the ADC will read around 900. If the pin is on VCC it read 1023. So you can put a tactile switch with two resistors and connect to the RESET pin without a reset. You can use the reset pin as an input. electronics.stackexchange.com/questions/195146/use-the-reset-pin-on-attiny85-as-input-with-voltage-divider

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      I've previously use the RST pin on a Tiny85 as a GPIO pin, Jens, (without changing any fuse bits) but you have to be VERY careful it doesn't drop too low in voltage otherwise you _will_ reboot the chip. Adding an extra pull-up resistor helps in this respect. All a bit unreliable for me but from what you say, YMMV.

  • @theonlymudgel
    @theonlymudgel 4 ปีที่แล้ว +2

    Hi Ralph, Seems I could be first to comment as I just got notified that the video was up. See you in 60 minutes or so. It usually takes an hour or more to watch through as I pause and check references etc. All the best.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I'm glad someone is checking my work! Benny does that sometimes but these days he just sleeps, dreaming about new C++ routines, I suspect.

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

    Hi Ralph Bacon. Great video. I like the way you pronounce my lastname :D I know it is hard but you did it pretty well. Thanks for credits. Take care!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      Hello Lucasz! When I listened to my video I realised I did not pronounce it quite right but I tried my best! Thanks so much for your supportive comments, I just LOVED your website with all the information (which I have only scratched the surface of, really). The tone code I used for the ATTiny13 was really complex but so efficient! I will try and refer to your website more often, as I think you have so much information there for many makers to enjoy! Thanks for posting, great to hear from you.

  • @williammanganaro9070
    @williammanganaro9070 4 ปีที่แล้ว +1

    Very good video! As you know sir, even that 'DELAY' command can be broken down to a couple lines of code to manipulate the TIMER/COUNTER peripheral directly. If one reads ANY chips data sheet and learns how to use it, it be a very enlightening and rewarding experience. Back in the day, that's all I did was pour through various MCU and CPU data sheets and learn all these peripherals at the register level. Its very rewarding experience ! Sometimes though you just need to get something done, so I do end up seeking out a decent library for a particular part I want to connect to, for example a port expansion, without learning all the I2C commands and registers. The mixing of both methods makes you a better programmer & hardware guy ! Thank you for posting ! Happy New Year !

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      You've summarised, William, why high-level language constructs are so useful: "Sometimes though you just need to get something done..." at the expense of code size and possibly speed too. But that's why we use them!

    • @uwezimmermann5427
      @uwezimmermann5427 4 ปีที่แล้ว

      the functions in the delay.h library are not using any timer and thus do not allocate any of the hardware functions. But if you want to have accurate timing under your own control than you should use timers and interrupts. If you do it yourself with just a few lines of code you still exactly know which hardware resources you are allocating and you can make your own compromises when it comes to having timing interrupts and pwm on the same timer.

  • @philowen2755
    @philowen2755 4 ปีที่แล้ว

    As a retired mainframe assembler systems guy this is like being back at work again ;-) Thanks Ralph.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I'm so sorry to hear that, Phil. A bit of a busman's holiday this video then? But it sounds like you enjoyed it anyway! Good to hear from you , thanks for posting.

  • @jessicacarter8264
    @jessicacarter8264 4 ปีที่แล้ว +1

    Great video as usual Ralph. I got two ATTiny13A's out of my order of 10... mistake in shipping but got a refund so not all bad! This look 'beneath the surface' to some of the AVR C calls has been fascinating. I'm building my own chip programmer (for both ATTinyX chips and the full 328 chips on a Arduino prototype shield with two zif sockets) and will be able to test out some of the examples you've gotten working. Look forward to the next one. I find your teaching method (and length of videos) to be just right for my learning style. :)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      It's great that my videos are inspiring you to "have a go" - it's just what I had hoped my channel would do! From what you say, you are taking the bull by horns, ZIF sockets, programmer, UNO shield - wow! And you may find it both frustrating and amazing how much (or little) you can fit (or not) into a Tiny13A! There is definitely a place for them. Good luck with your projects, sounds like fun!

  • @blic-sx9ix
    @blic-sx9ix 4 ปีที่แล้ว

    Thanks Ralph for all the great videos. Your 2 part EasyEDA videos got me started designing my own PCBs. I just received my 4th board design in the mail. My first 3 were different basic 555 timer / blinking LEDs boards that I use in the learn to solder events I host at our local public library. The latest board is a custom relay board with a Arduino Nano socket. It uses industrial style plug-able terminal blocks. It will be used on my farm to pass a single water meter pulse to 3 dosing pumps. Who says you can't do real world projects with an Arduino.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Oh yes, we most certainly can do Real World projects using an Arduino UNO or Nano, no doubt about it. And I'm delighted that you have progressed to this level so quickly. Once you have got the bug you will never look at strip booard again! Thanks for posting, appreciated.

    • @blic-sx9ix
      @blic-sx9ix 4 ปีที่แล้ว

      @@RalphBacon I see it all the time on the forums. They start something like this "Arduino is fun but I (have never seen) (would never use in) (are not suitable for) a real world application.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      What do they know? Pah!

  • @superdau
    @superdau 4 ปีที่แล้ว +1

    And now one level deeper even! I was programming AVRs in assembler before Arduino even existed. My (maybe unhealthy) search for efficiency couldn't get over the many instructions the C code compiled into. So back to assembler it was, even though there was no contest in ease of programming between assembler and C. Well I think I'm over that now, but I find myself doing the same with Arduino and C. I almost always end up writing registers directly (definitely for the timers and ADC, sometimes for serial and ports as well) and dismiss the Arduino functions, because of the huge overhead of those.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I don't know about the relative efficiency of the avr-gcc compiler, but I do know that the Microsoft C++ compiler could code better assembler than I could. I realise that's not a very high bar, but it was considered a very efficient compiler by those in industry. And it didn't make silly mistakes, not that we ever make those.

    • @superdau
      @superdau 4 ปีที่แล้ว

      @@RalphBacon
      Yes, the cases where handcrafted assembler is better, are definitely edge cases. And it's all too easy to fall into the optimize everything trap, while for most parts of the code it doesn't even matter if it runs twice as fast or not (that's a trap independent of programming language). But two examples where the compiler just wouldn't produce what I wanted (maybe it could have, if I knew more about the C-compiler itself):
      I needed exactly timed pulses depending on some conditions. But it was impossible for me to write C code that lead to the "if" and "else" parts take the same amount of clock cycles. I tried adding asm("nop")s, but the timing would sometimes change again depending on changes somewhere else in the code, because suddenly a register had to be saved away for example.
      A similar, but not related case, was "animating" 16 LEDs with selectable patterns in software (essentially 8-bit software PWM). Calculating the new frame and then setting the outputs never got to the speed I needed when using C, even though I tried to keep all loops and functions as small as possible. The compiler was creating too many "housekeeping" instructions, like pushing registers on the stack or saving registers to SRAM.

  • @pfeerick
    @pfeerick 4 ปีที่แล้ว

    Excellent video Ralph... nice to see more people showing that there is life beyound Arduino-ese... and that it's not that big a jump and well worth the effort if you want smaller and tighter code. Will certainly be fun to see how this exercise in unnecessary pain and torture evolves... we at least know it can beep and blink an LED! ;)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I will have expose all (code wise) for my Fridge Door Alarm soon (before I forget it all). It does more than blink an LED!

  • @jjab99
    @jjab99 4 ปีที่แล้ว

    Hi Ralph, great to see you and I hope that you and your family (and cats) are well. I notice that you still have your eye patch on, I really hope that you get this sorted out soon and can get back to normal again. It must be a real pain with working up close on Tiny Projects. Wishing you all the best for 2020,
    Joe

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      Me too, Joe, hopeful that it gets fixed this month, I mean. It really is a pain to try and solder with just one (not so great) eye! But needs must, as they say! Thanks for your concern and Benny sends his regards. 😻

  • @Hackvlog
    @Hackvlog 4 ปีที่แล้ว +1

    "Arduino or C++?" BOTH!. I like to take the easy way and use Arduino, but I'm not stranger to going one level lower and using pure C(++).
    Like you said, C(++) is way to go, when working with limited memory. Also, when timing or some low level features has to be handled more precisely than Arduino is handling it. Making something simple and fail proof can often have impact on performance, same is with Arduino. It's indeed the reason Arduino became as popular as it is today.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Yes, using both (the best of both, perhaps) is a good way to go.

  • @foxabilo
    @foxabilo 4 ปีที่แล้ว +1

    That poor old LED being driven without a resistor to current limit, ohhh the humanity!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      It's a _blue_ LED and works fine like that, really! That's why I use it. I tried it with a red one the other side without a resistor and it is now meeting its maker in LED heaven. Naughty Ralph.

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

      @@RalphBacon hehehehe, I had to do it!

  • @Chriva
    @Chriva 4 ปีที่แล้ว

    Aaaaand welcome. BACK! I can't be the only one saying it when the video starts? :D

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      Yes, it's just you, Christian. Just you.
      Hahahaha! Some of my viewers refer to me as "The Welcome Back Guy!" As good a moniker as any, I suppose. I could say "G'mornin' all" (oh, already taken) or "The Guy with the British Accent" (oh, also taken). One day, I'll explain why I started that with my very first video, and it's all to do with Dbase II.

    • @ManfredAckermann
      @ManfredAckermann 4 ปีที่แล้ว

      @@RalphBacon 'WB' when DBase II restarted after it crashed as usual?

  • @andrewtoogood1429
    @andrewtoogood1429 4 ปีที่แล้ว

    Hi Ralph, good video as always. The programming board is a good idea, with the low cost of PCB manufacturing these days I also use designs for convenience/tools not just productionisation of products.
    When I saw the sketch at first I thought you we about to teach bitwise logic. with your diverse group of followers I think you made the right call in just explaining what they mean rather than why.
    When prototyping I always use arduino syntax as its about Proof of concept. Only if resources go low and I have shaved off the library what I can, do I start to consider direct port manipulation. For attiny13 its your only choose really.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Bitwise logic is a somewhat complex concept to get your head around for most people, I think. Whilst totally logical it can really seem unfathomable to begin with. I'm glad you think I struck the right balance here. I have to admit I "code in Arduino" too, after all, why not? It's only if code size or run speed is an issue that we need to take a step back. Or find a faster processor. LGT8F328P, anyone?

  • @TuttleScott
    @TuttleScott 4 ปีที่แล้ว

    great video, stuff you need to know no matter what chip you're programming

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      It's always good to peek behind the friendly facade of high(er) level languages and see what really goes on, just like the Wizard of Oz - it's not scary after all!

  • @Gaark
    @Gaark 4 ปีที่แล้ว +2

    WB Ralph! Hope the eye's fixing good :)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      Ha ha! Glad to be back, Jeff! More news on the eye in a couple of weeks, I hope.

  • @flemmingchristiansen2462
    @flemmingchristiansen2462 4 ปีที่แล้ว

    Great work. Your really digging into this, fantastic.
    Still quite a few bytes to turn a pin on and off.
    Could be interesting to see how much of that each command is using.
    Im suspecting the "delay" command is using the most?
    Your right, playing around with bit values in registers can be mind blowing, so easy to lose track of them.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I'm hoping you will be equally impressed with my Fridge Door Alarm sketch for the Tiny13 in a couple of weeks, Flemming. I'm amazed what I could cram in there! Delay doesn't use much as it is triggered by the interrupt millis() or micros().

  • @SpeccyMan
    @SpeccyMan 4 ปีที่แล้ว +2

    I've probably mentioned this before but this is how I've been doing it for years. I just have this inbuilt dislike of waste and a penchant for compact code. Hopefully your video will encourage others to "throw off the shackles" of Arduino and get down to some "proper" AVR programming. Next stop assembly language, hehe.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I wrote assembly for PIC (for a while) but found that the C compiler did a better job than I ever could, so that was that! And productivity went up by about 1000%. I think this in-between stage is probably a good start though. Good to hear from you Nick.

    • @henrikjensen3278
      @henrikjensen3278 4 ปีที่แล้ว

      Last time I compare assembler to C programming I could easily do assembler better than the compile, but that was 20 years ago. With assembler there is also the advance that you control the CPU, i.e. you can reserve register for special purpose across all routines (Long long time ago I lowed using the extra register set on a Z80 for my fastest interrupt routine).

    • @noweare1
      @noweare1 4 ปีที่แล้ว

      I really loved programming in assembler using the now defunct 6809 but honestly one of the best reasons to code in C is that you can go back 6 months later and know what going on. Assembler just doesn't self-document.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I once converted an assembly program from a Z80 to a 6502 processor. A digital clock, if I recall. That was "interesting"!

  • @wires4auto
    @wires4auto 4 ปีที่แล้ว

    Great video Ralph!! Glad someone can put the c++ code into laymans terms for us noobs. Still I would opt for the attiny85

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I'd opt for the Tiny85 too, Gordon! I'm just programming one now and it's a whopping 8K Flash and 512 bytes SRAM. So very different from the Tiny13 (1K Flash 64b SRAM). Glad you liked the video! You can run that code on the Tiny85 without changes, so what's stopping you?

    • @wires4auto
      @wires4auto 4 ปีที่แล้ว

      @@RalphBacon I only have attiny85s in the parts drawer 😅 I will definitely use some of them tricks tho if I am ever stuck for space.

  • @uwezimmermann5427
    @uwezimmermann5427 4 ปีที่แล้ว

    Major Thumbs Up for this video.
    Just a small comment in order to go all the way: (1

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Thanks for the thumbs up, Uwe! I understand what you are saying regarding the use of _BV (which does, after all, stand for Bit Value) vs the "magic number" of 1 - but assembly is all about mnemonics so I just prefer _BV (and ~_BV to set a pin LOW) but perhaps I'll try using numbers to see how I really feel! Thanks for posting, good to hear from you!

    • @uwezimmermann5427
      @uwezimmermann5427 4 ปีที่แล้ว

      @@RalphBacon 👍 (1

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Uwe Zimmermann - Do you understand timers and interrupts on Arduino boards? Didn’t think si.
      Major thumbs and other parts down.

    • @uwezimmermann5427
      @uwezimmermann5427 4 ปีที่แล้ว +1

      @@boonedockjourneyman7979 I do understand the timers and interrupts within the ATmega/ATtiny chips to a good enough level to teach these to university students.
      I don't care about the timers and interrupts within the Arduino framework, because I almost exclusively program the AVR chips directly in C using the Atmel toolchain and gcc.

    • @uwezimmermann5427
      @uwezimmermann5427 4 ปีที่แล้ว +2

      @@RalphBacon two books which I recently discovered for my students - in order to make the step from Arduino to C:
      doi.org/10.1007/978-1-4302-4777-7
      www.amazon.com/C-Programming-Arduino-Julien-Bayle/dp/1849517584
      and of course this one:
      www.amazon.com/AVR-Programming-Learning-Software-Technology/dp/1449355781

  • @kevingpearce
    @kevingpearce 4 ปีที่แล้ว +1

    Hi Ralph, great videos as usual. Excuse my ignorance, but just a quick question. Why do you use the programmer shield on an arduino uno for the ICSP connections to your ATtiny PCB ? Why not just use the ICSP connection that already exists on the uno ? I have had some of your little PCBs made (at JLCPCB), but unable to get any of my ATtiny 85's to program, even after following your video #175. I always get "Yikes! Invalid device signature". Maybe I need to reset fuses ? Do I need to burn bootloader first ? Sorry to ask this here, but I cannot get onto your blog page (since January).

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      The programmer shield's ICSP socket contains a RST connection that is actually connected to pin 10 of the underlying Arduino. You can't connect the standard RST of an Arduino to another one, it won't work.
      Apart from that, I got the programmer to program naked ATMega328Ps initially but now use for all sorts of things.
      Regarding the Tiny85s, I would not expect a bootloader, that's for devices with a USB port. You will be uploading via ICSP (aka SPI) and the reason you get the "Invalid Device" is possibly due to the very first sentence in this reply! Or you have chosen the wrong device or have not said "Upload Using Programmer" instead of just "Upload". Phew! Let me know if you get it working?

    • @kevingpearce
      @kevingpearce 4 ปีที่แล้ว

      @@RalphBacon Sorry Ralph, I'm still confused. Does this RST line mean that I cannot use the Arduino uno's ICSP connections directly ? I have ordered the programmer shield (from China), but deliveries are IMPOSSIBLY slow (due to Covid). Many items that were originally ordered early in 2020 never got to me.
      I've had to keep track of dozens of missing items, with constant "Disputes" with AliExpress. (I've virtually given up on using them for the time being).
      P.S. I'm running IDE v1.8.13 under Win 7. I've also tried the direct wired method (using uno pins 10,11,12,13 for ATtiny pins 1,5,6,7) as per this video:
      th-cam.com/video/VlUq2COFjj4/w-d-xo.html&ab_channel=LiveSparks
      I checked out your suggestions and connections, but still no-go. Spent hours and hours on this and very tempted to throw all my Digispark and ATtinys in the bin.
      Give me those good ol' trusty nanos anyday !!!!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      OK, Kevin, don't give up. Step by step (using 1.8.13):
      1. You have uploaded the ArduinoISP sketch to the Arduino
      2. You have the following connections (Arduino → Tiny85 physical pin):
      10 → 1 (RST)
      11 → 5 (MOSI)
      12 → 6 (MISO)
      13 → 7 (SCK)
      VCC & GND (5v) from Arduino to pins 8 & 4.
      3. Tools → Board: Select the correct ATTiny85 board from the list of ATTiny25/45/85 boards, 1MHz internal.
      4. Tools → Programmer: Arduino as ISP
      5. Tools → Port: Whatever your Arduino (as ISP) UNO is connected to
      6. Sketch → *Upload using programmer*
      If you upload the blink program and use Pin 0 (physical pin 5 on the Tiny85) as the LED flasher pin connect an LED and 180 ohm (approx) between pin 5 and GND and it will flash.
      *Fully tested* at great expense (time wise) by me as I was writing this just to make sure that 1.8.13 wasn't playing silly buggers (technical expression).
      If it doesn't work tell me the exact message (copy/paste) into a reply here!

    • @kevingpearce
      @kevingpearce 4 ปีที่แล้ว

      @@RalphBacon Cheers Ralph, and thanks for your enthusiasm in trying to get to the bottom of my problem. I have solved the mystery. My connections and method were all sound, but I have discovered there are fake (Chinese) chips out there !!!!!! I have read about this in posts about other chips. I finally tried some newly purchased ATtiny85's from a local supplier, and they worked fine. The Arduino IDE warnings suggest that the proper device signature for an 85 is 0x1e930b, but mine were 0xffffff. The new ones did indeed give the correct signature. Also, I had problems when using solderless breadboard connections. The fake chip pins are shorter than the genuine ones, which made for dubious contact as they barely reach far enough into the breadboard to make good contact.
      I'll buy a few more from my local supplier now that I know I can use them. Thanks again for all your patience and help. Keep up the fantastic work, and stay safe and well.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Excellent news, Kevin, very glad you got it sorted (as are you, I'm sure)!

  • @Mr.Leeroy
    @Mr.Leeroy 4 ปีที่แล้ว +1

    The '_BV()' macro is not a Cpp, nor Arduino, it is an AVR C.
    And it only works in this code because of `Arduino.h` include that calls 'avr/io.h', which binds bitshift mask macros for each pin depending on chip specified by compiler.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      True what you say, but anyone could define a _BV "macro" , Leeroy. If I write _BV(PB4) that gets replaced by (1

    • @Mr.Leeroy
      @Mr.Leeroy 4 ปีที่แล้ว

      @@RalphBacon I'm not saying you should not use it, on the contrary. But don't call it low level C lang because it is a well known extension called `avr-libc` and language flavor is known as AVR C.
      P.S. and it is kinda strange to attempt direct register coding and minimize binary size while still including `Arduino.h` and not `avr.h`

  • @bipolarchemist
    @bipolarchemist 4 ปีที่แล้ว

    Nice explanations on explaining the 'bare metal' functions. I've been doing a bit of bare metal programming with the SAMD21 series to undo the extremely conservative defaults Arduino.cc(.org?) made when setting up the defaults for the mkr1000. Still using the wrappers for everything else, but configuring the ADC myself has made a world of difference in the speed in which values are read and returned(while still using analogRead). Going from nearly a millisecond per read to

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      And that's why we have high-level languages with easy-to-use wrappers - ease of use! But which comes at a price of code size and speed. If we start to use simple commands at the "native" level and build on that it could work well, I reckon. Good ot hear from you, thanks for posting.

    • @bipolarchemist
      @bipolarchemist 4 ปีที่แล้ว

      Any time. I was thinking that it was about time for another video while watching Rise of the Dark Knight earlier and wondering what you had for us in terms of the SOIC-8 programmer you had mentioned. It is a nice solution and one I totally forgot about as I was all 'Finally, someone explaining what all that bit shifting means'.

  • @roberteliassen5020
    @roberteliassen5020 4 ปีที่แล้ว +1

    12:00 while (1) means "while true". In fact, any integer except 0 is true, so you could write while (42), but that would be pretty rude to anyone reading your code. :-) Come to think of it... I believe you can write while (3.14) as well, or while (2.718281828). Still confusing to please use while (1) :-)
    It is also worth to mention that int main () is just required by the language. The return value is never used in an Arduino. First, the loop never ends hence main() never returns. Second, there is no way an Arduino can handle the return from main() even if loop() did finish.
    Nice video! I've ordered some 13A's to play with. I'm using Atmel Studio, but that's just because I like the environment.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Yes! I like the "while (3.1415926)" so I may use that in future, just to confuse people! Make them think it has special significance. Well, in some ways it does!
      Yes, in Arduino-land the return value is not used but in other C++ programs it most certainly is returned to the caller, hence the C language requirement (which I know you know, I'm just stating it for others to read).
      Have fun with our Tiny13A chips and be sure to use MicroCore, latest version. Let me know if you get Serial to work. Good to hear from you Robert, I thought I saw you lurking in the background!

    • @roberteliassen5020
      @roberteliassen5020 4 ปีที่แล้ว +1

      ​@@RalphBacon I'm always in the background :)

    • @raykent3211
      @raykent3211 4 ปีที่แล้ว

      But defining FOREVER as one allows you to write while(FOREVER) which is more obvious and takes no runtime resource. Sadly, some low level programmers delight in being cryptic. It's a bad habit.

    • @roberteliassen5020
      @roberteliassen5020 4 ปีที่แล้ว

      @@raykent3211 Nice one!
      #define FOREVER 1
      ...
      while (FOREVER) {
      ...
      Never seen it before though, still like it. :-)

    • @raykent3211
      @raykent3211 4 ปีที่แล้ว

      @@roberteliassen5020 it's because my poor lump of jelly has trouble remembering whether the convention is that TRUE is zero or non zero. It's not intuitive. Nor is it intuitive whether FALSE is exactly zero or just not one. Horrible! I've written routines saying while (keepGoing) where it's obvious that something buried in the routine could cause it to exit, but that it is not known at this point in the logic. So if do everything I can to make the code more intuitive, and in some cases it costs zero memory and zero machine cycles. Writing while (1) can hide the possibility of another exit point. Not good.

  • @danparkman2078
    @danparkman2078 4 ปีที่แล้ว +1

    Ralph, you didn't indicate that you were using a different IDE from Arduino, what it was or how to set it up.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      It's the same one that I use in almost my demos, Dan, no functional difference as far as compiling the code goes, but (for me) much easier to use as I've used MS VS for decades. It's Eclipse, found here:
      eclipse.baeyens.it/

    • @gavinsmalley1513
      @gavinsmalley1513 4 ปีที่แล้ว

      @@RalphBacon Hi Ralph, have you ever considered using Microsoft Visual Studio Code (now free of charge) with PlatformIO for Arduino development? Would have thought it would suit you well given your background.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Yes, it's up and running but there are further moves afoot... more in another video, I hope.

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

    it's Woocash Marchin Podkalitzky (sorry had to do that ;p) and many thanks for crediting him here, i've found soooo much inspiration into Tiny13 :)

  • @jensschroder8214
    @jensschroder8214 4 ปีที่แล้ว +1

    When I want to set all output to a level at one time, I can use C++ to set it at once. In Arduino I have to set Pinmode() one after an other...

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 4 ปีที่แล้ว

      Pinmode() is ok for setting one pin. your correct it's much better to work on the port at a lower level if you want to use more pins. in my soldering iron project, i diode or 3 buttons to an interrupt pin so use 4 input pins. on interrupt i read the port as 8 bits, mask off the bit that or not required, then i can use a switch statement to select the action for each button.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Well, Jens, now you know how to set ALL pinModes at once, just by using DDRB |= and then then values you need in a byte (eg 00110010) or using _BV(PB2) | _BV(PB0)... etc. The latter is preferred - more verbose but more descriptive).

    • @neildarlow
      @neildarlow 4 ปีที่แล้ว

      Pinmode is hardware agnostic and, used correctly, is portable across Arduino boards.
      Use of port manipulation takes you away from the portability advantage that the Arduino libraries afford. It's a trade-off.

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

    Nice info, thanks :)

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

      Glad it was helpful!

  • @willofirony
    @willofirony 4 ปีที่แล้ว

    OK, come back all I have written. I can see a reason for using the ATTiny13 : it is a great introduction into writing native AVR code and I am all for that. Once the neophyte leaves the relative comfort of the Arduino wrapper, he/she is getting a real taste of embedded code. Why bother? Well given some experience with native code, he/she is learning skills that are applicable to MCUs from other manufacturers;/ Furthermore, he/she is gaining experience in writing efficient code. The Arduino IDE IS great for the newbie but its ease of use is bought at the cost of memory use and speed. Now , the latter may not seem that important with 20 MHz to play with, especially when most of its time is spent in delay loops. but when responsive and reliable interfaces to the User and peripherals is needed, interrupt driven code is essential. The code to support interrupts has to be as fast as possible , every cycle of the MCU counts. 32KB of memory seems to be far more than any maker would needed but the arduino wrapper code generates many lines of native code more than a human would, often as much as 10 times more, so, that even a simple sketch like the flasher example uses up more than half the flash memory. In conclusion, every maker has to accept that there comes a time when he/she needs to do away with the training wheels . Programming the ATTiny13 may well be the friendliest way of doing that.
    Tell me to mind my own business, if I am being too nosy, but: how is the eye coming on? How are you managing, soldering and editing videos without stereoscopic vision? What is the prognosis on the left eye?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      You said it very well, Michael: do away with the training wheels! Well, sometimes people feels safer with them on and that's fine. But to "grow" one's code expertise a dabble into real C++ even if it's just an experiment!
      So, my eye. Hmm. Right eye, effectively no vision due to dense cataract, hopefully to be sorted out this month if NHS gets its act together. Left eye, misty vision due to less severe cataract, getting worse. Also due cataract surgery but only once the right eye is 100%. So, XMAS 2020, then.
      Not having stereoscopic vision is a real bind whens soldering but I can just about still (sort of) do it, as you will see next week. Yes, even 0603 components!

    • @ManfredAckermann
      @ManfredAckermann 4 ปีที่แล้ว

      I 100% second the first paragraph. And the ATTINYs are as excellent as they are because: less pins/timers is less confusing.

    • @noweare1
      @noweare1 4 ปีที่แล้ว

      I don't understand how using the arduino IDE costs someone in terms of memory and speed. You mean on the desktop or on the chip itself ?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Joey, using Arduino-speak (whether in the Arduino IDE or a plain text editor) uses some "safe" code constructs to protect us from our own coding stupidity (eg turning on a GPIO when it's already being used by PWM). That extra "safety net" means the code is more verbose (it's doing more) and because there is more code it must run more slowly, overall.
      That all said, the difference for us hobbyists is negligible and probably worth it for most people. This video just shows the fundamental C direct register manipulation without all the fluff, so would actually compile to less code and run more quickly.
      But does it really matter (unless you are trying to cram stuff into a too small chip)? Let's not get too hung up on that!

  • @spotterinc.engineering5207
    @spotterinc.engineering5207 4 ปีที่แล้ว

    Hey Ralph, maybe you could use 2 tiny 13's as function specific processors - one for sound etc. That is how I think car systems distribute the processing and then communicate.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      And that's exactly where a relatively limited chip would work well, David - a single purpose that is not too stretching in terms of code size or resources. We'd need a fairly reliable comms system though (CANBUS might work well).

  • @MUHAMMADYAWARIFRAHEEM
    @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว

    Very informative video sir

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Glad you liked it, Muhammad, and even better this was the first comment you made that was not flagged as potential spam by TH-cam! Perhaps they have learned something!

  • @RottnRobbie
    @RottnRobbie 4 ปีที่แล้ว

    Hi Ralph... good video!
    But for your BLINK sketch, why did you make the two delays different durations? If the on and off times were the same, you could've coded your "While (1)" loop as an Exclusive OR of 1 with the output pin, followed by a single delay call.
    I haven't tried it, but I'd hope the compiler would use a register, so still no RAM, and probably a smaller program.
    "Every byte counts"

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I used different delays so I get a blink-blink-pause effect. So much better IMHO than an equal flash-pause!

    • @RottnRobbie
      @RottnRobbie 4 ปีที่แล้ว

      @@RalphBacon Fair enough...

  • @GeorgeGeorge-xj2bc
    @GeorgeGeorge-xj2bc 4 ปีที่แล้ว +2

    Using ready made sketches or pseudocode languages you can not learn in depth nothing.Knowing the resources of the devices and how to access them from C then you can develop your own circuits in your demands and wishes.For example i havent find yet a complete datasheet to read and understand the resources of esp8266 nor a language to write my own code.In that case using the ready sketches is difficult to adopt them to a specific needs.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I, too, think that just copying other people's code teaches you very little (as they will find out when it doesn't work or goes wrong) but libraries can be viewed as a black box component, most of the time. That said, I've edited a few libraries in my time either to correct them or add functionality. If you subscribe to the ESP8266 mailshot(s) you get all the updated information (including revised datasheets). Well worth it. www.espressif.com/subscribe

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Ralph is a Chinese shill. If you want to learn anything, get out of the Arduino IDE. Go to the manufacture’s IDE.

  • @reelrebellion7486
    @reelrebellion7486 4 ปีที่แล้ว +1

    While available flash is approaching zero, the available breadboard space is approaching that of a car park.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +3

      Ha ha! That would be the large breadboard that you saw (briefly). Yes it is quite large, Kent, and good quality too, unlike all the little ones I have that are, quite frankly, rubbish. You gets what you pays for!

  • @henrikjensen3278
    @henrikjensen3278 4 ปีที่แล้ว

    Nice PCB for playing with the small tiny processors.
    I did miss some comparison between much the code would fill when using standard Arduino, compared to the more direct coding (Standard Arduino port IO does more than just flip bits, that may be nice if you are a beginner, but is not needed when you know what you do).
    Generally I am not in favor of a macro like _BV(), I see it as an excuse to not learn the language. Using (1

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Hmm. I kept changing my mind, Henrik, on using _BV (or 1

    • @henrikjensen3278
      @henrikjensen3278 4 ปีที่แล้ว

      Your video was first time I noticed the _BV() function. Arduino has a BitSet() and BitClear() that can do something similar (They are not the same) and there are probably a couple of other macros for the same.
      I have been using macro assemblers for many many years (Many years ago is more correct) and seen people trying to do a programming language in them. It may be useful for the guy doing it, but is very hard to read for other people that do not know the macros. It is the same in C, when you know the macro it may be easy to read, but if you do not know the macro it is harder to read than standard C.

  • @blic-sx9ix
    @blic-sx9ix 4 ปีที่แล้ว

    Ralph, I received a key ring with my last JLCPCB order. It has an image of a circuit board with a cat sitting on top. Did Benny pose for that? It has some similar markings but the ears are too light.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Benny does get around, it must be said, but whether this is a picture of Benny I am unsure. I got a key ring/bottle opener too but no picture {sad face). Send me a photo of key ring if you like, you know where my email can be found, right?

    • @blic-sx9ix
      @blic-sx9ix 4 ปีที่แล้ว

      @@RalphBacon No... can I have a hint?

    • @pfeerick
      @pfeerick 4 ปีที่แล้ว

      @@blic-sx9ix It's on the about page for the channel ;)

  • @paulyorke1437
    @paulyorke1437 4 ปีที่แล้ว

    Hi Ralph. Interesting video as always. Following your earlier videos demoing the ATTiny85 I did purchase a few and had a play with them. I bought the programming shield and the SPI programming cables etc so can load a sketch etc. I also just had JLCPCB make some fuse burner boards so I'm ready to burn fuses on the 85 or the 13. Hmmm. My faithful following of your videos however has led me to a corner. A corner that only a 328P gets me out of. I realise I just don't have any projects where only 6 I/O lines are enough. I could use I2C and connect up a load of servos (sensors etc) on the 85 or use the shift register to increase I/O but then why bother when the simple (and similarly priced) answer is the 328P. OK, I get the need to reduce code size for the 13 but again, why bother to go through that pain of learning real C++ when the Arduino IDE makes life so much easier. Does this make me a philistine? so be it. Completing the projects is more important to me than learning a harder to understand version of C. I did enjoy the challenge but my focus is on project completion with the best tools, no trying to force the inadequate tool to do the job. Now on a different subject, what about the new Seeeduino Xiao board? I look forward to your videos using this amazing new development!!! 256K flash ram should be enough not to need to stray into complex C++ !!! :-) All the best

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Using a 328P instead of a TinyXX does not you a Philistine make, my young Padawan! (Sorry for the Yoda-speak). As you say, the focus is usually the project at hand, rather then some theoretical exercise on coding "a better" way. But it's always good to know! The fact you have some chips on order, together with a programmer and ICSP cable means that you can, at the very least, try all this out first hand. And for that, respect!
      So, you saw that new Seeedstudio XIAO board too! It's only on pre-order right now, but at less than $5 will be worth a look. If you were worried about the number if GPIO pins earlier then this will not help, of course. But the SAMD21 is supported in the Arduino IDE (and someone will doubtless write a specific "core" for it, if there is not one already) so it will be "interesting", but for me as a theoretical exercise - the STM32 is cheaper, offers many more pins and is probably just as fast in the Real World. Oh, and it's 3v3 ONLY so we have to be careful on how we interface to other 5v modules. Time will tell!

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Paul Yorke - can you tell me the precision (not accuracy) of the Arduino IDE timers? Didn’t think so. Find a channel with a host that gets it.

    • @paulyorke1437
      @paulyorke1437 4 ปีที่แล้ว +2

      @@boonedockjourneyman7979 - Thanks for your message if a little disparaging. Still, I can say that of the 30 or more projects I have engineered with arduino compatible products and the excellent information provided in Ralph's videos over the last year, I can honestly say that neither the accuracy nor the precision of the Arduino timers has ever been an issue. For my level of competence, Ralph is my go to vlogger as he explains the technology at the level I can absorb it. At 68 years old I'm not looking for nanosecond accuracy from any of my projects. Thanks for your comment though.

  • @jensschroder8214
    @jensschroder8214 4 ปีที่แล้ว

    it is easier if I want to write BCD code on all ports. PORTB = BCD2 *16 + BCD1; (m328p)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      That's a great tip, easy to understand too! I shall use that at the next available opportunity, thanks Jens.

  • @paulmaydaynight9925
    @paulmaydaynight9925 4 ปีที่แล้ว

    that reminds me of sir Clive's one KiloBYTE ZX80/81, how did his Beginners All purpose Symbolic Instruction Code fit in there And translate to machine code so efficiently.. and so the question becomes why dont arduino boards do the same as an option with more power and storage !

    • @SpeccyMan
      @SpeccyMan 4 ปีที่แล้ว

      It fitted into an 8K ROM, that's how. Also, there are BASIC implementations out there for AVR.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      The ZX81, Paul? I repaired one once, for my boss at the time, he was most impressed and immediately gave me a pay rise. Oh no, that is what I _hoped_ for but it never materialised! That had a BASIC ROM chip that was separate from the memory IIRC so the RAM just stored the tokens. But yes, it was quite impressive. I had a Spectrum, that was quite impressive too, I even had the matching little tape drives too, not quite so impressive! But it also had access to a TV output (not available on the AVR chips, not without extra hardware, and these days it would be HDMI). Perhaps there is a market for this out there?

    • @SpeccyMan
      @SpeccyMan 4 ปีที่แล้ว

      @@RalphBacon Actually Ralph, I do believe there is a library out there to produce a TV signal (with very little additional hardware) most likely to be found somewhere on github.

    • @neildarlow
      @neildarlow 4 ปีที่แล้ว +1

      The BASIC interpreter shrank commands down to a single byte so the "bulk" in programs was in literal strings, variables and their assignment. 1K of BASIC program storage space went quite a way.

    • @paulmaydaynight9925
      @paulmaydaynight9925 4 ปีที่แล้ว

      @@RalphBacon maybe you can take *ben's POC (running at 25/50 Hz in this case, as its true integer based) + cheap vga2hdmi dongle
      th-cam.com/video/uqY3FMuMuRo/w-d-xo.html and translate it to some ESP32 type interface core pcb module and sketch for fun
      *World's worst video card? The exciting conclusion
      1,072,545 views•Jul 13, 2019,Ben Eater

  • @Ed19601
    @Ed19601 4 ปีที่แล้ว +2

    I have been trying to hold back for a couple of videos but now i am gonna say it : Arrrrgh

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Shiver me timbers, matey, what can you mean?

    • @ManfredAckermann
      @ManfredAckermann 4 ปีที่แล้ว

      What a useless statement...

    • @Ed19601
      @Ed19601 4 ปีที่แล้ว +1

      @@ManfredAckermann i agree and i dont understand why you made it

    • @chrisleech1565
      @chrisleech1565 4 ปีที่แล้ว +1

      You don't need the ..gh . Its just ... Arrr Mateys

  • @32_bits
    @32_bits 4 ปีที่แล้ว

    Hi Ralph, another good video but wonder why not use a larger mcu with more memory, is mcu size such a big problem for your project? Also, are you planning to continue your explorations with Kicad?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      This exercise with the Tiny13 was instigated by some of my viewers - so I thought I'd give it a good go (and I haven't shown you the fruits of my labour with the Fridge Door Alarm challenge on the Tiny13 yet).
      In Real Life I would obviously choose a more "capable" chip; even the Tiny85 is streets ahead of the Tiny13 in terms of memory (and speed). But it's always good to know _why_ the bigger chips are being used.
      KiCad? Don't get me started! I'm (trying to) design a board right now using it and it is quite frustrating after some weeks of EasyEDA. It's definitely written for geeks by geeks, with no disrespect meant to anyone! But eventually I will remember all the strange behaviour quirks and calm down! Keep tuned.

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      32bits - Good? Do you think you understand the timer problem? Does the creator get anything? Oh ya. He gets paid by a Chinese web site. How about you?

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

    WHY is _BV a 1? ok here's why:It stands for Bit Value where you pass it a bit and it gives you the byte value
    with that bit set. SOURCE: dubworks.blogspot.com/2012/07/introduction-to-c-language-bitwise_21.html. Makes sense now!

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

      Glad you researched this and got the answer. You will remember that forever! My work here is done.

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

    This is a bridge I have been reluctant to cross yet. "Arduino speak" is currently working for me and there is even a lot more I haven't yet touched there. :-)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I hear you, Bora. But if you wanted to use a ATTiny13 or 85 in your next project then perhaps Arduino-speak would just be too verbose to fit. As I've discovered with my Fridge Door Alarm! The obvious solution is to use a bigger chip. Yeah, sounds a good idea!

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

      @@RalphBacon I made some projects with the 85 (learned a lot from you there) and they were simple enough to fit in the 8K memory with quite some space to spare. Even designed my own "programming and development shield" for them to fit on a UNO. I did not think of including an ICSP header on that PCB back then, something I really regret today. Haven't tried the 13 yet, but since I bought my 85 chips in bulk (20) some time ago, I still have some at my disposal.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Probably worth sticking to the Tiny85 then, as 8K / 512b is so much bigger than the Tiny13 - more than just the numbers would indicate!

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว +1

      Can you tell me the precision (not accuracy) of the Arduino IDE timers? Didn’t think so. Find a channel with a ho

  • @jstro-hobbytech
    @jstro-hobbytech 3 ปีที่แล้ว

    I had to take visual basic back in university and it made me lose brain cells haha

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

      Microsoft are pushing Visual Basic again (as an alternative to C#), so much so that they are almost identical these days.

    • @jstro-hobbytech
      @jstro-hobbytech 3 ปีที่แล้ว

      @@RalphBacon I remember the version we used (1999) you didn't have to declare variables or their type, just make up a name for the data container (variable) on the fly. I made pc versions of duckhunt and breakout for class projects haha maybe 300 lines of code between them lol there was no Nintendo zapper support though because we used early lcd displays in lab haha

  • @Hasitier
    @Hasitier 4 ปีที่แล้ว

    Hey Ralph. I always knew that Arduino language was a wrapper of some sort of c code. But I also was sure that the compiler in the end just made machine code out of it and so it would not make any difference if you used one or the other? Maybe I was wrong with that assumption. I like your little attiny Adapter board. Maybe I can get one or get the files to order some myself?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Arduino C++ is aimed at beginners, primarily, so contains extra code to ensure the coder is not doing anything stupid. And there are lots of IF...THEN...ELSE statements in there too! So the code will be larger, possibly less efficient (so slower) but ultimately quite safe and robust.
      Regarding sample PCBs, Michael, stand by for an announcement that will affect the way I offer these in the future.

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Can you tell me the precision (not accuracy) of the Arduino IDE timers? Didn’t think so. Find a channel with a host that gets it.

    • @pfeerick
      @pfeerick 4 ปีที่แล้ว

      @@boonedockjourneyman7979 That would mean, for starters, that you would need to specify what clock source you're using, as the speed you're running the ATTiny13A, and what prescaler you are using varies the frequency at which the timers trigger. Then, how have you set TCNT0 up? How often do you want it to overflow? After all, 64 uS leading to 15625 overflows per second (/8 prescaler) is a lot...

  • @jahe80
    @jahe80 4 ปีที่แล้ว

    You are mixing c++ chich is what arduino is written on and pure C what you used on this. Those are very differend things.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Technically, they may be different but it's still all "code". C++ and C are different beasts, the former supporting OOP and the latter being strictly procedural. But in the Arduino world (and elsewhere) the lines are very blurred. But C is not C++ as you rightly point out so thanks for posting.

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Ralph S Bacon - Do you have any idea what you’re talking about?
      Your reply is sort of like saying “use JLCPCB because it’s JLCPCB.”
      Have you ever written either C or C++? If so, show me a single multi variable function call that works in the Arduino IDE.
      You can’t keep faking everything.

    • @DavidUnderhill
      @DavidUnderhill 4 ปีที่แล้ว +1

      @@boonedockjourneyman7979 I don't think you really know C++, C and the nature of the underlying avr-gcc compiler used by the ARDUINO IDE. C, C++, ASM syntax can be all used even in same program.

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 4 ปีที่แล้ว

    Never can get my head around why embedded software needs an Int main(void), there is no operating system to pass anything to the code at startup and also there is normally nothing for the program to return an int to. can anybody throw some light on this? another nice thought provoking video Ralph

    • @Dust599
      @Dust599 4 ปีที่แล้ว +1

      You need to tell the compiler where the first bit of code is to run.

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 4 ปีที่แล้ว

      @@Dust599 that i understand, but the int in front of main indicates that the program will return an int. in a microprocessor environment there is no software process to pass the int to! i can get the void in main(void) as there is no calling code to pass any variables to the main code! these two are only of any use if there is a calling program which can pass or receive data. int main(void) only makes sense when there is an operating system. Where in Ralph's code is the returned int going? this is getting the old grey cells a work out. best part of Ralph's channel

    • @willofirony
      @willofirony 4 ปีที่แล้ว

      The GNU compiler, which is the backbone of the AVR compiler (and for almost all the MCUs available) uses the main function address as the entry point for the executable code. Compiled code is arranged by the compiler such that the static information comes first, allowing the addresses of that information to be constant within the generated code. Included in that static information is the entry point ie, the address that has to be in the Program Counter when the device has powered up. Main is just the a uniform way of specifying "this is were we start".

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      C++ needs to start running code somewhere, so it is logical that it starts that the main() function. That returns an int response in case whatever called it (eg another program) needs to know success or failure. You are correct that in an AVR environment it's unlikely we'd use this feature, but C++ is much bigger than just AVR!

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 4 ปีที่แล้ว

      @@RalphBacon you hit it on the head. if you were to compile the same program but written in assembler there would be no main statement just a statement to show where you want the code to go. there will be no return int needed and no variables past in. so when the c++ compiler, complies it just throws these away. it's just a shame to write something that is not need or required. just there for C++ comparability. May be in the future there may be an ATTiny running an RTOS. so it might be required after all. :)

  • @boonedockjourneyman7979
    @boonedockjourneyman7979 4 ปีที่แล้ว +1

    The timing implementation alone of “Arduino” is so poor as to be legendary. Dump the “Arduino” IDE and start learning C++ day one. This fiddle with half measures is extremely misleading.

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

      "Extremely misleading", you say? In what way? The constructs I've used are in the underlying Arduino C++ code. If everyone had to start "learning C++ day one" there would be no Arduino movement. Think about what the Arduino.cc has achieved in getting millions into coding, whatever level that might be.

    • @uwezimmermann5427
      @uwezimmermann5427 4 ปีที่แล้ว +1

      @@RalphBacon I guess what he means that is completely obscure on which timer is used for time keeping, and thus taken up and cannot be freely used. This also affects the possibility to freely control the PWM-modes etc.

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Ralph S Bacon - I don’t know if you will get this. No insult intended. You just won’t get it.
      The “Arduino” IDE is so bad that your continued attempts to prop it up are hopeless. I honestly believe you don’t understand either timers or interrupts. No insult. You just don’t get it. I don’t believe you ever read the (horrendously huge) data-sheet. All forgiven except your quack attempt to pretend you do actually get it (which - as to timers and interrupts) you clearly don’t.
      The “official” IDE simply cannot work, ever. Users must get out of it and into the manufacture’s IDE ASAP.
      By constantly trying to work around problems you don’t understand you are misleading your viewers. There are endless TH-cam providers who do understand the issue. You, well Sir, JLCPCB says it all. You’re a hack.
      Either learn what these ICs are about or just keep being a shill for China. Your choice chap. Not a problem if you keep your fake channel going. People love it. Sort of like daytime TV.
      What irritates me is your fake-ass act that you know anything. You’re a clown. You’re a pimp for China. OK. Good for you. Make some coin. But for God’s sake stop pretending you understand anything.
      Again, I don’t intend to insult you. You know damn well you’re a pimp for a Chinese board manufacturing operation (which means the CCP). Just try being honest. There is value in your “profession.”

    • @boonedockjourneyman7979
      @boonedockjourneyman7979 4 ปีที่แล้ว

      Uwe Zimmermann - Sort of. What I mean is that the channel is clueless. He has no idea why the timers and interrupts are useless in the Arduino IDE.
      He is simply a shill for crap Chinese business sites. I honestly don’t believe he has read the data-sheet.
      This is garbage content.

    • @uwezimmermann5427
      @uwezimmermann5427 4 ปีที่แล้ว +1

      @@boonedockjourneyman7979 Ralph is on his best way to leave the Arduino framework - help him instead of talking down.
      Given the fact how widespread and misunderstood Arduino is, this channel will certainly help other people to take the next step.
      I myself am still hesitant to use platformIO even though I can see its advantages when it comes to cross-platform development, which is an advantage of Arduino over my avr-gcc programming. However, most of my projects are using ATtiny and ATmega chips and I never bothered for myself to use the Arduino IDE on those.