| Electronics > Microcontrollers |
| Cheap microcontroller for JavaScript or fast interpreter. |
| << < (5/7) > >> |
| NorthGuy:
--- Quote from: brucehoult on December 20, 2024, 05:35:13 am ---I just don't understand the problem here. --- End quote --- Me neither. This reminds me of "But I was thinking of a plan To dye one's whiskers green, And always use so large a fan That it could not be seen." Engineering is about simplicity. If you pile lots of things together and then work on negating the influence of these things on your work process you will waste lots of efforts and the solution will be very convoluted. Instead, isolate your signal processing code into a self-sufficient module, make sure you can compile the code both on PC and on MCU. On PC, insert the code into an application which does visualizations. Once your code is working, all you need to do is re-compile the MCU project and run it on MCU. That's all there's to it. If I was doing this, my task would compile the code on PC, process a training set of hundreds (or thousands) pre-recorded gesture files, calculate statistics to evaluate recognition accuracy, isolate bad cases and print debug info on them. With all this written in C, it would probably take a few seconds to compile and run through the whole set. Then, once the test set is working, run it through much bigger and independent database of gestures to see if it still works. Testing on the chip is prohibitively time cosuming - producing even a 100 of gestures manually takes too much time. Using pre-recorded gestures is the only way. |
| Georgy.Moshkin:
--- Quote from: NorthGuy on December 20, 2024, 03:10:23 pm ---Engineering is about simplicity. If you pile lots of things together and then work on negating the influence of these things on your work process you will waste lots of efforts and the solution will be very convoluted. --- End quote --- I agree about simplicity, and the risk of spending too much effort without much improvement is high. Let's not forget that I have a great working algorithms in JavaScript. MinGW C + external Sciter.JS GUI approach was irritating enough to try JS-only. To be honest, I even don't care about the time that it takes to create JS-only prototype (within reasonable limits). Because I feel great working on the prototype, interesting, there is a sense of progress and nothing stops the momentum. But later I experience the consequences of using JS instead of C. --- Quote from: NorthGuy on December 20, 2024, 03:10:23 pm ---Instead, isolate your signal processing code into a self-sufficient module, make sure you can compile the code both on PC and on MCU. On PC, insert the code into an application which does visualizations. Once your code is working, all you need to do is re-compile the MCU project and run it on MCU. That's all there's to it. If I was doing this, my task would compile the code on PC, process a training set of hundreds (or thousands) pre-recorded gesture files, calculate statistics to evaluate recognition accuracy, isolate bad cases and print debug info on them. With all this written in C, it would probably take a few seconds to compile and run through the whole set. Then, once the test set is working, run it through much bigger and independent database of gestures to see if it still works. Testing on the chip is prohibitively time cosuming - producing even a 100 of gestures manually takes too much time. Using pre-recorded gestures is the only way. --- End quote --- A great advice! A small remark is needed here. I am not working on gesture recognition. The product prototype that I was demonstrating at the 2023's competition used STM32H7 only to demonstrate possible applications, such as real-time audio pitch for DJ turntables, image scroll/zoom on the screen, etc. The recognition algorithm itself is fully analytical, doesn't use any neural networks or patterns, and can work on a sliding window without any memory by storing temporary data in few registers on ancient 16bit MCU. That was easy stuff! Made by me to meet the criteria of the competition to get funds for a greater project. And the selling attempt was basically to meet the criteria of "entrepreneurship". I am more like a researcher, but every entity I've reached to was redirecting me to this enterpreneurship competition. So, the video above is only to demonstrate how visualization works in the browser and the performance of final algorithm running on the device. I'll try to rephrase. Imagine I do exactly as you say, and you can control each my step. So, I have written an "isolated signal processing code into a self-sufficient module" - or have I? This code changes all the time, and the difficulty is here: 1. I am not aware of any IDE/framework that will allow me to create a windows32 executable and create custom GUI outputs in a same convenient manner as in JavaScript+HTML. There are frequent changes, and I usually have a chain of algorithms with certain inputs/outputs that sometimes I want to visualize. 2. Dynamic typing in JavaScript helps a lot but complicates the porting on limited memory device. For example, copy-pasting of something like a=b-c to C from JavaScript will create a bug if c>b and both defined as unsigned numbers (uint8_t). |
| Siwastaja:
--- Quote from: Georgy.Moshkin on December 21, 2024, 02:44:14 am ---Let's not forget that I have a great working algorithms in JavaScript. --- End quote --- I think that if your greater plan is to have these run on various devices, including embedded (but possibly also desktop and servers), reimplement them in C and after that, keep maintaining them in C; C is probably one of the sanest choices between portability and efficiency and it seems you already have grasp of the language. Choosing right tool for the job is important, and maintaining everything in two languages is not a long term solution (and probably not even short term) as you have realized already. --- Quote ---1. I am not aware of any IDE/framework that will allow me to create a windows32 executable and create custom GUI outputs in a same convenient manner as in JavaScript+HTML. There are frequent changes, and I usually have a chain of algorithms with certain inputs/outputs that sometimes I want to visualize. --- End quote --- You need a graphics library or data visualization library or GUI library. If you have been googling IDEs and frameworks no wonder you won't find anything. You don't need IDE or framework; "frameworks" specifically are evil's tools to lock down choices and add complexity to any project. There are so many visualization libraries available that you will struggle to choose; I have used SFML in past but it's no good for graphs etc. I'm sure you can get some recommendations here, or do a Google search. --- Quote ---2. Dynamic typing in JavaScript helps a lot but complicates the porting on limited memory device. For example, copy-pasting of something like a=b-c to C from JavaScript will create a bug if c>b and both defined as unsigned numbers (uint8_t). --- End quote --- Yeah. This is solved by switching the algorithm into one language only. If you don't feel like using graphics libraries from C or C++, JS can still be decent option for visualization; in that case you would want to output/input data from/to C using double FP data type, but keep the algorithm itself C only. |
| NorthGuy:
--- Quote from: Georgy.Moshkin on December 21, 2024, 02:44:14 am ---Imagine I do exactly as you say, and you can control each my step. So, I have written an "isolated signal processing code into a self-sufficient module" - or have I? This code changes all the time, --- End quote --- You're in the process of creating it (since the code is changing). You currently have 2 codes - JS and C, and you must change them both in sync. This is a nightmare, even if you find/write tools to automate this somehow. I propose you rewrite it all in C and maintain it in C. Your module will have well-defined inputs and outputs. Physically, this would be a number of .c and .h files. You can sym-link them into any number of project. The point is, whether you compile the firmware for an MCU (or for a number of MCUs) of for a test program on PC (or for lots of different test programs), you always use the same files - once a file changes, this change is visible everywhere. --- Quote from: Georgy.Moshkin on December 21, 2024, 02:44:14 am ---1. I am not aware of any IDE/framework that will allow me to create a windows32 executable and create custom GUI outputs in a same convenient manner as in JavaScript+HTML. There are frequent changes, and I usually have a chain of algorithms with certain inputs/outputs that sometimes I want to visualize. --- End quote --- IDE doesn't create executables, compilers do. There are two very common on Windows - MSVC++ and GCC, both free. Create a bat file or a makefile which compiles the project for you (this is very short, may be even one line). A decent text editor will let you run the file, compile the executable and even launch it. Windows has API (WinAPI) which is installed on every Windows. It includes GDI module, which is used for drawing. Although very primitive, it let you draw various objects. For example, there's an ellipse function, which draws a circle. https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-ellipse To draw a black circle with a red circle inside, you will have to call this function twice. Doesn't look hard to me. And will be much faster from pressing button to looking at the results than any JS. Or, if you're scared of WinAPI, or need more features, there are various drawing frameworks you can use. --- Quote from: Georgy.Moshkin on December 21, 2024, 02:44:14 am ---2. Dynamic typing in JavaScript helps a lot but complicates the porting on limited memory device. For example, copy-pasting of something like a=b-c to C from JavaScript will create a bug if c>b and both defined as unsigned numbers (uint8_t). --- End quote --- Looks like JS doesn't actually make your life easier. There are periods where it may make things easier (such as when you write), but then it requires porting to C. In my view, the drawbacks outweigh the benefits. So, don't use JS then. You will have to port the existing code to C (if you haven't already), but if you stop using JS afterwards, it'll prevent future complications. |
| tellurium:
Take a look at https://github.com/cesanta/elk If you want an interpreter that works on Arduino Nano. However, whilst tiny, it is slow and SEVERELY stripped-down. |
| Navigation |
| Message Index |
| Next page |
| Previous page |