-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create new parts (chips, sensors, etc.) with custom logic #301
Comments
Yes please! ❤️ |
Started working on this and uploaded an early prototype so users can start playing around and share their feedback. Here's a quick demo project: https://wokwi.com/projects/327144279206003284 And a google doc with further explanations: https://link.wokwi.com/custom-chips-alpha |
Can I suggest the new part creating uses the Fritzing images and pin maps to speed up device creation? |
@sjamesparsonsjr that suggestion may fit better in #302 |
Hi, |
Thanks for the feedback! It's possible to create multiple instance of each chip type. Here's a recent example with 2 copies of the same chip: https://wokwi.com/projects/335750100024296020 What do you mean by "saving" custom chips for using in other simulation? |
Hi, |
The definition is implicitly made whenever you have a pair of "whatever.chip.json" and "whatever.chip.c" files. Right now, the chips are saved along with the project, but we're looking into a way to make them separate entities that can be imported into a project (much like you can import Arduino libraries using the Library Manager). The current solution we're looking into is hosting custom chips on GitHub - you create a github repo with the custom chip source code and definition, and then you'll be able to submit the repo to a central Wokwi Chip registry, and users will be able to pull chips from this registry. Still working out the details.
These parts aren't officially supported. Some are incomplete (e.g. I'm curious, what are you using the custom chips for? |
Thanks for the information. A GitHub chip repository seems very reasonable. I will await developments. |
Sounds like a cool use-case! Do you have some models?
Only for a few of them, e.g. the ILI9163 Display Driver. I guess you are looking for the code of the MPU6050? Is there anything else? |
Not sure if this is the appropriate place to put this, but I was thinking that it would be cool to be able to select several predefined components and click a button that allowed you to make your own custom component. So , for example, If I m working with a lot of LEDs and their associated resistors, I would like to be able to generate an LED and connect it to a resistor, then with both items selected, define a custom component that would only show up locally in my dev. environment. Then every time I needed one of these, I could grab it from my + button under My Custom Components and voila it would appear just how I had wired it. This would be super easy to code and the combined elements as their own custom component would have all of the attributes that were not already defined. In other words, it would have two pins (the two open pins) to connect to as well as the resistance on the resistor, the color on the LED. When I generate my custom component made of other components, that stuff would automatically be exposed. Maybe that's a different request, but just in case. |
Yeah, that sounds like a new feature request - some kind of "modules" library. One way to sort-of achieve this now is to have a project with your common "modules", and then you can select several parts, copy them, and paste them into another projects. They'll be copied along with all the internal connections. Anyway, feel free to open a new feature request! |
Update: the Custom Chip API is now getting into a beta phase. There will probably be some minor changes, but I think we're already clear on the general direction. You can view the current API reference here: https://gist.github.com/urish/f9129d3d34ffd557eccf354907663051, and we expect to shortly migrate it to https://docs.wokwi.com. Here's a bunch of examples for custom chips, showing what you can do with the current API:
|
Nice work! The API documentation is clear, but it lacks information about the And my propositions:
//edit: You wrote:
Is possibl eto create multiple different chips? (eg |
Thanks for the feedback @bato3!
Yeah, the details aren't clear yet, but this might be part of #302. Probably uploading an SVG file and defining the pins.
There'll probably be some way to submit your custom chips and for other users to add them. Perhaps through GitHub. Still thinking of possible ways to accomplish this.
Yes, you can have many chip types in a single project, and multiple instances of each chip type. |
Are you planning to create a custom SVG element resource that WOKWI loads and all SVGS can simply reference? Like what you do with the "hole" symbol on your current SVG artwork? Ideally, given a default library set, someone could create any svg and include your resources for "pins" or solder points or connectors of any sort and that SVG would be ready to be added to the layout, including accessibility to connections. The only thing it would require for simulation would be the underlying code which would benefit from the standardization of the connector SVG resources. By standardizing every connector type and perhaps some common display types like (on board LEDs), simple hooks in the API would help with the logic part. But even before the logic part was not done, having the SVG with standardized components would enable layout and connections immediately. Upon adding a custom component all of the "pin" SVG symbols would be enabled for connections, for example. This might make it easier to debug upon running the simulation. Ill check out 302 to see if its covered there. Great work on custom elements. thanks |
Probably for starters, the user will just provide the complete SVG. To make things simple. Then we'll see how to evolve it based on how users will use it and the feedback we get (that's how Wokwi goes in general) |
Update: We have a proof-of-concept of creating custom chips using the Rust language. Here's an example of an inverter: |
New docs for custom chips: https://docs.wokwi.com/chips-api/getting-started Also, a new example of a chip hosted in GitHub repo: https://github.com/wokwi/inverter-chip |
Thank you for the progress on this amazing addition, |
It is supported in Visual Studio Code. Please take a look at the documentation: https://docs.wokwi.com/vscode/project-config#custom-chips Is the documentation about this clear or does it need any improvements? |
Ah, perfect, it seems that once again I failed to locate the relevant documentation. It took me a second to work out that its possible to replace the 'wasm' with the 'c' file, and now it works perfectly. I think the thing that tripped me up was the requirement to define the chip in the '.toml' file, instead of the web version auto detecting, though its added ability to add the chip definitions to sub folders is really neat. Keep up the amazing work |
I may have spoke too soon on it working with a *.chip.c file, it seems to hang on the 'Loading project...' message. |
Yeah, it doesn't know how to compile things - you have to feed it with binaries :) Do you need any assistance in converting the chips to wasm? |
I will see what I can do for a little bit, using the existing examples, and try to convert the 'eeprom_custom_chip_test' example into wasm. I will let you know in an hour if i'm stuck. :) |
Ive had some luck using your example for an inverter and the EEPROM example, to compile the wasm at the following repo https://github.com/alextrical/wokwi-24C01-custom-chip Ive managed to force it through to a release, and can now see the desired chip.zip file :) edit: all fixed, I wasn't using "tags" in the push, now I have done that it works without having to edit the Workflow. The error was pretty clear |
New UI to easily create custom chips and add them to your project: Also, updated the documentation:
|
New video tutorial - how to create custom chips, 3 examples in 15 minutes |
Another video tutorial: Creating an I2C I/O expander chip from scratch in Wokwi, using the Custom Chips API |
This is really great! One question, is or will there be a searchable part library, where i can checkout what other users did? Just so I don't have to reinvent the wheel when it comes to common chips. |
We plan to have some list soon - probably in a public GitHub repo. For now, you can find the most comprehensive list here: https://docs.wokwi.com/chips-api/getting-started#chip-examples |
hello, i would like to ask if there is a component like bluetooth module and nrf module in wokwi? |
Is an icon/image editor for the custom components something planned for? |
Can you elaborate on what would you like to see? |
It's more of an aesthetic thing really. Rather than just the default green block look, maybe users can have the option to upload or edit an image replicating the actual component being modeled. Like all other built-in components in the library. |
Can somebody create a module sensor with RS485? Maybe the sensor can read only one input such as temperature. Those who would like to expand the sensor with more than one input can modify the basic module to include, may be humidity, oxygen concentration and so on. |
Make it possible to create custom parts and program your own logic:
I've done some prototyping, and one way to implement this in a secure and performant way is to use AssemblyScript together with Web Assembly.
Initial thoughts about the API for creating custom parts:
Here's a proposal of what the code for a simple part (pulse counter with an I2C interface) might look like:
And another example - HC-SR04 Ultrasonic sensor (for now, with a fixed distance):
The text was updated successfully, but these errors were encountered: