he351ve can

Testing and development of Megasquirt 3

Moderators: jsmcortina, muythaibxr

jsmcortina
Site Admin
Posts: 39619
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: he351ve can

Post by jsmcortina »

MSQ also please.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

no the mapping of the pot is not perfect. outputValue = map(val, 0, 1024, 0, 2255);
My pot is acting funny i didn't look into. but i do get smooth movement from wide open to about half way closed.

if i change the following
byte data[] = { outputValue, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // data message with an added counter

to
byte data[] = { outputValue, 0x02, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // data message with an added counter
the actuator zeros it's self. worked for me

i got the info from here. i don't much about coding. Figured it would be easier to pick up since i know some g code.
http://community.lilbb.com/general-disc ... oma-build/
33 psi boost on lpg
Alfagta
Experienced MS/Extra'er
Posts: 239
Joined: Wed Aug 21, 2013 2:54 am

Re: he351ve can

Post by Alfagta »

What i mean is you try to send 2255 as an Byte...
A Byte can only be 0..255.

BR
Alfa 156 GTA
Alfa 75 Race Car MS III -- alway latest FW
Alfa 164 V6 Turbo
Alfa 155 2,5TD RIP
Test MS II --always latest FW
Tunerstudio V2.6.11 Registered
MegaLog Viewer V3.4.04 Registered
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

may be that's why it is acting funny.
It moves to about half way closed then jumps all the way open if i continue to rotate pot same direction. eventually veins will star moving towards closed again.
default position is full open. if can signal is removed veins move to full open.

I have a lot of reading to do.
33 psi boost on lpg
jsmcortina
Site Admin
Posts: 39619
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: he351ve can

Post by jsmcortina »

I didn't check your code fully, if the max value is 2255 but the max required value is 255, try the following pseudo code.

new_out = (old_out * 255) / 2255

Depending on size of an integer you may need 255UL

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

i wish I knew what your talking about.
I borrowed that code from somewhere.
I know the veins only except 40 to 960 positions.
but i don't under stand how exactly that is mapped to pot.
back to :RTFM:
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

found something i think i add that extra 2 oops
As for normal operation of the veins it is really simple...

Message ID in hex: 0cffc600

For Data the first byte is a range of 0 - 255 for how far open the veins should be. 255 is all the way open.

Data Structure is 8 bytes, example is for veins half way open in decimal and hex.
125, 2, 1, 255, 255, 255, 255, 255
7d, 2, 1, ff, ff, ff, ff, ff
33 psi boost on lpg
jsmcortina
Site Admin
Posts: 39619
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: he351ve can

Post by jsmcortina »

This is exactly what the MS3 is already doing when you enable that CAN broadcast option and boost control.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

yep you guys new i had a problem when i didn't have a clue.
compiling notes

E:\Users\AVA CAD CAM\Documents\Arduino\vgt_test\vgt_test.ino: In function 'void extendedMessage()':

E:\Users\AVA CAD CAM\Documents\Arduino\vgt_test\vgt_test.ino:42:70: warning: narrowing conversion of 'outputValue' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

byte data[] = { outputValue, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // data message with an added counter

^


Sketch uses 4,844 bytes (15%) of program storage space. Maximum is 32,256 bytes.
Global variables use 310 bytes (15%) of dynamic memory, leaving 1,738 bytes for local variables. Maximum is 2,048 bytes.
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

Ill go over my can wiring from ms3 at lunch. Once the ms3 is working the arduio will be a paper weight again.
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

I definitely have a wiring problem.
So i hooked up DMM to CAN wires at lunch. get signal from turbo but nothing with turbo powered off engine running.
I enabled other CAN broadcasting still no signal.
I think i mixed up the spare outputs. I know i was rushing when i hooked those up.
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

think i had a bad connection on spade connector.
but ms3 and turbo are not talking?
I checked polarity by chasing wires and with DMM
I'll play with trying to read CAN signal from ms3 with arduino when i get time.
I can double check i got ardunio configured properly by reading signal from turbo.
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

this sketch work good on arduino
#include <SPI.h>
#include <can.h>
#include <Timer.h>


MCP CAN1(10);
int Timer1Interval = 2; // update turbo position
int Timer2Interval = 5; //read inputs.. not used in this example
int Timer3Interval = 2000; //time between position change commands
int MaxPosition = 1000; //maximum value to command VGT to
int MinPosition = 0; //minimum value to command VGT to
int PositionDeadband = 0; //don't move if it isn't worth it
int SendPosition; //The value we're sending to the VGT

unsigned int RealPosition; //The positon the VGT is actually at (read from the CAN messages)
unsigned int CommandPosition; //The position the VGT is thinking it's target is
signed int MotorCommandSpeed; //The speed and direction the vane motor is set to
int VGTtemp; //Temperature of the VGT control unit... should be pretty close to coolant temp in most situations

unsigned long StatusMessageID = 0x18FFC502UL; //this is the message id of the messages we're concerned with
unsigned long BreakMessageID = 0x18FF0A02UL; //This is the message id of a 'terminator' string, or something... no relevant information it seems


volatile int TssCounts;
Timer t1;
Timer t2;
Timer t3;


void setup() {

// put your setup code here, to run once:
Serial.begin(115200);
delay(100);
Serial.println("Starting Can bus");

CAN1.begin(NORMAL, 250);
delay(250);
Serial.println("CAN bus started... Starting timer...");
t1.every(Timer1Interval, Timer1Routine);
t2.every(Timer2Interval, Timer2Routine);
t3.every(Timer3Interval, Timer3Routine);


CAN1.clearRxBuffers();

}

void Timer1Routine() {
SendPositionToVGT(SendPosition);
}

void Timer2Routine() {

}
void Timer3Routine() {
//Update serial display
static boolean inOrOut = false;
inOrOut = !inOrOut;
if (inOrOut) {
SendPosition = MaxPosition;
}
else {
SendPosition = MinPosition;
}
}

void readMessage() {
//This is from the MCP examples, modified to work for what I need
unsigned long ID; // assign a variable for Message ID
byte length; //assign a variable for length
byte data[8]; //assign an array for data

if (CAN1.msgAvailable() == true) { // Check to see if a valid message has been received.

CAN1.read(&ID, &length, data); // read Message and assign data through reference operator &
// if (ID != BreakMessageID){ //ignore the break message
// Serial.print("ID");
// Serial.print(" | ");
// Serial.print(ID, HEX); // Displays received ID
// Serial.print(" | ");
// Serial.print("Data Length");
// Serial.print(" | ");
// Serial.print( length, HEX); // Displays message length
// Serial.print(" | ");
// Serial.print("Data");
// for (byte i = 0; i < length; i++) {
// Serial.print(" | ");
// if (data < 0x10) // If the data is less than 10 hex it will assign a zero to the front as leading zeros are ignored...
// {
// Serial.print("0");
// }
// Serial.print(data, HEX); // Displays message data
// }
// Serial.println(); // adds a line
// }
}
if (ID == StatusMessageID) {
CommandPosition = ((data[6] * 256) + data[5]);
Serial.print("Command Position = ");
Serial.println(CommandPosition);
RealPosition = ((data[2] * 256) + data[1]);
Serial.print("Real Position = ");
Serial.println(RealPosition);

MotorCommandSpeed = data[7]-127;
Serial.print("Motor command speed = ");
Serial.println(MotorCommandSpeed);

VGTtemp = data[3];
Serial.print("Temp is ");
Serial.println(VGTtemp);

}
else if (ID == BreakMessageID) {
//do nothing.. it's an unimportant message
}
else {
//we got a new message type.. lets figure it out
Serial.println("================================= CHECK THAT OUT... a new kind of message!! ======================================");
}
}



void loop() {
t1.update();
t2.update();
t3.update();
if (CAN1.msgAvailable()) {
readMessage();
}
}
// put your main code here, to run repeatedly:



void SendPositionToVGT(int Position) {
static int LastPosition;
if (Position > LastPosition + PositionDeadband || Position < LastPosition - PositionDeadband) {
Serial.print("Sending ");
Serial.println(Position);
LastPosition = Position;
}
byte lo_byte = lowByte(Position);
byte hi_byte = highByte(Position);

byte data[] = { lo_byte, hi_byte, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // data message with an added counter
//byte data[2] = {0x02, 0x00}; //for recalibrating gearbox
// Load message and send
CAN1.send (0x0CFFC600, extID, 8, data);
}
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

this works in Arduino

byte data[] = { lo_byte, hi_byte, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // data message with an added counter
//byte data[2] = {0x02, 0x00}; //for recalibrating gearbox
// Load message and send
CAN1.send (0x0CFFC600, extID, 8, data);

i think the 0x02 is the problem.

if (ram5.can_bcast2 & 0x02) {
/* holset HE351VE VGT turbo and a wastegate
29bit CAN message 0x0cffc600
8 bytes
D0 = 0 - 0xff for how far open the vanes should be. 0xff is all the way open.
D1 = 0x02
D2 = 0x01
D3 = 0xff
D4 = 0xff
D5 = 0xff
D6 = 0xff
D7 = 0xff
----------------------
*/
data[0] = (outpc.boostduty * 255U) / 100U;
data[1] = 0x02;
data[2] = 0x01;
data[3] = 0xff;
data[4] = 0xff;
data[5] = 0xff;
data[6] = 0xff;
data[7] = 0xff;
send_can29bit(0x0cffc600, data, 8);
}
33 psi boost on lpg
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

got some help but still struggling to understand but I'm learning new stuff.
Code: [Select]

byte lo_byte = lowByte(final_vane_position);
byte hi_byte = highByte(final_vane_position);
byte data[] = { lo_byte, hi_byte, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // data message with an added counter
// data[2] = 0x02 for recalibrating gearbox


final_vane_position = 500

lo_byte = 0x01
hi_byte = 0xF4

//

final_vane_position = 750

lo_byte = 0x02
hi_byte = 0xEE

The first 2 bytes in the can message, are low and high. Hope that makes a little sense. 255 values isn't enough, so to get from 0 to 1000, you need 4 low bytes, 0 = 0 - 255 range, 1 = 256 - 510, 2 = 511 - 765, 3 = 766 - 1020.

Make sense ?
33 psi boost on lpg
jsmcortina
Site Admin
Posts: 39619
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: he351ve can

Post by jsmcortina »

Not four bytes. You need two bytes to store a 0-1000 value. (0-65535 actually.)

Conversion is straightforward.
Low_byte = value & 255;
High_byte = value >> 8;

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

How does this look? I'm sure I screwed something up.
Turbo will listen to 0-1000 commands but i believe 0-40 and 960-1000 is dead area. and could be adjusted out in boost duty min max.

Code: Select all

if (ram5.can_bcast2 & 0x02) {
/* holset HE351VE VGT turbo and a wastegate
29bit CAN message 0x0cffc600
8 bytes
D0 = 0 - 0xff for how far open the vanes should be. 1000 is all the way open.
D1 = 0 - 0x03
D2 = 0x01
D3 = 0xff
D4 = 0xff
D5 = 0xff
D6 = 0xff
D7 = 0xff
----------------------
*/
val=outpc.boostduty * 10
data[0] =(unsigned char)(val & 0xff); //byte 1 = low_byte;
data[1] =(unsigned char)(val >> 8);   //byte 2 = hi_byte;
data[2] = 0x01;
data[3] = 0xff;
data[4] = 0xff;
data[5] = 0xff;
data[6] = 0xff;
data[7] = 0xff;
send_can29bit(0x0cffc600, data, 8);
}
33 psi boost on lpg
jsmcortina
Site Admin
Posts: 39619
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: he351ve can

Post by jsmcortina »

fpvmustang wrote:How does this look?

Code: Select all

...
val=outpc.boostduty * 10;
data[0] =(unsigned char)(val & 0xff); //byte 1 = low_byte;
data[1] =(unsigned char)(val >> 8);   //byte 2 = hi_byte;
...
Looks good to me. I checked and 'val' is a 16bit variable, so that's ok.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
fpvmustang
Helpful MS/Extra'er
Posts: 109
Joined: Sat Oct 13, 2012 11:17 pm
Location: Quincy CA. USA

Re: he351ve can

Post by fpvmustang »

should i change?

Code: Select all

D0 = 0 - 0xff for how far open the vanes should be. 1000 is all the way open.
D1 = 0 - 0x03
to

Code: Select all

D0 = 0x00 - 0xff for how far open the vanes should be. 1000 is all the way open.
D1 = 0x00 - 0x03
I don't understand why the release code doesn't work. If I understand it the vgt should have been moving from position 512 to 767.

But I spent along time trying to understand how ff=255
33 psi boost on lpg
jsmcortina
Site Admin
Posts: 39619
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: he351ve can

Post by jsmcortina »

fpvmustang wrote:should i change?

Code: Select all

D0 = 0 - 0xff for how far open the vanes should be. 1000 is all the way open.
D1 = 0 - 0x03
to

Code: Select all

D0 = 0x00 - 0xff for how far open the vanes should be. 1000 is all the way open.
D1 = 0x00 - 0x03
That's a comment, it has no effect on the functionality of the code.
I don't understand why the release code doesn't work. If I understand it the vgt should have been moving from position 512 to 767.
Are your CAN wires connected?
From memory you should see about 2.5V on both of them at the Megasquirt with nothing else on the CAN bus.
But I spent along time trying to understand how ff=255
I trust you've learned what hexadecimal is now?

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
Post Reply