Page 2 of 2

Re: C-code

Posted: Wed Nov 20, 2019 11:31 pm
by mnf
Hi,

Glad to hear it's receiving ok!
Can you post your code that's giving the errors? I used m ((msg) as an array to receive the data and x (& y) as data to be extracted.

Both were declared as local variables ( hence the '.' at the start) - it's good practice to keep a minimum number of globals to aid readability.

You can output all the data in the message using a loop: - for example to output it to UART. Note that m, i and error are defined as local (m[12] byte, byte and byte) and I don't check error (if .error & 0x80 then something has gone awry)
output.JPG
output.JPG (26.85 KiB) Viewed 3181 times
Martin

Re: C-code

Posted: Fri Nov 22, 2019 8:57 pm
by Dutch
Martin, i did send you an message. can you check if you received it.

Re: C-code

Posted: Wed Nov 27, 2019 12:23 pm
by mnf
For completeness:

Combined j1850 - here demo'd as if pin d4 is pulled high acts as receiver else as transmitter....
Not sure if it's worth pulling the code off as a component??
j1850.fcfx
(43.09 KiB) Downloaded 77 times
Note this code is very AVR specific (should work on any Arduino/AVR chip with Timer1) - the timing code is however very localised (start, stop timer and retrieve number of ticks) so it might be possible for some PIC/ARM whizz to convert??


Then I found this-
http://www.interfacebus.com/Automotive_ ... 0_Bus.html which gives a good description of the bus - and I've used an inverse of this from the c above.. Note that the bus may be at 20v so the signal needs to be shifted and inverted to work with the arduino. It would be fairly straightforward to invert the signal - I also don't think the send compiled with the message standard - for example there is no crc - although the code is there..

Martin