Hallo Du! Bevor du loslegst den Talk zu transkribieren, sieh dir bitte noch einmal unseren Style Guide an: https://wiki.c3subtitles.de/de:styleguide. Solltest du Fragen haben, dann kannst du uns gerne direkt fragen oder unter https://webirc.hackint.org/#irc://hackint.org/#subtitles oder https://rocket.events.ccc.de/channel/subtitles oder https://chat.rc3.world/channel/subtitles erreichen. Bitte vergiss nicht deinen Fortschritt im Fortschrittsbalken auf der Seite des Talks einzutragen. Vielen Dank für dein Engagement! Hey you! Prior to transcribing, please look at your style guide: https://wiki.c3subtitles.de/en:styleguide. If you have some questions you can either ask us personally or write us at https://webirc.hackint.org/#irc://hackint.org/#subtitles or https://rocket.events.ccc.de/channel/subtitles or https://chat.rc3.world/channel/subtitles . Please don't forget to mark your progress in the progress bar at the talk's website. Thank you very much for your commitment! ====================================================================== [Music] otherwise Rick is going to talk to you about how with very limited means some of you may know shenzen iio that's where this comes from an assembly variant that he built in Hardware using very little money to create a very cool thing that children and young people can use to learn assembl language it's supposed to be a lot of fun I don't remember being assembly being so much fun but anyhow here we go Rick your stage this my talk Shen iio in real life which where I would like to introduce my product the MC 5000 dev kit that is an electronic puzzle game consisting of a application and a circuit board and task is to solve simple language simple tasks using an assembl language about me I've been chering for about 15 yearses in maker spaces and outside of them on various projects these are some of the things I built in the last few years now regarding the current project I came to the idea playing the game shenen IO from 2016 um and in this game you are an electronic engineer um that newly arrived in Shenzhen in China and works on hardware and you receive tasks via email built a usable security camera with two blinking LEDs and in the game you have a cat cat CAD program which you use to design a microcontroller and other components or put them onto the working workspace you develop them you connect them through lines assem and use a pseudo assembler language to uh write a microcontroller to solve those tasks and you then have a simulator that you run and you can check whether you've actually fulfilled the requirements and then you've passed your task and you pass on the whole documentation is completely uh put down in data sheets as you find them with electronic components and the further levels have data sheets that are in Chinese sometimes for some components so that you have to find out by yourself what they actually do or how you use them there are two types of microcontrollers in the game there is the MC 4000 and the MC 6000 they differ in the number of lines of cod e the 4,000 takes nine lines and the 6000 takes 14 lines five more and it also has a one register more and two pins more there are two types of pins that the controllers have there are simple IO pins and xbus pins simple IO are analog ports or like analog ports you have a value from 0 to 100 as you can set there and that corresponds to the signal level that what um you generate or receive or generate and send out if you can set these and query these at any time let's find out what's happening at the pin at the time then the xbus pins are more like a Serial bus um you can set values from - 999 to plus 999 there but on the other side a device has to be present that will take the data you send if there isn't one such device there the code blocks at the point where you want to set the um value until the value has been accepted by the other on the other side the assembler language is fairly simple there are 15 instructions only and I can run simple mathematical Comm calculations with the accumulator and simple queries is a larger than b or something like that are possible tests so um in Hardware I rebuilt this by taking a USB serial interface of creating one for programming I built a firmware very cheap Chinese controller the PED PFS 73 and I have two of those here these are my so-called MC 5000 controllers which I can program through the serial interface and outut have a few input and output per peripherals there on the circuit board and these are connected to the CPU used through simple jumper wires so that gives you the connections that genen IO has in its program The Objective here is to build this circuit Port as cheaply as possible it can be uh bought readily equipped at a Chinese maker if you order 50 it's 65650 66 and a half per piece including shipping um the app is written in qt5 Cross compiles for Windows Mac OS and Linux doesn't have to be installed and is prepacked for every platform and so you can just download and run it and I'll now show you how the whole thing works this is the def kit circuit board circuit board here are the two microcontrollers the MC1 and mc2 both type MC 5000 and they both have four IO pin two signal IO P P0 and P1 and X+ X1 and X1 x0 and X1 and then you have the output peripherals the display is the three digigit seven segment LED display that's an xbus peripheral the buzzer that can play sound again xbus then you have three simple iio outputs the red and green and yellow LED and as inputs I have two buttons one temperature sensor and a light sensor now this is the desktop application I have two editors here two windows in which I can write the code for the two microcontrollers I can use these buttons to save the code in a file or open it from a file there is a link here to the manual on GitHub and the upload button saves the code on the microcontrollers down here you have a display for the registers they are always initialized with zero at the start of the program and when the program is running this these are updated four times a second and the red area here shows you that there is no program on the microcontrollers at this time if there is a program uploaded then this turns to Green now I can enter assembly instructions here such as the move instruction so let's say move 42 to the data register I'll upload that it the the square turns green and you have the value to 42 here and in the same way I can write something into the ACC register and you see that d23 has arrived the whole thing of course the same thing of course works on the other microcontroller so that has been seated with values now again and if I delete these and press upload then the programs are erased and the is go back to zero now I'll connect a button with P0 of the first microcontroller and I'll write the value that is P0 into the AC register press upload the program has run ACC shows zero if I press the button now ACC turn goes up to 100 so the program um runs in a loop and always quer is p z always WR it to the register a nd buttons therefore work simply by setting the output to 5 volts and in the hardware version the value between Z and 100 simply is hey um is between Z and 5 volt in steps of 100s now I'll connect P1 with the red LED and now I'll write the ACC register to P1 I'll upload that and if I now press the button the red LED turns on because the ACC register is set to 100 and uh this is then written to P1 and P1 lights the LED that's perhaps a bit too complex complicated I can do the same thing directly I'll press the button the same thing happens only the register doesn't change simp iio that is simple iio x xus Works in much the same way I can read the P0 value that my button is connected to and write it to x0 and I'll connect x x0 with the display the display simply it shows what it is sent through the xus connection and if I upload that and press the button then the display will as you can probably not see too well on the screen in reality it is much brighter but you see the value changing to 100 so that's the XB the expert I can also use to communicate between the two microcontrollers are connect X1 on MC1 with x0 on mc2 and I write p 0 to X1 now and on the second microcontroller I will um I connected this to x0 on the second micr so I'll take x0 and save it in the DAT register upload the whole thing and when I press the button now you see how the data register is set to 100 because the value from the first micr controller was communicated to the second one if I release the button then it turns goes back to zero and uh one difference to Chen IO is that Chen IO forces you to run a sleep include a sleep command which is simply putting the microcontroller on hold for a while and for me one time unit is 100 micros seconds milliseconds so if I put in the number 10 um that is 10 * 100 milliseconds 1 second waiting time so that gives you a slight delay when I press the button one second delay you probably see it better if I'll make turn this into 5 seconds I press the button t akes a while and now data is set to 100 exactly so this Loop has now stopped for 5 seconds then it reached the value again writes it again and again and that is the time when the that register on MC two is finally reset and in the same way I can send something to the buzzer the buzzer works by taking values between 1 and 75 and these are increasing pitches frequencies so you can we can use a mathematical feature now such as ADD add one means take the ACC reg and add one to it because it's initialized with zero by uploading it I see that it's immediately put um set to 999 the reason for that is that the code runs quite quickly if I don't put a sleep in there if I add a sleep for 100 milliseconds you see how the value is slowly increasing I'll increase that to five even so the value is increased and this value I will now I can now uh transmit to x0 and you see how things happen on the display now how it how the count increases and if I now connect this to The Bu buzzer instead you can hear so you can actually play melodies that way no on to tests conditionals comparisons you've seen how the ACC value has is always increased and I I could do some things such as if well first I'll sleep again to prevent it from running too fast teq tests for equality test equal and I will now look into ACC and test it for 50 and after such a test I can add further lines with a plus in front which means that they are only executed if the test evaluates to true so AC equals 50 exactly and lines that I prefix with a minus are executed if the test is yields false and if the value is 50 of course I have my X1 still connected with x0 on the other controller so I'll simply move the value 23 to X1 and the second controller still is running the code that is simply moves x0 to that so upload this we see ACC increasing and as soon as it reaches 50 this line will be executed and the value 23 will be sent and the data reg there you go it chose 23 so in this way you can Implement quite a lot of funct ionality and the purpose of the game is to Sol tasks such as this so this is about uh getting a traffic light to work uh the light is red uh a pedestrian is pushing a button and uh the light should switch to Yellow to Green uh The Pedestrian should have time to cross uh the road and uh also there should be countdown from 10 to zero so uh to solve this problem I'm adding a couple of connections so use the yellow LED uh the green one with P0 because uh because both controllers only have have two simple IO pins and I can only use Simple IO with simple IO pins so I I'm using the second controller as kind of a port expander so uh the remaining connections can stay as they are I already wrote that program this is slightly more complex and uh we're also using labels this time I haven't shown that so far anywhere in the code you can add a label and you can use the jump command and to jump to that particular label so I'm uploading this now and when I push the button I can see the timer counting down to zero uh the traffic light uh is turning green uh the light switching back to red and we can do it again the timer counts to zero uh the traffic light turns green um and then it turns back to Red so I solved that problem and on the next level I would need to add some beeps uh uh when the light turns green so I started with this project last year and uh basically uh to work on the pedal microcontrollers uh they're really cheap uh but they can't do a lot uh a open source tool chain became available previously there was only proprietary tools from the vendor uh that you had to pay for so now uh it is supported by the sdcc compiler and there is an open Hardware programmer so uh I ordered a programmer and a bunch of the microcontrollers and played around with it uh a bit and looked for something to do with them and I I looked at the data sheets uh a lot and I was reminded of the Shen iio uh data sheets and so the idea was born to reimplement shenz iio in real Hardware so the the pro cessor that seemed the most trating is this one uh because it has an analog digital converter I can use that for the simple IOP ports and he's it's also got pwm and so there isn't the serial interface but there's an interrupt capable pin so that can be used for receiving uh on the serial port and there's one pin that is open drain uh so that can be switched only to ground and uh if you set it to one it's an open [Music] circuit you can use that to to uh communicate with multiple controllers at once it's kind of a bus so uh otherwise if you connect multiple together they would interfere with with each other so uh as long as only one of them is uh transmitting at any time uh you can connect multiple to the same busio so for the simple iio output connected the uh I I added a low pass filter um to use the pwm signal to convert that uh to a an analog voltage and I'm using that to send uh to send the signal to a simple iio Port uh on receiving uh the pin is uh switched uh to in an input connected to the ADC and uh that works wonderfully for simple IO uh the xus is slightly more complicated so we need a signal uh that uh the sender is ready to send and the receiver must be able will uh to tell the sender that it's ready to receive data so so that's the way it's imple implemented in shenzen iio and for that I used the feature that the PFS 173 uh has internal pull-ups we can use so I can switch the PIN to an input but use the pullup nonetheless and that pulls up the pin and and when the output is uh not active and when the output is not active it's pulled down so the cender uh raises the signal the receiver sees that and the sender pulls it down to Signal uh to to send the data and uh sends 12 bits uh to Signal uh value fromus 999 to plus 999 so uh these chips don't have very good timing only in internal RS illat so an Expos transfer is relatively slow it takes about 50 milliseconds and that's uh mostly sufficient and that's uh that's really sufficient for the tasks that are needed to be implemented for the game so the firmware uh was quite a struggle uh because uh the microcontroller has very little uh RAM so I need quite a bit of those bites to store the program and the remaining storage uh uh was never enough update what really helped comp uh was the compiler uh because it actually was optimized for this architecture um uh in particular function calls uh were using less Ram than before and so I learned a lot about when to inline functions so uh to to decrease their memory use so the sdcc compiler is not good at figuring that out automatically generate the assembler code into the 65 bytes I'm doing this I take a command like move and I'm using the upper six bits to encode that and so since there are only 15 instructions that's fully sufficient um for for the lines that have a plus or minus in front of them false uh depending on uh like what the previous test command was testing uh so I in in the same bite I'm using the two low most bits to encode the plus or minus so that means that it won't take up any more memory in the microcontroller the parameters always fixed and the first parameter can be an integer or a register um the second parameter can always only be a register uh for parameters that can be uh registers or integers I'm using 16 bits uh for a register I only need eight bits so uh for this line move 42 to P0 I I'm using four bytes and in the firmware there's a counter that uh that shows where we are in the program code and uh for a move command uh that is in incremented by three bytes and that that means that the 14 lines of assembler code uh can always be stored in the 65 uh bytes of Ram uh labels were a bit tricky uh so I'm paring the complete assembl code uh to extract the labels um they're basically strings with a on after it and I'm assigning a unique ID uh a number uh between one and 255 um encoding then uh uh by by having um an OP code uh for label and then the index of the label and uh when a jump uh command uh occurs then I simply scan for the through the entire uh program code to find the label to search for the index of the label and then I jump there and that uses very little memory one trick uh in the program code can add uh labels to lines that already have a uh command I added that uh I added that because uh that's possible in chenz IO it's not documented but it works so my goal definitely was that any code that works in ch enz iio should work on my microcontroller um if you want to try this for yourself uh then you should be able to get to my GitHub page uh I have added a lot of GitHub actions uh so all the binaries are built automatically for the different platforms C the the cad files uh the key CAD files are all processed and uh uh gbas bomb and pick and place files are created automatically and you can upload them to jlc PCB uh um so that includes all the order numbers from JL cbcb and uh at early April uh the padak chips are unfortunately not available right now uh so it's a bit weird that they're all sold out right now uh so we have to wait until they're available again but uh then you can buy all the parts I've uh created the layout in a way that all parts uh uh yeah can jlc PCB should have all the parts available so you you can have them assemble it automatically for you um and you can order pieces uh five to 50 pieces um um add uh the pick and place option upload the bomb files and they will populate the board for you and and mail them to you LS uh here's a couple of links uh to the G repo to the free pdk and shenzen IO and the last time I checked on Google games um it was on special offer uh on Google games uh for only a couple of dollars um so if you haven't played it uh give it a try uh it's a very nice game yeah so I I can't hear the Herold very [Music] well so I think the Herold is saying that there is quite a few questions Rick and we can't hear the speaker could be flag who who becomes to the SP sorry um sorry for the technical glitch uh where where did you get the board from so I can't hear the speaker and uh I'm guessing he's not on on the stream right now hopefully somebody will notice that soon been uted ah so F finally the director noticed that the speaker was not uh was not available by Audio so there were a few technical problems we have to start over Okay question one where did did you get the board from can you hear me now okay so the board uh comes from the uh Chinese manufacturer jlc PCB and on the GitHub page there are all production files that are needed to order a set of boards yourself if there's a lot of interest uh I could try doing a bug order like 50 pieces um as soon as the microcontrollers are available again and uh order a batch and send them on to people who are interested uh really cool project uh so in my old age uh I might uh might be convinced to actually play around with this so next question is that your first cool project or is that list what what have you done elsewhere I have done a lot the last 10 years I uh am working professionally in product development so uh my hobby projects took the back we on the back burner uh so so I my website is fmatic prototyping um and if you search for that uh you should see a couple of my projects uh so the next logical question is what will you be doing next so I just heard about a project as we were uh as we were talking uh to the operating team there apparently there's a game where you have to defuse a bomb and only one person has the instructions uh I forgot the name but uh it sounded like it would be very nice to build a hardware version of it and only one person has the board and uh has to work on the board and the others uh have to explain to them uh H how to do that over a video conference so uh clearly the next question is by a person uh that uh is very very experienced an assembler uh uh did can would it be possible uh to use the Unicode um minus character um instead of the dash character so it lines up uh well in the editor so yeah I I need to check if the parza can work with that um the the GUI is uh haven't worked on very intensively and um since it's an open source project uh if you want to improve the code editor uh please go ahead uh bring it on yeah the question had a smiley behind it uh so so where where is the open source project uh it's on GitHub uh it's released under the gpl3 license uh here we can see the link uh I can't see the Stream So hopefully it's visible in the Stream and all the source code is there as well for for the board as well as the firmware as well as the uh desktop application it's all open source and you can all do with it whatever you like and uh I would love to see a makeer space uh to create a couple of those and um to use that as an introduction to programming uh that sounds uh like a very nice uh project for K chaos Mak school so another question that comes to mind [Music] um I I wrote to se and I just uh copied some stuff from the documentation and uh because I reimplemented uh all this stuff one to one and he really likes the project and gave me permission to do all of this did you get that in writing yeah I have that in writing sorry and the question uh the elephant in the room question one one finally when is he going finally to ask it how did you make that hat uh so this this has been integrated into my video feed through Snap camera uh Tool uh published by Snapchat and uh I built that from that documentation um there's an example where you can put a crown on your head and basically I edited uh the file and you can see that the the hat is very two-dimensional I haven't rebuilt it as 2D but I like it s camera snap camera all right looks very nice uh here's another question no there aren't any more questions uh I could ask you myself uh are you uh planning to to to like go to schools with this project or do do you want other people to do that but uh you were talking about a bu order yeah um I think I'll add that to the website um just a link to um uh uh for people to express the interest in getting one or two boards and then uh collect all those people and uh uh do a bug order and send them on and uh I I'll add that to the GitHub page um I'm uh active into maker spaces and when we can do uh inperson workshops again then I I would check if uh there's interest in that uh and and uh would get a couple boards uh and uh use them in my maker space yeah it sounds like a really cool project uh especially in the context of K yeah I I noted that down and I'll stay in contact with [Music] you