Protocol j1587

For general Flowcode discussion that does not belong in the other sections.
mnfisher
Valued Contributor
Posts: 953
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Protocol j1587

Post by mnfisher »

You can set a character in a string to 128.as above. Each character is a byte. You can set values using a number as shown or a character (in single quotes) or set the whole string.

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

Re: Protocol j1587

Post by mnfisher »

Just done a quick test

I did PutArray(.test, 10)
LookForValue(.seek, 1, true, true)

Where test = {x,x,x,128,129...) where x is any value
and seek[0] = 128

LookForValue just returns 1 if the search value is found. (would the index (or -1) be better?) Then GetByte returns the 'following' data
So in this case - the GetByte returns 129

If you are using an interrupt to load the data - you could use WaitForValue as an alternative..
cb.fcfx
(9.38 KiB) Downloaded 8 times

RGV250
Posts: 264
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 23 times
Been thanked: 30 times

Re: Protocol j1587

Post by RGV250 »

Hi,
When you say it works on the bench are you using live data from the tractor or some simulator? If it is live data then are you using a bench PSU and when on the tractor using the tractor supply. Does it work OK with the engine not running and then give problems when it is running?

Regards,
Bob

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

Re: Protocol j1587

Post by bios33 »

Thank you very much "minfisher" for the example, it helped me understand searching for data in the buffer.
Now there is a new problem: the bytes are repeated on the screen, although I display them in turn from "Mid_array[0] to Mid_attay[3]. What could be the problem?
Regards Joni!
Attachments
V1.6.fcfx
(21 KiB) Downloaded 8 times
IMG_20240313_165401530_HDR.jpg
IMG_20240313_165401530_HDR.jpg (74.63 KiB) Viewed 290 times
Last edited by bios33 on Wed Mar 13, 2024 3:08 pm, edited 1 time in total.

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

Re: Protocol j1587

Post by bios33 »

RGV250 wrote:
Wed Mar 13, 2024 12:28 pm
Hi,
When you say it works on the bench are you using live data from the tractor or some simulator? If it is live data then are you using a bench PSU and when on the tractor using the tractor supply. Does it work OK with the engine not running and then give problems when it is running?

Regards,
Bob
Greetings! Everything is fine with the food, there are no problems, that’s for sure. The problem is that the device does not work correctly when other control units are on the bus. For example: in a certain line checksum =102 and at the same time there is PID 102 - turbo pressure and mixing the turbine readings skips unnecessary data, and so on with almost all indicators. Something like this

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

Re: Protocol j1587

Post by mnfisher »

I think the issue is - your code continually searches for 128 - and as soon as it is found - attempts to read 4 bytes from 'after' the 128.
These may not have been received yet...
So - one solution is wait for 128 to be found then wait until caunt_rx >= 4 and then display the values.

Martin

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

Re: Protocol j1587

Post by mnfisher »

I tried this - I've used a timer interrupt to add data if running as a simulation.
V1.7.fcfx
(23.77 KiB) Downloaded 9 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 tried V1.7 but the repetition is still there, I changed the delay but alas to no avail, everything is perfect in the simulator.
I’ll transfer it to the mega2560 in a minute and try, maybe there’s a problem with the controller.

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

Re: Protocol j1587

Post by mnfisher »

Odd, how about waiting until the value changes from 128 - it sounds as though only the start byte is being received correctly. Can you just display (or send to uart) all the data received?

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

Re: Protocol j1587

Post by bios33 »

Here are the screenshots
The controller receives the same data as the FC
Attachments
Out STM to LCD.png
Out STM to LCD.png (53.07 KiB) Viewed 299 times
J1587 in to FC.png
J1587 in to FC.png (96.52 KiB) Viewed 299 times

Post Reply