Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daly BMS support #4

Closed
softwarecrash opened this issue Nov 8, 2021 · 15 comments
Closed

Daly BMS support #4

softwarecrash opened this issue Nov 8, 2021 · 15 comments

Comments

@softwarecrash
Copy link

softwarecrash commented Nov 8, 2021

Hello,
it is possibil that you make your lib work with the daly bms?
i have atached the protocol that i found, and in my version the bluetooth dongle communication adress says 0x80, the pc software 0x40
Daly RS485+UART protocol.pdf
dump.txt

@ForrestFire0
Copy link
Owner

Hello,

Since I do not have a Daly BMS, I would be unable to test the code I write. And there is pretty much a zero percent chance of writing code correctly the first time. Additionally, my code makes two requests to get all the data - you need to make 9 requests to get it to work.

However, even without knowing you, I know you are capable of doing this yourself. You'll have to edit most of the functions. Start with the requestResponse and get it working with a single data request. At first just print out the buffer variable.

@softwarecrash
Copy link
Author

thanks, so i tried to start a fork and would test with other data.. but, it looks you ar working on the code, i get erros when compile
error: 'struct BMSPacket' has no member named 'data'

@ForrestFire0
Copy link
Owner

oop my bad. There was a dynamically allocated buffer that had no reason to be dynamically allocated. (I never resized it or freed the memory in the destructor.) When I was reviewing the code I changed it to a 50 byte buffer object that is now a class member. It compiles now for me. The basic read example sketch now compiles for me.

Sorry!

@softwarecrash
Copy link
Author

softwarecrash commented Nov 10, 2021

oop my bad. There was a dynamically allocated buffer that had no reason to be dynamically allocated. (I never resized it or freed the memory in the destructor.) When I was reviewing the code I changed it to a 50 byte buffer object that is now a class member. It compiles now for me. The basic read example sketch now compiles for me.

Sorry!

no problem, i have removed this for the moment.
but can you give me a hint what i must change in the bms.h that it send the command as one commant like a5 40 90 08 00 00 00 00 00 00 00 00 7d
actual i bekomme in the serial bypass this like
a5
40
90
....
so i strugle with this, im not the pro in this, or softwareserial
its this part
Serial.print("wird zum inverter gesendet: ");
BMSSerial->write(header, 2);
Serial.write(header, 2);
BMSSerial->write(outdata.command);
Serial.write(outdata.command);
BMSSerial->write(outdata.len);
Serial.write(outdata.len);
for (size_t i = 0; i < outdata.len; i++)
{
BMSSerial->write(outdata.nullbyte);
Serial.write(outdata.nullbyte);
}
//if (outdata.len)
// BMSSerial->write(outdata.data, outdata.len);
BMSSerial->write(outdata.checksumA);
Serial.write(outdata.checksumA);

@ForrestFire0
Copy link
Owner

ForrestFire0 commented Nov 10, 2021

I am going to make a second class (Maybe DalyBMS.h and DalyBMS.cpp)

Give me like 30 mins to get this started. I'll see what I can do.

@ForrestFire0
Copy link
Owner

ForrestFire0 commented Nov 10, 2021

Ok I pushed 3 new files. Try opening the Daly BMS example and seeing if that makes it go. @softwarecrash

@softwarecrash
Copy link
Author

softwarecrash commented Nov 10, 2021

Ok I pushed 3 new files. Try opening the Daly BMS example and seeing if that makes it go. @softwarecrash

thanks, i have tested it, but the data comes again in segmentation, it looks like after every bit it makes a new line. the daly needs the data in a one line, with "spaces" wetwen the bits

i think the bits must write in one action like write(data+data+data)

@softwarecrash
Copy link
Author

softwarecrash commented Nov 11, 2021

so i have tested and tried arround, but i cant get the send funktion to write an array of hex data in one line, it sends every bit at allone, that makes me grazy, its eventualy a problem with softwareserial?

byte wBuff[13];
wBuff[0] = BMS_START_ADDR; //fixed start byte 0xA5
wBuff[1] = BMS_HOST_ADDR; //fixed Host byte 0x40
wBuff[2] = outdata.command; //request ID
wBuff[3] = 0x08; //fixed length of the following
memset(wBuff+4, 0, 8); //place Zeros
wBuff[12] = 0;
for(size_t i = 0; i <= 11; i++) {
wBuff[12] += wBuff[i];
//Serial.println(mbuf[i], HEX);
}
BMSSerial->write(wBuff, sizeof(wBuff));
BMSSerial->flush();

so when i grab the outgoing data with a second serial usb interface it get the data again like
a5
40
90
08
.......
so i dont unterstand why, the right way is the data in one packet

@ForrestFire0
Copy link
Owner

ForrestFire0 commented Nov 11, 2021 via email

@softwarecrash
Copy link
Author

What do you mean it sends every bit (I assume byte?) alone? Are you monitoring the communications somehow? I don't know what the issue is. Does it work with your BMS?

On Thu, Nov 11, 2021 at 8:32 AM Rocky @.***> wrote: so i have tested and tried arround, but i cant get the send funktion to write an array of hex data in one line, it sends every bit at allone, that makes me grazy, its eventualy a problem with softwareserial? — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#4 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJQ54WVRM6Z3CV4JYAXUUQDULPAXLANCNFSM5HS4KDTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

thats is actual send from the arduino to the bms, the bms dont understand that
recive from arduino

that is was send from the pc software to the bms
data from pc software

its the same data, but the arduino send every byte in a new line

@ForrestFire0
Copy link
Owner

I don't have experience with the software you are using.

Have you wired up the BMS and tested it with your Arduino? What does your circuit look like right now? How does your computer see what is being sent between the Arduino and the BMS?

Technically there is no concept of "packets" on the actual serial lines. The byte is sent, and then the wires just hold a constant voltage until the next byte is sent. However, USB does have a concept of "packets". I assume when your serial port reader (whatever thing that is) reads the serial port, it has to decide how to send the binary data using the packet system the USB has.

My guess is that shouldn't matter to the BMS. Does the BMS respond when you send the code you sent in the first picture?

Also: what hardware and software are you using to monitor the serial data? That might help me figure out how and why you are getting these packets.

@ForrestFire0 ForrestFire0 reopened this Nov 11, 2021
@softwarecrash
Copy link
Author

softwarecrash commented Nov 11, 2021

I don't have experience with the software you are using.

Have you wired up the BMS and tested it with your Arduino? What does your circuit look like right now? How does your computer see what is being sent between the Arduino and the BMS?

Technically there is no concept of "packets" on the actual serial lines. The byte is sent, and then the wires just hold a constant voltage until the next byte is sent. However, USB does have a concept of "packets". I assume when your serial port reader (whatever thing that is) reads the serial port, it has to decide how to send the binary data using the packet system the USB has.

My guess is that shouldn't matter to the BMS. Does the BMS respond when you send the code you sent in the first picture?

Also: what hardware and software are you using to monitor the serial data? That might help me figure out how and why you are getting these packets.

my foul, i have found the issue, now i get for the 0x90 command a5 01 90 08 01 01 00 00 75 30 01 46 2c back
a5 is start bit, 01 the bms id (when stacked) 90 the answer for the requested data 08 how many data bits, and 2c checksum

@ForrestFire0
Copy link
Owner

Yay! I am so glad it is working out and that you are able to interpret what the different parts of the returned data does.

Now you just need to look more at the datasheet and convert those 8 data bytes into properties like voltage and SOC.

@softwarecrash
Copy link
Author

softwarecrash commented Nov 13, 2021

hello,
i have another code found, thats more reliable as base for work, so dont must do all the work, only the half to get it as libray.
actual i rewrite it, but one thing i dont understand, why i can implement a function to send commands to the bms to switch fet. eventualy you can help me by this?
and a little other thing is command 95 wich send more then 8 byte.
have u discord or something?
you can take look here, https://github.com/softwarecrash/daly-bms-uart

@ForrestFire0
Copy link
Owner

ForrestFire0 commented Nov 16, 2021

Hello, I do have discord. It is Forrest # 0803. Sorry for the delay in my response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants