<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.robolabo.etsit.upm.es/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rafaels</id>
		<title>RobolaboWiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.robolabo.etsit.upm.es/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rafaels"/>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php/Special:Contributions/Rafaels"/>
		<updated>2026-04-23T11:13:06Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.25.3</generator>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=2040</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=2040"/>
				<updated>2023-03-01T11:23:08Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install STM32CubeIDE and to run a Hello World example, please check it here: http://wiki.robolabo.etsit.upm.es/index.php/Nucleo_Boards&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; GPIO read and write &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Read from a GPIO&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_ReadPin (GPIOA, GPIO_PIN_9);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Write to a GPIO&amp;lt;/h2&amp;gt;&lt;br /&gt;
- High level:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Low level:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Theory &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The encoder used in the laboratory is a position sensor that uses a two-channels hall effect sensor. It is a quadrature encoder that is attached to the motor shaft and which provides a resolution of &amp;lt;b&amp;gt;48 counts per revolution&amp;lt;/b&amp;gt;. This means that, for a complete turn of the motor shaft, the encoder provides a value of 48 counts. The hall sensor requires an input voltage, Vcc. Additionally, the output of the encoder comes from reading the output of the two channels, channel A and channel B, of the hall sensor. These two channels are square waves which are 90º out of phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Encoder Configuration in STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
This section explains how to easily configure an STM32 timer as an encoder with STM32CubeIDE. &lt;br /&gt;
The first step is to select one of the available timers that can be &lt;br /&gt;
The main timers that can be set as PWM are: TIM2, TIM3, TIM4 and TIM5.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; It is recommended to use the timer that matches directly with the pins connected to the encoder of the motor through the H-bridge. &lt;br /&gt;
&lt;br /&gt;
It is very important to configure this timer using the Encoder Mode in the Combined Channels (Channels 1 and 2) of the selected timer.&lt;br /&gt;
Once the timer has been configured as an encoder, we must activate corresponding global interrupt in the NVIC Interrupt Table.&lt;br /&gt;
Other relevant parameters are:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parameter to set the value of the ARR register. It represents the max. value of the timer's counter before reset. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Encoder Mode:&amp;lt;/b&amp;gt;Should be set to &amp;quot;Encoder Mode TI1 and TI2&amp;quot; for handling both encoder channels.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once configured, we should start the timer as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;HAL_TIM_Encoder_Start_IT(&amp;amp;htimx, TIM_CHANNEL_ALL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Additionally, we have to code a callback function that is executed every time the interrupt is activated. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim){&lt;br /&gt;
// Rellenar &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The current value of the counter can be accessed though the following function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
__HAL_TIM_GET_COUNTER(htim)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where htimX is the instance of the timer X used as encoder (e.g. htim2 or htim3).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Theory &amp;lt;/h2&amp;gt;&lt;br /&gt;
One method that is often used to control the speed of a DC motor is the Pulse Width Modulation (PWM) method. The speed of the electric motor depends on the modulator voltage. The greater the voltage, the faster the rotation of an electric motor. The use of this PWM can be used to control motor rotation through changes in PWM duty cycle or PWM pulse width. When the duty cycle is 0%, the motor will stop completely. When the duty cycle is 50%, the motor will rotate at half the speed of the maximum speed and when the PWM is 100%, the motor rotates with maximum speed. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Main registers &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prescaler is a register that divides the timer clock frequency to obtain a specific frequency.&lt;br /&gt;
Specifically, the frequency reduction is applied using the following formula:  &lt;br /&gt;
&lt;br /&gt;
f_TMR = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Therefore, if the frequency to set is the same as the frequency of the clock, the PSC register must be set at PSC=0.&lt;br /&gt;
The STM32 timers allow a prescaler value up to 65535, through 16 bits registers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) and Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
The ARR register storages the maximum value that the counter can reach before going back to zero. &lt;br /&gt;
Moreover, the CCR registers the value of the corresponding timer counter after which the output PWM signal goes from high to low level. &lt;br /&gt;
Every channel of the timer used to generate the PWM will have a different CCR register (for example, CCR1 and CCR2 for channels 1 and 2).&lt;br /&gt;
In this way, the value of the CCR together with the value of the ARR define the width of the pulses and, therefore, the duty cycle of the PWM signal:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
This is the register that storages the value of the counter used to generate the PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;PWM Configuration in STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To configure a timer as PWM, the first thing to do is to select one of the timers that could be configured as a PWM generator. &lt;br /&gt;
Additionally, also the channels that will be used as PWM output must be decided. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; As different PWM outputs are needed, it is recommended to use different channels of the same timer to the extent possible.&lt;br /&gt;
&lt;br /&gt;
The main timers that can be set as PWM are: TIM2, TIM3, TIM4 and TIM5, with 4 different channels each of them. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; It is recommended to use the timer and the corresponding channels that match directly with the pins that feed the H-bridge to modulate the speed of the motor. Otherwise, the PWM output signals must be bridged with the H-bridge input signals. &lt;br /&gt;
&lt;br /&gt;
Therefore, the pins that the channels of the timer are using need to be checked in the &amp;quot;Pinout&amp;quot; section of the STM32CubeIDE.&lt;br /&gt;
&lt;br /&gt;
Once the channels of the timer have been activated, some parameters and the configuration of the timer must be changed. &lt;br /&gt;
&lt;br /&gt;
Main parameters:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Clock Source:&amp;lt;/b&amp;gt; Clock of the timer. The Internal clock option must be selected. Moreover, it must be checked that the frequency of the clock that is being used is the one desired. This could be checked within the clock configuration tab of the STM32CubeIDE. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Channel x:&amp;lt;/b&amp;gt; Configuration for the channel x of the timer. The option “PWM Generation CHx” must be selected, in which x will be the number of the channel to configure.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Prescaler (PSC):&amp;lt;/b&amp;gt; Parameter to introduce the value of the PSC register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parameter to set the value of the ARR register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Pulse (16 bits):&amp;lt;/b&amp;gt; Parameter to mofidy the CCR register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Mode: &amp;lt;/b&amp;gt; The PWM mode 1 must be selected.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, within the code, the timer to use must be initialized following the structure below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_TIM_PWM_Start(&amp;amp;htim3, TIM_CHANNEL_1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The CCR value can be modified by introducing the following instruction: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR1 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which CCR1 indicates that we are accessing to the channel 1 register, new_ccr is the new to set and htimx refers to the timer x (for example, htim2 or htim3).&lt;br /&gt;
&lt;br /&gt;
In the same way, to modify the register of the channel 2: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR2 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Serial Port &amp;lt;/h1&amp;gt;&lt;br /&gt;
In STM32CubeIDE we can enable the UART serial port communication of the STM32 by activating the corresponding USART_TX and USART_RX pins in the Pinout View. &lt;br /&gt;
Then, we can transmit data as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
uint8_t msg[] = &amp;quot;Hello World !!!\r\n&amp;quot;;&lt;br /&gt;
HAL_UART_Transmit(&amp;amp;huart1,msg,sizeof(msg),10);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the execution, in order to read the sent data in our computer, we have to configure a console terminal as Serial Port. We recommend to set up the native console in STM32CubeIDE, selecting the correct USB serial port and fixing the desired baud rate and data size.&lt;br /&gt;
Command Shell Console&amp;quot;. In the console configuration we create a new connection.&lt;br /&gt;
&lt;br /&gt;
In order to enable the transmission of float data, the setting &amp;quot;use float&amp;quot; must be enabled in the config route &amp;quot;Project/Properties/C/C++Build/Settings/MCU Settings&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=2039</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=2039"/>
				<updated>2023-03-01T08:23:29Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install STM32CubeIDE and to run a Hello World example, please check it here: http://wiki.robolabo.etsit.upm.es/index.php/Nucleo_Boards&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; GPIO read and write &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Read from a GPIO&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_ReadPin (GPIOA, GPIO_PIN_9);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Write to a GPIO&amp;lt;/h2&amp;gt;&lt;br /&gt;
- High level:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Low level:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Theory &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The encoder used in the laboratory is a position sensor that uses a two-channels hall effect sensor. It is a quadrature encoder that is attached to the motor shaft and which provides a resolution of &amp;lt;b&amp;gt;48 counts per revolution&amp;lt;/b&amp;gt;. This means that, for a complete turn of the motor shaft, the encoder provides a value of 48 counts. The hall sensor requires an input voltage, Vcc. Additionally, the output of the encoder comes from reading the output of the two channels, channel A and channel B, of the hall sensor. These two channels are square waves which are 90º out of phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Encoder Configuration in STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
This section explains how to easily configure an STM32 timer as an encoder with STM32CubeIDE. &lt;br /&gt;
The first step is to select one of the available timers that can be &lt;br /&gt;
The main timers that can be set as PWM are: TIM2, TIM3, TIM4 and TIM5.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; It is recommended to use the timer that matches directly with the pins connected to the encoder of the motor through the H-bridge. &lt;br /&gt;
&lt;br /&gt;
It is very important to configure this timer using the Encoder Mode in the Combined Channels (Channels 1 and 2) of the selected timer.&lt;br /&gt;
Once the timer has been configured as an encoder, we must activate corresponding global interrupt in the NVIC Interrupt Table.&lt;br /&gt;
Other relevant parameters are:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parameter to set the value of the ARR register. It represents the max. value of the timer's counter before reset. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Encoder Mode:&amp;lt;/b&amp;gt;Should be set to &amp;quot;Encoder Mode TI1 and TI2&amp;quot; for handling both encoder channels.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once configured, we should start the timer as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;HAL_TIM_Encoder_Start_IT(&amp;amp;htimx, TIM_CHANNEL_ALL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Additionally, we have to code a callback function that is executed every time the interrupt is activated. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim){&lt;br /&gt;
// Rellenar &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The current value of the counter can be accessed though the following function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
__HAL_TIM_GET_COUNTER(htim)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where htimX is the instance of the timer X used as encoder (e.g. htim2 or htim3).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Theory &amp;lt;/h2&amp;gt;&lt;br /&gt;
One method that is often used to control the speed of a DC motor is the Pulse Width Modulation (PWM) method. The speed of the electric motor depends on the modulator voltage. The greater the voltage, the faster the rotation of an electric motor. The use of this PWM can be used to control motor rotation through changes in PWM duty cycle or PWM pulse width. When the duty cycle is 0%, the motor will stop completely. When the duty cycle is 50%, the motor will rotate at half the speed of the maximum speed and when the PWM is 100%, the motor rotates with maximum speed. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Main registers &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prescaler is a register that divides the timer clock frequency to obtain a specific frequency.&lt;br /&gt;
Specifically, the frequency reduction is applied using the following formula:  &lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Therefore, if the frequency to set is the same as the frequency of the clock, the PSC register must be set at PSC=0.&lt;br /&gt;
The STM32 timers allow a prescaler value up to 65535, through 16 bits registers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) and Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
The ARR register storages the maximum value that the counter can reach before going back to zero. &lt;br /&gt;
Moreover, the CCR registers the value of the corresponding timer counter after which the output PWM signal goes from high to low level. &lt;br /&gt;
Every channel of the timer used to generate the PWM will have a different CCR register (for example, CCR1 and CCR2 for channels 1 and 2).&lt;br /&gt;
In this way, the value of the CCR together with the value of the ARR define the width of the pulses and, therefore, the duty cycle of the PWM signal:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
This is the register that storages the value of the counter used to generate the PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;PWM Configuration in STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To configure a timer as PWM, the first thing to do is to select one of the timers that could be configured as a PWM generator. &lt;br /&gt;
Additionally, also the channels that will be used as PWM output must be decided. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; As different PWM outputs are needed, it is recommended to use different channels of the same timer to the extent possible.&lt;br /&gt;
&lt;br /&gt;
The main timers that can be set as PWM are: TIM2, TIM3, TIM4 and TIM5, with 4 different channels each of them. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; It is recommended to use the timer and the corresponding channels that match directly with the pins that feed the H-bridge to modulate the speed of the motor. Otherwise, the PWM output signals must be bridged with the H-bridge input signals. &lt;br /&gt;
&lt;br /&gt;
Therefore, the pins that the channels of the timer are using need to be checked in the &amp;quot;Pinout&amp;quot; section of the STM32CubeIDE.&lt;br /&gt;
&lt;br /&gt;
Once the channels of the timer have been activated, some parameters and the configuration of the timer must be changed. &lt;br /&gt;
&lt;br /&gt;
Main parameters:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Clock Source:&amp;lt;/b&amp;gt; Clock of the timer. The Internal clock option must be selected. Moreover, it must be checked that the frequency of the clock that is being used is the one desired. This could be checked within the clock configuration tab of the STM32CubeIDE. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Channel x:&amp;lt;/b&amp;gt; Configuration for the channel x of the timer. The option “PWM Generation CHx” must be selected, in which x will be the number of the channel to configure.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Prescaler (PSC):&amp;lt;/b&amp;gt; Parameter to introduce the value of the PSC register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parameter to set the value of the ARR register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Pulse (16 bits):&amp;lt;/b&amp;gt; Parameter to mofidy the CCR register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Mode: &amp;lt;/b&amp;gt; The PWM mode 1 must be selected.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, within the code, the timer to use must be initialized following the structure below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_TIM_PWM_Start(&amp;amp;htim3, TIM_CHANNEL_1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The CCR value can be modified by introducing the following instruction: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR1 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which CCR1 indicates that we are accessing to the channel 1 register, new_ccr is the new to set and htimx refers to the timer x (for example, htim2 or htim3).&lt;br /&gt;
&lt;br /&gt;
In the same way, to modify the register of the channel 2: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR2 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Serial Port &amp;lt;/h1&amp;gt;&lt;br /&gt;
In STM32CubeIDE we can enable the UART serial port communication of the STM32 by activating the corresponding USART_TX and USART_RX pins in the Pinout View. &lt;br /&gt;
Then, we can transmit data as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
uint8_t msg[] = &amp;quot;Hello World !!!\r\n&amp;quot;;&lt;br /&gt;
HAL_UART_Transmit(&amp;amp;huart1,msg,sizeof(msg),10);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the execution, in order to read the sent data in our computer, we have to configure a console terminal as Serial Port. We recommend to set up the native console in STM32CubeIDE, selecting the correct USB serial port and fixing the desired baud rate and data size.&lt;br /&gt;
Command Shell Console&amp;quot;. In the console configuration we create a new connection.&lt;br /&gt;
&lt;br /&gt;
In order to enable the transmission of float data, the setting &amp;quot;use float&amp;quot; must be enabled in the config route &amp;quot;Project/Properties/C/C++Build/Settings/MCU Settings&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=2038</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=2038"/>
				<updated>2023-03-01T08:21:23Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install STM32CubeIDE and to run a Hello World example, please check it here: http://wiki.robolabo.etsit.upm.es/index.php/Nucleo_Boards&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; GPIO read and write &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Read from a GPIO&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_ReadPin (GPIOA, GPIO_PIN_9);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Write to a GPIO&amp;lt;/h2&amp;gt;&lt;br /&gt;
- High level:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Low level:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Theory &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The encoder used in the laboratory is a position sensor that uses a two-channels hall effect sensor. It is a quadrature encoder that is attached to the motor shaft and which provides a resolution of &amp;lt;b&amp;gt;48 counts per revolution&amp;lt;/b&amp;gt;. This means that, for a complete turn of the motor shaft, the encoder provides a value of 48 counts. The hall sensor requires an input voltage, Vcc. Additionally, the output of the encoder comes from reading the output of the two channels, channel A and channel B, of the hall sensor. These two channels are square waves which are 90º out of phase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Encoder Configuration in STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
This section explains how to easily configure an STM32 timer as an encoder with STM32CubeIDE. &lt;br /&gt;
The first step is to select one of the available timers that can be &lt;br /&gt;
The main timers that can be set as PWM are: TIM2, TIM3, TIM4 and TIM5.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; It is recommended to use the timer that matches directly with the pins connected to the encoder of the motor through the H-bridge. &lt;br /&gt;
&lt;br /&gt;
It is very important to configure this timer using the Encoder Mode in the Combined Channels (Channels 1 and 2) of the selected timer.&lt;br /&gt;
Once the timer has been configured as an encoder, we must activate corresponding global interrupt in the NVIC Interrupt Table.&lt;br /&gt;
Other relevant parameters are:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parameter to set the value of the ARR register. It represents the max. value of the timer's counter before reset. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Encoder Mode:&amp;lt;/b&amp;gt;Should be set to &amp;quot;Encoder Mode TI1 and TI2&amp;quot; for handling both encoder channels.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once configured, we should start the timer as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;HAL_TIM_Encoder_Start_IT(&amp;amp;htimx, TIM_CHANNEL_ALL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Additionally, we have to code a callback function that is executed every time the interrupt is activated. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim){&lt;br /&gt;
// Rellenar &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The current value of the counter can be accessed though the following function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
__HAL_TIM_GET_COUNTER(htim)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where htimX is the instance of the timer X used as encoder (e.g. htim2 or htim3).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Theory &amp;lt;/h2&amp;gt;&lt;br /&gt;
One method that is often used to control the speed of a DC motor is the Pulse Width Modulation (PWM) method. The speed of the electric motor depends on the modulator voltage. The greater the voltage, the faster the rotation of an electric motor. The use of this PWM can be used to control motor rotation through changes in PWM duty cycle or PWM pulse width. When the duty cycle is 0%, the motor will stop completely. When the duty cycle is 50%, the motor will rotate at half the speed of the maximum speed and when the PWM is 100%, the motor rotates with maximum speed. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Main registers &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The prescaler is a register that divides the timer clock frequency to obtain a specific frequency.&lt;br /&gt;
Specifically, the frequency reduction is applied using the following formula:  &lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Therefore, if the frequency to set is the same as the frequency of the clock, the PSC register must be set at PSC=0.&lt;br /&gt;
The STM32 timers allow a prescaler value up to 65535, through 16 bits registers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) and Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
The ARR register storages the maximum value that the counter can reach before going back to zero. &lt;br /&gt;
Moreover, the CCR registers the value of the corresponding timer counter after which the output PWM signal goes from high to low level. &lt;br /&gt;
Every channel of the timer used to generate the PWM will have a different CCR register (for example, CCR1 and CCR2 for channels 1 and 2).&lt;br /&gt;
In this way, the value of the CCR together with the value of the ARR define the width of the pulses and, therefore, the duty cycle of the PWM signal:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
This is the register that storages the value of the counter used to generate the PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;PWM Configuration in STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To configure a timer as PWM, the first thing to do is to select one of the timers that could be configured as a PWM generator. &lt;br /&gt;
Additionally, also the channels that will be used as PWM output must be decided. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; As different PWM outputs are needed, it is recommended to use different channels of the same timer to the extent possible.&lt;br /&gt;
&lt;br /&gt;
The main timers that can be set as PWM are: TIM2, TIM3, TIM4 and TIM5, with 4 different channels each of them. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Advice:&amp;lt;/b&amp;gt; It is recommended to use the timer and the corresponding channels that match directly with the pins that feed the H-bridge to modulate the speed of the motor. Otherwise, the PWM output signals must be bridged with the H-bridge input signals. &lt;br /&gt;
&lt;br /&gt;
Therefore, the pins that the channels of the timer are using need to be checked in the &amp;quot;Pinout&amp;quot; section of the STM32CubeIDE.&lt;br /&gt;
&lt;br /&gt;
Once the channels of the timer have been activated, some parameters and the configuration of the timer must be changed. &lt;br /&gt;
&lt;br /&gt;
Main parameters:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Clock Source:&amp;lt;/b&amp;gt; Clock of the timer. The Internal clock option must be selected. Moreover, it must be checked that the frequency of the clock that is being used is the one desired. This could be checked within the clock configuration tab of the STM32CubeIDE. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Channel x:&amp;lt;/b&amp;gt; Configuration for the channel x of the timer. The option “PWM Generation CHx” must be selected, in which x will be the number of the channel to configure.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Prescaler (PSC):&amp;lt;/b&amp;gt; Parameter to introduce the value of the PSC register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parameter to set the value of the ARR register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Pulse (16 bits):&amp;lt;/b&amp;gt; Parameter to mofidy the CCR register.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Mode: &amp;lt;/b&amp;gt; The PWM mode 1 must be selected.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, within the code, the timer to use must be initialized following the structure below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_TIM_PWM_Start(&amp;amp;htim3, TIM_CHANNEL_1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The CCR value can be modified by introducing the following instruction: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR1 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which CCR1 indicates that we are accessing to the channel 1 register, new_ccr is the new to set and htimx refers to the timer x (for example, htim2 or htim3).&lt;br /&gt;
&lt;br /&gt;
In the same way, to modify the register of the channel 2: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR2 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Serial Port &amp;lt;/h1&amp;gt;&lt;br /&gt;
In STM32CubeIDE we can enable the UART serial port communication of the STM32 by activating the corresponding USART_TX and USART_RX pins in the Pinout View. &lt;br /&gt;
Then, we can transmit data as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
uint8_t msg[] = &amp;quot;Hello World !!!\r\n&amp;quot;;&lt;br /&gt;
HAL_UART_Transmit(&amp;amp;huart1,msg,sizeof(msg),10);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the execution, in order to read the sent data in our computer, we have to configure a console terminal as Serial Port. We recommend to set up the native console in STM32CubeIDE, selecting the correct USB serial port and fixing the desired baud rate and data size.&lt;br /&gt;
Command Shell Console&amp;quot;. In the console configuration we create a new connection.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=679</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=679"/>
				<updated>2023-02-05T17:33:56Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Lectura&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_ReadPin (GPIOA, GPIO_PIN_9);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Escritura&amp;lt;/h2&amp;gt;&lt;br /&gt;
- A nivel alto:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- A nivel bajo:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de encoder en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Consejo:&amp;lt;/b&amp;gt; Al usar varias salidas PWM es recomendable usar diferentes canales del mismo timer en la medida de lo posible.&lt;br /&gt;
&lt;br /&gt;
Los principales timers configurables como PWM son el TIM2, TIM3, TIM4 y TIM5, con 4 canales independientes cada uno. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Consejo:&amp;lt;/b&amp;gt;  Es recomendable usar el timer y los canales que se correspondan directamente con los pines que alimentan las entradas del Puente H para modular la velocidad del motor. En caso contrario deberemos puentear las salidas del timer PWM con las entradas del puente H.&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, deberemos buscar los pines asociados a los canales del timer a usar en la vista “Pinout” del entorno de desarrollo.&lt;br /&gt;
&lt;br /&gt;
Una vez hemos activado los canales del timer necesarios, debemos modificar la configuración y parámetros del timer.&lt;br /&gt;
Los principales parámetros&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Clock Source:&amp;lt;/b&amp;gt; reloj a tomar como referencia por el timer. Debemos seleccionar la opción Internal clock. Además, debemos asegurarnos que la frecuencia del reloj usada es la deseada, en la pestaña de clock configuration.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Channel x:&amp;lt;/b&amp;gt; configuración deseada para el canal x del timer. Debemos seleccionar la opción “PWM Generation CHx”, donde x será el número del canal en cuestión.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Prescaler (PSC):&amp;lt;/b&amp;gt; Parámetro para configurar el registro de PSC.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parámetro para configurar el valor del registro ARR.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Pulse (16 bits):&amp;lt;/b&amp;gt; parámetro para modificar el registro de CCR.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Mode: &amp;lt;/b&amp;gt; Debemos seleccionar PWM mode 1.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Además, en nuestro código debemos activar el timer ya configurado e inicializado de la siguiente manera:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_TIM_PWM_Start(&amp;amp;htim3, TIM_CHANNEL_1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Podemos modificar el valor de CCR (aceder al registro) mediante código de la siguiente manera:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR1 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
donde CCR1 indica que estamos accediendo al registro del canal 1, new_ccr es el nuevo valor entero que queremos establecer y htimx es la instancia correspondiente al timer x (por ejemplo, htim2 o htim3).&lt;br /&gt;
&lt;br /&gt;
De igual manera, para modificar el registro del canal 2: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR2 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=678</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=678"/>
				<updated>2023-02-05T17:30:08Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Consejo:&amp;lt;/b&amp;gt; Al usar varias salidas PWM es recomendable usar diferentes canales del mismo timer en la medida de lo posible.&lt;br /&gt;
&lt;br /&gt;
Los principales timers configurables como PWM son el TIM2, TIM3, TIM4 y TIM5, con 4 canales independientes cada uno. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Consejo:&amp;lt;/b&amp;gt;  Es recomendable usar el timer y los canales que se correspondan directamente con los pines que alimentan las entradas del Puente H para modular la velocidad del motor. En caso contrario deberemos puentear las salidas del timer PWM con las entradas del puente H.&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, deberemos buscar los pines asociados a los canales del timer a usar en la vista “Pinout” del entorno de desarrollo.&lt;br /&gt;
&lt;br /&gt;
Una vez hemos activado los canales del timer necesarios, debemos modificar la configuración y parámetros del timer.&lt;br /&gt;
Los principales parámetros&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Clock Source:&amp;lt;/b&amp;gt; reloj a tomar como referencia por el timer. Debemos seleccionar la opción Internal clock. Además, debemos asegurarnos que la frecuencia del reloj usada es la deseada, en la pestaña de clock configuration.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Channel x:&amp;lt;/b&amp;gt; configuración deseada para el canal x del timer. Debemos seleccionar la opción “PWM Generation CHx”, donde x será el número del canal en cuestión.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Prescaler (PSC):&amp;lt;/b&amp;gt; Parámetro para configurar el registro de PSC.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parámetro para configurar el valor del registro ARR.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Pulse (16 bits):&amp;lt;/b&amp;gt; parámetro para modificar el registro de CCR.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Mode: &amp;lt;/b&amp;gt; Debemos seleccionar PWM mode 1.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Además, en nuestro código debemos activar el timer ya configurado e inicializado de la siguiente manera:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HAL_TIM_PWM_Start(&amp;amp;htim3, TIM_CHANNEL_1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Podemos modificar el valor de CCR (aceder al registro) mediante código de la siguiente manera:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR1 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
donde CCR1 indica que estamos accediendo al registro del canal 1, new_ccr es el nuevo valor entero que queremos establecer y htimx es la instancia correspondiente al timer x (por ejemplo, htim2 o htim3).&lt;br /&gt;
&lt;br /&gt;
De igual manera, para modificar el registro del canal 2: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
htimx.Instance-&amp;gt;CCR2 = new_ccr;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=677</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=677"/>
				<updated>2023-02-05T17:25:26Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Consejo:&amp;lt;/b&amp;gt; Al usar varias salidas PWM es recomendable usar diferentes canales del mismo timer en la medida de lo posible.&lt;br /&gt;
&lt;br /&gt;
Los principales timers configurables como PWM son el TIM2, TIM3, TIM4 y TIM5, con 4 canales independientes cada uno. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Consejo:&amp;lt;/b&amp;gt;  Es recomendable usar el timer y los canales que se correspondan directamente con los pines que alimentan las entradas del Puente H para modular la velocidad del motor. En caso contrario deberemos puentear las salidas del timer PWM con las entradas del puente H.&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, deberemos buscar los pines asociados a los canales del timer a usar en la vista “Pinout” del entorno de desarrollo.&lt;br /&gt;
&lt;br /&gt;
Una vez hemos activado los canales del timer necesarios, debemos modificar la configuración y parámetros del timer.&lt;br /&gt;
Los principales parámetros&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Clock Source:&amp;lt;/b&amp;gt; reloj a tomar como referencia por el timer. Debemos seleccionar la opción Internal clock. Además, debemos asegurarnos que la frecuencia del reloj usada es la deseada, en la pestaña de clock configuration.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Channel x:&amp;lt;/b&amp;gt; configuración deseada para el canal x del timer. Debemos seleccionar la opción “PWM Generation CHx”, donde x será el número del canal en cuestión.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Prescaler (PSC):&amp;lt;/b&amp;gt; Parámetro para configurar el registro de PSC.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Counter Period:&amp;lt;/b&amp;gt; Parámetro para configurar el valor del registro ARR.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Pulse (16 bits):&amp;lt;/b&amp;gt; parámetro para modificar el registro de CCR.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt;Mode: &amp;lt;/b&amp;gt; Debemos seleccionar PWM mode 1.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=676</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=676"/>
				<updated>2023-02-05T17:13:11Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
{{mbox}} &lt;br /&gt;
# header&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Template:Warning&amp;diff=675</id>
		<title>Template:Warning</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Template:Warning&amp;diff=675"/>
				<updated>2023-02-05T17:09:12Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: Created page with &amp;quot;This is a test&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a test&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=674</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=674"/>
				<updated>2023-02-05T17:07:55Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=673</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=673"/>
				<updated>2023-02-05T17:06:06Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
wfLoadExtension( 'Math' );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;/alpha&amp;lt;/math&amp;gt;&lt;br /&gt;
{{warning|1=Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.}} &lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=672</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=672"/>
				<updated>2023-02-05T17:02:32Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; CNT &amp;lt;/h3&amp;gt;&lt;br /&gt;
Es el registro que almacena el valor actual del contador usado para la generación PWM. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Configuración de PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Para configurar el timer como PWM primero debemos seleccionar uno de los posibles timers configurables como generador PWM. &lt;br /&gt;
También debemos decidir los canles que queremos usar como salidas PWM.&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=671</id>
		<title>Nucleo Boards for Control Systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=Nucleo_Boards_for_Control_Systems&amp;diff=671"/>
				<updated>2023-02-05T16:58:36Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Lectura y escritura de pines &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; Encoder &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt; PWM &amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Teoría &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Principales registros &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Prescaler (PSC) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El preescalado es un registro que especifica entre cuánto se debe dividir la frecuencia de referencia del reloj usado por el timer.&lt;br /&gt;
En concreto, la reducción  de frecuencia se aplica de la siguiente manera:&lt;br /&gt;
&lt;br /&gt;
f_PWM = f_CLK / (PSC + 1)&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, hay que tener en cuenta que si queremos mantener la misma frecuencia que la del reloj de referencia debemos fijar PSC=0.&lt;br /&gt;
Los timers del STM32 admiten valores de preescalado de hasta 65535, mediante registros de 16 bits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Auto Reload Register (ARR) y Capture Compare Register (CCR) &amp;lt;/h3&amp;gt;&lt;br /&gt;
El registro ARR almacena el valor máximo que debe alcanzar el contador antes de volver a cero. &lt;br /&gt;
Por otra parte, CCR registra valor del contador del timer asociado a partir del cual la señal PWM de salida pasa de nivel alto a nivel bajo. &lt;br /&gt;
Cada canal del timer usado para la generación de señal PWM tendrá un registro CCR diferente (por ejemplo CCR1 y CCR para canales 1 y 2). &lt;br /&gt;
De esta manera, el valor de CCR junto con el valor de ARR definen la anchura de los pulsos y con ello el ciclo de trabajo de la señal PWM:&lt;br /&gt;
&lt;br /&gt;
Duty_Cycle (%) = 100 * (CCR / ARR)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Configuración PWM en STM32CubeIDE&amp;lt;/h2&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	<entry>
		<id>https://wiki.robolabo.etsit.upm.es/index.php?title=GPU_server&amp;diff=648</id>
		<title>GPU server</title>
		<link rel="alternate" type="text/html" href="https://wiki.robolabo.etsit.upm.es/index.php?title=GPU_server&amp;diff=648"/>
				<updated>2019-09-30T17:14:13Z</updated>
		
		<summary type="html">&lt;p&gt;Rafaels: Created page with &amp;quot;&amp;lt;h1&amp;gt; Workspaces and Gnome Extensions &amp;lt;/h1&amp;gt; &amp;lt;ul&amp;gt; &amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt; gnome-tweak-tool &amp;lt;/b&amp;gt; for defining static workspaces and see gnome shell extensions &amp;lt;/li&amp;gt; &amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt; Workspace G...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt; Workspaces and Gnome Extensions &amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt; gnome-tweak-tool &amp;lt;/b&amp;gt; for defining static workspaces and see gnome shell extensions &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt; Workspace Grid &amp;lt;/b&amp;gt; extension for arrange in Grid &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt;topicon &amp;lt;/b&amp;gt; extension to remove strange sidebards and put icons on top bar &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt; frippery bottom panel &amp;lt;/b&amp;gt; to have the bottom panel &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Use &amp;lt;b&amp;gt; Launch new instance &amp;lt;/b&amp;gt; to not group windows &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Alternate Tab&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Applications Menu&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; system-monitor&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rafaels</name></author>	</entry>

	</feed>