Open schwinn opened 5 years ago
To be honest - I am not sure. 127502 name is "Switch Bank Control", so I would expect that is for setting binary bank status. Binary bank itself would then inform its staus with 127501. You logic to use group function is in principle OK, but what is 127502 then for?
Note that with 127502 you can also set single switch status by setting other to NA.
I think CZone uses those for controlling, spying network with CZone devices would give more information.
Should I implement 127502 support?
I found this information about switch control: https://www.panbo.com/maretron-dcr100-nmea-2000-switching/
The information is older, but I haven't found any more up-to-date information about it.
Empirbus seems to use a Proprietary PGN 65280. It's documented here: https://www.empirbus.com/wp-content/uploads/Application-Specific-PGN-65280_1.pdf
I think CZone uses also some proprietary PGNs, because there's no support for a dimmer in N2K. Do you have access to a CZone device to do a trace?
CZone surely uses proprietary, but it probably uses also available PGN:s.
I thought to by units for spying, they are too expensive just for testing. If you are doing that for your own, use 127501 ans 127502 and if necessary some proprietary for your own. If you think to publish it in future, just have good layers on program so you can easily change the communication way after joining to NMEA organization and getting necessary info.
I'll do it this way. Thanks for your support.
Hi, Schwinn: Do you plan to publish your efforts? And to Timo: Now that i'm here I might as well ask you one of the dumb questions. I have installed and run your great work on Arduino like boards. Now I want to to up in the world, and am wondering what would be your "best" among lager boards? Raspberry (do to its rich environment) Best Jorgen
What you are looking for? I have made extension board for RPi to connect it directly to NMEA2000. RPi works also with PiCAN2 board. But I have not yet tried to send anything with RPi and have not investigated how they handle sending. The problem is that CAN drivers does not normally handle NMEA 2000 fast packet sending right, so I had to modify all supported CAN drivers to get them work with NMEA 2000. One guy was trying to use library on mBed, but there was the same problem and he could not fix the driver problem.
As always very very helpful explanation. Seems as if RPi should do other stuff and Teensy continue in the NMEA role it does so well. Thanks Jorgen
Med venlig hilsen / Best Regards Jørgen B. Christensen
From: Timo Lappalainen notifications@github.com Sent: Monday, December 3, 2018 3:06:28 PM To: ttlappalainen/NMEA2000 Cc: newbezz; Comment Subject: Re: [ttlappalainen/NMEA2000] Binary Switch Control (#128)
What you are looking for? I have made extension board for RPi to connect it directly to NMEA2000. RPi works also with PiCAN2 board. But I have not yet tried to send anything with RPi and have not investigated how they handle sending. The problem is that CAN drivers does not normally handle NMEA 2000 fast packet sending right, so I had to modify all supported CAN drivers to get them work with NMEA 2000. One guy was trying to use library on mBed, but there was the same problem and he could not fix the driver problem.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fttlappalainen%2FNMEA2000%2Fissues%2F128%23issuecomment-443721236&data=02%7C01%7C%7C25ab054646e4450fb37a08d65928853b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636794427897516561&sdata=mLALpBorkwbq%2Fu7TnL9YKBmjXrh3qZ7LLS77Zbq6130%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAJx5AMZySSPrfWa58HkpI7yT5MUu3ldvks5u1S_kgaJpZM4Yd7md&data=02%7C01%7C%7C25ab054646e4450fb37a08d65928853b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636794427897516561&sdata=WVVcxPG7tBDqTQmWuPD5k9KRsm1NnFyrq98KM8Gry6A%3D&reserved=0.
That is sure solution. On the other hand there is no development, if nobody tries anything new and publish it. I would try, but just now for some months I do not have time. And as i mentioned, it depends much, what you are trying to do. Teensy can also act like Actisense NGT-1 and then SignalK can use data from it. Also it can send, but I do not know, does SignalK have sending possibilities.
adding 127502 support would be nice, yachtdevices has a module that works with that pgn. i configured my B&G according to their website, i cannot get it working. maybe you can look in to this. YDCC-04 and YDSC-04 the write: ompatible with other NMEA 2000 digital switching devices managed by standard NMEA 2000 PGNs 127501 and 127502.
I have no devices to test 127502, thats why I have not added it. I do not how to exactly to use it. I would expect that if you turn on some switch, you send once 127502 on for that switch single switch only. The the device should send 127501, where you can check did it turn on.
no it did not turn on, I can also not see a 127502 message beeing transferred over the n2kbus. Can you made a small script sending 127501 and 127502 ? then i can test that.
//*****************************************************************************
void SetN2kPGN127502(tN2kMsg &N2kMsg, unsigned char DeviceBankInstance, tN2kBinaryStatus BankStatus) {
N2kMsg.SetPGN(127502L);
N2kMsg.Priority=3;
BankStatus = (BankStatus << 8) | DeviceBankInstance;
N2kMsg.AddUInt64(BankStatus);
}
//*****************************************************************************
inline void SetN2kSwitchBankCommand(tN2kMsg &N2kMsg, unsigned char DeviceBankInstance, tN2kBinaryStatus BankStatus) {
SetN2kPGN127502(N2kMsg,DeviceBankInstance,BankStatus);
}
//*****************************************************************************
void SetSwitch(unsigned char DeviceBankInstance, uint8_t SwitchIndex, bool ItemStatus) {
tN2kBinaryStatus BankStatus;
tN2kMsg N2kMsg;
N2kResetBinaryStatus(BankStatus);
N2kSetStatusBinaryOnStatus(BankStatus,ItemStatus?N2kOnOff_On:N2kOnOff_Off,SwitchIndex);
SetN2kSwitchBankCommand(N2kMsg,DeviceBankInstance,BankStatus);
NMEA2000.SendMsg(N2kMsg);
}
Then, when you want to turn on switch 0 on bank instance 0 you call: SetSwitch(0,0,true); and off SetSwitch(0,0,false);
Note that B&G may use 126208 for commanding switches.
i put this in my arduino sketch in and set switch in de void loop. the 127502 pgn is send i can see in the actisense nmeareader. no reponse ir what ever on the czone page of my plotter :(
The plotter says the device is offline :( ill think it is not so simple to get this working. i
Please clarify what you try to do. Do you have YDCC-04 or YDSC-04 or do you try to make one? What devices you have on your test system.
i have a teensy3.1 and a vulcan plotter. found the czone config file of the YDCC-04. I want to switch outputs with the vulcan plotter on the teensy3.1.
The YDCC-04 uses pgn 127501 and 127502, so my simple understanding: load the config file in the vulcan plotter, let the teensy send the 127501 and 127502 and see what is going on. When looking at the n2kbus with the actisense reader i see the 127501 and 127502 send from the teensy3.1, but no 127501 and 127502 send from the vulcanplotter to the bus. In the plotter is the fault message that the YDCC-04 is not present.
So you have to send 127501 periodically to bus, where you inform you switch states. Then you have to add listener for 127502. When you receive that PGN, you parse switch states from it, set you switch state according to state. Since you update switch states with 127501, Vulcan should see it. Note that you should also add 127501 to Transmit and 127502 to Receive messages for library.
The problem is that your configuration file seem to contain information about YDCC-04. So it may be that even your device is on the bus, Vulcan will not see it, since it expects to see YDCC-04 there. So test first just send peridically 127501 to inform switch states. If Vulcan does not see your device, then you have to try to set all information (serial number, device info, manufacturer number etc.) to library as on configuration file.
I set all relevant information in the teensy. In the device list there is an YDCC-04 device. The serial numbers are correct as well. Regardless of parsing the 127502 message, the vulcan should send that on the network.
I think Vulcan (or any device) should send 127502 once only, when you change the switch state. It can not send message continuously, since point of digital switches is that you can control them from different places and they may be disabled to force them off.
You do not need to parse 127502 at first. Just see that Vulcan will see your device and send 127502 on switch state change. If you do not change that switch state to 127501, Vulcan should return switch to your state - maybe give error, that it could not switch.
The online tool https://www.yachtd.com/products/ds/?czone should create a valid configuration for the Vulcan.
YDCC-04 Manual https://www.yachtd.com/downloads/ydccydsc.pdf
i made de valid configuration with that tool.
it just looks like the vulcan doesnt get a response and thinks the device is offline. if i use the buttons on the vulcan there is no message send
Yes I have seen that. But have you tested to use it? What information fixes configured device to Vulcan? Serialnumber etc. Has anybody tried to find, what vulcan configuration file should contain?
i put that file in my vulcan. i pressed a switch button but no message on the n2knetwork
As I understand when a new config is detected it will replace the config on ALL czone devices in that group so if any device fails the rest of the network keeps working. If your device is not completing the network initialization correctly perhaps it's being ignored.
ok, that makes sense. now to find a way to let the vulcan think there is a module. Do you know what message need t be end to the czone config to initialise a module ?
That's the mystery of the czone proprietary messages, please let me know when you find out. The fact the there is a YDCC indicates it's possible to reverse engineer. I doubt BEP approved this device as it wipes the configuration of any other czone devices on the network! From the YDCC manual:
If you already have CZone equipment installed, you will overwrite the exiting CZone configuration with our file and your CZone equipment will not function correctly.
The czone devices are not in the config file that you download from the yachtdevice website. I downloaded the czone configurator, opened the config file, nothing special there just the device with 4 outputs.
I work with pgn127501 from the library. On the garmin plotter that I have appears the 10 buttons that I would like to have.The only problem that I have now it is how to take the request from the plotter to turn on the switches.i am searching if it is necessary to use the pgn126208 to can take the request for changing the status of the switches.
can you share your work so far ?
Of course I will do that.
wunderfull, i am also curious how you got the buttons on your plotter.
//#define N2k_CAN_INT_PIN 21
const unsigned long TransmitMessages[] PROGMEM={127501L,127502L,0};
void setup() {
NMEA2000.SetProductInformation("112233", 100, "Binary Switches", "2.6.3.20 (2020-3-20)","1.1.1.1 (2020-3-15)", 0,0,0,0);
NMEA2000.SetDeviceInformation(112233,140, 30,333,4,0 );
Serial.begin(115200); NMEA2000.SetForwardStream(&Serial);
NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22); NMEA2000.ExtendTransmitMessages(TransmitMessages); NMEA2000.Open();
pinMode(2, INPUT); pinMode(3, INPUT); pinMode(4, INPUT); pinMode(5, INPUT); pinMode(6, INPUT); pinMode(7, INPUT); pinMode(8, INPUT); pinMode(9, INPUT); pinMode(10, INPUT); pinMode(11, INPUT);
}
void loop() {
SendN2kBinaryStatus(); NMEA2000.ParseMessages();
}
typedef int64_t BankStatus;
void SendN2kBinaryStatus(){ unsigned char BankInstance=0; static unsigned long SwitchUpdated=millis(); tN2kMsg N2kMsg; tN2kOnOff Status1,Status2,Status3,Status4, Status5,Status6,Status7,Status8, Status9,Status10;
if ( SwitchUpdated+SwitchUpdatePeriod<millis() ) { SwitchUpdated=millis();
if(digitalRead(2)==LOW )
{ Status1=N2kOnOff_On;
}
else if (digitalRead(2)==HIGH )
{ Status1=N2kOnOff_Off;
}
if(digitalRead(3)==LOW )
{ Status2=N2kOnOff_On;
}
else if (digitalRead(3)==HIGH )
{ Status2=N2kOnOff_Off;
}
if(digitalRead(4)==LOW )
{ Status3=N2kOnOff_On;
}
else if (digitalRead(4)==HIGH )
{ Status3=N2kOnOff_Off;
}
if(digitalRead(5)==LOW )
{ Status4=N2kOnOff_On;
}
else if (digitalRead(5)==HIGH )
{ Status4=N2kOnOff_Off;
}
if(digitalRead(6)==LOW )
{ Status5=N2kOnOff_On;
}
else if (digitalRead(6)==HIGH )
{ Status5=N2kOnOff_Off;
}
if(digitalRead(7)==LOW )
{ Status6=N2kOnOff_On;
}
else if (digitalRead(7)==HIGH )
{ Status6=N2kOnOff_Off;
}
if(digitalRead(8)==LOW )
{ Status7=N2kOnOff_On;
}
else if (digitalRead(8)==HIGH )
{ Status7=N2kOnOff_Off;
}
if(digitalRead(9)==LOW )
{ Status8=N2kOnOff_On;
}
else if (digitalRead(9)==HIGH )
{ Status8=N2kOnOff_Off;
}
if(digitalRead(10)==LOW )
{ Status9=N2kOnOff_On;
}
else if (digitalRead(10)==HIGH )
{ Status9=N2kOnOff_Off;
}
if(digitalRead(11)==LOW )
{ Status10=N2kOnOff_On;
}
else if (digitalRead(11)==HIGH )
{ Status10=N2kOnOff_Off;
}
SetN2kBinaryStatus(N2kMsg,0,Status1,Status2,Status3,Status4, Status5,Status6,Status7,Status8,
Status9,Status10);
NMEA2000.SendMsg(N2kMsg,0);
}
}
![Uploading 20200326_130952.jpg…]() And that is the images.
wow that looks great, hos did you make the switches on your plotter ? My B&G doesn't have a predefinded button field of possibility
I check that when running in the network the pgn127501 information automatically recognized from the plotter.Before I did not have these option on my plotter.
Antoni,
which plotter is this? 7** ? curious if that will work on my GPSMAP 4008 and 5008 or they are too old!
cheers
V
I have the gpsmap1022.I think that if you make the new update 7.80 maybe you can have it,but I am not so sure.I check in the Garmin update but I do not find something there.
Have you read the bus how your MFD would handle button press. There are two ways: it sends 127502 with switch information it wants to change or it uses 126208, which is more complex. So extend your ReceivePGNList with 127502 and then spy bus doesgpsmap send that pgn on switch press.
I check the traffic of the nmea 2000 the plotter send pgn127502 and pgn126208 you have right. My problem for now is to collect the information from the pgn127502 but i could not add on the library to call them then. The pgn126208 is much difficult to check it and it is neccecary to send and listen all the commands. If you have any idea please let me know. thanks
Hi, I just managed to send a 127501 to my Garmin 922xs and all of a sudden switches appered on my screen. When I set one bank switch high in 127501 the corresponding switch in my MFD turns high 😀👍. Now my problem is to manage to parse 127502 sent from my MFD when pressing a switch. Has someone managed to do that?
best regards Niklas
would you share your code ?
If you use my code you can see that is working in these way. I make a lot of tries to take the neccessary phrase from the nmea 2000. First I change the divice settings to listen and send NMEA2000.SetMode(tNMEA2000::N2km_ListenAndSend); And now I am try to separate the phrase that running in the network to take only the Pgn127502 and then to change the status of the switch. The phrase of 127501 and 127502 can manage 28 switches in 1 sid.
N2km_ListenAndSend mode is for analysing and test purposes. Device will then not respond to requests. This will cause that it will disappear from the devices list on MFD.
Parsing 127502 is similar as 127501. When you receive 127502, you should change your switch status according received information. Note that you should not touch to any switches, which values on messages is NA. Then you update 127501 as normally.
You have right Timo. I used this NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,22); But I could read the phrase of pgn 127502.
Hi.
Of course I will share my code. But It might not be all pleasant reading ;) It partial has some swedish names but without the dots. How should I share it?
My project is based on a Arduino Mega2560, a CAN-BUS shield with a MCP2515, a Nextion Enhanced display 7". The system "Diginautic" originally aimed to collect engine RPM, oil pressure and coolant temperature. But while I got to know Arduino and that "world" I realized that a touch display and some relays would easily replace my ordinary switches. And while I was going I found the ACS712 current sensors and now I have:
Arduino Mega2560 CAN-BUS shield Nextion Enhanced 7" display 16 relays 13 current sensors 2 op-amps measuring voltage drops over 3 shunt resistors I2C-bus with 4 16-bits ADC to collect data
Along that in my boat I have Garmin MFD, AIS, VHF, Fusion FM-Radio, Compass and GFL10 Fluid Level sensor on my NMEA2000-bus. I collect lots of data from N2k and send quite a lot of data back on N2k.
When I change state on any of my relays I send a 127501 on N2k to my GPS:
When pressing button 1 I do this N2kSetStatusBinaryOnStatus(SwitchBoard,N2kOnOff_On,1); SendN2kBinaryStatus(true);
My next step is to add support for 127502 to receive that PGN. The thoughts I have is to do the opposite of 127501. Parse SwitchBoard to find out what button was pressed on my GPS. After that I'll send a corresponding 127501 telling my GPS that it actually was turned on.
I'll let you know on my progress /Niklas
Den fre 17 apr. 2020 kl 10:07 skrev AntonisPapa notifications@github.com:
You have right Timo. I used this NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,22); But I could read the phrase of pgn 127502.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ttlappalainen/NMEA2000/issues/128#issuecomment-615107141, or unsubscribe https://github.com/notifications/unsubscribe-auth/APG4JCANRTUP2CZ5HFZXIQLRNAE53ANCNFSM4GDXXGOQ .
Hi All,
I have followed this topic with interest, I have been using Timo's excellent and robust libraries and have built a number of projects using the Teensy and Rpi platforms for my yacht.
Digital switching from my Raymarine Axiom plotter being a most desirable addition, after several failed attempts, it is probably worth relating what I have learnt.
The Axiom supports 3 vendors in digital switching, Empirbus, Yacht Devices, and CZone. All require a custom Qt page, designed and loaded. This isn't so hard as Empirbus and Yacht Devices have tools on there websites that generate the required pages.
Both Empirbus and Yacht Devices both publish some information regarding the N2K PGN's their devices use, mainly dealing with the switching PGN's, so far so good.
The problem is the Axion needs to detect the hardware is on the bus before it enable the switching page or the onscreen switches.
This in my opinion, during the startup interaction between the device and Axion, and is probably in the Vendor/Device/Serial Number PGN's exchanges between the two devices.
Having tried several time to simulate these exchanges, I have concluded without an actual vendor device to look at these interactions, it is near impossible.
Regards
Have you tried to just set device manufacturer ID to Yacht Devices 717? They use standard messages 127501 and 127502
Hi!
On my boat I only use 127501 and 127502 and no configuration files in my plotter. I have a Garmin 922xs and it works perfectly.
Regards Niklas
Den ons 24 juni 2020 kl 13:55 skrev Timo Lappalainen < notifications@github.com>:
Have you tried to just set device manufacturer ID to Yacht Devices 717? They use standard messages 127501 and 127502
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ttlappalainen/NMEA2000/issues/128#issuecomment-648774828, or unsubscribe https://github.com/notifications/unsubscribe-auth/APG4JCFXV7RMFLWV2DPANHLRYHSTVANCNFSM4GDXXGOQ .
Hi guys!
Please if you could can you share with us the code that you use? The Garmin plotters are recognize direct from the pgns the modules that have been installed in the network.
The raymarine with empire bus works in different pgns and to appear in the network it is neccessary to fix an html5 page with the number of the items icons amd etc.
Στις Τετ, 24 Ιουν 2020, 23:46 ο χρήστης diginautic notifications@github.com έγραψε:
Hi!
On my boat I only use 127501 and 127502 and no configuration files in my plotter. I have a Garmin 922xs and it works perfectly.
Regards Niklas
Den ons 24 juni 2020 kl 13:55 skrev Timo Lappalainen < notifications@github.com>:
Have you tried to just set device manufacturer ID to Yacht Devices 717? They use standard messages 127501 and 127502
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/ttlappalainen/NMEA2000/issues/128#issuecomment-648774828 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/APG4JCFXV7RMFLWV2DPANHLRYHSTVANCNFSM4GDXXGOQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ttlappalainen/NMEA2000/issues/128#issuecomment-649062393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO57YUHNJUN3I5FYPU6VBE3RYJQ3JANCNFSM4GDXXGOQ .
Hi Timo,
Last years i was working on an engine interface, that worked fine at home on a B&G vulcan 5 plotter.
Last winter I installed it on my ship, a bigger n2k network with more sensors and I encounter some difficulties.
After playing for a whole season with settings on the network I finally gave up.
It even prevents me from experimenting with outputs on the N2knetwork
The device is not visible and then it is for a while and then it is gone no data on the data fields and there is again in the device list.
Basically it random appears and disappears on the netwok
It look lik It fight’s with the N2k fusion radio , that stops working and need a hard reset,
I changed the network address but that doesn’t do the trick.
Even build in a delay that works sometimes but not consistent
Obviously I am doing something wrong can you help me?
I used your example and modify some setting so it works for me.
Perhaps I need to add or remove something.
The code that is used initial is below:
// Yanmar motor interface, various sensors added to the engine block
// Need about 1 minute starting delay, other wise the plotter wil not recognize the interface,
// i have to sort this out some day........
// Big thank you to Timo Lappalainen for sharing the N2K lib on github.
//
//Demo sketch modified to this version by F. Meijlink. 04-2020
//Running on a Teensy 3.2
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;
//int refsig=20;//for converting the analog signal coming from hall sensor to digital through arduino code
int val;//the digital value of the incoming analog signals
int prev_val=0;
unsigned long t,cur_t;//time variables
U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, / reset=/ U8X8_PIN_NONE);
// Yanmarlogo
static unsigned char yanmarlogo1_bits[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f,
0xe0, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x3f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0xbf, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xbf, 0xef, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x87, 0x0f,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xf8, 0x61, 0xdf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xf8, 0x5c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x7c, 0x0c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xe0, 0x0f, 0xff,
0x01, 0x3c, 0xf0, 0xe0, 0x0f, 0xf0, 0x07, 0xf0, 0x1f, 0xe0, 0xff, 0x0f,
0x3f, 0xe0, 0x8f, 0xff, 0x01, 0x3e, 0xf0, 0xf0, 0x0f, 0xf8, 0x07, 0xf0,
0x3f, 0xf0, 0xff, 0x0f, 0x3e, 0xf0, 0x87, 0xff, 0x01, 0x3e, 0xf0, 0xf0,
0x1f, 0xf8, 0x07, 0xf8, 0x3f, 0xf0, 0xff, 0x1f, 0x3e, 0xf8, 0xc7, 0xff,
0x01, 0x3e, 0xf8, 0xf0, 0x1f, 0xfc, 0x07, 0xf8, 0x3f, 0xf0, 0xff, 0x1f,
0x7c, 0xfc, 0xe3, 0xff, 0x03, 0x7e, 0xf8, 0xf0, 0x1f, 0xfe, 0x07, 0xfc,
0x3f, 0xf8, 0xff, 0x0f, 0xf8, 0xff, 0xe0, 0xcf, 0x03, 0xff, 0xf8, 0xf8,
0xbf, 0xff, 0x03, 0xfe, 0x7f, 0xf8, 0x81, 0x0f, 0xf8, 0x7f, 0xe0, 0xcf,
0x03, 0xff, 0xf9, 0xf8, 0xbf, 0xff, 0x03, 0x7f, 0x7f, 0xf8, 0xc1, 0x07,
0xf0, 0x3f, 0xe0, 0xc7, 0x03, 0xff, 0xff, 0xf8, 0xff, 0xff, 0x03, 0x7f,
0x7f, 0xf8, 0xff, 0x07, 0xf0, 0x1f, 0xf0, 0xc7, 0x07, 0xff, 0x7f, 0xf8,
0xff, 0xff, 0x03, 0x3f, 0x7f, 0xfc, 0xff, 0x03, 0xe0, 0x1f, 0xf0, 0xc3,
0x87, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x03, 0x3f, 0x7f, 0xfc, 0xff, 0x03,
0xe0, 0x1f, 0xf8, 0xc3, 0x87, 0xff, 0x7f, 0xf8, 0xfe, 0xff, 0x01, 0x3f,
0xff, 0xfc, 0xff, 0x07, 0xe0, 0x0f, 0xf8, 0xff, 0x87, 0xff, 0x7f, 0xfc,
0xfc, 0xf3, 0x81, 0xff, 0xff, 0xfc, 0xe1, 0x07, 0xe0, 0x0f, 0xf8, 0xff,
0x87, 0xff, 0x7f, 0xfc, 0xfc, 0xf3, 0x81, 0xff, 0xff, 0xfc, 0xe1, 0x03,
0xe0, 0x07, 0x7c, 0xc0, 0xcf, 0xdf, 0x7f, 0x7c, 0x78, 0xf0, 0xe1, 0x07,
0xfe, 0xfc, 0xe1, 0x03, 0xe0, 0x07, 0x3e, 0xc0, 0xcf, 0x9f, 0x7f, 0x7c,
0x70, 0xf0, 0xe1, 0x07, 0xfe, 0xfc, 0xe1, 0x03, 0xe0, 0x07, 0x3e, 0xc0,
0xcf, 0x1f, 0x7f, 0x7e, 0x70, 0xf8, 0xf1, 0x03, 0xfe, 0xfd, 0xf1, 0x03,
0xe0, 0x03, 0x1f, 0xc0, 0x8f, 0x0f, 0x7e, 0x7c, 0x60, 0xf0, 0xf1, 0x03,
0xfc, 0xfc, 0xe0, 0x01 };
//----------------------------- nmea2000 parser-----------------------//
typedef struct {
unsigned long PGN;
void (*Handler)(const tN2kMsg &N2kMsg);
} tNMEA2000Handler;
void BinaryStatus(const tN2kMsg &N2kMsg);
tNMEA2000Handler NMEA2000Handlers[]={
{127501L,&BinaryStatus},
{0,0}
};
//---------------------------------------------------------------------//
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g2.drawXBMP( 0, 0, yanmarlogo1_width, yanmarlogo1_height, yanmarlogo1_bits);
}
void setup()
{
u8g2.begin();
delay (10000); //10sec delay
//draw logo after 10 sec delay
u8g2.firstPage();
do {
draw();
} while ( u8g2.nextPage() );
delay (20000); // display logo for 20sec
u8g2.firstPage();
do {
//u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.setFont(u8g2_font_t0_13b_te);
u8g2.drawStr(10,14,"Yanmar N2K interface");
u8g2.drawStr(10,24,"Version 1.3.1");
u8g2.drawStr(10,36,"Sproktronics");
} while ( u8g2.nextPage() );
delay (10000);// delay 10 seconden
u8g2.firstPage();
do {
//u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.setFont(u8g2_font_t0_13b_te);
u8g2.drawStr(10,14,"Waiting 15 sec ");
u8g2.drawStr(10,24,"(c) 2020");
u8g2.drawStr(10,36,"Sproktronics");
} while ( u8g2.nextPage() );
delay (10000);
// Set Product information
NMEA2000.SetN2kCANSendFrameBufSize(150);
NMEA2000.SetN2kCANReceiveFrameBufSize(150);
NMEA2000.SetProductInformation("550440", // Manufacturer's Model serial code
100, // Manufacturer's product code
"Sproktronic", // Manufacturer's Model ID
"1.3.1 (2020-20-01)", // Manufacturer's Software version code
"1.0.0.0, (2017-01-01)" // Manufacturer's Model version
);
// Set device information
NMEA2000.SetDeviceInformation(777888, // Unique number. Use e.g. Serial number.
132, // Device function=Analog to NMEA 2000 Gateway. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
25, // Device class=Inter/Intranetwork Device. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
381, // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf
4 //marine
);
// Uncomment 3 rows below to see, what device will send to bus
Serial.begin(115200);
NMEA2000.SetForwardStream(&Serial); // PC output on due programming port
// NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format.
// NMEA2000.SetForwardOwnMessages();
// If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
// NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22);
NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,96);
//NMEA2000.SetDebugMode(tNMEA2000::dm_ClearText); // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
NMEA2000.EnableForward(false); // Disable all msg forwarding to USB (=Serial)
NMEA2000.SetMsgHandler(HandleNMEA2000Msg);
NMEA2000.Open();
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
//pinMode(9,
pinMode(21, INPUT);
delay (30);
//freq1.begin(A7); // set rpm input pin
u8g2.enableUTF8Print(); // enable UTF8 support for the Arduino print() function
//int Oledrpm;
//Interrupt 0 is digital pin 2, so that is where the IR detector is connected
//Triggers on FALLING (change from HIGH to LOW)
attachInterrupt(21, rpm_fun, RISING);
rpmcount = 0;
rpm = 0;
timeold = 0;
} // end void setup
float sum1=0;
int count1=0;
//elapsedMillis timeout;
//int rpm = 0;
int Oledrpm = 0;
//----------------------------- coolant temp --------------------------//
OneWire oneWire(ONE_WIRE_BUS);// Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
//DeviceAddress CoolantSensor = { 0x28, 0xFF, 0x9C, 0xA0, 0x81, 0x16, 0x03, 0x1A }; // Define device <- test device
DeviceAddress CoolantSensor = { 0x28, 0xFF, 0xBD, 0xBC, 0x94, 0x16, 0x04, 0xF9 }; // Define device address
//DeviceAddress EngineRoom = { 0x28, 0xFF, 0x71, 0xE3, 0x81, 0x16, 0x03, 0x44 }; // Define device <- test device
DeviceAddress EngineRoom = { 0x28, 0xFF, 0x68, 0xA4, 0x81, 0x16, 0x03, 0xAD }; // Define device address
//DeviceAddress Exhaust = { 0x28, 0xFF, 0x87, 0xF6, 0x81, 0x16, 0x03, 0xC7 }; // Define device <- test device
DeviceAddress Exhaust = { 0x28, 0xFF, 0xD5, 0x80, 0x94, 0x16, 0x04, 0x8C }; // Define device address
double CoolantTemp = 0.0f;
double EngineRoomTemp = 0.0f;
double ExhaustGasTemp = 0.0f;
int engtmp;
int EngRmTmp;
int ExHstTmp;
void readTemp()
{
// Start up the library
sensors.begin();
// set the resolution to 10 bit
sensors.setResolution(CoolantSensor, 10);
sensors.setResolution(EngineRoom, 10);
sensors.requestTemperatures();
float tempC = sensors.getTempC(CoolantSensor);
float tempE = sensors.getTempC(EngineRoom);
float tempU = sensors.getTempC(Exhaust);
//Serial.println(tempC);
CoolantTemp = (tempC);
EngineRoomTemp = (tempE);
ExhaustGasTemp = (tempU);
engtmp = tempC; // coolanttemp for Oled display
EngRmTmp = tempE; // engineroom temp for Oled display
ExHstTmp = tempU;// exhaust temp for Oled display
}
//----------------------------- oil pressure --------------------------//
double OilPressure;
double OilPress;
void Readoilpressure()
{
float ratio = (analogRead (A9) + 0.5) / 1024.0 ; // 0 to 1 range
float pressure_PSI = (ratio - 0.1) * 500.0 / 0.8 ;
if (analogRead(A9) < 170){
pressure_PSI = 0;
}
OilPressure = round (pressure_PSI /10)*68.97 ; // 68.947 psi to mBar
OilPress = OilPressure / 1000; // devide by 1K for Oled display
}
//----------------------------- oil temp --------------------------//
double oiltemp = 0;
double sensorInput = 0.0f;
int Oiltmp;
double Voltpin = 0;
const int N = 16; // aantal te middelen meetwaardes
int meetwaardes[N]; // opslag van individuele meetwaardes
int filteraccumulator = 0; // optelsom van alle individuele meetwaardes
int i = 0; // meetwaardeteller
void readoilTemp()
{
// average over 16 measurement values
filteraccumulator -= meetwaardes[i]; // vergeet oudste meetwaarde
meetwaardes[i] = analogRead(A8); // bewaar nieuwe meetwaarde
filteraccumulator += meetwaardes[i]; // accumuleer nieuwste meetwaarde
i++; i %= N; // teller loopt van 0 tot N-1
sensorInput = filteraccumulator/N; // bereken de gemmiddelde waarde
delay(100);
float voltage = sensorInput * 3.3;
oiltemp = round (voltage - 500) /10 ; //
//((1000 mV - 500) / 10) = 50 degrees Celsius
//oiltemp = round (oiltemp 4.1 100); //multiply by 4.1V to get voltage
oiltemp = round (oiltemp);
Oiltmp = oiltemp; // oiltemp for Oled display
}
//-----------------output---------------------------------------------//
void BinaryStatus(const tN2kMsg &N2kMsg) {
unsigned char BankInstance;
//N2kOnOff Status1,Status2,Status3,Status4;
tN2kBinaryStatus BankStatus;
///naryStatusFull(N2kMsg);
if (ParseN2kBinaryStatus(N2kMsg,BankInstance,BankStatus) ) {
digitalWrite(7, ( N2kGetStatusOnBinaryStatus(BankStatus,1)==N2kOnOff_On ? HIGH : LOW ) );
digitalWrite(8, ( N2kGetStatusOnBinaryStatus(BankStatus,2)==N2kOnOff_On ? HIGH : LOW ) );
}
}
//-------------------------------- NMEA 2000 message handler -----------------------//
void HandleNMEA2000Msg(const tN2kMsg &N2kMsg) {
int iHandler;
// Find handler
//OutputStream->print("In Main Handler: "); OutputStream->println(N2kMsg.PGN);
for (iHandler=0; NMEA2000Handlers[iHandler].PGN!=0 && !(N2kMsg.PGN==NMEA2000Handlers[iHandler].PGN); iHandler++);
if (NMEA2000Handlers[iHandler].PGN!=0) {
NMEA2000Handlers[iHandler].Handler(N2kMsg);
}
}
void rpm_fun()
{
//Each rotation, this interrupt function is run twice, so take that into consideration for
//calculating RPM
//Update count
rpmcount++;
}
void loop()
{
while ( Serial.available()>0 ) Serial.read();
// rpm start here ---------------
//Update RPM every second
delay(1000);
//Don't process interrupts during calculations
detachInterrupt(0);
//Note that this would be 601000/(millis() - timeold)rpmcount if the interrupt
//happened once per revolution instead of twice. Other multiples could be used
//for multi-bladed propellers or fans
rpm = 601000/(millis() - timeold)rpmcount;
timeold = millis();
rpmcount = 0;
Serial.print("RPM=");
Serial.println(rpm);
//Restart the interrupt processing
attachInterrupt(21, rpm_fun, RISING);
NMEA2000.ParseMessages();
readTemp();
Readoilpressure();
SendN2kRapidData();
SendN2kSlowData();
readoilTemp();
//---------------------------- Oled ----------------------------//
u8g2.firstPage();
do {
//u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.setFont(u8g2_font_t0_13b_te);
u8g2.drawStr(0,12,"EngRoomTmp ");
u8g2.setCursor(90, 12);
u8g2.print(EngRmTmp);u8g2.print("°C ");
u8g2.drawStr(0,30,"Oil");
u8g2.setCursor(25, 30);
u8g2.print(Oiltmp);u8g2.print("°C "); u8g2.print(OilPress);u8g2.print(" Bar");
u8g2.drawStr(0,45,"Engine");
u8g2.setCursor(45, 45);
u8g2.print(engtmp);u8g2.print("°C ");u8g2.print(rpm);
u8g2.setFont (u8g2_font_t0_11b_te);
u8g2.print("/min");
u8g2.setFont(u8g2_font_t0_13b_te);
u8g2.drawStr(0, 61,"ExhaustTmp ");
u8g2.setCursor(90, 61);
u8g2.print(ExHstTmp);u8g2.print("°C ");
} while ( u8g2.nextPage() );
//---------------------------engine room ventilator----------------------------------------------------//
//if(EngineRoomTemp >= 23){
// digitalWrite(9, HIGH);
// } else {
// digitalWrite(9, LOW);
// }
} // end void loop
//double ReadTemp() {
// return CToKelvin(99.5); // Read here the true temperature e.g. from analog input
// }
//double ReadCabinTemp() {
// return CToKelvin(22.22); // Read here the true temperature e.g. from analog input
// }
//double ReadExhaustTemp() {
// return CToKelvin(222);
//}
void SendN2kSlowData() {
static unsigned long SlowDataUpdated = millis();
tN2kMsg N2kMsg;
//static double Heading = 227.5;
// !delay is not good practise withing loops! I use it in this sample since
// I tested Arduino Mega as receiver without inteerupt and it could not handle all messages
// send without delay. With interrupt, it can do it and you can set DelayBetweenSend to 0.
const int DelayBetweenSend = 0;
if ( SlowDataUpdated + SlowDataUpdatePeriod < millis() ) {
SlowDataUpdated = millis();
//SetN2kDCBatStatus(N2kMsg, 1, 12.72);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//static unsigned char sid = 0;
// SetN2kDCBatStatus(N2kMsg, 0, 12.45, 5.08, CToKelvin(27.15));
//SetN2kPGN127508(N2kMsg, 0, 13.8, 0.95, N2kDoubleNA, sid++);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
// SetN2kTemperatureExt(N2kMsg, 1, 1, N2kts_MainCabinTemperature, ReadCabinTemp(), CToKelvin(21.6));
// delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
SetN2kTemperature(N2kMsg,1, 1, N2kts_EngineRoomTemperature, CToKelvin(EngineRoomTemp), CToKelvin(21.6));
delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
SetN2kTemperature(N2kMsg,1, 2, N2kts_EngineRoomTemperature, CToKelvin(ExhaustGasTemp), CToKelvin(21.6));
delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kTemperatureExt(N2kMsg, 1, 1, N2kts_FreezerTemperature, CToKelvin(ExhaustGasTemp), CToKelvin(21.6));
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kTemperature(N2kMsg, 1, 2, N2kts_ExhaustGasTemperature, CToKelvin(ExhaustGasTemp), CToKelvin(21.6));
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kTemperatureExt(N2kMsg, 1, 1, N2kts_ExhaustGasTemperature, CToKelvin(ExhaustGasTemp), CToKelvin(21.6));
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kEnvironmentalParameters(N2kMsg, 1, N2kts_MainCabinTemperature, ReadCabinTemp(), N2khs_InsideHumidity, 55, mBarToPascal(1013.5));
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kOutsideEnvironmentalParameters(N2kMsg, 1, ReadWaterTemp(), CToKelvin(25.3), mBarToPascal(1013.5));
//elay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kBatConf(N2kMsg, 1, N2kDCbt_AGM, N2kDCES_Yes, N2kDCbnv_12v, N2kDCbc_LeadAcid, AhToCoulomb(410), 95, 1.26, 97);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kDCStatus(N2kMsg, 1, 1, N2kDCt_Alternator, 86, 91, 1420, 0.21);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kAttitude(N2kMsg, 1, DegToRad(-3.1), DegToRad(2.4), DegToRad(-7.8));
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kEngineDynamicParam(N2kMsg, 0, mBarToPascal(OilPressure), CToKelvin(oiltemp), CToKelvin(CoolantTemp), 14.21, 5.67, hToSeconds(2137.55), N2kDoubleNA, N2kDoubleNA, N2kInt8NA, N2kInt8NA, true);
SetN2kEngineDynamicParam(N2kMsg, 0, mBarToPascal(OilPressure), CToKelvin(oiltemp), CToKelvin(CoolantTemp) ,0 ,0 , hToSeconds(2137.55), N2kDoubleNA, N2kDoubleNA, N2kInt8NA, N2kInt8NA, true);
delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kTransmissionParameters(N2kMsg, 0, N2kTG_Forward, 750000, CToKelvin(65.5), true, false, true);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kSystemTime(N2kMsg, 1, 17555, 62000);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kGNSS(N2kMsg, 1, 17555, 62000, 60.1, 22.5, 10.5, N2kGNSSt_GPS, N2kGNSSm_GNSSfix, 12, 0.8, 0.5, 15, 1, N2kGNSSt_GPS, 15, 2);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//SetN2kGNSSDOPData(N2kMsg, 1, N2kGNSSdm_Auto, N2kGNSSdm_Auto, 1.2, -0.8, N2kDoubleNA);
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
// Serial.print(millis()); Serial.println(", Temperature send ready");
//SetN2kMagneticHeading(N2kMsg, 0, DegToRad(Heading), DegToRad(-3.0), DegToRad(5.5));
//delay(DelayBetweenSend); NMEA2000.SendMsg(N2kMsg);
//Heading+=1; if (Heading>=360.0 ) Heading-=360.0;
//SetN2kAISClassAPosition(N2kMsg, 1, tN2kAISRepeat::N2kaisr_First, 123456789, 26.396, -80.075, 1, 1, 1, 20, 20, 30, 0, tN2kAISNavStatus::N2kaisns_At_Anchor);
//NMEA2000.SendMsg(N2kMsg);
//SetN2kBinaryStatus(N2kMsg, 8, N2kOnOff_On, N2kOnOff_Unavailable, N2kOnOff_Off);
//NMEA2000.SendMsg(N2kMsg);
//SetN2kPressure(N2kMsg, 0, 2, N2kps_Atmospheric, mBarToPascal(1024));
//NMEA2000.SendMsg(N2kMsg);
//SetN2kRudder(N2kMsg, DegToRad(5), 1, N2kRDO_MoveToStarboard, DegToRad(-5));
//NMEA2000.SendMsg(N2kMsg);
//tN2kBinaryStatus SwitchBoard;
//N2kResetBinaryStatus(SwitchBoard);
//N2kSetStatusBinaryOnStatus(SwitchBoard, N2kOnOff_On, 7);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(14)==1?N2kOnOff_Off:N2kOnOff_On),1);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(15)==1?N2kOnOff_Off:N2kOnOff_On),2);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(16)==1?N2kOnOff_Off:N2kOnOff_On),3);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(17)==1?N2kOnOff_Off:N2kOnOff_On),4);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(18)==1?N2kOnOff_Off:N2kOnOff_On),5);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(19)==1?N2kOnOff_Off:N2kOnOff_On),6);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(20)==1?N2kOnOff_Off:N2kOnOff_On),7);
//N2kSetStatusBinaryOnStatus(SwitchBoard,(digitalRead(21)==1?N2kOnOff_Off:N2kOnOff_On),8);
//SetN2kBinaryStatus(N2kMsg, 3, SwitchBoard);
//NMEA2000.SendMsg(N2kMsg);
}
}
void SendN2kRapidData() {
static unsigned long RapidDataUpdated = millis();
tN2kMsg N2kMsg;
if ( RapidDataUpdated + RapidDataUpdatePeriod < millis() ) {
RapidDataUpdated = millis();
SetN2kEngineParamRapid(N2kMsg, 0, rpm); //,820000,48);
//rpm = 0;
NMEA2000.SendMsg(N2kMsg);
//SetN2kCOGSOGRapid(N2kMsg, 1, N2khr_true, DegToRad(115.6), 0.1);
//NMEA2000.SendMsg(N2kMsg);
}
}
Many thanks in advanced
Ferry Meijlink
Hi Timo,
thanks for the great library!
I want to build a binary switch bank and I'm currently unsure, what's the correct way to control the switches.
Should it be done by a pgn 127502 or by a write or command request group function (pgn 126208) to pgn 127501? I did some research on the internet and I'm still unsure.
I'm aware, that I have to extend the group function code to handle it by a group function for pgn 127501.
Thanks, T.