Friday, February 10, 2017

Signal-K and the Alternator Regulator

Here is it!  For some time I have been working on and off with the Signal-K team to add electrical components.  Slow work, at times on the back burner  - but today I can share this with you:





What you are seeing is a simple Signal-K display showing real-time alternator voltage and current, as well as temperature (in kelvin - 308 --> ~35c/94f)  On the bottom right is the % field drive (57% at this time).

Currently the 'connection' is made via a serial port, with a javescript provider converting the ASCII status strings from the regulator into Signal-K JSON messages.  The 'provider' is located here:
https://github.com/thomasonw/signalk-parser-OSEnergy 

The script will work with Gen 2 or Gen 3 regulators, no problem.  And if you have the blue-tooth module installed you could point the incoming ASCII steam to the script wirelessly!

It is based on the  NMEA0183 --> SignalK converter, thank you to Fabian Tollenaar.   I do have two issue right now, and perhaps folks can help.

1) In the file /lib/index.js are two variables:   deviceName and associatedBus.  They are used to create linkage of the name and battery bank the alternator is connected - but at present I can not figure out how to define them outside of global variables. The issue is if you have two alternators and want to run two copies of this scrip, the names get mixed up - as there is only one locate to store them.   What I want is to have them defined and accessible to each instance of the javescrip ---  Is there a Javascrip expert out there who could point out the quick and simple way to change the code?  Pushes are welcomed!
Update:  This issue has been resolved, and multiple sources are now supported.


2) I use a windows client for pushing files up to github.  Seems there is an issue with this where the 'executable' permission flag is lost.  The impact is if you try to run the demo on a Linux or Apple machine you will get a 'non-executable' trap.  Presently one has to change the permission of the file 'osenergy-from-file' to allow execution.   There may be a way to configure github to force this, again if there are any github experts out there - please speak up!


OK - a start.  There is still work to be done, the Signal-k spec needs to be expanded, I need to solve the global-variable issue above, and the next step will be to create a CAN based bridge.  My RPi and CAN shield are already on order!