VCU/controller for 4 motor setup

aesthetect
Posts: 21
Joined: Fri Jun 03, 2022 6:15 am
Has thanked: 4 times
Been thanked: 1 time

Re: VCU/controller for 4 motor setup

Post by aesthetect »

Pete9008 wrote: Wed Mar 29, 2023 2:30 pm I'm probably doing the same as you here - I know little about your algorithms so may well be overestimating their complexity, processing requirements, need for debug access and so over complicating the solution.

If that's case it does open up other possibilities. If you are happy to work on the firmware in C/C++ it's possible that a VCU could handle the whole job. The main limitation is that the the CPU only has one core running at 72MHz (assuming it's the STM32F1 family - afraid I'm not too familiar with the Zombie) and no hardware floating point support. If that's enough to do what you need, and if you use the IO inverter board to allow them all to exist on the same CAN bus then it would be an option. If you need a bit more performance then it would be possible to offload that to a Pi and leave the VCU to just handle contactors, monitoring, etc.

Regarding the Raspberry Pi vs the OKdo board it was really the IO that caught my eye, for example the Pi 4 has 1 UART available while the OKdo has 8, the Pi has 2 SPI ports, the OKdo has 4, Pi has no analogue inputs while the OKdo does and so on. The UART and SPI in particular could be used to add CAN ports (either via serial to CAN dongles or MCP2515 type chips). Having said that it is harder to use the IO on the OKdo as a custom motherboard is needed, on the Pi you can just add shields. The best thing to do is get hold of some hardware and have a play.

On the real time side the simplest way to test it is to just generate an IO line toggle from whatever language you want to use and check it on a scope. If the worst case pulse output timing is regular enough, and has low enough jitter, to satisfy your algorithms requirements then go with it.

On the two options for controlling the motors.

Using the Leaf protocol has the advantage that you are using the motors in the way Nissan intended and so benefiting from the 1000's of hours they will have spent tuning the inverter, algorithms and motor to each other. The downside is that if you find that Nissan approach causes problems (for example any throttle ramps are too slow to suit the needs of your algorithms) then there is very little you can do about it. You also need multiple CAN ports.

The OI option on the other hand gives you much more control of what the motor is doing. If you find something that causes you a problem you have the ability to dive into the parameters, or even the firmware as it's open source, and fix it. You can also have as many motors as you want (within reason!) sharing the same CAN bus. The main downside is that it's not as mature a platform. For example until fairly recently there were still problems running above base frequency (search unwanted regen or acceleration on the forum). Hopefully that's all now sorted but I doubt it is ever going to be as well tuned to the motor or quite as stable as the OEM solution.
Well, if you are, thankfully 100% of your input is helping me greatly, and is greatly appreciated. That post especially put a lot of things in perspective.

The algorithms really are simple, or just to say they are not driving the speed / processing requirements any more than a throttle pedal input would if it was CAN. Would you say 10 ms (required for the pulse/counter signals to keep inverter happy) would require real time? I think that will be my most critical time constraint.

Also I'm really glad you said that about ramp rate limitations with the OEM inverter controls. That right there might be enough to push the whole thing solidly into the whole openinverter world. Although I would very much like to use the 160 kW units, I guess that’s not an option if I have to change control boards.

Thanks again Pete. Pretty sure you are 4,000 miles away or I'd love to buy you a beer.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: VCU/controller for 4 motor setup

Post by Pete9008 »

Sounds like I may have been over complicating things, sorry about that :oops:

The way I've always done this is start from the algorithm. You know its processing requirements so can use that to estimate the processor power required. The real time bit is down to how much latency on an interrupt, or jitter on a timing edge, you can live with. That's best determined from the response of the system you are controlling (in this case how fast grip can change, and how fast the car can move?).

I'm a little out of date but my guess on latencies would be typically a few ms (possibly with the occasional to tens/hundreds of ms - dependant on the OS, number of cores and what else is going on) on a standard OS or half a ms on a real time OS. Without an OS (OpenInverter or the VCU) you can get well below a us if using interrupts.

A real time OS could handle the 10ms no problem. A standard OS might but depends on the specific OS, the hardware and what else is running on it - you would need to do the testing to ensure that it could achieve it in worst case conditions.

Edit - just to be clear, I've no idea whether there actually are any ramp limitations in the OEM inverters, it's just an example of the kind of thing that might be there that you can't do anything about.
aesthetect
Posts: 21
Joined: Fri Jun 03, 2022 6:15 am
Has thanked: 4 times
Been thanked: 1 time

Re: VCU/controller for 4 motor setup

Post by aesthetect »

MEGA EDIT - moved big long new post into the quote below. Summary here:
I think the number of USBs I need makes all the microcontroller and SBC options not practical.

Software and skill level wise, I think CODESYS is very perfect. It is powerful, nice and high level, and learning it will be useful for other aspects of my life. And as far as run time, seems to be a much better choice than Python. I had seen it was expensive before, but now I think is free (?). We'll see.

Based on that, some kind of automation direct PLC likely fits the bill. I may see if an industrial PC is also an equal or better option. probably get a zombieverter VCU as well for testing at the least.

Huge huge thanks to Pete for input and sounding board for me to get my thoughts together.

Now to assemble finances for the full bench setup ...aaand we're off!
Well, I think what you are discussing is the proper way to do it. And with that help I think I now have narrowed down what it is I really need (below).

You are right that there are aspects that would be good to have real fast response time (particularly traction control, especially for making it smooth). I just dont want (because dont know how) to manage and deal with scheduling, priorities, etc which is my aversion to true hard real time per se. And the most critical parts of functionality I need won't necessitate those speeds, so I'm willing to gamble on those capabilities.

I think if I get the hardware in the right ballpark and run real time linux OS (so at least OS wont intro suprise interrupts/delays) [edit: reading more, I think low latency ubuntu may fit the bill just right] then I will be close enough that I will just plan to run routines in regular python and speeds should be sufficient (unless I'm told otherwise).

I've been toying with numbers and gear ratios and I definitely need to use the 160 kW leaf motors, and I cant use openinverter control board on 160kw/gen3 leaf inverter, as best I can tell, so I will definitely be planning on (at least) 4 separate CAN networks. I will just take my chances on limits for ramp rate (understood its not certain, but def the kind of thing I want to be taking into account. limited max torque for regen is actually another similar concern though it seems fine by lookign at CAN protocol).

I got a preliminary list of IO together. This is bare minimum and preliminary so would like at least a couple extra of each. Glad I dug in, as more than I thought were CAN or USB. However, this is obviousy a lot of USB now... does that change anything? I think this points me straight at industrial PC. or could I just use a hub? or any 'smart' way I should go about it?
Digital inputs: 2x USB
Analog outputs: 14x, all just 0-12V for contactors and relays so I could double up quite a bit
Analog inputs: 6x 0-5V, 4x 0-12V

So then what I need to find is the right piece of hardware, something like a SBC or industrial computer (ie exactly like your very first suggestion...) so its complete and ready out of the box. But basically just for IO and to run the algorithms - if possible I'd like to spec it so it could run everything, or maybe end up having it working in concert with zombieverter (just have them communicate w eachother via CAN?) then just see what works best on the bench. So any help in picking or speccing that piece of hardware would be huge.

TLDR - summary, looking for a 'complete' SBC setup or industrial PC with:
- Linux RT compatible
- 4 USB for CAN networks
- Digital inputs: 2x USB
- Analog outputs: ~14x 0-12V
- Analog inputs (min): 6x 0-5V, 4x 0-12V

Processing power and memory I frankly dont know. I'd tend to lean towards just overdoing it.
How could I best approximate that procesing power requirements? I could start writing that code, its pretty solidified conceptually, but it would be a while before it was running (so a bit of delay as far as using that to get started on buying hardware). Presuming I could test speed by picking a couple static sample inputs and measure the time it takes to run through the process for a few different conditions?

Edit:
This looks good but $1800 and a bit overkill
https://www.mouser.com/ProductDetail/Ad ... S_EALw_wcB
then when I dig in too much it makes me second guess python. which leads me to consider codesys (which we use for industrial applications at work so I would be eager to learn). which leads me back to industrial controllers/PLCs...
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: VCU/controller for 4 motor setup

Post by Pete9008 »

Sounds good, glad you've found a solution that your comfortable with and looking forward to updates :)

Just curious what kind of targets you have for torque, power and max rpm from each motor, which is pushing you towards the 160kW motor? A 640kW capable vehicle with torque vectoring is going to be a very, very interesting vehicle!!
aesthetect
Posts: 21
Joined: Fri Jun 03, 2022 6:15 am
Has thanked: 4 times
Been thanked: 1 time

Re: VCU/controller for 4 motor setup

Post by aesthetect »

The problem is mostly just with four motors, gears, etc it’s going to be heavy (especially in a ‘garage / budget’ version), hopefully not too far north of 4,000 lb, so trying to keep power to weight up. And no doubt the end result and acceleration will be compared to Teslas etc

Also my front gear ratio(s) may not be ideal, so total torque might be compromised; so then it’s definitely worth getting every Nm I can for ‘free’.

Also also having all the headroom I can on power gives me a lot more options for how to do torque vectoring (ie being able to run it at marginal level and have room to bump up in certain conditions), a lot of which should help with it feeling natural and intuitive.
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: VCU/controller for 4 motor setup

Post by Romale »

with the help of the v3 OI boards, I received 160 kW! from the leaf gen2 kit (85 kW / 110 horsepower in the factory version)
So it's not necessary to buy expensive gen3 leaf kits, you can get impressive power from cheap gen2.
evil neodymium :twisted:
aesthetect
Posts: 21
Joined: Fri Jun 03, 2022 6:15 am
Has thanked: 4 times
Been thanked: 1 time

Re: VCU/controller for 4 motor setup

Post by aesthetect »

Romale wrote: Mon May 01, 2023 10:09 pm with the help of the v3 OI boards, I received 160 kW! from the leaf gen2 kit (85 kW / 110 horsepower in the factory version)
So it's not necessary to buy expensive gen3 leaf kits, you can get impressive power from cheap gen2.
Very interesting! Any indication as to the degree with which it can do that "continuously" without thermal issues?

Some updates -

1. I found there is a linux PREEMPT RT kernel for raspberry pi and also that CODESYS has a package for raspi as well so I have just bought one to use as an initial bench test setup and get my CODESYS stuff going. I'll expect to purchase a more powerful PLC later but we'll see, may not really be necessary. I'm also going to test if I can just use a USB hub for the 4+ CAN busses.
2. Started more detailed work on the algorithms and realized I am even more dependent on a need for direct / closed loop speed control than I thought. I know cascadia provides that mode and can switch on the fly which is perfect. That might steer me towards using their products instead of the leaf motors. But that is funding dependent (which is where my time/effort/questions are mostly focused right now)... in any case it is a realization that is causing a good bit of a re-think.

edit: Also also - any suggestions for cheap devices I can use to test CAN communication on a bench setup? I'd rather have an actual device as opposed to checking via wireshark or something. bonus points if it is a variable speed motor...

I was thinking of using a Volvo electric-hydro power steering pump in the car, which can be controlled via CAN, so thought about just getting one of those - but I'd really like something cheaper so I can test multiple of them (and thus test multiple CAN networks simultaneously)
Post Reply