Circuit Simulation

Under progress..............

In order to download the proteus components library for proteus simulation follow the link..

Follow the youtube link lectures regarding the proteus installation and tutorials.

To avoid crashing your software while running the simulation follow the link.


A website to get more info about the proteus simulation.

A blog link for proteus motor simulation

While doing the schematics, avoid using the net 


while simulating leds in proteus never forget to select the digital model instead of analog i.e. the default value, this can be done by clicking on the leds.


Project-1: LED blinking

  • Basic code generation using STM32CubeMX
  • For code editing, i am using here Keilv5
  • For simulating it on Proteus using STM32F103C6 processor from STMicroelectronics





in the main function's infinite while loop, put the below lines of code for LED blinking operation.

  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_0);
  • HAL_Delay(10);
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
  • HAL_Delay(10);
Project-2: UART



write the code
  • char buffer[]="testing\n\r";
and in the main's while loop:
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_0);
  • HAL_Delay(10);
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
  • HAL_Delay(10);
  • //UART
  • HAL_UART_Transmit(&huart1,(uint8_t *)buffer,sizeof(buffer),1000);
  • HAL_Delay(10);
Project-3: ADC
ADC with DMA is not working on proteus, because proteus does not have model to support the DMA peripheral of micro-controller. Hence, here i will be using the ADC without using the DMA.





Global variables
  • /* USER CODE BEGIN PV */
  • char buffer[]="testing\n\r";
  • char trans_str[64] = {0,};
  • uint16_t adc[1] = {0};
  • /* USER CODE END PV */
Code before the infinite while loop in main()
  •  /* USER CODE BEGIN 2 */
  • HAL_ADC_Start(&hadc1);
  •   /* USER CODE END 2 */
Infinite while loop code
  • /* USER CODE END WHILE */
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_0);
  • //HAL_Delay(5);
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
  • //HAL_Delay(5);
  • //UART
  • HAL_UART_Transmit(&huart1,(uint8_t *)buffer,sizeof(buffer),1000);
  • //HAL_Delay(5);
  • //Reading channel 3
  • HAL_ADC_PollForConversion(&hadc1,10);
  • adc[0] = HAL_ADC_GetValue(&hadc1);
  • snprintf(trans_str, 63, "throtle %d\n\r", (uint16_t)adc[0]);
  •     HAL_UART_Transmit(&huart1, (uint8_t*)trans_str, strlen(trans_str), 1000);
  • //HAL_Delay(5);
Project-4: EXTI
External pin interrupts are used to capture the output events






  • /* USER CODE BEGIN Includes */
  • #include "stdio.h"
  • #include "string.h"
  • /* USER CODE END Includes */


  • /* USER CODE BEGIN PV */
  • char buffer[]="testing\n\r";
  • char trans_str[64] = {0,};
  • uint16_t adc[1] = {0};
  • /* USER CODE END PV */

  • /* USER CODE BEGIN 0 */
  • void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
  • }
  • /* USER CODE END 0 */

  • /* USER CODE BEGIN 2 */
  • HAL_ADC_Start(&hadc1);
  •   /* USER CODE END 2 */


  • /* USER CODE BEGIN 3 */
  • HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_0);
  • //HAL_Delay(5);
  • //UART
  • HAL_UART_Transmit(&huart1,(uint8_t *)buffer,sizeof(buffer),1000);
  • //HAL_Delay(5);
  • //Reading channel 3
  • //HAL_ADC_PollForConversion(&hadc1,10);//will be used in real hardware
  • adc[0] = HAL_ADC_GetValue(&hadc1);
  • snprintf(trans_str, 63, "throtle %d\n\r", (uint16_t)adc[0]);
  •     HAL_UART_Transmit(&huart1, (uint8_t*)trans_str, strlen(trans_str), 1000);
  • //HAL_Delay(5);
Project-5: 3-PWM
Along with the three PWM signals, i have also implemented its control at PA6 pin. Using a button PA6 PWM generationg can be stopped/started. When the button is pressed: PWM will be ON else off.















  • /* USER CODE BEGIN Includes */
  • #include "stdio.h"
  • #include "string.h"
  • /* USER CODE END Includes */

  • /* USER CODE BEGIN PV */
  • char buffer[]="testing\n\r";
  • char trans_str[64] = {0,};
  • uint16_t adc[1] = {0};
  • /* USER CODE END PV */

  • /* USER CODE BEGIN 0 */
  • void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
  • HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_1);
  • }
  • /* USER CODE END 0 */

  • /* USER CODE BEGIN 2 */
  • HAL_ADC_Start(&hadc1);
  • HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
  • HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_2);
  • HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_3);
  •   /* USER CODE END 2 */

  • /* USER CODE BEGIN 3 */
  • TIM1->CCR1=100;
  • TIM1->CCR2=200;
  • TIM1->CCR3=300;
  • HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_0);
  • //HAL_Delay(5);
  • //UART
  • HAL_UART_Transmit(&huart2,(uint8_t *)buffer,sizeof(buffer),1000);
  • //HAL_Delay(5);
  • //Reading channel 3
  • //HAL_ADC_PollForConversion(&hadc1,10);//will be used in real hardware
  • adc[0] = HAL_ADC_GetValue(&hadc1);
  • snprintf(trans_str, 63, "throtle %d\n\r", (uint16_t)adc[0]);
  •     HAL_UART_Transmit(&huart2, (uint8_t*)trans_str, strlen(trans_str), 1000);
  • //HAL_Delay(5);
Project-6:

Comments