Protocol j1587

For general Flowcode discussion that does not belong in the other sections.
Post Reply
chipfryer27
Valued Contributor
Posts: 1147
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: Protocol j1587

Post by chipfryer27 »

Hi

And you have spelling issues too :lol:

Good you are getting values.

To convert two 8-bit values to a 16-bit value is quite easy.

Create a new unsigned integer e.g. Speed. This can have a value of 0 - 65,535

You have two bytes of data, lets call them B1 and B2. Say they are (in binary coz it's easier to understand the process) 0b11010101 and 0b00000001

Speed = 0 // this is in binary 0b0000000000000000
Speed = B1<<8 // Speed = the value of B1 shifted 8 places to the left. Speed now equals 0b1101010100000000
Speed = Speed + B2 // Add the value of B2 giving Speed = 0b1101010100000001

You can of course combine the above into a more simplistic calculation but the above shows the process.

Regards

PS
Really nice looking display.

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

Re: Protocol j1587

Post by bios33 »

Hi all!
Finally it worked and very quickly :)!
Repeated reading of your posts helped me a lot, I am very grateful to everyone for pointing me in the right direction.
It remains to figure out how to calculate “resolution/bit” for the accuracy of the values ​​​​on the screen

Thanks again everyone!

Joni.
Attachments
Flowcode1.fcfx
(22.65 KiB) Downloaded 47 times

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

Re: Protocol j1587

Post by bios33 »

Hi all!
I returned to this project again because it is working very poorly. Everything was fine on the table, but when I connected it to the tractor, and there were other blocks on the j1587 bus, everything became very sad :).
I've been playing for the second week now and there is no result. Who can help me with this project? or advise who to contact with this question.
I'm not asking for help for free, I'm ready to pay. Maybe someone knows who to contact to create component 1587 for FC.

Best regards Joni!

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: Protocol j1587

Post by chipfryer27 »

Hi

If it is working on the "bench" then you are most of the way there, so to speak.

I'm guessing a tractor is a very noisy environment in terms of DC/signals, so perhaps look at screening and filtering? I assume you are just reading the bus, not injecting, so we can rule out collisions based on your device.

A scope could be your friend here as it can show the signals in real time.

Do things improve if you unplug certain devices from the bus?

Hope this helps.

Regards

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

Re: Protocol j1587

Post by bios33 »

With mid128 one on one and with the engine turned off, it somehow works, but when the engine starts, everything changes for the worse, the tachometer needle begins to jump, and so do the indicators. I looked at it with an oscilloscope, the bus is perfectly clean, the logic analyzer clearly sees the packets with all the blocks connected. I have 3 devices on the bus: Mid128 - motor, Mid144-central module and Mid216 - light controller

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: Protocol j1587

Post by chipfryer27 »

Hi

I would try next to isolate supplies. For example power your circuit / display etc from a source independent to the tractor to see if things improve.

You mention you can see the data clearly, does this data match up with what your display is doing? Is the data as expected, for example tacho data says 0, but display says 50 or the like?

Regards

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

Re: Protocol j1587

Post by bios33 »

Hi!
The situation is this: I connected an instrument panel from Volvo (+24, gnd and j1587) to the place of my device, and it shows all the parameters normally.
that is, the problem is only in my device. I believe that it is necessary to calculate the checksum of each frame, but when I use this function, the device starts to work very slowly.
Tomorrow I'll post the project, maybe you can tell me something

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

Re: Protocol j1587

Post by bios33 »

Hi.
Can anyone tell me how to find the required 3 bytes in a circular buffer? Only the value of the first one is known, for example: 128,123,12 - only 128 is known? LookForValue cannot find a numeric value, only looks for ASC||

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

Re: Protocol j1587

Post by mnfisher »

You can use LookForValue with a byte array or a string.

byte or string .val[1] // Looking for 1 value
.val[0] = 128

Then use LookForValue(.val, 1, ...)

Martin

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

Re: Protocol j1587

Post by bios33 »

mnfisher wrote:
Wed Mar 13, 2024 7:48 am
You can use LookForValue with a byte array or a string.

byte or string .val[1] // Looking for 1 value
.val[0] = 128

Then use LookForValue(.val, 1, ...)

Martin
LookForValue does not allow me to use an array, only a string variable. Maybe I'm doing something wrong? Can you please provide at least some example of searching for bytes in a buffer using an array?

Post Reply