Wokwi
Wokwi
  • 52
  • 436 392
Building a custom I2C chip for Wokwi simulation - PCF8575 [full walkthrough]
Get from datasheet to digital simulation. This guide will walk through all the steps to getting a fully modeled custom chip, that may be used in any wokwi circuit simulation.
We'll look at the datasheet and figure out how the chip works, test understanding in simulator and real life, define a test scenario and circuit and implement everything to get this PCF8575 (an I2C I/O expander) usable in any circuit.
If you haven't seen the custom chip intro video, it's a useful foundation that goes over the basic concepts, including the types used and reasoning behind much of the structure of custom chip implementations (init, callbacks, pin watching etc):
czcams.com/video/yzdCS3A4DvU/video.html
Here, we'll dive deep into the I2C chip itself and look at the way I'm figuring out how things work prior to coding, finishing up with actual implementation. The important sections are:
00:00 - Intro
00:35 - Goal and plan
01:30 - Device Analysis
06:50 - Test + real device
08:44 - simulating open drain
12:20 - Custom chip test circuit
15:07 - Implementing the custom chip
23:50 - Arduino test driver
You can play with, and download a copy of, the PCF8575 custom chip and test code on wokwi, at:
wokwi.com/projects/374157774982675457
If you're curious about that opendrain test, it's also available:
wokwi.com/projects/374056916957689857
zhlédnutí: 9 715

Video

Custom Chips: Test any digital circuit in your browser with Wokwi
zhlédnutí 122KPřed rokem
Get a complete simulation of your digital circuit running, including all the peripherals, thanks to Wokwi's support for Custom Chips. In this tutorial, we'll walk through three different projects that show you, step by step, how this powerful feature let's you add any IC you want to use in your circuits to simulations. Try it out now on wokwi.com where you can start with any of the samples on t...
PIND Arduino Simulator Bug - Building Wokwi
zhlédnutí 5KPřed 2 lety
We're tackling a subtle but impactful bug in the AVR simulator. We start by analyzing a tiny Arduino program which shows the problem: an LED turns off when it shouldn't. Then we dive into the assembly code, and take a look at the implementation of the offending instructions in the simulator's source code. One we pinned down the bug (pun intended), we create a regression test case, and change th...
GDB Debugging ATtiny Simulator Bug - Building Wokwi
zhlédnutí 4,6KPřed 3 lety
See how I hunt for a sneaky ATtiny85 timer issue using GDB and a virtual logic analyzer. We'll dive into Arduino's internals, dig into the implementation of delay() and micros(), and eventually find the bug! Original GitHub issue with the details: github.com/wokwi/wokwi-features/issues/159 How I got GDB to run in the browser: blog.wokwi.com/running-gdb-in-the-browser/ Wokwi Arduino simulator: w...
Scary XMAS from The Skull
zhlédnutí 266Před 3 lety
Scary XMAS from The Skull
Splendida ✨
zhlédnutí 727Před 3 lety
Splendida ✨
The Skull's Secret Message 💀
zhlédnutí 278Před 3 lety
The Skull's Secret Message 💀
The Skull Prototype Hand Assembly ☠
zhlédnutí 177Před 3 lety
The Skull Prototype Hand Assembly ☠
Simulating Arduino PWM in JavaScript (AVR8js)
zhlédnutí 1,8KPřed 4 lety
Simulating Arduino PWM in JavaScript (AVR8js)
Let's Code Arduino Simulator from Scratch (with JavaScript) 😬
zhlédnutí 11KPřed 4 lety
Let's Code Arduino Simulator from Scratch (with JavaScript) 😬
How Fast Does Your Arduino Code Run? ⏱
zhlédnutí 26KPřed 4 lety
How Fast Does Your Arduino Code Run? ⏱
Optimizing Arduino Code: no setup(), no loop() ⛔
zhlédnutí 202KPřed 4 lety
Optimizing Arduino Code: no setup(), no loop() ⛔
Programming Arduino Dice Roller: Making random() more Random [3/3]
zhlédnutí 2KPřed 4 lety
Programming Arduino Dice Roller: Making random() more Random [3/3]
Programming Arduino Dice Roller: 44 ⇒ 7 Lines of Code [2/3]
zhlédnutí 2,2KPřed 4 lety
Programming Arduino Dice Roller: 44 ⇒ 7 Lines of Code [2/3]
Programming Arduino Dice Roller from Scratch! [1/3]
zhlédnutí 6KPřed 4 lety
Programming Arduino Dice Roller from Scratch! [1/3]
Live Coding lit-element, SVG and Web Components with Uri Shaked [3/3]
zhlédnutí 595Před 4 lety
Live Coding lit-element, SVG and Web Components with Uri Shaked [3/3]
Live Coding lit-element, SVG and Web Components with Uri Shaked [2/3]
zhlédnutí 880Před 4 lety
Live Coding lit-element, SVG and Web Components with Uri Shaked [2/3]
Live Coding lit-element, SVG and Web Components with Uri Shaked [1/3]
zhlédnutí 3,2KPřed 4 lety
Live Coding lit-element, SVG and Web Components with Uri Shaked [1/3]
Hanukkah Tune on CircuitPython 🕯️🕯️🕯️
zhlédnutí 578Před 4 lety
Hanukkah Tune on CircuitPython 🕯️🕯️🕯️
Simple Wireless Power with Arduino
zhlédnutí 2,6KPřed 4 lety
Simple Wireless Power with Arduino
ATtiny85 Capture The Flag and CircuitPython
zhlédnutí 416Před 4 lety
ATtiny85 Capture The Flag and CircuitPython

Komentáře

  • @krishnabharathi6221

    🎉🎉🎉🎉🎉🎉🎉🎉🎉😊😊😊😊😊😊😊🎉🎉🎉🎉🎉🎉😊😊😊😊😊

  • @krishnabharathi6221

    ec

  • @NilsBelde
    @NilsBelde Před 13 dny

    Amazing content! And I have only just started watching.

  • @thomasthemaker
    @thomasthemaker Před 18 dny

    Hi, I came across this. I'm building a Raspberry Pi Zero 2W emulator. Can the same library be used for it?

    • @Wokwi
      @Wokwi Před 18 dny

      No, it uses a different chip

  • @DjEdu28
    @DjEdu28 Před 25 dny

    Genial! Muitíssimo obrigado Urish. Não conhecia esse projeto do tawjaw, ele me deu algumas ideias para soluções das aulas remotas. Se conhecer outros projetos similares, ficarei muito feliz de receber indicações.

  • @darklegend9868
    @darklegend9868 Před měsícem

    How to get the exact desired delay?

  • @stephanc7192
    @stephanc7192 Před měsícem

    Great video

  • @richardlynneweisgerber2552

    Are any of these simulators capable of allowing user to stick the Boolean Algebra equation(s) of one's design, then spit out the schematic?

  • @Lunolux
    @Lunolux Před 2 měsíci

    nice

  • @I_am_Ashok
    @I_am_Ashok Před 2 měsíci

    Mind blowing video. May god keep you happy and healthy.

  • @aralozkarsli8939
    @aralozkarsli8939 Před 2 měsíci

    Uri Shaked is a true genius, I always say this. Mr. Shaked has changed my life, I can not thank you enough sir, I am very grateful for everything you have done to teach us your knowledge and wisdom.

    • @urishaked4548
      @urishaked4548 Před 2 měsíci

      Thank you!

    • @aralozkarsli8939
      @aralozkarsli8939 Před měsícem

      @@urishaked4548 Mr. Shaked I am truly honored that you saw and replied my comment. You taught me the true meaning of being a real engineer. I always talk about the amazing projects you do, I read all the articles in your blog, I watched most of the content you share on CZcams, I studied the avr8js source code line by line, I know about the SiliWiz, The Skull Challenge, amazing work you do with Tiny TapeOut, I even studied the whole github library of Jumperless Breadboard project that your techonology made possible, and so on... Finding out about Wokwi because my LDR sensor broke and deep diving into the ecosystem you created made me realise this is the kind of work I want to do in my life. The lesson you gave me was far more important than any technical knowledge sir, you taught me how to start on the path of not being a noob. More than 140 hours of CZcams lectures, all these priceless opensource technology, you really are a man of the people sir and when I say that Uri Shaked changed my life, this is no exaggeration. You really are a big inspiration to me sir, I thank you for everything. All the best wishes from me Mr. Shaked. Thank you.

  • @Sourabh-jv2ip
    @Sourabh-jv2ip Před 2 měsíci

    Really great content, helps a lot to understand stuff!!

  • @ragnar-the-giant
    @ragnar-the-giant Před 3 měsíci

    Great. You saved bytes you don't even need in this case. The code is terrible and nobody understands it anymore. Whatever. Nice expert insight that most people never need.

  • @Gamestersaify
    @Gamestersaify Před 3 měsíci

    hello from discord

  • @terrybailey2769
    @terrybailey2769 Před 3 měsíci

    I've no doubt that to those who are familiar with this, it all makes sense, but for me who is still trying to learn this it is way way too fast. Please can you do something that is a little more sedate for us mere mortals.

  • @e.x.p8832
    @e.x.p8832 Před 3 měsíci

    how you Know all this information :)

  • @helderalmeida3993
    @helderalmeida3993 Před 3 měsíci

    simple great tutorial! keep doing it...

  • @tsclly2377
    @tsclly2377 Před 4 měsíci

    as an ad-on, for paying customers, add on a chip supplier data base and market portal; new (with chip place of origin) and used (ditto, as so many come from China). Your logical area of development then would be into hardware for setting and soldering on chips and board chip removal for the used market. Further hardware would be automated chip testers. Grinding up chip is so anti-productive from at the very least the energy perspective. I see this tool as a good start to get the electronic cottage industry going.

  • @stevec5000
    @stevec5000 Před 4 měsíci

    He lost me at designing his own chip! LOL

  • @rizkitrimukti3827
    @rizkitrimukti3827 Před 4 měsíci

    Can I2C Communication Components such as LCD 12C or Oled use this port manipulation?

  • @kahlo2943
    @kahlo2943 Před 4 měsíci

    Your 158 bytes are not the end. This one uses 80 bytes only and 0 bytes dynamic memory: int main() { DDRB = DDRB | 0b00001000; while (1) { PORTB = PORTB ^ 0b00001000; // flipping 1 pin only for(long i = 0; i < 500000; i++) { asm(""); } } }

  • @robstevense152
    @robstevense152 Před 4 měsíci

    From the arduino IDE it can easily be done in 148 bytes by using a smaller counter variable i of 3 bytes: int main() { // ========== Setup ========== for (;;) { // ========== Loop forever =========== PINB |= 1 << 5; for (__uint24 i = 0; i++ < 3000000;) { asm(""); } } // ================ Loop forever =========== }

  • @lecturerintisaar3015
    @lecturerintisaar3015 Před 4 měsíci

    Is it possible to do biometric simulation like palm, face , iris or fingerprint into wokwi simulator??

  • @matejptacek8020
    @matejptacek8020 Před 4 měsíci

    The active waiting saves space but definitely is not optimal in terms of energy consumption

  • @LambdaTechnology
    @LambdaTechnology Před 4 měsíci

    My dude dropped us off at Arduino code Dropped us into C code Then he optimized us with some ASM 😂 🫡🫡🫡 my hat is off to you sir, FANTASTIC Explanation for memory save. Keep up with the ASM tuts….it’s a dying breed, but this is a fantastic platform to teach it on. Everyone wants to “talk to the metal” 👍

  • @Astrabajt
    @Astrabajt Před 4 měsíci

    Im wondering why PINB can be assigned with the value. I thought it was read only ;)

  • @PeetHobby
    @PeetHobby Před 5 měsíci

    There are AVR app notes that discuss this topic and compare loops and code structures with each other on speed and size. You can search for: 'Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers.' Prettified code is not necessarily faster, but repeating code is also not smart.

  • @jakeowsley6552
    @jakeowsley6552 Před 5 měsíci

    Hello, This was something I hadn't seen before. Writing PINB toggles all bits (i.e. 0xFF). That part wasn't clear from your narration, "totals the pins". PINx is considered a read only register in Atmel docs. Thanks.

  • @joamarticorena9018
    @joamarticorena9018 Před 5 měsíci

    Greate video

  • @newklear2k
    @newklear2k Před 5 měsíci

    Dude, if you were teaching them how, so many more people would want to learn code and hardware. You're a delight to watch.

  • @baili8654
    @baili8654 Před 5 měsíci

    wokwi is wonderful, but web simulation is a little slow, why there is not an exe file running in windows or linux

  • @pmwicaksana
    @pmwicaksana Před 5 měsíci

    Keren om, penjelasannya sangat bagus👍

  • @sohaiblekhdar8752
    @sohaiblekhdar8752 Před 5 měsíci

    Tank you

  • @whac-a-robot
    @whac-a-robot Před 5 měsíci

    I am trying to read a analog value and print it in chip console. I get the value as either 0 or 5 instead of other values. Is there any other way to do it?

  • @antonkavaler2749
    @antonkavaler2749 Před 5 měsíci

    Спасибі за ще один хороший огляд! Єдине: маленька одруківка в назві відео: ''Я там Катя?", хоча це надало цікавої ''фарби'' назві цього фільму.

  • @whac-a-robot
    @whac-a-robot Před 5 měsíci

    I am trying to make an analog read circuit for custom circuit. Is it possible to do it? The value(0-255 or 1024) should be printed in the chip console.

  • @paulalmquist5683
    @paulalmquist5683 Před 5 měsíci

    Smaller but at what price? Readability, which directly effects maintainability! Part of the purpose of the Arduino IDE is to make programming easier, especially for the beginner. There are plenty of microcontrollers on the market so if you need more memory or more speed buy a different one. If one needs to minimize size then write the code in the assembly language for the target device and document it well but don't expect it to be easily understood by a wide audience.

  • @weash33
    @weash33 Před 5 měsíci

    I would really like to see an demonstration on how much of a speed gain we can achieve as a result of these kind of optimizations.

  • @thomasdalberto6762
    @thomasdalberto6762 Před 6 měsíci

    It would be interesting to see how this could be adapted to work with the new Arduino UNO R4. It is not based on an ATmega chip therefore the registers are different and from what I could see also the execution of instruction is rather different. I tried to apply the same concept presented in this video using the General Purpose Timers but I could not obtain a working example. Maybe you are able to do it having more experience in the field.

  • @Dragirek
    @Dragirek Před 6 měsíci

    How to convert a readable code into a nightmare

  • @tomekprzytarski9167
    @tomekprzytarski9167 Před 6 měsíci

    What about incresing code? 924 bytes is preloaded arduino.h content, which will be used for building bigger code.

  • @felipeparente
    @felipeparente Před 6 měsíci

    Muito bom

  • @MrSummitville
    @MrSummitville Před 6 měsíci

    You did not "optimize" the easy to use Arduino code ... You replaced it with garabage.

  • @zbigniewrichard8291
    @zbigniewrichard8291 Před 6 měsíci

    The moment you started typing code like a mad woman/man? you lost everybody's interest in term of simplicity about Wowki.

  • @lutzmuller5703
    @lutzmuller5703 Před 6 měsíci

    Hi, how can I insert a simple diode 1N4004 or transistor 2N3906.

  • @joostpalucki6560
    @joostpalucki6560 Před 6 měsíci

    useful information, thanks

  • @dmitryefimkin6550
    @dmitryefimkin6550 Před 6 měsíci

    Спасибо. :) Очень интересное видео.

  • @bobvanwagner6099
    @bobvanwagner6099 Před 6 měsíci

    Great simple descriptive video. If ever redone in.a newer video: The sizing comments should include a description of what the mods were, and the operating result. Also would be nice to know what the empty loop time elapsed is, measured. You can use a stopwatch and and outer loop to lengthen the time to that which your fingers can operate the stopwatch to some good accuracy.

  • @khroomlet8821
    @khroomlet8821 Před 6 měsíci

    Is there any way to use this tool to test DC motors and or other things like 12V DC LED arrays for power consumption or circuit integrity? This popped up on my feed and looks perfect.

  • @PRINCE-pt5gx
    @PRINCE-pt5gx Před 6 měsíci

    I want to work with Mq135 should I use custom chip for it.....?? Name mq135 for Air Quality Monitoring

    • @Wokwi
      @Wokwi Před 6 měsíci

      Depending on how you want to use it, just a simple switch may be enough to simulate it (if you only use the digital input), or a potentiometer (if you only use the analog input). Otherwise, you can also create a custom chip to simulate both at the same time.