I have to go to bed soon, I haven’t been able to get anything working, except that when I click upload in arduino it does say it uploaded the file to the stm32 successfully. However there is no way I have figured out yet to ascertain if it is actually executing the code or not.
A good first start would be to get serial communication with the stm32 working. It’s not safe to do any kind of thing with the motor until I know it’s executing code properly and can do some tests. Again, an indicator led would be good. Right now there could be some kind of problem with my efforts to monitor the serial port or something I can’t know. There could be a problem with the connector or something, the clock may not be set right, which could explain why serial communication isn’t working, as I suppose the baud rate would be wrong. I can’t know, there is no diagnostic information or anything. I can try to figure out some way to toggle a pin or something tomorrow perhaps. or maybe I will take a risk and run some kind of code, maybe lower the voltage on that open loop example, or try to run a closed loop torque mode example later.
However, I need to ascertain the clock rate has been set properly, for which I need serial communication, maybe I should buy a TTL to usb converter. I think I will if I can’t get it going tomorrow, I expected to need one but I thought the stlink had one.
Another problem that arose is that it’s not clear what the minumum and maximum voltages of the lepton are. I see it has a 12 volt step down regulator, it’s not clear what that is for, but I assumed there could be a problem if the input voltage is less than 12 volts because it won’t be able to give it’s 12 volts output. Or if the input is too close to 12 volts. There is passing mention of 30 volts in the documentation, but it’s not clear if that is talking about some subcomponent or the actual input of the board.
This is the code I’m trying to get working:
#include <SimpleFOC.h>
BLDCMotor motor = BLDCMotor(1);
BLDCDriver6PWM driver =
BLDCDriver6PWM(PA8, PA7, PB3,
PB0, PB6, PB1);
float target_velocity = 1.0;
float target_voltage = 2.0;
void setup() {
Serial.setRx(PA15);
Serial.setTx(PA2);
Serial.begin(9600);
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
- in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 8;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
void loop() {
Serial.println(F_CPU);
delay(1);
}
BTW, I noticed in the mosquito documentation that it says not to connect the 3.3 volts line from the microcontroller to the 3.3volt line on the stlink’s SWD port, any ideas why that is? The way they do it with the blue pill seems to be that they connect those two pins together, so the 3.3 volts can supply the microcontroller with power. I did not have the board you used with the mosquito, so I can’t do it that way. I tried the bog standard approach, and it says it programmed the stm32. Maybe it didn’t actually program shit.