Outlander rear motor and inverter

Mitsubishi hybrid drive unit hacking
User avatar
rstevens81
Posts: 386
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 29 times
Been thanked: 114 times

Re: Outlander rear motor and inverter

Post by rstevens81 »

Looks like I might be investing in a long steel bar to do some experiments 🤣
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

Romale wrote: Tue Aug 13, 2024 10:04 am item "a".
Hm... i am thinking of connecting to my other inverter and sensing unknown wires for transient signal when putting it in short. Of course i would be doing this with 48Vdc power supply...

In Volt inverter i see fault signal as a weak pullup with NMOS pulling it down when inverter is active. If something would happen control would release the pullup and stop the logic. A failsafe design.
If control is any similar the signal would look as a pullup to Va when powering up. Then when you start the PWM you should see that signal drop and if you provide any 3V to that line you should see a stop to PWM.
I think that would be best tested with OEM wiring intact, since inverter already requires 12V signal to operate. If you remove that signal you stop PWM completely.
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

@Romale: I put general info of Outlander inverter OI lobotomy to wiki. Feel free to input more data.
https://openinverter.org/wiki/OEM_Inver ... dification
User avatar
Romale
Posts: 550
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 346 times
Been thanked: 101 times

Re: Outlander rear motor and inverter

Post by Romale »

Hi. Yes, there is one significant edit. The HV signal must go through a divider of two 3.3 kOhm resistors. Otherwise, the level becomes too high after about 330 volts and the v3 board is not able to fully measure.
I soldered two resistors directly at the input of the measurement wire, through one signal itself, and the second from the entry point to the ground.
evil neodymium :twisted:
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

Ok i put the latest comment in there as well...
akoni
Posts: 5
Joined: Wed Sep 10, 2025 9:04 am
Has thanked: 3 times

Re: Outlander rear motor and inverter

Post by akoni »

aot93 wrote: Thu May 20, 2021 11:00 pm For me it was bad connection between inverter and motor ( Resolver)

I metered every pin on the inverter to check against the values listed in the service manual (see attached)

Note that RSDN should be pulled low.

Once that was sorted it all worked very easy, no particular sequence.

2021-05-20 23_58_10-[W_M]OUTLANDER PHEV (GG#).png
Hi , Just want to ask about your RSDN post, does it mean you apply +12V to RSDN if you want to shutdown? and cutoff/dont connect RSDN if yiu want to enable/start the motor? thanks
User avatar
bobby_come_lately
Posts: 486
Joined: Sun May 03, 2020 5:39 am
Location: Manchester, UK
Has thanked: 56 times
Been thanked: 63 times
Contact:

Re: Outlander rear motor and inverter

Post by bobby_come_lately »

Belatedly noticed the earlier posts about nicked seals etc. If anyone needs spare parts I have two gearboxes that I need to get rid of. Available for collection in South Manchester.
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

Hello
I'm new (not to world)

I'm trying my hand at the inverter, first reading out CAN bus data as with the charger.
Unfortunately, it seems that this is not so easy, or the rear inverter is broken.
My approach so far:
Connected to the grey inverter socket as in ewiki.
GND, CAN H L, IGCT, and RSDN to GND.

Couldn't see any CAN data, which is disappointing at first, as it was so easy with the Outlander charger!
190mA current consumption at IGCT
Then connected the motor in the hope that it would come to life

I now have 350v at the inverter and 12v (1A power supply)
No CAN data :-(

Now I have reconnected the grey inverter socket, but upside down.
Perhaps it was incorrectly shown in the wiki.
0 mA consumption.
No CAN data.

Grey inverter socket reconnected correctly, now 490 mA power consumption ;-)
I can't imagine that it's broken, but it was probably already broken before!

So my question is, what do I need to do to get data to the REAR inverter?
The second very important question is, is it possible to get CAN data just by connecting these 5 pins?


Hier Bilder
https://ibb.co/bRggHzzd
https://ibb.co/js5GbWQ

Image
Image
User avatar
rstevens81
Posts: 386
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 29 times
Been thanked: 114 times

Re: Outlander rear motor and inverter

Post by rstevens81 »

Try switching can low/high around there's some contradiction on the wiki when you look at both diagrams
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

OutlanderTry wrote: Sat Jan 10, 2026 6:05 pm .....
Connected to the grey inverter socket as in ewiki.
GND, CAN H L, IGCT, and RSDN to GND.

....
The second very important question is, is it possible to get CAN data just by connecting these 5 pins?
Connect 12V power to IGCT and 0V to GND.
RSDN should NOT see 12V when in normal operation!
You should use a propper power supply, 5A at least. I suspect inverter can go into brownout if not enough power
When you connect to CAN H/L you need to terminate connection on at least one end if not on both ends. Transciever inside inverter is not terminated.

How my car is connected to inverter
1. I provide 12 ignition through the key to IGCT pin and 0V to GND
At this time VCU is online and in ready mode. This means it is actively sending 0x285 telegram at 30ms in drive mode
There is NO CAN from inverter at this time!
2. When i provide START pulse precharge relay raises voltage and then DC+ contactor goves HV. You should see active inverter CAN reports then
I use charger CAN signal to verify correct voltage just a precaution with precharge
3. When i put car in drive mode all inverter messages are flying on the CAN bus

To summarize;
1. You need to connect 12V to IGCT
2. You need to connect HV to inverter (by precharge)
3. Inverter CAN reports are active when HV is online.
4. Only then you can read and command inverter with your VCU
EDIT: I went out in the -10°C cold to demonstrate this via screen grab... it says -6 but i assure you it is lower than that :)...
0x289 is one of the inverter CAN reports
0x285 is BMS heartbeat that all Mitsu components require for operation

I sugget you make all connections with your motor, resolver and HV first in your workshop as you would in the car. Then start the "car".
Attachments
Screenshot 2026-01-11 182052.png
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

rstevens81 wrote: Sun Jan 11, 2026 4:45 pm Try switching can low/high around there's some contradiction on the wiki when you look at both diagrams
I swapped low and high, but I don't think it's related to high voltage.
I'll have to test it again. Everything from the inverter is dismantled, I can't find any faults, it looks like new.
I'll reconnect everything. Precharging is done by the inverter itself with its resistor anyway.

https://ibb.co/4RbWWRHZ
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

arber333 wrote: Sun Jan 11, 2026 5:07 pm Connect 12V power to IGCT and 0V to GND.
RSDN should NOT see 12V when in normal operation!
You should use a propper power supply, 5A at least. I suspect inverter can go into brownout if not enough power
When you connect to CAN H/L you need to terminate connection on at least one end if not on both ends. Transciever inside inverter is not terminated.

How my car is connected to inverter
1. I provide 12 ignition through the key to IGCT pin and 0V to GND
At this time VCU is online and in ready mode. This means it is actively sending 0x285 telegram at 30ms in drive mode
There is NO CAN from inverter at this time!
2. When i provide START pulse precharge relay raises voltage and then DC+ contactor goves HV. You should see active inverter CAN reports then
I use charger CAN signal to verify correct voltage just a precaution with precharge
3. When i put car in drive mode all inverter messages are flying on the CAN bus

To summarize;
1. You need to connect 12V to IGCT
2. You need to connect HV to inverter (by precharge)
3. Inverter CAN reports are active when HV is online.
4. Only then you can read and command inverter with your VCU
EDIT: I went out in the -10°C cold to demonstrate this via screen grab... it says -6 but i assure you it is lower than that :)...
0x289 is one of the inverter CAN reports
0x285 is BMS heartbeat that all Mitsu components require for operation

I sugget you make all connections with your motor, resolver and HV first in your workshop as you would in the car. Then start the "car".
Thanks 4 your speedy answere :-)

3. Inverter CAN reports are active when HV is online.

you mean without any sending Can data ?
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

arber333 wrote: Sun Jan 11, 2026 5:07 pm Connect 12V power to IGCT and 0V to GND.
RSDN should NOT see 12V when in normal operation!
You should use a propper power supply, 5A at least. I suspect inverter can go into brownout if not enough power
When you connect to CAN H/L you need to terminate connection on at least one end if not on both ends. Transciever inside inverter is not terminated.

How my car is connected to inverter
1. I provide 12 ignition through the key to IGCT pin and 0V to GND
At this time VCU is online and in ready mode. This means it is actively sending 0x285 telegram at 30ms in drive mode
There is NO CAN from inverter at this time!
2. When i provide START pulse precharge relay raises voltage and then DC+ contactor goves HV. You should see active inverter CAN reports then
I use charger CAN signal to verify correct voltage just a precaution with precharge
3. When i put car in drive mode all inverter messages are flying on the CAN bus

To summarize;
1. You need to connect 12V to IGCT
2. You need to connect HV to inverter (by precharge)
3. Inverter CAN reports are active when HV is online.
4. Only then you can read and command inverter with your VCU
EDIT: I went out in the -10°C cold to demonstrate this via screen grab... it says -6 but i assure you it is lower than that :)...
0x289 is one of the inverter CAN reports
0x285 is BMS heartbeat that all Mitsu components require for operation

I sugget you make all connections with your motor, resolver and HV first in your workshop as you would in the car. Then start the "car".
Hold on.
I swear on my life.
This morning, from 1 a.m. to 5 a.m.,
I tried everything, including a different power supply. I even removed my termination and added it back again.
It was as if something was against me. A wall of sabotage (matrix)?

Now after I answer messages here.
I replaced the power supply with the 2.5A 12V and immediately swapped the CAN bus
low with high and high with low

I did not connect any HV
I am not sending any data
BUT
I am now receiving data
What is going on here?
I'm also using more power than in the very first test.
Can anyone confirm that the device draws 450mA in standby mode and not 200mA?

What I did do to the two CAN transceivers, one is 8-pin and the other is 16-pin, was remove the paint with isopropanol and scratch around the pins and conductor tracks.

Did I accidentally fix it?
iAM an Idiot and ich bin ein blindes Huhn und hab ein Korn gefunden :-)

https://ibb.co/xqj6cPSS
User avatar
Romale
Posts: 550
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 346 times
Been thanked: 101 times

Re: Outlander rear motor and inverter

Post by Romale »

450ma it's ok
evil neodymium :twisted:
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

Now the world has loosing the Game
in the Future we drive the Outlander Engine with ESP32 Web Interface

Don't let the mouse slip out of your hand when accelerating.
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

Romale wrote: Sun Jan 11, 2026 7:01 pm450ma it's ok
Thanks
Then was anything wrong in the beginning , i had only 200mA
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

OutlanderTry wrote: Sun Jan 11, 2026 6:51 pm .....

I did not connect any HV
I am not sending any data
BUT
I am now receiving data
What is going on here?
I'm also using more power than in the very first test.
Can anyone confirm that the device draws 450mA in standby mode and not 200mA?
....
Hm... strange

I connect car saux battery with ignition so i provide inverter, OBC and heater with 12V so it is more than 1A.
But even if i provide 12V and 0x285 telegram i only get response from inverter is when i give it HV via precharge process.

To verify this i use ECAN USB interface
https://www.ebay.com/itm/315582425941

or

https://www.aliexpress.com/item/1005010 ... in_prod%3A
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

OutlanderTry wrote: Sun Jan 11, 2026 7:20 pm Now the world has loosing the Game
in the Future we drive the Outlander Engine with ESP32 Web Interface

Don't let the mouse slip out of your hand when accelerating.
...
I love the new 2026 calendar :D

I already have my ESP32 VCU interface ready.
Dual CAN
3x protected outputs
5x ULN2003 outputs
5x digital inputs
2x analog inputs via the ADS1115 i2C interface

I only need to provide the code... i am only a ME so very slow in coding... :oops:
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

arber333 wrote: Sun Jan 11, 2026 7:22 pm Hm... strange

I connect car saux battery with ignition so i provide inverter, OBC and heater with 12V so it is more than 1A.
But even if i provide 12V and 0x285 telegram i only get response from inverter is when i give it HV via precharge process.

To verify this i use ECAN USB interface
https://www.ebay.com/itm/315582425941

or

https://www.aliexpress.com/item/1005010 ... in_prod%3A
Yes its very strange
Now is fine :-)
i dont ask!

for canbus i change the savyycan esp32 firmware
and now it can be used cheap fo savyycan and LilyGo :-)

very simple :-)
https://github.com/KlausLi/ESP32RET_LiLyGO_T-CAN485
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

arber333 wrote: Sun Jan 11, 2026 7:28 pm I love the new 2026 calendar :D

I already have my ESP32 VCU interface ready.
Dual CAN
3x protected outputs
5x ULN2003 outputs
5x digital inputs
2x analog inputs via the ADS1115 i2C interface

I only need to provide the code... i am only a ME so very slow in coding... :oops:
########################
Very IMportant
I love the new 2026 calendar
where can i buy that ?
########################
can you sendme ESP32 VCU interface
as pdf and schematic ?
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

OutlanderTry wrote: Sun Jan 11, 2026 7:40 pm ########################
Very IMportant
I love the new 2026 calendar
where can i buy that ?
########################
can you sendme ESP32 VCU interface
as pdf and schematic ?
I updated files in my ESP32 repository
https://github.com/arber333/ESP32-VCU/tree/main

Search for the latest version 2.4 and 2.5
2.4 is meant for application with 2x CAN ports controling chademo fast charging or receiving BMS updates
2.5 is simpler, only single CAN but it can drive more PWM outputs

I put schematic on paper somewhere and i would have to redraw it. I will add schematic at a later time. For now let the pcb file guide you :).
It was drawn with Designspark PCB.
There are also pinouts for VCU that i envisioned. You can certainly adapt them to your use...

If you want a single blank PCB board for testing i can quickly send you one...
Attachments
20260111_234858.jpg
20260111_234845.jpg
20260111_234837.jpg
User avatar
Romale
Posts: 550
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 346 times
Been thanked: 101 times

Re: Outlander rear motor and inverter

Post by Romale »

It's not like I'm using can control. I install a johu version 3 board in these inverters. together with it on the table, when I first start up from the power supply at 12-13 volts, I see a current consumption of about 430 ma. The O.I. board itself consumes catastrophically little, so the consumption of the inverter in these areas is ok
evil neodymium :twisted:
User avatar
Romale
Posts: 550
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 346 times
Been thanked: 101 times

Re: Outlander rear motor and inverter

Post by Romale »

O.I. management greatly expands the scope of available use. with it, I got 350 amperes of battery current with this small inverter, it seems to me that controlling the can bus will not give such a result. I also get a higher speed than in the Mitsubishi itself initially.
Screenshot_2026-01-03-13-51-50-73_40deb401b9ffe8e1df2f1cc5ba480b12.jpg
evil neodymium :twisted:
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Outlander rear motor and inverter

Post by arber333 »

Romale wrote: Mon Jan 12, 2026 9:00 am O.I. management greatly expands the scope of available use. with it, I got 350 amperes of battery current with this small inverter, it seems to me that controlling the can bus will not give such a result. I also get a higher speed than in the Mitsubishi itself initially.
Yes i can draw max 200A from battery with OEM setup
On the RPM i am not exactly sure, but i can go up to 160km/h on that motor and that seems enough :D
OutlanderTry
Posts: 9
Joined: Sat Jan 10, 2026 5:01 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Outlander rear motor and inverter

Post by OutlanderTry »

arber333 wrote: Mon Jan 12, 2026 7:32 am I updated files in my ESP32 repository
https://github.com/arber333/ESP32-VCU/tree/main

Search for the latest version 2.4 and 2.5
2.4 is meant for application with 2x CAN ports controling chademo fast charging or receiving BMS updates
2.5 is simpler, only single CAN but it can drive more PWM outputs

I put schematic on paper somewhere and i would have to redraw it. I will add schematic at a later time. For now let the pcb file guide you :).
It was drawn with Designspark PCB.
There are also pinouts for VCU that i envisioned. You can certainly adapt them to your use...

If you want a single blank PCB board for testing i can quickly send you one...
Hello, thank you.
There's no rush; I don't plan on using the circuit board.
I'm learning and appreciate things like what you've shared. :-).

I've had the Outlander charger, inverter and motor since Christmas.
I programmed a web test platform for the charger; you don't need an EVse, it's simulated with pwm.
Today I created a test programme for the inverter.
I limited it to maximum torque input in the minus and plus range.
And I limited it in terms of runtime.
So on the HTERM console, you enter your torque up to 33 minus or plus, and at the same time to test the brakes, press Enter,
and it then runs for 4 seconds.
The setting can be changed in the code.

Hterm
https://ibb.co/d4bvMBzR


Video from my Beautiful Setup with esp32 Tool :-):
https://youtu.be/-KZqMIiRytE


It's for the faint-hearted :-)
But it makes perfect sense.

Esp32 Firmware binary
https://we.tl/t-gW0o4Lxxel

ESP32 Board mit usb-c
https://de.aliexpress.com/item/1005009331675752.html

MCU-230 Bus Transceiver SN65HVD230 CAN-Kommunikationsmodul
https://de.aliexpress.com/item/1005008251308592.html


Here is the code for the quick inverter test in vscode programmiert
Platformio.ini :
[env:esp32doit-espduino]
platform = espressif32
board = wemos_d1_uno32
framework = arduino
upload_speed = 921600
upload_port = com10

Code :

Code: Select all

#include <Arduino.h>
#include "driver/twai.h"

// Pins für ESP32 & SN65HVD230
#define TX_PIN GPIO_NUM_16
#define RX_PIN GPIO_NUM_17

// Gemeinsam genutzte Variablen
volatile uint16_t TorqueVal = 10000;
volatile bool motorRunning = false;
volatile unsigned long startTime = 0;
const uint16_t TorqueNeutral = 10000;

//#############################################################
// SETTINGS
int TorqMaxRange = 33;
const unsigned long RunTimeMax_ms = 4000; 
// SETTINGS
//#############################################################


byte motorFunction = 0x03;
int lastSecondsPrint = -1;

volatile int16_t currentRPM = 0;
float currentVoltage = 0;
volatile int16_t maxRPM = 0;
volatile float currentPhase1 = 0;
volatile float currentPhase2 = 0;
volatile float maxPhase1 = 0;
volatile float maxPhase2 = 0;

// TWAI Konfiguration
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_PIN, RX_PIN, TWAI_MODE_NORMAL);
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_500KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();

// Task-Handles
TaskHandle_t TaskCanSendHandle;
TaskHandle_t TaskCanRecvHandle;
TaskHandle_t TaskSerialHandle;

void sendCAN(uint32_t id, uint8_t len, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
{
    twai_message_t msg;
    msg.identifier = id;
    msg.extd = 0;
    msg.rtr = 0;
    msg.data_length_code = len;
    msg.data[0] = d0; msg.data[1] = d1; msg.data[2] = d2; msg.data[3] = d3;
    msg.data[4] = d4; msg.data[5] = d5; msg.data[6] = d6; msg.data[7] = d7;
    twai_transmit(&msg, pdMS_TO_TICKS(10));
}

// --- TASK 1: CAN SENDEN & LOGGING (CORE 1) ---
void TaskCanSendLoop(void *pvParameters)
{
    unsigned long lastSendTime = 0;
    for (;;)
    {
        unsigned long currentTime = millis();
        unsigned long elapsedTime = currentTime - startTime;

        if (motorRunning)
        {
            if (elapsedTime >= RunTimeMax_ms)
            {
                motorRunning = false;
                TorqueVal = TorqueNeutral;
                lastSecondsPrint = -1;
                Serial.print("Core 1: Motor Stopp.");
                Serial.print(" | Maximal RPM: ");
                Serial.print(maxRPM);
                Serial.print(" | Max Ph1: "); Serial.print(maxPhase1, 1); Serial.print(" A");
                Serial.print(" | Max Ph2: "); Serial.print(maxPhase2, 1); Serial.println(" A");
    
    // Werte für den nächsten Lauf zurücksetzen
    maxRPM = 0; 
    maxPhase1 = 0;
    maxPhase2 = 0;


                
            }
            else
            {
                float remainingSeconds = (RunTimeMax_ms - elapsedTime + 499) / 1000;
                if (remainingSeconds != lastSecondsPrint && remainingSeconds > 0)
                {
                    if (TorqueVal > 10000) Serial.print("-> Motor rueckwaerts ");
                    else Serial.print("-> Motor vorwaerts ");
                    
                    Serial.print(", Rest: ");
                    Serial.print(remainingSeconds);
                    Serial.print("Sek.");
                    Serial.print(" | Aktuelle RPM: ");
                    Serial.print(currentRPM);
                    Serial.print(" | VCB: ");
                    Serial.print(currentVoltage, 1);
                    Serial.print(" V");
                    Serial.print(" | Ph1: ");
                    Serial.print(currentPhase1,1);
                    Serial.print(" A | Ph2: ");
                    Serial.print(currentPhase2,1);
                    Serial.println(" A");

                    lastSecondsPrint = remainingSeconds;
                }
            }
        }

        // Senden alle 100ms (Timing aus deinem Code)
        if (currentTime - lastSendTime >= 50)
        {
            lastSendTime = currentTime;
            uint8_t tHi = highByte(TorqueVal);
            uint8_t tLo = lowByte(TorqueVal);
            byte currentFunc = motorRunning ? motorFunction : 0x00;

            sendCAN(0x371, 8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
            sendCAN(0x286, 8, 0x00, 0x00, 0x00, 0x3D, 0x00, 0x00, 0x21, 0x00);
            sendCAN(0x285, 8, 0x00, 0x00, 0x14, 0x39, 0x91, 0xFE, 0x0C, 0x10);
            sendCAN(0x287, 8, tHi, tLo, tHi, tLo, tHi, tLo, currentFunc, 0x00);
        }
        vTaskDelay(pdMS_TO_TICKS(10)); 
    }
}

// --- TASK 2: SCHNELLER CAN EMPFANG (CORE 0, PRIO 5) ---
void TaskCanRecvLoop(void *pvParameters)
{
    twai_message_t rx_msg;
    for (;;)
    {
        // Wir nutzen die High-Speed Schleife aus deinem Code
        while (twai_receive(&rx_msg, pdMS_TO_TICKS(1)) == ESP_OK)
        {
          if (rx_msg.identifier == 0x289) 
{
    // Byte 2 ist MSB, Byte 3 ist LSB
    uint16_t rawRpm = (rx_msg.data[2] << 8) | rx_msg.data[3];
    currentRPM = rawRpm - 20000;
    
    // abs() nutzen wir nur zum Vergleich, gespeichert wird die echte Zahl
    if (abs(currentRPM) > abs(maxRPM)) 
    {
        maxRPM = currentRPM; 
    }

    // VCB: Byte 4 ist MSB, Byte 5 ist LSB
    uint16_t rawVoltage = (rx_msg.data[4] << 8) | rx_msg.data[5];
    // Da dein Log 3420 zeigt, teilen wir durch 10.0f für 342.0V
    currentVoltage = rawVoltage / 10.0f; 
}
else if (rx_msg.identifier == 0x732)
{
    // Phase 1: Byte 0 ist MSB, Byte 1 ist LSB
    uint16_t rawPh1 = (rx_msg.data[0] << 8) | rx_msg.data[1];
    // Phase 2: Byte 2 ist MSB, Byte 3 ist LSB
    uint16_t rawPh2 = (rx_msg.data[2] << 8) | rx_msg.data[3];

    // Offset laut DBC ist -1000. 
    // Wir nehmen den Rohwert, ziehen 1000 ab und teilen durch 10.0f, 
    // um auf die 5A aus SavvyCAN zu kommen (Dezi-Ampere).
    currentPhase1 = (float)(rawPh1 - 1000) ;
    currentPhase2 = (float)(rawPh2 - 1000) ;
   // Vergleich über den Betrag (abs), aber Speichern des echten Werts (inkl. Vorzeichen)
    if (abs(currentPhase1) > abs(maxPhase1)) {
        
         maxPhase1 = currentPhase1; 
    }
    if (abs(currentPhase2) > abs(maxPhase2)) {
        maxPhase2 = currentPhase2;
    }
}
        }
        vTaskDelay(pdMS_TO_TICKS(1)); // Minimaler Delay für Core-Stabilität
    }
}

// --- TASK 3: SERIELLE EINGABE (CORE 0, PRIO 1) ---
void TaskSerialInputLoop(void *pvParameters)
{
    for (;;)
    {
        if (Serial.available() > 0)
        {
            int inputVal = Serial.parseInt();
            if (inputVal != 0)
            {
                if (inputVal > 0 && inputVal > TorqMaxRange) inputVal = TorqMaxRange;
                else if (inputVal < 0 && inputVal < -TorqMaxRange) inputVal = -TorqMaxRange;

                TorqueVal = TorqueNeutral + inputVal;
                startTime = millis();
                motorRunning = true;
                Serial.println("#########################################################");
                Serial.print("Core 0: Motor Start Torq: ");
                Serial.println(TorqueVal);
            }
        }
        vTaskDelay(pdMS_TO_TICKS(100)); // Reicht für Tastatur locker aus
    }
}

void setup()
{
    Serial.begin(115200);
    delay(1000);
    Serial.println("Outlander Inverter  Tester @BAVARIANSuperGuy was here @MIT");
    Serial.println("Input: -35 bis 35 | Runtime: 4 Sek.");
     

    if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK && twai_start() == ESP_OK)
    {
        Serial.println("CAN-Bus bereit.");
    }

    // Task 1: Senden auf CORE 1
    xTaskCreatePinnedToCore(TaskCanSendLoop, "CAN_Send", 4096, NULL, 5, &TaskCanSendHandle, 1);

    // Task 2: Empfangen auf CORE 0 (Hohe Priorität)
    xTaskCreatePinnedToCore(TaskCanRecvLoop, "CAN_Recv", 4096, NULL, 5, &TaskCanRecvHandle, 0);

    // Task 3: Serial Input auf CORE 0 (Niedrige Priorität)
    xTaskCreatePinnedToCore(TaskSerialInputLoop, "Serial_In", 4096, NULL, 1, &TaskSerialHandle, 0);
}

void loop()
{
    vTaskDelete(NULL);
}
CODEEND
Post Reply