Protocol j1587

For general Flowcode discussion that does not belong in the other sections.
bios33
Posts: 42
http://meble-kuchenne.info.pl
Joined: Thu Jun 23, 2022 11:43 am
Has thanked: 12 times

Re: Protocol j1587

Post by bios33 »

This is brilliant :)
I'll be home tonight and try it with a controller.

mnfisher
Valued Contributor
Posts: 972
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 515 times

Re: Protocol j1587

Post by mnfisher »

Let us know how it goes... Remote debugging is notoriously tricky :cry:

I think the one piece of error checking it needs is to check the length of the message - if it's greater than 21 bytes then reset and start looking for MID again.

As it stands - is the end isn't found then it will trample over memory and crash (using the position mod 10 would solve this)

Martin

bios33
Posts: 42
Joined: Thu Jun 23, 2022 11:43 am
Has thanked: 12 times

Re: Protocol j1587

Post by bios33 »

Hi!
Regarding the row of two byte PIDs, for example: engine speed - PID 190, data 087 009 - PID_data[0] /; 087;/ + (PID_data[1] /;009;/<<8) I get a 16-bit value and multiply it by 0.25 (res/bit)

bios33
Posts: 42
Joined: Thu Jun 23, 2022 11:43 am
Has thanked: 12 times

Re: Protocol j1587

Post by bios33 »

In this only option, it displays on the screen and after a few seconds the values ​​​​hang on the screen, but at the same time the diode (port B7) on the board blinks synchronously with the diode on the rs485 transceiver

bios33
Posts: 42
Joined: Thu Jun 23, 2022 11:43 am
Has thanked: 12 times

Re: Protocol j1587

Post by bios33 »

bios33 wrote:
Wed Mar 20, 2024 9:47 pm
In this only option, it displays on the screen and after a few seconds the values ​​​​hang on the screen, but at the same time the diode (port B7) on the board blinks synchronously with the diode on the rs485 transceiver
Attachments
viber_image_2024-03-20_23-52-36-675.jpg
viber_image_2024-03-20_23-52-36-675.jpg (128.02 KiB) Viewed 471 times

bios33
Posts: 42
Joined: Thu Jun 23, 2022 11:43 am
Has thanked: 12 times

Re: Protocol j1587

Post by bios33 »

bios33 wrote:
Wed Mar 20, 2024 9:55 pm
bios33 wrote:
Wed Mar 20, 2024 9:47 pm
In this only option, it displays on the screen and after a few seconds the values ​​​​hang on the screen, but at the same time the diode (port B7) on the board blinks synchronously with the diode on the rs485 transceiver
Attachments
V1.8.1.fcfx
(27.83 KiB) Downloaded 12 times

mnfisher
Valued Contributor
Posts: 972
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 515 times

Re: Protocol j1587

Post by mnfisher »

Regarding the row of two byte PIDs, for example: engine speed - PID 190, data 087 009 - PID_data[0] /; 087;/ + (PID_data[1] /;009;/<<8) I get a 16-bit value and multiply it by 0.25 (res/bit)
So - the PID - get from PID[0] - if this is >= 128 then the 16 bit value is PID_Data[0] (NOT PID_Data[0] + PID_Data[1]) As mentioned - the value might have the MSB and LSB swapped. If PID[n] <= 127 then PID_Data[n] = 8 bit value (padded to 16 bits with 0 in MSB)

The PID PID[1] has it's value in PID_Data[1]

There should be PID[n] and PID_Data[n] where n = 0..ISR_POS

However - it does sound like it is then crashing - see notes above about error checking - I'll add a couple of checks - max message size is trickier - but where "ISR_Pos = ISR_Pos+1" -> change to ISR_Pos = (ISR_Pos + 1) % 10 (Two places in the ISR) It might just be the reset needs a tweak too?

Can you step through in simulation using some of the data from above.

mnfisher
Valued Contributor
Posts: 972
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 515 times

Re: Protocol j1587

Post by mnfisher »

The reset needs the checksum resetting too. So will only receive one message as is...

V2. 0 this evening 🙄

bios33
Posts: 42
Joined: Thu Jun 23, 2022 11:43 am
Has thanked: 12 times

Re: Protocol j1587

Post by bios33 »

Hi all !
I understand that if the checksum = 0, this means the end of the line formation

mnfisher
Valued Contributor
Posts: 972
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 515 times

Re: Protocol j1587

Post by mnfisher »

Yes, and no.

It actually stores a 16bit sum - the twos complement of this (% 256) needs to be 0.

Martin

Post Reply