Alternative ESC firmware (reflashing)

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,
Could you please test latest r90 with your UniLog? ;)

regards,
ziss_dm

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Simon,

Hello! With r72, the MT3506 motor actually seems to run quite well, without losing timing (or recovering well, I can't tell )


You can connect LED to SCK line of ISP connector, this is my DbgLED ;) In case it is on, was ZC recovery..

r75: btw, you can use movw temp1, temp3, instead of the two movs, when the registers are in order. Also, there is a redundant sei near the top of update_timing.

Tnx. ;)

Trying r84, startup seems much better, but I'm not quite sure why. Is that just the MSB change?

Looks like, I found it experimenting with over-clocked Plush.

I can't start the HD on this BlueSeries 30A board because it keeps getting false timing and makes tones instead of turning,

For me it starts quite reliable on 16Khz PWM. If you interested, I can commit config. But still it is not clear for me, which is better: PWM synced comparator scan, but not filtered or filtered, but asynchronous.

Starting with 3 props on one motor doesn't work reliably and not at all unless I have at least 13V input voltage.

Even with higher PCT_PWR_STARTUP?

I'm surprised that you actually got it to work so well considering that there does not seem to be any alignment to PWM.

There are couple:
- It is correcting on/off cycles, taking into account ISR overhead
- It is performing last cycle without exiting from ISR ;)

regards,
ziss_dm

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

the spikes are still there. Is it possilbe that the filter is causing some "input lag"?

I also soldered a second capacitor (220uF/35V) on the ESC, without any noticeable changes.

Cheers,
Heiko.
Attachments
4S_1.jpg
4S_2.jpg

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,

the spikes are still there. Is it possilbe that the filter is causing some "input lag"?

Yes, and looks like I can see it on the graph. But looks like it also limiting the current (was 42 now 36, and taking into account that now your battery in better condition, it is quite sugnificant). The question is: Is it worth it?
Is it still screming? ;)

EDIT: Looks like you changed time base.. So step response still the same ~500 msec?

regards,
ziss_dm

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi,

But looks like it also limiting the current (was 42 now 36).

Not necessarily, because the sample rate is really slow. I measured spikes up to 45A with r90.

The question is: Is it worth it?

Nope it's not, because we also lose the fast response at normal changes. And the case with a 70% throttle jump will almost never happen ;).

Is it still screming? ;)

Yes, sometimes. But only for some seconds. I will make a short video tomorrow, because I also have some resets when idle throttle is to low.

funth1ngs wrote:I have timing problems (screams) on the first 3-4 fast throttle changes, but then they are gone until the ESC is restarted. Is it possible to make a special version which writes the working timing values into the eeprom, then we can read the eeprom an use them as start values in the normal version?

It this possible or am I completely wrong :roll:?

EDIT: Looks like you changed time base.. So step response still the same ~500 msec?

Hm yeah, but as you can see on the older picture, the begin of the throttle and power jump happens nearly at the same time. On the newer pictures it is always delayed by around 50ms. I will verify that tomorrow.

Cheers,
Heiko.

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi,

I also have some resets when idle throttle is to low.


This is probably because of this:

Code: Select all

;*************************
; Run settings           *
;*************************
#define    RPM_RUN_MIN_RPM     750 ; 3200


750 - is too low. Remeber, this is electrical RPM. ;)

I have timing problems (screams) on the first 3-4 fast throttle changes, but then they are gone until the ESC is restarted. Is it possible to make a special version which writes the working timing values into the eeprom, then we can read the eeprom an use them as start values in the normal version?

The timing is constantly updated on each commutation. I think, that most reasonable explanation is that battery is slightly discharged.

BTW: It also would be interesting if you can do the same with "working" motor. Maybe we can see the difference. ;)

regards,
ziss_dm

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

Hi all!
First of all I want to thank you guys for this alternative ESC firmware. I saw some results and looks realy nice. I going to reflash my Mystery 20A with this firmware too but have some questions:

- What version should I use? Latest from svn ? O maybe hex file attached to topic?
- For mystery 20A should I remove capacitors ? or this is not required?
- And last one question, I know there are some function to protect ESC when motor stop imediately but in practice did you burn ESC when you have some accidents in a fly ?

Maybe this is not important but I'm going to use this ESC with KDA 20-22L (924kv).

Cheers,
Marcin.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

Code: Select all

750 - is too low. Remeber, this is electrical RPM.

Oh... :oops:, so electrical rpm = (motor rpm * stator poles) / 2? Is this correct?

Speaking of settings, can you please tell me if my understanding of them is right ;):

Code: Select all

RPM_START_MIN_RPM

Minimal RPM for transition from starting into running mode.

Code: Select all

RPM_RUN_MIN_RPM

If RPM is below this value, the motor falls back into starting mode.

Code: Select all

ENOUGH_GOODIES

Amount of successful rotations,commutations? before transition inro running mode.

Code: Select all

RPM_STEP_INITIAL, RPM_STEP_MAX

I played with them, but I didn't notice any difference. I don't know what they should do :( .

Code: Select all

PWR_CURVE_POINT

It affects the RPM_RUN_RANGE and PCT_PWR_MAX_RPM values which are used in set_new_duty_low_ranges and set_new_duty_range_01 but I don't understand what they should do ;).

Cheers,
Heiko.
Last edited by funth1ngs on Tue Oct 25, 2011 12:11 pm, edited 1 time in total.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi marbalon,

- What version should I use? Latest from svn ? O maybe hex file attached to topic?

I would suggest you try r86 from svn. You only need to adapt the path to your AvrAssembler2 installation in _make.cmd (AS and AS_FLAGS). In my case it's:

Code: Select all

SET AS="%ProgramFiles%\Atmel\AVR Tools\AvrAssembler2\avrasm2.exe"
SET AS_FLAGS= -I "%ProgramFiles%\Atmel\AVR Tools\AvrAssembler2\AppNotes"


- For mystery 20A should I remove capacitors ? or this is not required?

I have one ESC with them and one without them on my bench and don't notice any difference, so I wouldn't remove them. I only removed the the capacitor in PPM_IN, because it caused trouble with the 1-wire bootloader. But if you don't plan to use a bootloader, you don't need to remove it ;). Which ESC do you have exactly (Mystery, HobbyKing, all nFets...)?

Maybe this is not important but I'm going to use this ESC with KDA 20-22L (924kv).

This one should work just fine.

Cheers,
Heiko.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

Thanks Heiko for quick answer. I have Mystery Blue with pFet+nFet.

Could you tell me more about one wire bootloader. I want to try different compilation with pwm_arduino_250.inc, pwm_fast_200.inc etc. to compare results and this is a little hard to disassemble everything to upload new firmware. I understand that you can change firmware using PPM_IN, but you compile wii-esc with different flags?

Thanks for help.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi Marcin,

i have all my information from the ARM-o-Kopter Wiki.

Here is a short summary in my own words ;):

- Build this flash adapter. I think we don't need the pullup/pulldown stuff (R2) because we don't connect more than one ESC at a time. As I understand it, it also depends on the resistor which is connected to PPM_IN on the ESC. In my case it's a 220R, so I don't need a pullup/pulldown.

- Download this package. Now you need to decide if you would like to flash all ESCs with the same BL-ID (BootSign). Since we can connect the ESCs individually, it doesn't matter (the ARM-o-Kopter uses a UART bus). If you would like to change the IDs just let me know then I will explain it.

- Flash .\Bin\ESCBL1.hex via ISP an set the fuses BOOTRST and BOOTSZ (512 words).

- Use AVRootloader.exe to flash the wii-esc firmware: Unpower the ESC, connect the flash adapter, hit connect in the flash tool and then power up the ESC. If everything works, you should now be able to flash it (Sign=ESCBL1) ;).

Cheers,
Heiko.

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,

Oh... , so electrical rpm = (motor rpm * stator poles) / 2? Is this correct?

Almost.. ;) rpm = (motor rpm * rotor poles) / 2.

ENOUGH_GOODIES - number of successful electrical rotations before checking RPM.
RPM_START_MIN_RPM - minimal RPM for transition to run
RPM_STEP_INITIAL, RPM_STEP_MAX - initially when there no back EMF, it starts commutation with RPM_STEP_INITIAL speed and accelerates up to RPM_STEP_MAX. For a good start you need to provide enough power to rotate motor (with load) at least at RPM_STEP_INITIAL and motor should be able to produce detectable back EMF somewhere inside this range.

RPM_RUN_MIN_RPM - below this RPM it exits from run mode. Currently we have 2 cases:
- if current power is lower than PCT_PWR_MAX_STARTUP it goes to startup
- if higher - reset

Code: Select all

PWR_CURVE_POINT(01, 3500, 25)
PWR_CURVE_POINT(02, 7000, 50)

Basically it says that below 3500 limit power to 25% and below 7000 limit power to 50%. It is done to prevent overcurrent in case you put WOT at low rpm. ;)

BTW: If somebody has suggestions for better names, I would love to change them. ;)

regards,
ziss_dm

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

funth1ngs wrote:- Build this flash adapter. I think we don't need the pullup/pulldown stuff (R2) because we don't connect more than one ESC at a time. As I understand it, it also depends on the resistor which is connected to PPM_IN on the ESC. In my case it's a 220R, so I don't need a pullup/pulldown.


So if I want to program only one ESC in the same time I need to only put resistor R1 between TTL-RX and TX? And there is no information about resistor values for Mystery 20A but this should be something about 4,7k-10k ?

Thanks for your all explanation!

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi,

So if I want to program only one ESC in the same time I need to only put resistor R1 between TTL-RX and TX? And there is no information about resistor values for Mystery 20A but this should be something about 4,7k-10k ?


R1 (2k2) has something to do with the 1-wire stuff, you need this one in any case. R2 is either used as pullup or pulldown and the value depends on the ESC (there are different resistors connected to PD0/PD2) and the number of ESCs. In my case (HobbyKing Blueseries 20A all nFET) the series resistor on the ESC has 220R, and I don't need R2 at all.

For example, here is a schematic, R24 is 220R in my case and C8 needs to be removed.

Cheers,
Heiko.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

Hi again ;)
So like I described I probably don't need to R2 but you suggest 2k2 as R1. I will try other values if will have problems. But last question...

I'm not AVR guru so I need to write this value to fuses:

avrdude -p m8 .....-U hfuse:w:0xD8:m

?

Cheers,
Marcin.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi,

So like I described I probably don't need to R2 but you suggest 2k2 as R1. I will try other values if will have problems. But last question...

R1 is a fixed value, you shouldn't have to change it. If you have problems, then try with different pullup/pulldown resistors (R2).

I'm not AVR guru so I need to write this value to fuses:
avrdude -p m8 .....-U hfuse:w:0xD8:m

Me neither, I use AvrProg to change fuse settings ;). According to a fuse calculator, 0xD8 should be OK.

EDIT: It's more likely 0xCA, because of CKOPT.

Cheers,
Heiko.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

Yes I calculated fusebits again and need to confirm that value 0xCA is better than 0xD8 ;)
But back to 1-wire bootloader. Yesterday I've prepare testing ESC, solder ISP holder and burn Mystery 20A + pm_arduino_250. I can startup engine so I think it is ok. But also tried to use method described above with bootloader but without success - can't connect from PC program. But I don't remove any capacitor because can find correct. Could you make describe with one did you remove ?

Cheers,
Marcin.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi Marcin,

But also tried to use method described above with bootloader but without success - can't connect from PC program. But I don't remove any capacitor because can find correct. Could you make describe with one did you remove ?

It will not work with the capacitor, try to remove the one in the red rectangle.

Cheers,
Heiko.
Attachments
20A.jpg

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

Almost.. ;) rpm = (motor rpm * rotor poles) / 2.

ENOUGH_GOODIES - number of successful electrical rotations before checking RPM.
RPM_START_MIN_RPM - minimal RPM for transition to run
RPM_STEP_INITIAL, RPM_STEP_MAX - initially when there no back EMF, it starts commutation with RPM_STEP_INITIAL speed and accelerates up to RPM_STEP_MAX. For a good start you need to provide enough power to rotate motor (with load) at least at RPM_STEP_INITIAL and motor should be able to produce detectable back EMF somewhere inside this range.

RPM_RUN_MIN_RPM - below this RPM it exits from run mode. Currently we have 2 cases:
- if current power is lower than PCT_PWR_MAX_STARTUP it goes to startup
- if higher - reset

Code: Select all

PWR_CURVE_POINT(01, 3500, 25)
PWR_CURVE_POINT(02, 7000, 50)

Basically it says that below 3500 limit power to 25% and below 7000 limit power to 50%. It is done to prevent overcurrent in case you put WOT at low rpm. ;)

Thanks for all the explanations, now everything makes more sense ;):

Code: Select all

PWR_CURVE_POINT(01, 6300, 25)
PWR_CURVE_POINT(02, 8400, 50)

#define    RPM_STEP_INITIAL    90
#define    RPM_STEP_MAX        250
#define    PCT_PWR_STARTUP     12
#define    PCT_PWR_MAX_STARTUP 16
#define    RPM_START_MIN_RPM   5600 ; 4200
#define    ENOUGH_GOODIES      20

#define    RPM_RUN_MIN_RPM     4200 ; 3200


However, I'm starting to think the MT3506 is a faulty design. I tried the software with a crappy HobbyKing NTM 28-30A 750KV motor, and it worked perfect.

I was too frustrated to post these pictures yesterday ;). I used r90 and a 4s. On an empty 4s, it's way better. On a 3S everything works just fine.

Cheers,
Heiko.
Attachments
LV03.jpg
LV04.jpg
LV05.jpg
LV06.jpg

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Oh, and i almost forgot to post some oscilloscope measurements of the MT3506 from Simon:

Simon wrote:Here are some from when I tried to do a differential measurement at the
ACO AVR pins by doing math on my two-channel scope:

...

I'm not sure how accurate the timing/spike behaviour is on both channels,
though, so a real differential probe would probably be better. However,
you can clearly see the commutation steps (every 1ms in the not full
speed case), and the noise it has to deal with, even on this AfroESC
board with filtering capacitors. That is modified code that had no delay
after zero cross, so it goes immediately to the next commutation step
after detecting the crossing. The zero crossing is when the purple line
crosses its zero point. (The noise on the purple line only cancels out
every 1 of 3 commutation steps, so ignore the rest.)

Cheers,
Heiko.
Attachments
motor_zero_cross1.png
(4.06 KiB) Not downloaded yet
motor_zero_cross_fullspeed.png
(3.31 KiB) Not downloaded yet

sim
Posts: 18
Joined: Tue Oct 18, 2011 11:40 pm

Re: Alternative ESC firmware (reflashing)

Post by sim »

Hi, Heiko!

I didn't realize you saw problems even with slow throttle increases. Does this also happen with my tree? I thought it was only a fast response change problem. This is with a 14" APC prop?

It's possible that the motor is just saturating due to too much current. It's rated for 14.5A and 200W according to http://www.rctigermotor.com/show.php?contentid=142 , and you are seeing the problem start at around 16A @ 16V (256W). I wish there was some simple way to collect a full high speed log of the whole drive and zero-crossing detection, like a 4-channel oscilloscope with long buffer. Hmm, perhaps it would work to trigger the scope from one of the unused pins when commutation loss is detected? At least then we could look at what is happening right around when it failed, on a digital scope.

Those scope pictures I posted were not from full load, but if you look at a shorter timescale, the noise patterns change as the motor current increases. The kick-back takes longer to demagnetize and so this affects the noise at the comparator -- the swing back to high stays high longer until the current stops and the undriven phase sees just backEMF. It's almost like a current sense by pulse length. The high part stays high longer based on current, while the lower part is just the length of the PWM ON cycle (and this is proportional to drive voltage). This scope screenshot is just one phase, not at the comparator which has the neutral subtracted, but if you imagine noise each time the signal changes, you can see how picking up a valid zero-crossing can be difficult: http://0x.ca/sim/tmp/motor_phase_zoom.png

If the motor saturates, I would expect the current to start spiking excessively at the end of the PWM ON cycle. I'm not quite sure what would happen next, however. :)

Cheers,
Simon-

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Simon,

I was just thinking: Maybe we are looking in wrong direction? Maybe something wrong with this "virtual" charge pump on this boards? As I remember you mentined that Plush is working just fine for you?
Can I also ask you to check voltage on charge pump capacitor with your scope? ;)
regards,
ziss_dm

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi simon and ziss_dm,

sim wrote:I didn't realize you saw problems even with slow throttle increases. Does this also happen with my tree? I thought it was only a fast response change problem. This is with a 14" APC prop?

Yes, I didn't notice that before, it only occurs on a fully charged 4S. With your current tree, I can't reach full throttle at all. The prop was a EPP 13x4.5".

sim wrote:It's possible that the motor is just saturating due to too much current.

I switched to a Graupner 11x5" E-Prop today, and it's way better. I still can't reach full throttle with your tree, but with ziss_dm's version it works quite well. There is still some noise, but it's only a very short click. So you are right, the 13" prop is causing too much load on a 4S.

ziss_dm wrote:I was just thinking: Maybe we are looking in wrong direction? Maybe something wrong with this "virtual" charge pump on this boards?

This made me to open another ESC ;). Unfortunately it looks like that is's also using a charge pump. I tried it anyway and figured out that it has the same pin assignment than the BlueSeries ESCs. To my surprise it works with the Mystery20A.inc without any changes :). Compared to the HK BlueSeries all nFet ESC it's even a little bit better (the clicks are quieter and nearly gone) (11x5" E-Prop and 4S)). The 2 capacitors are 330uF/25V, on the my BlueSeries board are currently 2x220uF/35V. Do you think if I increase them to maybe 2x470uF/25V can help?

Cheers,
Heiko.
Attachments
Turnigy TY-P1 25A
Turnigy TY-P1 25A
Last edited by funth1ngs on Sat Oct 29, 2011 9:28 am, edited 1 time in total.

sim
Posts: 18
Joined: Tue Oct 18, 2011 11:40 pm

Re: Alternative ESC firmware (reflashing)

Post by sim »

Well, there are a couple of problems here. I saw your problem originally on Plush at 15.8V, with a 10x4.7 prop on the MT3506. I made some changes, and it was totally fixed for me, so I was happy, and posted, and you said it didn't fix it. So, I ordered a BlueSeries 20A and 30A. The stock firmware seemed to work with them and the MT3506 at 15.8V, but with slow throttle response, as expected. I was surprised to see that they went with 16kHz PWM for startup but defaulted to 8kHz for run mode. Anyway, when I tried my tree, I noticed that the backEMF sense either has differently-timed noise or is for some reason more noisy/less sensitive, since driving any of my motors with my tree is much worse than the Plush at slow speeds. Also, it missed like the Plush did when accelerating quickly to full throttle, even though that was fixed for me on the Plush. D'oh! :) Finally, it suffers from resets at high current even though this never happens on the Plush.

I haven't tried >15.8V on the Plush since the capacitor that they shipped with it is only 16V, even though they rate it for 16.8V. I need to swap it for a 25V cap and compare. Also, I haven't tried removing the BlueSeries backemf sense capacitors yet, but I just got an smd rework station today, so I can try that, but I'm really not expecting it to make much difference. I also don't have a high-ampere 16.8V source to compare with, just an 18V supply at about 5A, so I probably need to order a 4S lipo to see exactly what you are seeing.

Newer ESCs, in particular the TowerPro "type 3" boards, are switching to gate drivers (finally), with a charge pump for the gate drive. The nFETs are inverted on those boards, but it seems that Turnigy TY-P1 25A HexFET ESC is yet another variant without inverted drive. It's weird that they went with the original Mystery pin configuration, hmm. :) Using both sides of the comparator allows the ACME to be turned off and the ADC during that cycle, so they can sample voltage/temperature without having to stop sensing timing, but the original and all-nfet Mystery pin configuration requires ACME and ADMUX to always be on. Also, you can't do any simplifications with a single out to turn off all NFETs regardless of commutation stage, etc.

Anwyay, there is no charge pump on my BlueSeries 30A, but there is a small 7805 type regulator just for VCC, separate from the BEC, and even though it has a regulation output capacitor, I see voltage across that comparator drop below 2.7V when the AVR resets. I'll take a scope screenshot so you can see what I mean. I'm thinking the sense noise might be a lot more difficult when combined with the fact that there is also this pulse noise on A(VCC) as well.

With gate drivers, I would really be inclined to PWM switch on the high side instead of the low side. I did this even on the Plush and it worked surprisingly well, especially considering that it only had transistors for gate drive and it was actually switching the pFETs. I even tried a variant which switched high and low at the same time. In theory, if the fets turn on and off at the same time, the motor voltage average always stays in the middle and the comparator does not even need a neutral reference, it can just use half of the input voltage. I figured backEMF sampling noise would thus be lower, but alas the fets of course turn on and off at different times, so I didn't notice any improvement at the time. Also, I didn't do any load tests and I figure that without gate drivers, it would probably behave badly at higher currents. But with all nFET boards, maybe..

Too many things to try at once as usual. ;)

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

Hi again,
So I tried this software with Mystery 20A (nFet + pFet) and KDA 20-22L but have some problems. I tested revision 44, 65, 79, 82, 106 and first version from this topic attached to this post:
http://www.multiwii.com/forum/viewtopic.php?f=13&t=516&start=20#p3044
All version was compiled with pwm_arduino_250.inc, and of course I've changed MWC code to use extend resolutions. All version have a huge problem with motor startup, motor shaking about 3-5s then start working normally - all version except this attached to post above. It works without any problems. So I think changes related with Mt motors is not good for other motors... But I can still use first version compiled int this topic ;).

I have some question for Mystery 20A users. I had some crashes when testing this software (because testing to high PID values, and landing in a grass, on the wall etc ;) but luckily didn't burn any mosfet, so did you guys burn anyone when you stop propellers ?

Cheers,
Marcin.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

today I played again with my MT3506 ;). I limited MAX_THROTTLE to 185 steps, and with the BEMF feedback capacitors removed the "screams" are completely gone, even with a 13x4.5 prop and a fully charged 4S battery. So I must retreat my previous statement that the behavior is the same with or without capacitors, it's a little bit better without them.

Code: Select all

                ror     temp1
.endif
                cpi     temp1, POWER_RANGE - 1 - 15
                brcs    eval_rc_p10
                ldi     temp1, POWER_RANGE - 1 - 15
eval_rc_p10:   
                mov     ZH, temp1

The only remaining problem are the resets which happen sometimes when idle throttle is increased too fast. So i recorded this short video. In the first half of the video the software is untouched, in the second half I flashed a modified version with resets disabled.

Code: Select all

run_to_start:   sbr     flags2, (1<<STARTUP)
                cpi     ZH, PWR_PCT_TO_VAL(PCT_PWR_MAX_STARTUP)
                ; brcs    run_to_start_2
                ; rjmp    restart_control
run_to_start_2:               
                rjmp    wait_for_power_on

I noticed with resets disabled that the motor nearly stops for a very short time, then immediatly accelerates to full speed. Do you know how to get rid of these resets in a proper way :)?

Cheers,
Heiko
Attachments
UL_01.jpg
UL_02.jpg
UL_03.jpg

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi Marcin,

All version have a huge problem with motor startup, motor shaking about 3-5s then start working normally - all version except this attached to post above. It works without any problems. So I think changes related with Mt motors is not good for other motors...


just checked that with 4 different motors (without propeller):

RCTimer A2830/14
RCTimer BC2836/11
RCTimer BC3536/11
HK NTM 28-30

Startup worked very well with every motor.

You can try to increase PCT_PWR_STARTUP and PCT_PWR_MAX_STARTUP to:

Code: Select all

#define    PCT_PWR_STARTUP     20
#define    PCT_PWR_MAX_STARTUP 25

and/or RPM_STEP_INITIAL and RPM_STEP_MAX to:

Code: Select all

#define    RPM_STEP_INITIAL    70
#define    RPM_STEP_MAX        250

Cheers,
Heiko.

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi,

@marbalon: Can you try the latest 0.11 tag? For my setups it is finally better or equal to the original one. ;)

I have some question for Mystery 20A users. I had some crashes when testing this software (because testing to high PID values, and landing in a grass, on the wall etc but luckily didn't burn any mosfet, so did you guys burn anyone when you stop propellers ?

The latest versions should be quite safe. I'm doing stop tests from half throttle. The erly ones may or may not burn FET's, depends on luck.

@Heiko:
I limited MAX_THROTTLE to 185 steps

But you are "loosing" 45W of power (according to the graphs), so maybe smaller prop is better? ;)
I also noticed that you always start ramping from different RPM. Can you try to fix initial RPM to fixed value? Maybe we have some treshhold, after which it start resetting? Would be fun if it is 1200 RPM ;)
BTW: How you generating input? Manually?

I noticed with resets disabled that the motor nearly stops for a very short time, then immediatly accelerates to full speed.

This is quite explainable: it goes to startup, performs pre-align (motor stops), starts and than slowly ramping to full power.

Code: Select all

#define    RPM_STEP_INITIAL    70
#define    RPM_STEP_MAX        250

Sadly enough, I've made same mistake. There are limits for lower RPM value, due the 17bit timer we using. ;(
The limits are:
~75 rpm for 8mhz boards and ~150 rpm for 16mhz boards. In case you setting lower than that, it is overflowing and rpm would be actually higher than intended.

regards,
ziss_dm
Attachments
bldc.0.11.zip
(64.68 KiB) Downloaded 270 times

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

ziss_dm wrote:@marbalon: Can you try the latest 0.11 tag? For my setups it is finally better or equal to the original one. ;)
The latest versions should be quite safe. I'm doing stop tests from half throttle. The erly ones may or may not burn FET's, depends on luck.


Will try on my backup motor and ESC. This will be a little hard in my quad because I need to disassemble it to get an access to ESC (I have ESC between centerplates - foto here). But I found that sometimes motor don't have a problem with startup without propeller but with propeller situations maybe be different. Will try to give you feedback soon.

Cheers,
Marcin.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Alternative ESC firmware (reflashing)

Post by crashlander »

funth1ngs wrote:Hi simon and ziss_dm,
...
This made me to open another ESC ;). Unfortunately it looks like that is's also using a charge pump. I tried it anyway and figured out that it has the same pin assignment than the BlueSeries ESCs. To my surprise it works with the Mystery20A.inc
...
Heiko.

Hello,
can you please post a picture of how-to connect Tgy TY-P1 for flashing.
Subquestion ;) does this ESC originally works with MultiWii (with original firmware)?

Regards
Andrej

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi Andrej,

here is the picture with the ISP pins. I have only one TY-P1, so I never used it in a copter.

Cheers,
Heiko
Attachments
Turnigy_TY-P1_ 25A.jpg

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

But you are "loosing" 45W of power (according to the graphs), so maybe smaller prop is better? ;)

Yes and no, it's all about efficiency at hover throttle ;). For example, with a 11x5" the max thrust is 800g and with a 13x4.5" it's 1100g. If the max thrust of the 13x4.5" needs to be limited to 800g, but the efficiency at hover throttle is better, I prefer to use the bigger prop.

I also noticed that you always start ramping from different RPM. Can you try to fix initial RPM to fixed value? Maybe we have some treshhold, after which it start resetting? Would be fun if it is 1200 RPM ;)
BTW: How you generating input? Manually?

I use an AVR development board with a poti and a self written software to generate a 400Hz PWM signal. Unfortunately, there is no constant treshold. The higher the voltage, the higher must be the RPM. And even at a fixed voltage the treshold fluctuates around 100-200 RPM:

3S 10,6V -> almost no problem
3S 12,4V -> ~850 RPM
4S 15,4V -> ~1050 RPM

But thats no problem, because I always use some idle throttle. It just needs to be high enough to prevent resets. As long it's below hover throttle, everything is fine ;). For the MT3508 the min idle throttle generates a thrust of 40g, what makes 240g on a hexa. Compared to the hexa weight of 1500g it's OK. I only thought it would be more fool proof if the resets could be prevented at all.

Another question: Is it possible to have the full POWER_RANGE between PCT_PWR_MIN and 100% (or even better PCT_PWR_MAX ;)) and start the motor always at MIN_RC_PULS?

Example (POWER_RANGE=200): At the moment with PCT_PWR_MIN=15 the "real" resolution would be 200-0,15*200 = 170 steps. The required pulse length to start the motor is 1100+(1900-1100)*0,15 = 1220us. It would be easier to understand, if the motor always starts at MIN_RC_PULS=1100, but with a start duty cycle of PCT_PWR_MIN=15. And the 200 steps POWER_RANGE are aligned to the remaining 75%.

But I think the resoultion of the timers is a problem, and maybe the math gets to complicated for the AVR.

Cheers,
Heiko.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

Hi,

ziss_dm wrote:Can you try the latest 0.11 tag? For my setups it is finally better or equal to the original one. ;)


I've just made some tests on one motor and ESC - this is not good test because sometimes one pair in my quad (motor+ESC) works fine with one firmware but other pair (of course the same models) have a problem with startup. But back to test results. I've uploaded version r82 and have huge problem with startup. Then uploaded version from tag 0.11 and motor make few rotation with some problems (a little noisy) but then works fine. Then I've added modifications suggested by Heiko:

#define PCT_PWR_STARTUP 20
#define PCT_PWR_MAX_STARTUP 25

And motor start with a short grind but much better then on original 0.11. But it is far away startup comparing this to original or Quax version (first working in this topic) - this firmwares start smoothly and without any any problems. I 'ca try to upload this firmware to all ESC but do your think you can try to tune startup procedure to work better?

Thanks for help,
Marcin.

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi marbalon,

What motors/props are you using? And have you removed back EMF feedback capacitors?
And if you like experiments, you can try to adjust STRT_ZC_FILTER_DELAY in core\str_zc_filter.inc. I think, you can lower it little bit.

regards,
ziss_dm

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,

I use an AVR development board with a poti and a self written software to generate a 400Hz PWM signal.

And to generate step, you just rotate pot fast? And it depends on idle rpm?

can you try to LOWER the second power curve point?

Code: Select all

PWR_CURVE_POINT(01, 3500, 25)
PWR_CURVE_POINT(02, 5600, 50)


The idea is:
- When you rotate pot, it can change fast but not immidiate, so motor can keep up and everythingis fine
- When RPM is low, the limiter limiting power to 50% and this is good, but than motor reaches treshhold RPM it can generate "step" change in power

regards,
ziss_dm

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

ziss_dm wrote:Hi marbalon,

What motors/props are you using? And have you removed back EMF feedback capacitors?
And if you like experiments, you can try to adjust STRT_ZC_FILTER_DELAY in core\str_zc_filter.inc. I think, you can lower it little bit.

regards,
ziss_dm


Hi,
My setup is KDA 20-22L + Mystery 20A (old version with p+nFet) + prop 10x4.5. And I like experiments so If you tell me what defines should I try to change I can make some test. I prepared one arm with motor + prop + ESC with soldered ISP so testing is easy now. Will try to tune STRT_ZC_FILTER_DELAY and will give you feedback when I get home.

Cheers,
Marcin.

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi!

@Marcin:
marbalon wrote:Will try to tune STRT_ZC_FILTER_DELAY and will give you feedback when I get home.

If this will not fix your problems, try to remove the BEMF capacitors on one ESC as the next step. It's possible that your capacitators have a greater capacitance what affects BEMF meassurement in a negative way. And you can try to increase PCT_PWR_STARTUP and PCT_PWR_MAX_STARTUP even more.

@ziss_dm:
ziss_dm wrote:And to generate step, you just rotate pot fast?

Yes, in all my tests I used the poti to set the PWM, so it was never set "immediately".

ziss_dm wrote:And it depends on idle rpm?

Sorry, i don't get it. What do you mean :)? I mean with idle throttle, that my motors are always spinning, even with the throttle stick in the lowermost position. I start/stop the motors with throttle off and yaw left/right (OP CopterControl).

ziss_dm wrote:Can you try to LOWER the second power curve point?

Code: Select all

PWR_CURVE_POINT(01, 3500, 25)
PWR_CURVE_POINT(02, 5600, 50)

The idea is:
- When you rotate pot, it can change fast but not immidiate, so motor can keep up and everythingis fine
- When RPM is low, the limiter limiting power to 50% and this is good, but than motor reaches treshhold RPM it can generate "step" change in power


I will try that, but as far as I understood you when you explained the settings, the RPM values are electrical RPM. Idle throttle on the MT3508 is arround 800-1000 "mechanical" RPM, and if I convert that to electrical RPM it's 5600-7000 RPM (electrical rpm = mechanical rpm * poles / 2). If this is right, PWR_CURVE_POINT 01 is never reached. But maybe I'm wrong ;)?

EDIT: OK, now I got it. That's exactly what you want me to test.

Cheers,
Heiko.
Last edited by funth1ngs on Fri Nov 04, 2011 11:09 am, edited 2 times in total.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

funth1ngs wrote:If this will not fix your problems, try to remove the BEMF capacitors on one ESC as the next step. It's possible that your capacitators have a greater capacitance what affects BEMF meassurement in a negative way. And you can try to increase PCT_PWR_STARTUP and PCT_PWR_MAX_STARTUP even more.


You think about three caps on the top right side on this foto?

Image

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi!

marbalon wrote:You think about three caps on the top right side on this foto?

Yes.

Cheers,
Heiko.

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,

In Rev 115, I have added support for "Complimentary" PWM (for n-fet boards, and it is disabled by default). It would be interesting to hear, how it performs on your setup. And it would be interesting to see acceleration/deceleration profiles, as it actively breaking.

regards,
ziss_dm

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

Can you try to LOWER the second power curve point?

Code: Select all

PWR_CURVE_POINT(01, 3500, 25)
PWR_CURVE_POINT(02, 5600, 50)


The idea is:
- When you rotate pot, it can change fast but not immidiate, so motor can keep up and everythingis fine
- When RPM is low, the limiter limiting power to 50% and this is good, but than motor reaches treshhold RPM it can generate "step" change in power


Tried it, but it had no affects on the resets.

In Rev 115, I have added support for "Complimentary" PWM (for n-fet boards, and it is disabled by default). It would be interesting to hear, how it performs on your setup.

OK, but I don't know what it should do ;). At first looking, I didn't see any difference with or without COMP_PWM.

Code: Select all

And it would be interesting to see acceleration/deceleration profiles, as it actively breaking.

Breaking is active with COMP_PWM, or needs something else to be activated (for what is CHARGE_BOOTSTRAP?)? This time, I used a timer to change the PWM:

Code: Select all

5sec - 1300us
2sec - 1900us
2sec - 1400us
2sec - 1200us

For both meassurements CHARGE_BOOTSTRAP was activated and HIGH_SIDE_PWM disabled.

Cheers,
Heiko
Attachments
UL_06.jpg
UL_07.jpg

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,

OK, but I don't know what it should do . At first looking, I didn't see any difference with or without COMP_PWM.

So, resets still happening?

CHARGE_BOOTSTRAP - to pre-charge bootstrap capacitors (apparently this is official name) before start.
And yes, braking is always active with COMP_PWM.

Graphs are look cool: Looks like down slopes are shorter now and it is charging battery (which is strange).

regards,
ziss_dm

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

So, resets still happening?

Unfortunately, yes. I noticed that with HIGH_SIDE_PWM enabled the ESC resets on any throttle change from 1300us to 1900us, while it's working up to 95% with HIGH_SIDE_PWM disabled. So I meassured RPM at 1300us an got:

HIGH_SIDE_PWM enabled: 1680 RPM
HIGH_SIDE_PWM disabled: 2050 RPM

Graphs are look cool: Looks like down slopes are shorter now and it is charging battery (which is strange).

Yes, this is very handy for heavy props. Nice feature!

Cheers,
Heiko.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Alternative ESC firmware (reflashing)

Post by marbalon »

ziss_dm wrote:Hi marbalon,

What motors/props are you using? And have you removed back EMF feedback capacitors?
And if you like experiments, you can try to adjust STRT_ZC_FILTER_DELAY in core\str_zc_filter.inc. I think, you can lower it little bit.

regards,
ziss_dm


Hi,
I tried to tune this valune but don't see the difference. So I only change this values:
#define PCT_PWR_STARTUP 20
#define PCT_PWR_MAX_STARTUP 25

And noe all my ESC and motors don't have a problem with startup. thanks for help.

Regards,
Marcin.

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Heiko,

Could you please try this version? The idea is simple: to have different ZC filter for low and high RPM. The question is: Is it worth to integrate it into main branch? ;)

regards,
ziss_dm
Attachments
bldc.ZCFastSlow.zip
(33.16 KiB) Downloaded 199 times

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Alternative ESC firmware (reflashing)

Post by ziss_dm »

Hi Quax, Rob, Sim,

Looks like I finally understand what is happening with zero crossing in case of low RPM and high voltage. Whe RPM is low, the BEMF voltage is really low and have really flat slope, as a result even small amount of ringing noise would cause comparator to switch especially around zero crossing. The usual way to prevent it from happenning is to create some positive feedback to the comparator, to create hysteresis. Unfortunately AVR comparator does not have this setting, and looks like it has 0 hysteresis. So I was thinking, if we can mirror comparator value to one of the free GPIO pins, it should be possible to feed it to the positive comparator input (in our case this is virtual common point) and this should create some hysteresis and reduce noise.

Any thoughts why it would not work? ;)

regards,
ziss_dm

User avatar
Rob
Posts: 77
Joined: Sun Apr 03, 2011 4:40 pm

Re: Alternative ESC firmware (reflashing)

Post by Rob »

Ziss,

- With 3 cels I don't have any problems.... Every combination have a nice startup and runs well.

- As I understand the only problem is a unwanted reset?

- if you want a hysteresis I can test it.

- Maybe the problem is not the software but the hardware :)

I'm going to read the previous posts and look to the schematics looking voor hardware "bugs"

If there is no problem in the software, even you can't find it :)

Rob

User avatar
Rob
Posts: 77
Joined: Sun Apr 03, 2011 4:40 pm

Re: Alternative ESC firmware (reflashing)

Post by Rob »

@all,

I'm looking for the Turnigy TY-P1 schematic...... (to find the hardware problem?)

thanks,


Rob

funth1ngs
Posts: 68
Joined: Tue Aug 09, 2011 8:37 pm

Re: Alternative ESC firmware (reflashing)

Post by funth1ngs »

Hi ziss_dm,

ziss_dm wrote:Could you please try this version? The idea is simple: to have different ZC filter for low and high RPM. The question is: Is it worth to integrate it into main branch? ;)

I can't test it before the weekend because I'am not at home.

Cheers,
Heiko.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Alternative ESC firmware (reflashing)

Post by crashlander »

funth1ngs wrote:Hi Andrej,

here is the picture with the ISP pins. I have only one TY-P1, so I never used it in a copter.

Cheers,
Heiko

Hi!
What input and hw files have you used? I have tried with Mystery20A and pwm_fast_125, with additional #define MINTHROTTLE 1220 and 1150 in MultiWii and the motor doesn't start properly (it only goes around slow and jerky).
I'm using http://www.hobbyking.com/hobbyking/stor ... duct=14847.

Regards
Andrej

Post Reply