Monday, March 5, 2018

A look at SeedStudio USB-CAN Analyzer API

Securing a CAN adapter is somewhat a challenge.  There are several available, commercial as well as open source - with their costs starting at $50 and quickly raising higher.  So it was with great interest that these little guys started showing up on Ebay:

USB-CAN Analyzer Dongle  (Note V7.00)

Costing around $25, they looked to be a promising little device to use, and for some reason they have somewhat wide availability.  Including SeedStudio who offers them for a reasonable price:   https://www.seeedstudio.com/USB-CAN-Analyzer-p-2888.html     I was able to purchase one through Mouser for the same price.  (SeedStudio branded).  And of note:  the one I have matches the photo, including the V7.00 revision.

However, the documentation is very lacking, and what is there is flat wrong.  It does come with a Windows program that one can use to look at CAN messages, as well as send out some packets - but if you want to intercept the USB port and use it for your own programs, well . . . .

So I did a little snooping.  Using a COMM monitoring program I have been able to decipher the ASCII commands to and from the little USB dongle for several of the key functions covering basic config, sending and receiving of packets.   Perhaps some official (and correct) documentation will come available, until then I hope this guide can help some folks.

BASICS:

The USB dongle connects to the USB port via a QinHeng CH340 USB2 serial to USB adapter.  Once your OS has loaded the needed driver a virtual COM port is created.




CONFIGURING

The Configure command is a 20 character string with the following format:

Byte
Use
Value
Notes
1
START TOKEN
0xAA
Fixed value
2
COMMAND
0x55
 Configure
3
?
0x12

4
SPEED
0x01 =  1Mbps   
0x02 = 800Kbps
0x03 = 500Kbps
0x04 = 400Kbps
0x05 = 250Kbps
0x06 = 200Kbps
0x07 = 125Kbps
0x08 = 100Kbps
0x09 =  50Kbps
0x0A =  20Kbps
0x0B =  10Kbps
0x0C =   5Kbps

5
FRAME TYPE
0x01 = Std
0x02 = Extended

6
FILTER
MSB
Example:  0x12345678   --> 0x78
7

    0x56
8

    0x34
9
LSB
    0x12
10
MASK
LSB
Example:   0xFCBA987   --> 0x87
11

    0xA9
12

    0xCB
13
MSB
    0xFE
14
MODE
0x00 = Normal
0x01 = Loopback
0x02 = Silent
0x03 = Loopback + Silent

15
?
0x00 or 0x01
At one time I noted this being 0x01, not sure why…
16
0x00

17
0x00

18
0x00

19
0x00

20
CHECKSUM
Calculated = 8-bit sum of Bytes 2..18



 Example, 250Kbps, Extended Frame, no filtering / no mask, Standard mode. (aka, what the regulator uses):  AA 55 12 05 02 00 00 00 00 00 00 00 00 00 01 00 00 00 00 1A     


SENDING  DATA PACKETS:

The format for sending a packet is variable length with no terminator.   It again begins with the 0xAA value, and follows these tables:

Sending STD frame:


Byte
Use
Value
Notes
1
START TOKEN
0xAA
Fixed value
2
COMMAND
Bits 6..7 = 11
Transfer Packet
STD/EXT
Bit 5     = 0
Standard message
?
Bit 4     = 0

LENGTH
Bit 0..3
Number of data bytes being sent


Example: Sending 6 bytes:  0xC6
3
ID
LSB
Example:  ID = 0xBA98  --> 0x98
4
MSB
    0xBA
5
DATA
Data byte 1
Data packet.  Transmit only the number of characters you want to send.
(Matching LENGTH above)

6
Data byte 2
7
Data byte 3
8
Data byte 4
9
Data byte 5
10
Data byte 6
11
Data byte 7
12
Data byte 8




Sending EXT frame:


Byte
Use
Value
Notes
1
START TOKEN
0xAA
Fixed value
2
COMMAND
Bits 6..7 = 11
Transfer Packet
STD/EXT
Bit 5     = 1
Extended message
?
Bit 4     = 0

LENGTH
Bit 0..3
Number of data bytes being sent


Example: Sending 6 bytes:  0xE6
3
ID
LSB
Example:  ID = 0xFEDCBA98  à--> 0x98
4

    0xBA
5

    0xDC
6
MSB
    0xFE
7
DATA
Data byte 1
Data packet.  Transmit only the number of characters you want to send.
(Matching LENGTH above)

8
Data byte 2
9
Data byte 3
10
Data byte 4
11
Data byte 5
12
Data byte 6
13
Data byte 7
14
Data byte 8




RECEIVING DATA PACKETS:

 Receiving is the same as Sending but includes a 0x55 prefix.  Note also, I am inferring the STD packets as I only captured EXTENDED frames.  Again, packets are variable length with no terminator.



Byte
Use
Value
Notes
0
?
0x55
Prefix value?  Help to re-sync??
1
START TOKEN
0xAA

2
COMMAND
Bits 6..7 = 11
Transfer Packet
STD/EXT
Bit 5     = 0
Standard message
?
Bit 4     = 0

LENGTH
Bit 0..3
Number of data bytes being sent


Example: Sending 6 bytes:  0xC6
3
ID
LSB
Example:  ID = 0xBA98  --> 0x98
4
MSB
    0xBA
5
DATA
Data byte 1
Data packet.  Transmit only the number of characters you want to send.
(Matching LENGTH above)

6
Data byte 2
7
Data byte 3
8
Data byte 4
9
Data byte 5
10
Data byte 6
11
Data byte 7
12
Data byte 8





Byte
Use
Value
Notes
0
?
0x55
Prefix value?  Help to re-sync??
1
START TOKEN
0xAA

2
COMMAND
Bits 6..7 = 11
Transfer Packet
STD/EXT
Bit 5     = 1
Extended message
?
Bit 4     = 0

LENGTH
Bit 0..3
Number of data bytes to receive


Example: Receiving 8 bytes:  0xE8
3
ID
LSB
Example:  ID = 0x 19F21280  --> 0x80
4

    0x12
5

    0xF2
6
MSB
    0x19
7
DATA
Data byte 1
Data packet
(Matching LENGTH above)

8
Data byte 2
9
Data byte 3
10
Data byte 4
11
Data byte 5
12
Data byte 6
13
Data byte 7
14
Data byte 8



I hope folks find this of some interest and help.  If you have any addition input, please add to the comments below.  I have this detail in a .wrd file and can send it to anyone who is interested to review / edit and/or correct.












Saturday, February 24, 2018

Source code v1.2.1 released

...  along with updated documentation.   This release is primarily ‘polishing’ – it contains a number of small fixes and improvements based on feedback from the field.  Most notable around how the regulator works when the current shunt is not connected, as well as improvements in how Equalize mode is both processed and some improvements to the default CPE tables.



Two changes of note:



CPE #5 (previously RESERVED) has been populated with charge parameters according to the manufacture of the Firefly `Oasis’  battery.  As with almost all other manufactures, Firefly Energy calls for monitoring of acceptance current as the appropriate way to recharge their batteries.



Another rather subtle, but perhaps notable, change is the renaming of the Regulator from “Alternator Regulator” to “VSR Alternator Regulator”.  This is in preparation for shifting of the products to a newly formed company VSR Systems, llc   Not to worry, this is still the same regulator, still open sourced, still all the good stuff.  Just time to grow up a little and get a bit more formal.  The regulator will become part of a family of products hopefully to be released over the next year or so, include the VSR DC Generator Controller, the VSR Port Expander / Battery Monitor, and perhaps even the VSR MPPT controller.   Combined with the work folks are doing around displays and applications – 2018 could be a very exciting year.



The documentation has also been refreshed.  A bit of cleanup, and a rather large edit around the CAN (Control Area Network) capabilities as well as how to use it.  Including some hints on NEMA2000 integration.



Many of the changes in v1.2.1 were the direct result of feedback.  I thank all who are helping improve this project and look forward to more to come!




Monday, February 19, 2018

News concerning the Alternator Regulator

5 years ago I split out the regulator portion from the DC Generator Controller and created this stand alone Alternator Regulator.   Sense then a few hundred have been send out, blank boards as well as fully assembled.  With the introduction of the 3rd Generation regulator I began to provide fully assembled units on a more consistent basis and interest has grown.  In fact, it has kind of caught me off-guard as the 2nd batch of 50x regulators are all but gone.  I have 5 units still here (If I scrounge).


It is time to do another build - with some improvements:  The layout will be modified to allow fitting into a Hammond “B” size project box.  Nice little plastic enclosures will provide a bit of dress up, protection, as well as a good way to mount the regulator.  If you still need a waterproof enclosure, those gray plastic electrical boxes are always an option.  Here is a 3D rendering of the new layout:


3D Rendering of Gen 3B regulator.
It will be known as Gen 3B (B, for BOX)


I am also going to simplify the manufacturing, ordering,  and shipping processes.  No more hand soldering connectors for me!  Over the next couple of months an ‘Order’ button will appear allowing folks to place an order directly  (though I am still here for Email).  I also will be using a land-based shipping service.  These changes will streamline ordering and delivery during the Spring / Summer / Fall when we are out cruising.  Plus it will free up my time to allow for continued development of other projects.  (It is amazing how much time it takes to box and ship these things)

And look for a ‘Brand’ name announcement soon.  With the increased interest is perhaps time to be a bit more professional. 

New layout, simplified manufacturing, and a more consistent ordering and shipping procedure.  All good changes I hope.  Sadly they also comes cost  (Fees, TAXes, supplies).  The new Gen 3B regulators will be available fully assembled for $125 each.  Included will be two temperature probes and support for 12v to 24v ‘batteries’.   (Higher voltages up to 48v available as an option).  In addition to being sized for a case, the 12/24v configuration will feature improved accuracy in the current shunt, and the FET drivers have been beefed up.  I am also looking into what will be involved to have some of the boxed pre-machined with cutouts.  And I am busy working on several other companion projects, more details as they get closer to being ready.


Now this has been planned this for some time – was looking at the Fall.  But the interest in the regulator has caught me off guard.  I am not expecting the next batch of regulators to be available until sometime in late April / early May.  As a small compensation for this inconvenience I am going to offer a special pre-paid price of $100 for the Gen 3B regulators.  This price will be valid until the regulators ship.  I also have a few of the current regulators left to send out  (Still $80 ea), and  there is a Floating Stash of 4 or so in the SW Pacific.  Contact me if you are interested in any of these.


I thank everyone who has supported this project.  It started out because I had a need, and thought I would share the solution with others.  The interest and feedback from folks has been great and I am looking forward for more to come.  

Wednesday, February 7, 2018

Config Tool!

Back in 2013 (yikes! - 5 years ago!!) when this project was conceived, there was the intention of a nice configuration / monitoring tool running on your PC, table, phone, refrigerator, etc.. that would simply advanced configuration of the Alternator Regulator.

Point and Click and be done!

The whole ASCII status / command set was developed to support communications between the regulator and this application, just happens that people can (with enough work) use the same API.  But it was primary intended for machine-to-machine communications, not machine-to-human.

That application was never developed, which made it fortunate that people could use the ASCII strings.

Well, flash forward a few years and Sailor Rick has taken up the task of an app!  Today he published the 1st Beta version, and you can download it here:

http://backstagesailing.com/downloads/category/osenergy-configuration-tool-beta-versions/

TO say I am tickled is an understatement.   As much capability as the Alternator Regulator has I have always felt a well designed application could bring as much, or more, value to this overall project.


Take a look, see what you think, pitch in!  This is just a start.
 
Thank you Rick!