NMEA2000 Need more information

Good evening to all of you.
I'm trying to read PGN12503 // PGN12504 which are deprecated but still used in several products for AC In and AC out.
. When I connect my actisence I can find those PGN sent by an official product and this is the content:

The product connected can read 3 AC lines and send voltages, but also frequency, Amperage .... (only for the first 2 inputs). So, there is 3 PGN 12504. On each line:

The first data is 00 or 01 or 02 is the Instance
The second data is the number of AC lines 1 if single phase, 3 if 3 phases.
The third one is always FC. probably the broadcast information according to the excellent topic MNEA2000 Shield here:
NMEA2000 Shield
after we can find the voltage "C3 59" (read 59 C3) which is 229.79V
just after, also in 2 octets "00 00" seems to be the Amps (C8-00 (read 00C8)) for 20.0 A.
After that, I can read a data moving from 81 to 8A (couldn't identify as it's maybe a partial information.
Couldn't find the end of this PNG and I don't know where is the frequency and what are the other information (lenght 20, fields 12).

Is someone can give me a solution to read the 12 fields so I can identify each of them and also complete the excellent library N2kMessages.h et N2KMessages.cpp or at least help me to understand how it's working. PNG missing on this library: 127503 and 127504 (Mastervolt) and 65013 - 65014 and 65016 (Victron). (I'm not good enough yet but I'm working on it :slight_smile: )

This can help many people to adapt Victron and mastervolt installation by transfering the deprecated PNG to the new PNG. (I will post that as soon as it's working)...

I'm working with Arduino DUE (CAN output) and an homemade ISO1040 as interface. it seems to work as I could see the excellent battery monitor N2K example on actisence.
Thank you for your help.

You can find missing descriptions e.g., on https://github.com/canboat/canboat/blob/master/analyzer/pgns.json . N2kMessages includes most common message parsers and there is a lot of messages not listed there.

1 Like

Fantastic Timolappalainen. I will try to modify the library. Thank you Sooo much, this will help me a lot.
Thank you thank you thank you :slight_smile:

If I make it work properly, I will upload the code.

I'm answering myself. for the one who's looking for the solution. It's now working but I didn't tried to parse NMEA, I've just sent messages.

This is probably not the best way to do it but it works.

Add this to .CPP and .H (N2kMessages.x) and the code to send the message from the program.

//to add to .H


void SetN2kPGN127504(tN2kMsg &N2kMsg, unsigned char SID, unsigned char NOL,
						double Voltg, double Inten, double Freq, double BreakSiz,
						double RlPwr, double ReacPwr, unsigned char PF
						);
inline void SetN2kACStatus(tN2kMsg &N2kMsg, unsigned char SID, unsigned char NOL,double Voltg, double Inten, double Freq, double BreakSiz,
							double RlPwr, double ReacPwr, unsigned char PF
						){
						SetN2kPGN127504(N2kMsg,SID,NOL,Voltg,Inten,Freq,BreakSiz,RlPwr,ReacPwr,PF);
						}
//parse N2K127504
bool parseN2kPGN127504(const tN2kMsg &N2kMsg, unsigned char SID, unsigned char NOL, double Voltg, double Inten, double Freq, double BreakSiz, double RlPwr, double ReacPwr,unsigned char PF);
inline bool ParseN2kACStatus(const tN2kMsg &N2kMsg, unsigned char SID, unsigned char NOL, double Voltg, double Inten, double Freq, double BreakSiz, 
							double RlPwr, double ReacPwr,unsigned char PF){
return parseN2kPGN127504(N2kMsg, SID,NOL,Voltg,Inten,Freq,BreakSiz,RlPwr,ReacPwr,PF);
}


//TO add to CPP'

// PGN127504 - 
//

void SetN2kPGN127504 (tN2kMsg &N2kMsg, unsigned char SID, 
						unsigned char NOL,
						double Voltg,
						double Inten,
						double Freq,
						double BreakSiz,
						double RlPwr,
						double ReacPwr,
						unsigned char PF
						){
	N2kMsg.SetPGN(127504);
	N2kMsg.Priority=6;
	N2kMsg.AddByte(SID);
	N2kMsg.AddByte(NOL);
	N2kMsg.AddByte(0xFC);
	N2kMsg.Add2ByteDouble(Voltg,00.1);
	N2kMsg.Add2ByteDouble(Inten,00.01);
	N2kMsg.Add2ByteDouble(Freq,00.1);
	N2kMsg.Add2ByteDouble(BreakSiz,00.1);
	N2kMsg.Add4ByteDouble(RlPwr,0000.1);
	N2kMsg.Add4ByteDouble(ReacPwr,0000.1);
	N2kMsg.AddByte(PF);
}
bool ParseN2kPGN127504(const tN2kMsg &N2kMsg, unsigned char &SID, unsigned char &NOL, 
						double &Voltg, double &Inten, double &Freq, double &BreakSiz, 
						double &RlPwr, double ReacPwr, unsigned char PF
						){
	if(N2kMsg.PGN!=127504) return false;
	int Index = 0;
	SID=N2kMsg.GetByte(Index);
	NOL=N2kMsg.GetByte(Index);
	int Res=N2kMsg.GetByte(Index); //reserved should read FC...
	Voltg=N2kMsg.Get2ByteUDouble(0.1, Index);
	Inten=N2kMsg.Get2ByteUDouble(0.01,Index);
	Freq=N2kMsg.Get2ByteUDouble(0.01, Index);
	BreakSiz=N2kMsg.Get2ByteUDouble(0.01, Index);
	RlPwr=N2kMsg.Get4ByteUDouble(0000.1, Index);
	ReacPwr=N2kMsg.Get4ByteUDouble(0000.1, Index);
	PF=N2kMsg.GetByte(Index);
	return true;
}

//To call this process from your program: (extracted and modified from the fantastic example BatteryMonitorNK2 from library NMEA2000 Library)
    SetN2kACStatus(N2kMsg,3,1,220.0,5.0,45.0,60.0,1100.0,1100.0,1);
    NMEA2000.SendMsg(N2kMsg);

//I could never make this work without this sample. // Demo: NMEA2000 library. Send battery status to the bus.

This compiles and send N2k messages PGN127504 which control 220 input.
In my program, I also use a modbus interface to read the 3 different input voltages and send the values to N2k network.
The N2k seems to be working, the modbus seems to be OK, let's see if I can make the both work together...
Material used Arduino Due
interface NMEA homemade from ISO1050
Modbus interface classic TTL to RS485 module
When everything workswith this configuration, I will try to make it work from a Mega 2560.
Thank you and sorry for the length of those messages.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.