Beginning of a proposal for Lepton 3.0

Ok, Valentine has done a great job on the Lepton 2.0, but it has become clear it’s not quite fast enough for me to get smooth, low noise motion (interruptions in the waveform make noise and some other stuff just needs to happen.) Thus, as much as I want to avoid doing work, I can’t avoid changing things for the next order of boards.

I will have to order more boards because it’s clear at this point that I’m using this approach of SimpleFOC, or at least some of it’s components plus a bunch of glue code. I’ve been able to experiment with a B-G431b-ESC1 board, and it works for what I need I think, but they are not boards you can buy a bunch of, ST sells them at a loss as dev boards and I’m sure they won’t let me buy and use a whole bunch of them, or I would just halt there, because the extra cost per part is worth the reduced workload, given that I am in thoroughly unfamiliar territory and thus everything takes me forever and tends to cost way more than you’d think.

Secondly, I think there needs to be some changes to give more wiggle room and make things more amenable for widespread adoption by the community as a successor to the SimpleFOC shield + uno+as5600 combo.

If things become adopted, there are more users, more support, more dev, the ball rolls, can gain inertia, snowball. But it needs a spark.

I propose that things be developed as a combo MCU + driver stage + magnetic sensor, however the AS5600 appears to be good enough for me. But it’s slow speed is clearly a major issue. There are considerable time delays apparently in reading it, and the read rate is only 1 kHz or so. SPI is apparently much faster. There are very similar chips that have SPI, but apparently they are expensive. The SC60228DC is reported by others in this community to be fast, cheap, and appears to be thoroughly available, however the driver is not quite working yet (it wraps around instead of continuing to count upwards).

I propose that I make and submit a design for the Lepton 3.0, if we may call it that, with board files.

I would be modifying the Lepton 2.0. I am really not the best person to do this but can probably muddle through it.

I propose this as a collaborative effort because even if I can, with much effort and gross inefficiency (probably have to order the boards at least 3 times), do something that works for me, I am dead sure I would end up doing a crap job and the results would not be a useful contribution to the commons/be useful to anyone else anyway. If we collaborate, we can roll this ball forward in a meaningful way that will help others. I believe that if we make even a small improvement over the Lepton 2.0 it will be a clear winner for many applications that people encounter in this community, probably - total guess - 80 percent of the things people post about on the forum.

Let not perfection be the enemy of progress… I don’t believe in the idea of making a “configurable design” as desirable - a handful of complete, down to every detail, board/code base/encoder or sensor combos (the magnetic sensors seem to be a lot easier to use than the other options), ideally for sale in small quantities, is going to be more useful to more people, I think, for the same workload, starting from this point. Some starts with one.

I would:
-Add an LED. This is important for many reasons during setup, debugging and to communicate with whatever user in the field. Very basic, human readable output.

-Make the connectors 2.54 mm pitch, both sides, except for power in/out, which has to be arranged to accommodate the higher current. I will be puting on screw terminal connectors, probably.

  • Ideally in a way that, with these particular MOSFETS, the pads can be flooded with solder to increase current capacity cheaply. IDK if I can swing that last one, but looking at the Lepton 2.0, I think maybe. Perhaps we can use some large gauge copper wire that you can solder on in the right places in addition, or as the approach to this, with some suitably sized through holes. That seems doable. Quick way to get your full 40 amps out of the MOSFETs without increasing the cost of the 10 amp config.

-Break out more pins. The right ones for CAN, PWM input, the ADC pins (good for analog input sensors, potentiometers etc), and the op amp pins ideally. Wiggle room.

-Getting more current out of the 5 volt regulator would be useful, I have a standard size RC servo in my machine that takes about 5 volts, an amp or so peak. Doesn’t work very hard, just has to move once in a blue moon, but it draws some. Basically the same thing a BEC is for on hobby ESC, basically, then, funnily enough.

I have no use for current sense apparently, so I cannot put the effort into trying to implement that. It won’t work as a sensorless ESC without that but there are already Bl_heli ones for that. It certainly has it’s uses to measure motor characteristics, sensorless commutation which is cheap and has it’s perks, but I just have to trim back what I bite off wherever possible and people keep saying this is expensive, too.

Integrating the sensor is too much work, and I would have to shrink the board which might be a problem, to fit inside my fan, so I decided not to undertake that.

Other people are already selling simplefoc boards of various kinds on aliexpress, and soon enough people will start selling them if this turns out ok, I believe. Those guys are always looking for stuff to sell, I think they will be all over it. Their costs of production are way lower than what JLCB charges, I am sure, and so is the cost of labor etc, so they can do a better job on that part. I don’t wish to discuss selling them personally, I don’t think that is a fruitful avenue of discussion (although people seem to tend to do that so go nuts if you want I guess).

For me, I am already roped into an “open core” business model, and want to be using standard, open source parts that have a community behind them because that’s more reliable for me as I try to produce my ventilators. I’m less likely to end up without the parts I need.

Secondly, it’s part of the product proposition that you can maintain the unit into the very distant future because you have the source code and it uses standard parts that you can source relatively easily and not from the original company (this removes the incentive for planned obsolescence and thus is expected to improve the financial return on investment greatly when compared to other industry-leading options. Thus it is an important selling point).

Anyone game to contribute with board design/review before production/have other modifications? I know I am getting a bit ahead of myself but I gotta plan ahead. I may make the board design within 4 weeks hopefully. I can buy ESC boards and kick the can down the road for a while, but need to do this eventually. Also I need to let the dust settle a bit on my list of modifications, be sure what I need.

I can buy the initial order of boards and then mail out boards to others who wish to test them/use them to develop the code base.

Let’s face it, there is likely to be at least one revision immediately after this, too. I’m hoping I can at least use the boards I purchase/avoid serious design issues with the first batch, but I think I will try to keep the order size small all the same, just in case.


Go for it! I think many people here would be happy to offer advise on any WIP or design you finish.

The latest state of the art in my project is to make an independent waveform generator module, which could be a G431 based board but I am not too keen on trying to do that and will probably try to use the Lepton to do that. It appears to be able to do open loop at 250 rads/s, I tested it last night. And that’s all I need. I just need to communicate with it efficiently, the program on the lepton can be nearly elementary (with the simplefoc library). I hypothesize this will obviate the need for a blazing fast processor and learning enough C to do a good job on a complex good quality driver that runs on only one MCU.

You will need far more C skills if you distribute the work across multiple CPUs rather than using just one. I don‘t know, what other things you need to process, but unless you are aiming at really high rpm, a G431 should have a lot of extra power besides running the motor control. If you add a second MCU, you may easily waste more CPU cycles for communication than you gain. Don‘t forget, that you need to properly synchronize everything and that you cannot have your driver MCU just sit and sleep for more than very few microseconds.

I’m not using C on the other one, I’m using micropython.

Wait so are you doing distributed computing across two different mcu type? STM32 and RP2040?

Yeah basically. But I’m treating the module with the STM32 as a peripheral. It is like a TMC2209 stepper motor driver, basically, but for three phase ac instead of two phase. That’s basically it. The STM32 doesn’t even reply any more, it just accepts voltage and speed commands, I had it so that it would print the electrical angle when I raised a pin high to request it, but I am hoping I don’t even need that any more. I am hoping to regulate motor timing by using a current sensor located at the input of the waveform generator. The motor timing is optimal when the current is minimal. The pico will adjust the voltage till it gets to that point. It has to search around, a problem I have encountered before, to find the local minima of a curve. The plan is to use a pid controller but detect the slope of the curve and reverse the direction of the controller accordingly. So it will wander on either side of the optimal point, but it sort of has to do that to keep track of the slope, I think. The giant capacitor on the lepton may hinder or help, IDK. Some smoothing is good, too much bad.

I can already do this manually just by twiddling the knob on the power supply and get a margin of about 0.4 volts before the timing gets too far off and the motor stalls, so I am hoping the pico can do it ok.

There are other manifestations. It occurred to me, idk if I mentioned this, that you could make the wave generator such that it accepts angles, not speeds. Then ramp the angle from the old value to the new value at a rate that is such that the new angle will be achieved after x time has passed, with x being the time since the last update. Thus, if you update the angle regularly, you get smooth motion. With upper and lower limits on the ramping speed. But it also works with lower speed and precise angles. Trinamic does this with their silent stepper motor drivers, I think the feature is called MicroPlyer.

If the angle updates are erratic it would still leave some clonkyness, but it would certainly still help a lot. The downside is very slightly increased time to achieve the commanded angle in some cases, where it probably does not matter anyway.

Every single supplier is out of the b-g431b-esc1 board. Every single one. I knew they weren’t dependable but thought I could squeak by for a while with them.

I got one board one time, and then that’s it. Poof. Clearly that’s no way to get anything done, I need to concoct a new board. At least the code is reasonably portable.

It’s too bad the lepton didn’t work out. Just one more round.

I am thinking a cross between the two boards, basically. And the features above. Shit, I really really don’t have time, that’s why I grabbed a development board.

I just ordered 4 from Newark last week, they said they had a ton in stock, like 200 . They are doping around and not sending them. Obviously they are going to flake out and say they don’t actually have any for me. Clowns.

I’ve got a couple b-g431b-esc1 that I’m unlikely to ever use now that I have Lepton, if you want them.

Lepton itself is also effectively out of stock since LCSC has been out of the unique SE3082G transistors for a while now. Hopefully they have more on order. Although it would be fairly easy to rework it for six 3x3mm transistors. I have a mostly-complete variant of my modified Lepton with that.

They have 27 in stock. Interesting. I will check for other mosfets that are similar.

Possible replacements:

DMT3009LDT-7 – C155503

RU30J30M – C2803361

BUK9K29-100E – C478189


1 Like

A 10 batch board order with G431 and the DMT3009LDT-7 DiodesInc MOSFET (30V/30A) would cost about $9 per board before shipping and taxes, may be cheaper, not including the sensor.

Do you expect the sensor to be on the same board? Or external to the board?

You cannot get any lower than $9 per board, even on aliexpress. You ordering from JLC is still the cheapest.

1 Like

Deku: I pm’d you

I am using the AS5600 sensor, so should be external to the board. I am actually using the analog output, incidentally. I finished my design for the fan before this hiccup of not being able to get the boards I designed around… A lesson in the importance of only using open source tech, but also based on common components. The b-G431b-esc1 is open source, but that’s not a solution here, so indeed it’s not enough on it’s own.

I have encountered serious noise related issues with the current Lepton, it may be a problem with my program. It occurs to me that the dead time for the driver could be the cause. It is running nearly the same code as the G431 board was running.

$9 usd per board would be really good. More is actually fine, the g431 boards are $23 USD each from Newark, if I could even get them… cost of the parts isn’t my biggest problem at this point, every day of development time is I figure ~$200, saving a couple bucks on each board is not worth huffing and puffing for, not for me, not for the number of units I am anticipating selling. Reliability and the ability to obtain more of the boards in the future is worth a lot.

Again, I offer to order extra boards and send them out to people who want some. I may be able to send them by DHL now for cheap, they give me 60 percent off, supposedly.


Also keep in mind that while I guess its fine to use the B-G431-ESC1 in your own projects or for making prototypes, its terms of use specifically preclude reselling it, either in whole or as part of a product…

And you can’t even recreate the design well because the FETs used aren’t easily available.

So working on a Lepton 3 instead that is both open source without restrictions and based on readily available parts is a good idea, IMHO.


The other day I started slowly putting together a Lepton Pro version, based on G431 - ESC pinout, except it will have inline current sensing. Given my current load and time availability, it may take perhaps at least a month, may be more, before I get something working. In a way, I aim this to be a really inexpensive B-G431-ESC1 open source replacement. If I can get it under $20, which is the B-G431-ESC1 price, it would be optimal.

I know different people here have different and conflicting ideas on what this replacement has to be, so I’m making certain executive decisions on the design, to keep cost and complexity to a minimum. I know I cannot please everyone but I aim to hit a “golden balance” where at least most will be achieved (minimaxing the problem).


PS: Started the PCB lay out, 30V / 60A, 35mm X 50mm, $13 per board.


Awesome, I may have to jump the gun and concoct my own board, but probably just as a proposal. Hopefully I can take the two and weave them together before placing an order.

I think we have laid the groundwork by considering the needs, desires and options fairly well at this point, although I should go around and round up and summarize things. Obviously I can only produce my take on the issue, such as my preference for screw terminal connectors.

I am concerned about duplicating the noise issue in the Lepton, if I proceed without understanding it.

I am going to try an experiment to change the dead time and see if that helps.

You mean for input voltage and motor phases?

for the most commonly used connections. you can get 2.54 mm ones that are the same pitch as dupont etc. but granted you can’t really put them back to back as you do there. You don’t need them for everything of course. I would just use 2.54 mm pitch rows of through holes wherever and let people solder their own connectors on so they can choose from dupont, molex, screw terminal or soldering wires directly on. May seem like a minor point but it’s nice to have details like that…

On another note, I tried changing the dead time of the lepton to 0.08 using

  driver.voltage_power_supply = 24;
  driver.dead_zone = 0.08;

And things do change, but they are worse than ever. The capacitor get hotter faster and the noise is so bad about one in every 50 characters gets through when I connect the pico. The TTL converter works better but… if I ground things even better the figure goes up to about one in 25. So it’s some kind of severe noise problem, apparently influenced by dead time. Maybe there is a problem with the code invoving the timers on this chip or something, which would at least mean it’s not the hardware, and that would be good to know. however I have no idea how to solve a low level problem like that. I guess it could be leapfrogged over, not every chip has to work. If the problem evaporates with the g431 chip then that’s enough for now. The question is, will it.

Edit: tried 0.03 but it seems to make little or no difference ,might even make it worse, not clear.

On the topic of power/motor connectors, I really like the pluggable terminal blocks, like these:

They’re available in 3.5mm pitch from many suppliers, and if you shop around you can even get different colours. If the boards are big enough to allow them to be used, I like to use them for power (2 pin) and motor (3 pin).


Yeah I discovered those a little while and got a ton of them on aliexpress, they are hard to get anywhere else. They sell ones with terminal connectors on both ends, like wire to wire not just wire to board, I use those all the time. I used to use candy block connectors but it’s hard to get good ones at a reasonable price. These pluggable connectors provide the same function plus you can disconnect stuff and swap things around.

The most common pitches are 5 mm and 3.81 mm