

Thank you, Slipy, for the hardware development! :thumb:Slipy said:I saw the firmware Lishui foc
Yes, the next versions will definitely be. But this is a beta version, for testing the firmware.john61ct said:Yes please open source everything.
Even better, get a batch of boards made, set up a detailed BoM for automated ordering, detailed howto for noobs
so anyone can get hands-on for testing and feedback!
Will you be iterating further versions?
these things are "nice to have" but not really necessary. A sensorless branch based on the observer used in the VESC project already exists, resistance and inductance are set in the config.h at the moment.Slipy said:for example, measuring the resistance and inductance of the motor
/* ADC1 init function */
static void MX_ADC1_Init(void)
{
ADC_MultiModeTypeDef multimode;
ADC_InjectionConfTypeDef sConfigInjected;
ADC_ChannelConfTypeDef sConfig;
/**Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; //Scan muß für getriggerte Wandlung gesetzt sein
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;// Trigger regular ADC with timer 3 ADC_EXTERNALTRIGCONV_T1_CC1;// // ADC_SOFTWARE_START; //
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 7;
hadc1.Init.NbrOfDiscConversion = 0;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure the ADC multi-mode
*/
multimode.Mode = ADC_DUALMODE_REGSIMULT_INJECSIMULT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Injected Channel
*/
sConfigInjected.InjectedChannel = ADC_CHANNEL_4;
sConfigInjected.InjectedRank = ADC_INJECTED_RANK_1;
sConfigInjected.InjectedNbrOfConversion = 1;
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_1CYCLE_5;
sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T1_CC4; // Hier bin ich nicht sicher ob Trigger out oder direkt CC4
sConfigInjected.AutoInjectedConv = DISABLE; //muß aus sein
sConfigInjected.InjectedDiscontinuousConvMode = DISABLE;
sConfigInjected.InjectedOffset = ui16_ph1_offset;//1900;
HAL_ADC_Stop(&hadc1); //ADC muß gestoppt sein, damit Triggerquelle gesetzt werden kann.
if (HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_7; //battery voltage
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_3; //Connector SP: throttle input
sConfig.Rank = ADC_REGULAR_RANK_2;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_4; //Phase current 1
sConfig.Rank = ADC_REGULAR_RANK_3;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_5; //Phase current 2
sConfig.Rank = ADC_REGULAR_RANK_4;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_6; //Phase current 3
sConfig.Rank = ADC_REGULAR_RANK_5;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_8;
sConfig.Rank = ADC_REGULAR_RANK_6; // connector AD2
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_9; // connector AD1, temperature or torque input for Controller from PhoebeLiu @ aliexpress
sConfig.Rank = ADC_REGULAR_RANK_7;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;//ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/* ADC2 init function */
static void MX_ADC2_Init(void)
{
ADC_InjectionConfTypeDef sConfigInjected;
/**Common config
*/
hadc2.Instance = ADC2;
hadc2.Init.ScanConvMode = ADC_SCAN_ENABLE; //hier auch Scan enable?!
hadc2.Init.ContinuousConvMode = DISABLE;
hadc2.Init.DiscontinuousConvMode = DISABLE;
hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc2.Init.NbrOfConversion = 1;
if (HAL_ADC_Init(&hadc2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Injected Channel
*/
sConfigInjected.InjectedChannel = ADC_CHANNEL_5;
sConfigInjected.InjectedRank = ADC_INJECTED_RANK_1;
sConfigInjected.InjectedNbrOfConversion = 1;
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_1CYCLE_5;
sConfigInjected.ExternalTrigInjecConv = ADC_INJECTED_SOFTWARE_START;
sConfigInjected.AutoInjectedConv = DISABLE;
sConfigInjected.InjectedDiscontinuousConvMode = DISABLE;
sConfigInjected.InjectedOffset = ui16_ph2_offset;// 1860;
if (HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
Where are they from? Ebikes? Scooters?Fluctuator said:I have few Lishui FOC controllers, that looks like that:
Fluctuator said:Could you please help to reconfigure PB8 as Voltage Sense (+V) ?
That's standard at the Lishui design. Normally it's the fourth channel of the quad op amp (3x phase current, 1x comparator) for Tim1 BKIN on PIN PB12. That's a safety feature for switching off the PWM at overcurrent.stancecoke said:It has also some kind of CURRENT comparator
Nice to hear from you, stancecoke.stancecoke said:First: great work![]()
Fluctuator said:I have few Lishui FOC controllers, that looks like that:
Where are they from? Ebikes? Scooters?
Fluctuator said:Could you please help to reconfigure PB8 as Voltage Sense (+V) ?
Sorry, but PB8 is no ADC input, you can't read in the voltage with this pin. See the datasheet.
For discussion of the firmware, please join the german forum, in this forum the project has met with little interest so far.
https://www.pedelecforum.de/forum/index.php?threads/open-source-firmware-f%C3%BCr-lishui-controller.61113/
stancecoke said:It has also some kind of CURRENT comparator
That's standard at the Lishui design. Normally it's the fourth channel of the quad op amp (3x phase current, 1x comparator) for Tim1 BKIN on PIN PB12. That's a safety feature for switching off the PWM at overcurrent.
regards
stancecoke
Fluctuator said:Also in my version i have Temperature sensor on PB1. This is interesting controller. It has also some kind of CURRENT comparator(may be, overcurrent protection, not sure. Maybe it is ADC input too)
benno said:Impressive work here with the hardware reverse engineering!
Fluctuator said:Also in my version i have Temperature sensor on PB1. This is interesting controller. It has also some kind of CURRENT comparator(may be, overcurrent protection, not sure. Maybe it is ADC input too)
My motor has a termistor in order to monitor the temperature. The cable of the thermistor connects to the PB5 pin (SS connector on the lishui print). Could that be an explanation for some kind of current measurement circuit on the board -> measuring the current through
the thermistor at constant voltage (from PB5) would be an indicator of the temperature.
I'm just guessing, i'm not an electronics hardware expert![]()