lizardmech Posted June 7, 2017 Share Posted June 7, 2017 Might it be the hall sensors? Not sure if they will work at higher RPM. There's probably some latency difference on either the halls or current sense that increases at higher RPM. Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 7, 2017 Share Posted June 7, 2017 Hall sensors are ok because if not, the 6 steps would not work. This motor have relative low RPM. Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 7, 2017 Share Posted June 7, 2017 This controller's 3 phase all connect a inductor in series. motordriver.PDF 1 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 7, 2017 Share Posted June 7, 2017 (edited) 5 minutes ago, KingQueenWong said: This controller's 3 phase all connect a inductor in series. Thanks!! I also did read about that option. Still I am looking to see if is possible to improve the issue with firmware only, and I think so. This motor have low inductance but the current seems to be possible to be read and limited... just need to find a way to sync ADC read of current signal with PWM signal, as the current increases and should be read a bit after PWM fires (when the voltage kicks at the motor/coils terminals. The EUC motor, with higher inductance, I just read the the middle of PWM and seems to be enough. On this motor I need to read it much earlier. And EUC motor without load never reach max current while this small EBike motor reaches and can be destroyed. I planned to use this EBike motor and a test to make an EUC with a bicycle wheel -- I saw a video of a Russian guy using this motor, for a balance skate. This motor needs to be hacked to loose the freewheel but after that should work. I think Firewheel EUCs also use this kind of geared motors. Edited June 7, 2017 by electric_vehicle_lover Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 7, 2017 Share Posted June 7, 2017 STM8's TIM1 TRGO event can trigger ADC conversion. 1 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 7, 2017 Share Posted June 7, 2017 (edited) 1 hour ago, KingQueenWong said: STM8's TIM1 TRGO event can trigger ADC conversion. Thanks @KingQueenWong -- very good to have you with me for firmware!! I think I will do it!! I was thinking in using TIMER1 -> TIMER5 -> ADC, where TIMER5 would make a timer so I could read at some specific point in time but turns out this STM8S105 do not have TIMER5, the only way seems to do it manually: TIMER1 interrupt start TIMER2, TIMER2 interrupt starts ADC. Let's see the best I can get... And now that motor is running with sinewave/SVM I can see the phase B current wave form that should be a sinewave and should be in sync with hall sensor signal, this way we get the best efficiency possible -- it is the objective of FOC. We can see the oscilloscope, blue line is phase B current signal and yellow line is one hall sensor signal and as we can see they are in sync.. if not, produced voltage with the PWM signal that we generate/control should be advanced in time in a way to keep this current in sync with the hall sensor (rotor position): Edited June 7, 2017 by electric_vehicle_lover 1 Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 8, 2017 Share Posted June 8, 2017 I implemented TIM1(TIM1_TRGOSOURCE_OC3REF) trigger ADC conversion throttle value. void adc_init (void) { //init GPIO for the used ADC pins GPIO_Init(THROTTLE__PORT,THROTTLE__PIN,GPIO_MODE_IN_FL_NO_IT); //de-Init ADC peripheral ADC1_DeInit(); //init ADC2 peripheral ADC1_Init(ADC1_CONVERSIONMODE_SINGLE,ADC1_CHANNEL_4,ADC1_PRESSEL_FCPU_D2,ADC1_EXTTRIG_TIM,ENABLE,ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL9,DISABLE); ADC1_ITConfig(ADC1_IT_EOCIE,ENABLE); } void pwm_init (void) { // TIM1 Peripheral Configuration TIM1_DeInit(); TIM1_TimeBaseInit(0, // TIM1_Prescaler = 0 TIM1_COUNTERMODE_UP, (1024 - 1), // clock = 16MHz; counter period = 1024; PWM freq = 16MHz / 1024 = 15.625kHz 0); // TIM1_RepetitionCounter = 0 TIM1_OC1Init(TIM1_OCMODE_PWM1, TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_DISABLE, 0, // initial duty_cycle value TIM1_OCPOLARITY_HIGH, TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_RESET, TIM1_OCNIDLESTATE_SET); TIM1_OC2Init(TIM1_OCMODE_PWM1, TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_DISABLE, 0, // initial duty_cycle value TIM1_OCPOLARITY_HIGH, TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_RESET, TIM1_OCNIDLESTATE_SET); TIM1_OC3Init(TIM1_OCMODE_PWM1, TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_DISABLE, 0, // initial duty_cycle value TIM1_OCPOLARITY_HIGH, TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_RESET, TIM1_OCNIDLESTATE_SET); // break, dead time and lock configuration TIM1_BDTRConfig(TIM1_OSSISTATE_DISABLE, TIM1_LOCKLEVEL_OFF, // hardware nees a dead time of 1us 16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16 TIM1_BREAK_DISABLE, TIM1_BREAKPOLARITY_HIGH, TIM1_AUTOMATICOUTPUT_ENABLE); TIM1_SelectOutputTrigger(TIM1_TRGOSOURCE_OC3REF); TIM1_Cmd(ENABLE); // TIM1 counter enable TIM1_CtrlPWMOutputs(ENABLE); // main Output Enable } uint16_t Conversion_Value; INTERRUPT_HANDLER(ADC1_IRQHandler, 22) { if(ADC1_GetFlagStatus(ADC1_FLAG_EOC)!= RESET) { Conversion_Value = ADC1_GetConversionValue(); GPIO_WriteReverse(GPIOA,GPIO_PIN_1); ADC1_ClearITPendingBit(ADC1_IT_EOC); } } while (1) { //static uint16_t adc_value; //adc_value = adc_read_throttle (); //adc_value = map (adc_value, ADC_THROTTLE_MIN_VALUE, ADC_THROTTLE_MAX_VALUE, 0, 1023); //pwm_value = adc_value; printf("%d\n\r",Conversion_Value); Delay(100000); //pwm_set_duty_cycle_channel1 (pwm_value); //pwm_set_duty_cycle_channel2 (pwm_value); //pwm_set_duty_cycle_channel3 (pwm_value); } 1 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 8, 2017 Share Posted June 8, 2017 1 hour ago, KingQueenWong said: I implemented TIM1(TIM1_TRGOSOURCE_OC3REF) trigger ADC conversion throttle value. Thanks. The thing is that TIM1 trigger happen at middle of low portion of the PWM (and when it is 50% duty_cycle, this even changes when duty_cycle changes). And as we can see, the need to read current about 14us after PWM rise to high value. On the screenshot we can see that we could read 2 times every PWM cycle but I think one is enough (we don't have much processing time). I am able now to: PWM trigger Timer2; Timer2 trigger starts ADC reading; ADC interrupt reads motor current value. But I have some small issues like: find how to calc the Timer2 count value based on PWM value, to achieve the correct time value to read the current pulse. I did push my current code so you can follow it. Quote Link to comment Share on other sites More sharing options...
lizardmech Posted June 8, 2017 Share Posted June 8, 2017 18 hours ago, electric_vehicle_lover said: And now that motor is running with sinewave/SVM I can see the phase B current wave form that should be a sinewave and should be in sync with hall sensor signal, this way we get the best efficiency possible -- it is the objective of FOC. We can see the oscilloscope, blue line is phase B current signal and yellow line is one hall sensor signal and as we can see they are in sync.. if not, produced voltage with the PWM signal that we generate/control should be advanced in time in a way to keep this current in sync with the hall sensor (rotor position): These things aren't FOC you're confusing yourself. If you aren't calculating the flux in the airgap it's not FOC. 2 Quote Link to comment Share on other sites More sharing options...
esaj Posted June 8, 2017 Share Posted June 8, 2017 On 6/7/2017 at 2:13 PM, electric_vehicle_lover said: I think Firewheel EUCs also use this kind of geared motors. The Firewheel's motor's not geared, I don't have pictures, but Vee opened it at one point. Rockwheel GR16's (and was there a smaller model called GR12?) had geared motors, not to be mixed with the new Rockwheel GT16, as well as the early Gotway MTens or maybe it was M8's (first gen). 2 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 8, 2017 Share Posted June 8, 2017 I got the current limiting working but half (1 every 2 PWM pulses). The results are clear, motor max current limited and less noise. Seems clear that should be implement fully the current limit. I had to lower the PWM frequency to half, now is at 8kHz -- seems to work ok. Processing power very limited. @KingQueenWong you can look at the code...., is it on github. 12 hours ago, electric_vehicle_lover said: Thanks. The thing is that TIM1 trigger happen at middle of low portion of the PWM (and when it is 50% duty_cycle, this even changes when duty_cycle changes). And as we can see, the need to read current about 14us after PWM rise to high value. On the screenshot we can see that we could read 2 times every PWM cycle but I think one is enough (we don't have much processing time). I am able now to: PWM trigger Timer2; Timer2 trigger starts ADC reading; ADC interrupt reads motor current value. But I have some small issues like: find how to calc the Timer2 count value based on PWM value, to achieve the correct time value to read the current pulse. I did push my current code so you can follow it. Quote Link to comment Share on other sites More sharing options...
OliverH Posted June 9, 2017 Share Posted June 9, 2017 19 hours ago, esaj said: The Firewheel's motor's not geared, I don't have pictures, but Vee opened it at one point. Rockwheel GR16's (and was there a smaller model called GR12?) had geared motors, not to be mixed with the new Rockwheel GT16, as well as the early Gotway MTens or maybe it was M8's (first gen). It's not geared. Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 9, 2017 Share Posted June 9, 2017 8 minutes ago, OliverH said: It's not geared. Ok, got it. The thing is that EBike motors are small and cheap - although we can find gear and no gear motors (no gear are more expensive, big and heavier, just like EUC motors). Also batteries and motor controllers can be reused to EUC application. I am afraid market will go low for EUC so I am looking more to EBike technology and see if can be reused for EUC application. 1 Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 9, 2017 Share Posted June 9, 2017 (edited) I buy a board which cost $29 from https://s.2.taobao.com/list/ Edited June 9, 2017 by KingQueenWong 1 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 9, 2017 Share Posted June 9, 2017 10 hours ago, KingQueenWong said: I buy a board which cost $29 from https://s.2.taobao.com/list/ @KingQueenWong that board is good, for the price and for what is capable. Unfortunately, is very hard for a westerns to buy it and also seems there happens to be a few versions which will make difficult to support with firmware and knowledge. I would prefer to have a stable version on a english shop that anyone could buy the board. 1 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 9, 2017 Share Posted June 9, 2017 (edited) Here is an EUC using a EBike motor and rim/wheel -- the same I would like to do, to have much more freedom on the motor supplier, motor controller, battery AND MOTOR SPEED!! @MattJ look at this EUC. On 08/06/2017 at 5:34 AM, codersarepeople said: I saw this really interesting interview with the founder of Grin Technologies, and thought it would really be interesting to people here. Interestingly, at about 45 minutes, he points to an EUC he made and claims he made it at about the same time as Shane Chen. He also talks at length from about 10-35 minutes about some really interesting aspects of batteries. In another great video of his, he shows off his pedal-assist regular unicycle, which is really cool. Edited June 9, 2017 by electric_vehicle_lover 1 Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 10, 2017 Share Posted June 10, 2017 The schematic has been done. S06S-Controller.PDF 2 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 11, 2017 Share Posted June 11, 2017 11 hours ago, KingQueenWong said: The schematic has been done. That's great!! Maybe we should continue the discussion on the Endless Shere forum, on the thread for this firmware, for EBike controllers. I think people prefer to talk here only about EUCs. Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 12, 2017 Share Posted June 12, 2017 (edited) @electric_vehicle_lover I found a chinese guy who release the generic EUC firmware that be annotated in Chinese! The guy said that the firmware can work well! I think the code is good for your EUC banlance control! I review the code,it don't run foc,just square wave. ZKTF_STM32_BALCAR_V5.rar Edited June 12, 2017 by KingQueenWong 3 Quote Link to comment Share on other sites More sharing options...
lizardmech Posted June 12, 2017 Share Posted June 12, 2017 1 hour ago, KingQueenWong said: @electric_vehicle_lover I found a chinese guy who release the generic EUC firmware that be annotated in Chinese! The guy said that the firmware can work well! I think the code is good for your EUC banlance control! I review the code,it don't run foc,just square wave. ZKTF_STM32_BALCAR_V5.rar Any idea which board and euc he was using it with? Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 12, 2017 Share Posted June 12, 2017 1 hour ago, lizardmech said: Any idea which board and euc he was using it with? The guy said nothing about the hardware. Quote Link to comment Share on other sites More sharing options...
lizardmech Posted June 12, 2017 Share Posted June 12, 2017 Did he write it or just get access to generic EUC firmware? Pretty useful, shows they use software kalman filter combined with a complimentary filter. Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 12, 2017 Share Posted June 12, 2017 (edited) 8 hours ago, KingQueenWong said: @electric_vehicle_lover I found a chinese guy who release the generic EUC firmware that be annotated in Chinese! The guy said that the firmware can work well! I think the code is good for your EUC banlance control! I review the code,it don't run foc,just square wave. THANKS!! You are our spearhead :-) :-) I still have GEN1 boards with me, maybe I can try the firmware or at least look at hardware and see if it makes sense... The code is not extensive... would you please be able to translate all the comments?? -- would be a good investment, and if this firmware is for Gen1 EUCs, that would be perfect at least for historic reasons!!!! Edited June 12, 2017 by electric_vehicle_lover Quote Link to comment Share on other sites More sharing options...
KingQueenWong Posted June 12, 2017 Share Posted June 12, 2017 (edited) 32 minutes ago, electric_vehicle_lover said: THANKS!! You are our spearhead :-) :-) I still have GEN1 boards with me, maybe I can try the firmware or at least look at hardware and see if it makes sense... The code is not extensive... would you please be able to translate all the comments?? -- would be a good investment, and if this firmware is for Gen1 EUCs, that would be perfect at least for historic reasons!!!! I have not GEN1 board,so now i can not find the difference between the firmware and the GEN1 board.But it seem that this firmware is designed for GEN1 board(Maybe i need to buy a GEN1 board to confirm my guess).I may will spend the next days to translate all the comments in English.Everyone just need more patience to my hard work. Edited June 12, 2017 by KingQueenWong 1 Quote Link to comment Share on other sites More sharing options...
electric_vehicle_lover Posted June 12, 2017 Share Posted June 12, 2017 19 minutes ago, KingQueenWong said: I have not GEN1 board,so now i can not find the difference between the firmware and the GEN1 board.But it seem that this firmware is designed for GEN1 board(Maybe i need to buy a GEN1 board to confirm my guess).I may will spend the next days to translate all the comments in English.Everyone just need more patience to my hard work. Don't wast time and money about GEN1 -- it is just like the S06S EBike motor controller that you just draw. The big different is that it does not do FOC: it just have powers resistors motor current sensor (no phase current sensors) and the mosfet drivers are with transistors just like S06S controller. Also do not have bluetooth module. - https://github.com/EGG-electric-unicycle/documentation/wiki/Generic_Controller - https://github.com/EGG-electric-unicycle/documentation/wiki/MicroWorks-18km-h-controller-board - https://github.com/EGG-electric-unicycle/documentation/wiki/Generic-EUC---GD32F130-microcontroller - https://github.com/EGG-electric-unicycle/electronics-gen1_boards/tree/master/generic_electric_unicycle If was a translation from Portuguese to English, would take me only 2 hours using google translator ;-) -- but the comments aren't translated by google, just a few variable names were translated. @KingQueenWong I would like to ask you what are the main motivations to work on this project and also for the firmware of EBike. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.