 Ok, now we are starting with firmware architecture, how to use our library, for me important part and at the end of the day we will finish with some tips and tricks etc. Or you can have a look to the document. Part about firmware architecture, firmware structure, firmware organization. It's a bit change from the previous library because now we are based on the AHL library and our software development team define some different way how to look to the application. We have this part when it's a user interface library, it's mean some user communication with the protocol LCD display or DAC output. That's some debug functionality which is not really necessary to use in real application. That's our part of user interface. Then they name the control like cockpit and the last one is motor control library. The motor control cockpit, the most important part is and contains also is three parts, first it's some interface. Motor control interface, we have two motors, we need start bows etc. Then we have some configuration part, small part but important we have to set up somehow our library, our peripheries. And last part it's some dynamics with some loops and it's handled with some FOC task, high frequency, motor control medium and some safety part. That's all about the structure, that's quite simplify and now we switch to the API application programming interface. What is the application programming interface? Setup of functions, some definition of some structure or some variables etc. Some interaction between your code and our library. It's exactly what is in this slide, we have some motor control, firmware, our library and we have to send some command, receive some information, some data from the application. We can split to two sections, one is some motor control user interface, that's some basic level how to start the motor etc. And second one is some lower level programming interface. For example, we can start motor, stop motor, we already know that inside the library it's some RAM generator for the speed. And we can program, set up some parameters of this speed RAM controller. And then we can go deeply to some a bit hidden stuff like PID regulators and we can set up some parameter of this regulator, that's necessary interface for that. Motor control interface contains two types of functions and it's good to know it. One it's buffered, that's first part and second one it's non-buffered. And different it's simply if we run buffered command for example execute, no execute. Program speed RAM, that's not execution, let's prepare some condition about the required RAM. We want to be at the exact speed defined in this function after some time. And that's our definition, it will be stored and in the time where it's possible use it. If it's motor running, not in the open loop, in closed loop we can use it. It is buffered and we use this value when it's possible. And second one react quite immediately, that it's start motor, stop motor. But to be sure that it's not react exactly immediately, maybe acknowledge react immediately because it's clear some flag, which define that something happen that could be immediately. But start motor define some flag that after this command the library which is running on the interrupt service routine initiate the section what is necessary, switch on the PWM generation etc. That it takes some time and for that it's not reaction immediately but it's executed immediately. Then one part with example of interface, motor control interface, which is the top level. We have received request mostly from China that our code is quite complex, it's difficult to use it. And for that our development team define this level of programming interface, which is quite similar. And define it like this one that contains only the necessary parameters. Finale, speed and ramp duration and rest is described in the name. That's the different. And second group is quite in the old start, but it is again quite simplified. And it's contains also some pointer to some structure, which is used inside. It's running on some structures, which is used in this case for the PI speed regulator and you have for that handle. You can find what is possible use inside in some mcconfig.h file. There is list definition because it's header file of the external variables and you can use it. There is about speed regulator, current regulator, temperature sensing, bus voltage, all stuff it's inside. And you can find what can you use inside. And it's this one, please don't forget use this one, because if you don't use include, you don't know this link and you have to type this include of this header. OK, again highlight variable formats, because in most cases customer forgot it and make it some disadvantage for that. Two formats for the speed in zero point hertz or in pulse per PWM cycle. And you have to recalculate through this equal at the end, it's multiplying, dividing by six, that's simple calculation. And for the speed ramp you have to remember taking account that we use milliseconds. And last one is digital per PWM. And last one, we maybe touch some time with the playing in the, with the workbench that our torque current inside the online tool, it's in some units that's not current in milliamps or amps. That's in the some internal unit that's signet, signet integer. And you can calculate from the definition from power stage, which is contains shunt value gain of the network and the VDD of micro. That's all you have to take in account. In our case it's good luck because we have power stage with current range, which is up to 3.268 and the range of 16 bit integer, it's 32, 76 and etc. That's only decimal point, that's good luck that we can imagine current really directly from the number. But in real life you will have bad luck and you have to calculate. But for today we have this case. Ok, there is some example of code, you see some not logic step in this code. What will be happen? Then stop, immediately cancel the start. Then it's nice in this example, it's that there is a possible see what we have inside that the NTC star, the all functionality about NTC start with NTC underscore about the PID regulator again. The common functions it start with MC, bus voltage sensing and etc. That's good to know and you can easily find it. Ok, we have some help file, which is in the section documentation and you have find all functions in the library with the description. This file is generated from the source code, you can find the same command in the source code and it is on your decision if you want to use help file or search in the project. Both is possible and you will find the same information. Ok, then we have about 2 hours and because we usually have lunch at 12 o'clock and we start with first part. We will see what is your possibility, how fast we can go through the examples and we will start now with the examples. We have just before, we have some slides about hands-on and example projects. First part it's because it's usually engineers learn from examples and copy-paste. It's a nice way to make own code but to be sure to make some not good step. For the learning it's good to have example, try play with them, modify. For that we have examples in the structure which is the same folder like installation folder in program files. We can find there some examples. First example it's quite similar to our first testing example but a bit simpler. It's use speed ramp and repeatedly start the motor with some slope and after some time stop the motor. Example it's prepared for combination Nucleo 303RE with our power stage AHM 07 with bulk running motor. That's only control part, it's different but I think it's easy to take the C code and use it also with this board. Then we have second example which is most close to our testing firmware with the potentiometer. And with this example you can find some technique how to use some state machine, how to take value information from the system state that it's running or something else. And this example simply use analog input, that's good information from this example that we can use the same ADC converter for the user channel. It's necessary to take micro with more ADCs if I want to define through the potentiometer position my speed. I can use the same, use only different input and my motor control library on the background take care about this one which is not time critical. And in this example it's how to handle reading of the bus voltage that we have to define some channel and then we can take result of the conversion.