Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Tell us about the project you do with the open inverter
Post Reply
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

johu wrote: Sat Jan 28, 2023 9:22 am Let me tell you using the motor as inductor is not quieter ;) It's a shame I never made a video of Polo charging, it was quite a palaver. 8.8 kHz plus 100 Hz hum. With 17.8 kHz it was just 100 Hz hum plus hot inverter.
Was thinking about this, because it' only a half bridge the centre aligned PWM doesn't help and 8.8kHz actually gives accoustic noise at 8.8kHz not 17.8kHz.
johu wrote: Sat Jan 28, 2023 9:22 am Nice find on LDFLAGS rather then hard coding the -L to the hardfp libs.
Thought about hard coding the library location but really didn't like the idea. Not sure the fix I've found quite does the job though; this is what you see in the disassembly window for the GetTotalVoltage function when using libm:
libm.png
libm.png (17.31 KiB) Viewed 2306 times
Not as conclusive as it could still be using the vsqrt call inside the call to sqrtf but that and the slower than expected execution (19.535us compared to 15us for fixed point) made me wonder.

Found a couple of posts suggesting that math errno can prevent the fpu being used so added the compiler flag -fno-math-errno but it didn't seem to make any difference.

Ended up binning libm and libc and instead using an inlineable function with a direct assembler call to the command. This is now the disassembler view of the same function:
asm.png
asm.png (14.26 KiB) Viewed 2306 times
Fairly clear that that is using the fpu! execution time for PwmGeneration::Run() also dropped from 19.535us to 16.795us :)

Not ideal as I now need to add a little bit of conditional compilation so that it will also run in the simulator but I was getting thoroughly fed up of trying to find the compiler/linker options to get libm to do the same (sure it's possible, I just don't know the magic combination of flags).
johu wrote: Sat Jan 28, 2023 9:22 am Was it a lot of changes to the F1 code base to run on the F4?
Not too bad at all, ignoring the fixed point to floating point stuff, libopencm3 hides most of the changes. Most of it is just changing reloads to suit the new clock frequencies. Did have to replace the old rtc with timer5 and a few changes to suit the new flash memory structure. You'd already done a lot of this on your libopeninv port. Most of my time was spent taking out all the legacy code which it no longer made sense to keep in and the rest restructuring the way interrupts/DMA work for triggering resolver/current sampling and the main control loop execution.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

The floating point F405 code is working in the simulator :)
SimF405.png
Not a particularly interesting plot but it is controlling the motor!

While porting I've found a idiosyncrasy in 5.24 - the picontroller does fixed point multiplication inside the error accumulator code without using FP_MUL. Doesn't affect operation at all but does mean all the gains are actually 32x less than we enter in the parameters. When using floats I had to drop kp and ki by a factor of 32 to get it to work.

Just need to start porting the newer algorithms across now, tidy up a few bits (following bug fixes in the float code) and fit all the connectors onto the PCB and it should be ready to try with a real motor :)
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by johu »

Great :)

Yes I know it's doing that, not the most stringent design I guess. Not really sure what the motivation was, maybe it allows a greater range without overflowing or something.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

Not got as much done over the weekend as hoped but have managed to get the logic board finished:
FullyPopBrd.JPG
The current filters are now set to 40kHz cutoff which gives a 10us phase delay. They won't do anything to attenuate PWM frequencies but should help reduce switching noise. The CT have been plugged in too and seem to work ok, yet to pug it into the inverter though.

For anyone who is designing hardware to interface to the Gen3 Prius I've also figured out how the current sensor interface should be done. The CTs actually use the +5V rail to provide their 0A reference (the output is +5V at 0A). If the CT output is just divided down to suit the ADC input range you get offset errors as both the +5V rail and 3V3 rails move (only regulators, not precision references so will move around with temperature and load). A better way to do it would be to use a diff amp (supplied from -5V and +26v) to provide a level shift function from the 5V input offset to a virtual earth generated from half the 3V3 rail. The diff amp can also include a bit of LP filtering. Done this way there will be no 0A shift as the rails move and it would probably be possible to get rid of the offset compensation block in the firmware.

Just wishing I'd clicked sooner. It's too late for this board but if there is ever a V2 I'll move to a proper diff amp then.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

Interesting!

What reference voltage would you use? The +5V rail isn't the best as it will still drift and a +5V precision reference powered from +12V or +26V will be resonable solid.
Wouldn't you want the +5V ref signal to the CT to drift with the ADC supply voltage i.e. powered from the same voltage as the VDDA?

Does the +5V reference to the CT need to be +5V or can +4,9V suffice?
Would a +4,9V reference generated from the +3,3V (VDDA) be an option? Then the simple voltage dividers could still be used. The ref voltage could be powered from the +5V rail if a rail-to-rail op-amp (MCP6001 as an example) is used to generated the amplified voltage from the +3,3V.
image_2023-01-31_062237032.png
image_2023-01-31_062237032.png (5.08 KiB) Viewed 2087 times
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

Thanks for that! I've been thinking along much the same lines and you are absolutely right it's the tracking of the 3V3 and 5V rails that matters most :)

Last nights thought was to use something like a INA597 to do something like this (but with the ref generated from half the 3V3 rail to allow bipolar operation and an extra divider to get the divide ratio nearer 3:1 rather than the diff amps 2:1):
INA597.png
If starting from scratch this is probably how I would do it.

Having slept on it I decided it was probably worth trying to get a handle on the size of the issue. I'm using a MC33063 for the 3V3 rail and a ADP2303 for the 5V. I'm going to ignore load regulation as the load should be fairly constant and just consider the temperature effect. The ADP part looks pretty good with only a 1mV change in reference for a 30C temperature shift, so say 3mV on the 5V rail. The MC part is not well specified but it's reference accuracy seems to get 15mV worse over the full temperature range so lets say 15mV (smaller temp range but on 3V3). The MG2 gain (based on a very rough measurement) is around 10mV/amp so that could be an error of around 1-2A as the inverter warms up from cold (depending on whether the two rails move together or go in different directions).

Not as bad as I was expecting and I can probably live with that. It's unlikely to be enough to notice in normal driving, it might have an impact on low throttle efficiency but even then it would probably be too small to measure. Given the extra cost and complication of the diff amp I'm not sure it is worth it.

I did come up with another couple of approaches in addition to yours:
1) - Your suggestion, create a 5V rail referenced to the 3V3 rail. Should work well but would depend on the CT circuitry and how much current it pulls/pushes into the 5V line. Would need to reverse engineer the CT circuit to see if it would work.
2) - Supply the CT with 3V3 instead of 5V. Nice and simple but would complicate the voltage divider arrangement (or limit range) and again would need to reverse engineer the CT circuit to see if the changed rail voltages would cause any issues.
3) - Use a spare ADC channel to measure the 5V rail (again using the 3V3 rail reference) and then compensate in software.

Number 3) is probably the approach I'll take. I have a spare input that was intended to be used for a regen pot so might see if it can be repurposed.

Edit - Have I got that right, 10mV/amp with a measured 0A offset of 1.8V going into the ADC would mean a max current of only 150A - that doesn't sound right. Need to check the scaling, 5mV/A would seem more realistic (in which case the offset could shift by 2-4A).

Edit2 - the 10mV/A is before the potential divider, on the ADC input it's more like 3.3mV/A. That means the current offset drift could be of the order of 3-6A.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

The load on the +3V3 voltage rail and hence the +5V rail is far from constant when using the WiFi-module and also the CAN-tranciever creates noticable load changes. I had a lot of spikes in the position measurement due to +3V3 fluctuation when I first started messing with the OI board. I have now a separate +3V3 regulator for the WiFi module and use a CAN-tranciever with 5V supply and separate 3V3 IO supply (MCP2562). But both of those might still create fluctuation on the +5V rail, though less pronounced.

If both voltages drift in the same direction with temperature the issue is smaller as it is the difference between the two that is causing the error.

Using a +5V voltage reference for the CT input and then using a +3V0 voltage reference (powered from +3V3 rail) as VDDA reference might increase precision on both the current and position measurement.

Do you have any idea of the CT:s current consumption on the +5V input?
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

Hm, found this reference/LDO to supply the +3V3 to both processor and VDDA. Not cheap though, starting at €7.
https://www.mouser.se/ProductDetail/Ana ... G8vg%3D%3D
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

bexander wrote: Tue Jan 31, 2023 10:09 am The load on the +3V3 voltage rail and hence the +5V rail is far from constant when using the WiFi-module and also the CAN-tranciever creates noticable load changes. I had a lot of spikes in the position measurement due to +3V3 fluctuation when I first started messing with the OI board. I have now a separate +3V3 regulator for the WiFi module and use a CAN-tranciever with 5V supply and separate 3V3 IO supply (MCP2562). But both of those might still create fluctuation on the +5V rail, though less pronounced.
Good point on the WiFi although I'm not planning on using it much. The module will be there mainly to do SD card logging but I plan to have the WiFi disabled unless it's actually being used, it is also located remotely from the inverter connected on a RS485 link so will not be pulling power from the logic board. I tend to go a bit overboard on power supplies and rail decoupling so hoping not to have too many many problems with load changes.
bexander wrote: Tue Jan 31, 2023 10:09 am If both voltages drift in the same direction with temperature the issue is smaller as it is the difference between the two that is causing the error.
Agreed, the 3A mentioned above is if they move in the same direction, the 6A if they move in opposite directions
bexander wrote: Tue Jan 31, 2023 10:09 am Using a +5V voltage reference for the CT input and then using a +3V0 voltage reference (powered from +3V3 rail) as VDDA reference might increase precision on both the current and position measurement.

Do you have any idea of the CT:s current consumption on the +5V input?
Just measured it, 32.6mA on the 26V rail and 10.9mA on the -5V rail, so the +5V rail must be sinking around 20mA (just moved the meter into the 5V link to check - 21.9mA). Not sure an op-amp generated 5V rail would be too happy with that.

Pulled the CT apart and had a look, there appear to be 4 hall effect sensor IC's (no visible markings) and a couple of what look like UPC4570 dual op-amps (specced at 5mA supply so guessing this is the 10mA and the rest is the hall effect sensors).

Just also rechecked the output voltage but with a proper meter rather than the scope, they actually sit at around 240mV above the 5V rail so it would appear that treating 5V as the 0A reference wouldn't be a good idea after all!

It's also occurred to me that I'm being a bit dim trying to calculate things. The hardware is there on the bench, the sensible thing to do is power it up, take measurements while it warms up and then point a fan heater at it and take a few more measurements. By measuring both the CT output, the rails and the ADC readings it should be possible to see exactly how big any errors are and what they are caused by.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

Pete9008 wrote: Tue Jan 31, 2023 11:46 am Just also rechecked the output voltage but with a proper meter rather than the scope, they actually sit at around 240mV above the 5V rail so it would appear that treating 5V as the 0A reference wouldn't be a good idea after all!
This is rubbish! No idea why it measured like that. The CT had been dissembled so the hall effect sensors were not inside their cores and the outputs were unloaded so guess one of the those must be the cause. When connected back up properly the output is within a few mV of the +5V rail.

Have had it running over lunch, and with some heat on it, so far no sign of any significant offsets. Having said that there is something not quite right with the way the injected ADC conversions are being read so need to do a bit more digging on that before drawing any real conclusions.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

Update, sampling issue now solved, scan mode wasn't enabled on the ADC so it wasn't doing the full injected conversion sequence, now sorted. Unfortunately this hasn't solved my noise problem. I have around 20mV noise on my -5V rail which is coupling through onto CTs output and giving me a noise level of a few amps. Going to have a look at the -5V rail to see what can be done.

Edit - The problem is that the -5V rail current is too low (the regulator is going into pulse skipping mode and the inductor in to discontinuous conduction mode) so it may improve when connected to the inverter and the load increases. If not will have to review the inductor value on the switching regulator to get it back into continuous operation mode.

What's noise level is considered normal on a gen3 Prius when using an OpenInverter board and doing single "get il1" commands on the terminal (with zero current flowing)?
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

Pete9008 wrote: Tue Jan 31, 2023 11:46 am Just measured it, 32.6mA on the 26V rail and 10.9mA on the -5V rail, so the +5V rail must be sinking around 20mA (just moved the meter into the 5V link to check - 21.9mA). Not sure an op-amp generated 5V rail would be too happy with that.
I assume this is for on pair of CT:s, i.e. measured on the cables from the connector to the CT:s?
So that would be the total power consumption on the 26V rail, in my case, using only MG2.

I think it will depend on what kind of op-amp you use. The MCP6001 can supply 23mA when powered from 5,5V so not far away.

Anyway, using a precision voltage reference to supply 5V to the CT is off the table.
Pete9008 wrote: Tue Jan 31, 2023 3:23 pm What's noise level is considered normal on a gen3 Prius when using an OpenInverter board and doing single "get il1" commands on the terminal (with zero current flowing)?
Do I check this with the inverter running, but no HV connected, then send "get il1" and check how the respons varies?

You are planning to use a switch-mode 3,3V regulator, right? Maybe a LDO is more stable? In the end I guess this is up to the design of the control circuit and not so much the topology used.
Did think about this LT6658BIMSE-3.3 again, that I linked above. With its two outputs it is possible to supply 150mA on 3,3V and 50mA on 5V, but that will require at least 7,5V supply to it. The outputs will have very minimal differential drift, and 1mV drift over the entire temperature range. Maybe worth the extra trouble?
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

bexander wrote: Tue Jan 31, 2023 5:44 pm I assume this is for on pair of CT:s, i.e. measured on the cables from the connector to the CT:s?
So that would be the total power consumption on the 26V rail, in my case, using only MG2.
Correct, it's for a single pair of CTs (actually MG2) measured on the connector so this will be your total current. Mine is twice this as I have both sets of CTs connected.
bexander wrote: Tue Jan 31, 2023 5:44 pm I think it will depend on what kind of op-amp you use. The MCP6001 can supply 23mA when powered from 5,5V so not far away.

Anyway, using a precision voltage reference to supply 5V to the CT is off the table.
I've been caught out a few times when trying to do things like this with op-amps, especially rail to rail input and output ones used near the limits of the spec. Some are fine but some cause problems. The rail to rail ones tend to be a bit on the slow side too.
bexander wrote: Tue Jan 31, 2023 5:44 pm Do I check this with the inverter running, but no HV connected, then send "get il1" and check how the respons varies?
If you could that would be great. Il1 and il2 are a little odd in that they are only sampled if the inverter is in run mode (they are measured in the main control loop). And yes, just take multiple individual measurements and see what extremes are seen. I get plus or minus around 1A with the CTs disconnected (no need for you to do this, just included for reference) and typically plus or minus 3A, with the occasional 5A, with the CTs connected. I have a feeling that this is higher than typical.

The ADC noise itself looks to be down at around 0.25A, the rest looks like it is coupling in from the supply rails.
bexander wrote: Tue Jan 31, 2023 5:44 pm You are planning to use a switch-mode 3,3V regulator, right? Maybe a LDO is more stable? In the end I guess this is up to the design of the control circuit and not so much the topology used.
Did think about this LT6658BIMSE-3.3 again, that I linked above. With its two outputs it is possible to supply 150mA on 3,3V and 50mA on 5V, but that will require at least 7,5V supply to it. The outputs will have very minimal differential drift, and 1mV drift over the entire temperature range. Maybe worth the extra trouble?
I've done a fair bit of design for precision instrumentation in the past and have usually had to use switch-mode supplies due to power budgets (which is why I'm a little annoyed that I haven't got this as good as it should be!). Low noise is a lot easier with linear regulators but switch-modes can be made to work very well. On this design I'm reluctant to re-spin the board and equally reluctant to start wire modding it (for reliability reasons) so I'm stuck with the switch-mode supplies on all the rails. In theory they should be fine. I'm hoping it's just a case of measuring what the load currents actually are and then tuning the regulator component values to match.

The inverter will hopefully be getting a good clean tomorrow so that it can be brought in to the house for testing with the logic board and so I should have a better idea of the +5V and -5V supply current requirements then.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

Did the "get il1" test. Inverter in car, in run mode, gear N selected.
I get +-0.37A with one 0.75A and twice 0.56A with approx 100 commands sent spread over both il1 and il2.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

bexander wrote: Wed Feb 01, 2023 7:25 am Did the "get il1" test. Inverter in car, in run mode, gear N selected.
I get +-0.37A with one 0.75A and twice 0.56A with approx 100 commands sent spread over both il1 and il2.
Thanks for that, appreciate it. It's pretty much what I was expecting but nice to have it confirmed. That's a pretty good result, surprisingly good in fact, and pretty much at the limit of what can realistically be expected. Is that with a standard EVBMW board?

Mine is about 10x worse which is more than a bit annoying. Having looked into it a bit more the main problem would appear to be my choice of switch mode regulators. There wasn't a lot of choice when I was designing the board due to the chip shortage and the device I used for the 3V3, +26V and -5V is a pretty poor choice (remember being at bit unsure about it at the time but it was the only one I could find). It always runs in pulse skipping mode which is always going to be noisier. The device used on the +5V rail is a much nicer part and has a chance of running quietly enough. The plan is therefore to improve the +5V rail as much as possible and then derive a reference from it to drive the VDDA line on the processor. This will hopefully both reduce the noise and eliminate any rail to rail drift. Hopefully it can be modded onto this board well enough, if not it's going to need a respin (although this board is probably good enough for testing with for the time being).

One other slightly worrying thing is this app note from ST https://www.st.com/resource/en/applicat ... ronics.pdf. It details how to disable the ART flash memory accelerator to improve ADC performance on the STM32F4 series. That is worrying enough by itself but what is even more worrying is that even with the ART disabled they are still talking about 17 ADC codes noise. There is another paper suggesting avoiding toggling output lines on the same port as the ADC inputs - bit difficult when most of the ADC lines are on the same port as the PWM! All in all these suggest that the F4 ADC may never be as quiet as the one on F103 :(
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

Pete9008 wrote: Wed Feb 01, 2023 10:22 am Thanks for that, appreciate it. It's pretty much what I was expecting but nice to have it confirmed. That's a pretty good result, surprisingly good in fact, and pretty much at the limit of what can realistically be expected. Is that with a standard EVBMW board?
It is a EVBMW board but it is modified with a separate +3V3 LDO for the WiFi and also uses a MCP2562 can-tranciever powered from the +5V-rail to eliminate voltage fluctuation on the +3V3-rail used by the STM32.
Pete9008 wrote: Wed Feb 01, 2023 10:22 am Mine is about 10x worse which is more than a bit annoying. Having looked into it a bit more the main problem would appear to be my choice of switch mode regulators. There wasn't a lot of choice when I was designing the board due to the chip shortage and the device I used for the 3V3, +26V and -5V is a pretty poor choice (remember being at bit unsure about it at the time but it was the only one I could find). It always runs in pulse skipping mode which is always going to be noisier. The device used on the +5V rail is a much nicer part and has a chance of running quietly enough. The plan is therefore to improve the +5V rail as much as possible and then derive a reference from it to drive the VDDA line on the processor. This will hopefully both reduce the noise and eliminate any rail to rail drift. Hopefully it can be modded onto this board well enough, if not it's going to need a respin (although this board is probably good enough for testing with for the time being).
Be careful with the VDDA powered from a separate supply.
stm32f103c8 datasheet states on page 39, "It is recommended to power VDD and VDDA from the same source. A maximum difference of 300 mV
between VDD and VDDA can be tolerated during power-up and operation."

Regarding the WiFi and your mention on RS485. Are you planning to have the WiFi module outside of the inverter and communicating with it using RS485-bus? Could you share your control chip used and how it is powered? I think it is a good idea to have the possibility to turn off the WiFi and having it externaly is even better. Just plug it in if needed.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

bexander wrote: Wed Feb 01, 2023 12:02 pm It is a EVBMW board but it is modified with a separate +3V3 LDO for the WiFi and also uses a MCP2562 can-tranciever powered from the +5V-rail to eliminate voltage fluctuation on the +3V3-rail used by the STM32.
I think you have done well with those mods, achieving that noise level is pretty good going!
bexander wrote: Wed Feb 01, 2023 12:02 pm Be careful with the VDDA powered from a separate supply.
stm32f103c8 datasheet states on page 39, "It is recommended to power VDD and VDDA from the same source. A maximum difference of 300 mV
between VDD and VDDA can be tolerated during power-up and operation."
The same sentence is in the F405 reference too and is why I left them on the same rail in the first place.

Now wondering about generating a virtual rail from an op-amp but with a Schottky diode clamp to force it to track VDD under all conditions. But before trying that I'm going to look a bit more at the power rails.

I've added a standard deviation calculation of the last 100 readings to the il2 readout to make it easier to see what changes have most effect and at the moment it's the 3V3 rail (as you originally suggested). The 3V3 was designed for 700mA but only needs to supply around 200mA (due both to over-estimating and removing chunks of the board without recalculating). This means that it is skipping 2 out of every 3 output pulses and so is only running at 23kHz rather than the design value of 70kHz. Fixing this and moving to the maximum of 100kHz should reduce the ripple by a factor of 4, I can also increase the output capacitance which will hopefully give another factor of 2 or 3. The other rails could do with similar attention. I'm hoping that these changes will get this board to the 'good enough for now' point but need to order a few replacement component values in order to try it.
bexander wrote: Wed Feb 01, 2023 12:02 pm Regarding the WiFi and your mention on RS485. Are you planning to have the WiFi module outside of the inverter and communicating with it using RS485-bus? Could you share your control chip used and how it is powered? I think it is a good idea to have the possibility to turn off the WiFi and having it externaly is even better. Just plug it in if needed.
Exactly, I don't like the idea of having a WiFi transmitter in a screened metal box with analogue signals! I'm just using a MAX3485 transceiver on the logic board connected to the standard UART lines (it can be powered from either 3V3 or 5V). I'll use another at the ESP32 end. I was limited on pins so went for half duplex which does need firmware changes both ends. If I'd has another 2 pins I would have used a pair of transceivers each end (one for Rx and one for Tx - RS422) to maintain full duplex comms and existing code compatibility. I'll leave it connected all the time (as I'm going to use it for SD card logging - see viewtopic.php?p=46207#p46207) but will add a switch to enable/disable the WiFi. I can't see any reason why it wouldn't be possible to have footprints for both options (header or MAX3485) on the board and then just populate whichever is needed.

Edit - if going full duplex RS422 then a transceiver like the DS8921 would be a better choice, only suits a 5V supply though.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

The parts needed to improve the ripple on the power supplies are on order but not turned up yet. Hopefully they will make a significant improvement but not convinced they are quite going to get it to where I want it to be. I can't face re-spinning the board at the moment so have come up with another plan. I'm half way through designing this (placement and board outline done, routing still to go):
ModBrd.png
The idea is that I'll remove the filter op-amps currently fitted on the logic board and fit this in their place. The castellated holes line up with existing pads to pick up the signals and power rails and it adds an instrumentation amp for each current channel. This will make the level shift independent of the absolute value and drift of the two rails (+5V and +3V3) and should also provide a good improvement in power rail ripple rejection too. Not going to order the PCB just yet as I still need to check the logic board will actually run a motor (if not it needs re-spinning anyway) but will probably order all the bits as they will be needed one way or the other.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

Replacement power supply bits turned up and have been fitted. Ripple on the rails is down to 5-10mV and calculated standard deviation on the current measurement inputs is down from around 4A to 1A so good enough to continue with bench testing but still room for improvement (so it looks like I will be ordering the mod board mentioned above).

Also tested the logic board with the ESP32, works fine at 115200 but wasn't keen on running at high speed. Turned out the problem was the cheap RS485 to USB to 232 to TTL adaptor I was trying to use. Since I'm going to be doing a PCB order it seemed to make sense to combine postage so started on another board too - an external ESP32 board to replace the adaptor. So far just the schematic done:
ESP32.png
My logic board doesn't have WiFi on it, instead the UART goes to a RS485 port. This board will connect to the far end of that link. The idea is to get the WiFi out of the inverter to improve WiFi signal strength, reduce interference and make it easier to update the ESP32 if needed.

The module also contains a SD card to support data logging and a real time clock (to time stamp the log files). The comms port is wired to support either RS422 or RS485 (full duplex or half duplex). It also has two power feeds, the idea is that power it from one and it will boot into data logging mode and power it from the other and it boots up into the normal web page server via WiFi mode.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

The external ESP board is now all routed. Decided not to bother with a box so no mounting holes as it's only 30x60mm. It will just be covered in heatshrink instead. The battery is soldered rather than replaceable now as calcs showed it should last over 10 years. Revised schema and PCB views below.
ESP32_Schema.png
ESP32_PCBt.png
ESP32_PCBb.png
Once I know it works I'll stick the design files up on github.
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Ev8 »

Wish I had half of the kicad skills you have Pete, I’m ok with schematics but once I start having to find missing footprints ect I get bored and give up!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

It's just takes practise - I've spent too much time over the years doing PCBs. Kicad is amazingly good for an open source package, I'd say it's easily better than many commercial packages and getting close to some of the best. So far I haven't had the latest version crash either (not sure whether that's due to the version change or the fact I switched from Windows to Linux at the same time).

I know what you mean about footprints though (I'd rather go and find another part than have to create one from scratch) but I've found that the libraries that ship with Kicad are now pretty comprehensive. There is a good chance of finding the exact part and even if not there's likely to be something close enough that it's just tweaking rather than creating. Didn't have to do a single footprint for this board (although the SD card socket was chosen specifically because a Kicad part for it already existed!).

Got to say it's quite nice to be doing electronics as a hobby again rather than for a living!
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by bexander »

A lot of footprints can be downloaded from mouser.com, or other large electronic suppliers.

EDIT: You need to create a free account to be able to download footprints from mouser.
royhen99
Posts: 195
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 14 times
Been thanked: 94 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by royhen99 »

I have managed to import a PCB design from EasyEDA, footprints only so far, to Kicad. Some parts did not translate correctly but most OK. This allows any footprint from JLCPCB library to be imported. Mouser library also good but some of the parts have errors so need to be checked carefully.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Smart Roadster (with Prius Gen3 Inverter and Outlander Rear Motor)

Post by Pete9008 »

It's occurred to be that I could probably fit a CAN transceiver onto this board too, there is just enough space above the SOIC14 package to squeeze it in:
image.png
image.png (159.12 KiB) Viewed 1378 times
It wouldn't be possible to have both RS485 and CAN at the same time (as they would need to share connector pins) but it would be possible to build the board for one or the other. It's not something I'm ever likely to use so if no-one else is interested I'll probably leave it as it is. If there is any interest I'll change it though.
Post Reply