2

I am trying to use the RPi as a LIN Master to communicate with a number of slave nodes on the LIN bus. I can send the correct bytes, starting with the sync byte of 0x55, and then the node ID, the message data and the checksum. In order for the nodes to listen, I need to send zeros for at least 13 bittimes prior to the sync byte. In pyserial, the port is set to eightbits, so, of course, I can only send 8 zeros when I need at least 13. Any ideas for solving this?

  • 1
    can you not send two lots of 8 bits? – rob Feb 6 '14 at 15:43
  • 1
    Unfortunately, no. I tried that first, but I get a stop bit between the two bytes. The pyserial port set up allows me to set the stop bits, but the choices are only 1, 1.5 and 2 bits, so there is no way to send zero stop bits between every byte. Also, the byte width choices only go up to 8. – user3276635 Feb 6 '14 at 20:44
  • Let me know if this works! I gave up trying to get this working. When I looked at the scope plots for the byte streams, it seeme dthe variations in timing was also a problem. – user3276635 Jul 22 '14 at 20:16
  • are you able to turn the TX line into a TTL output and zero two zero for a time and then configure back as serial? Late to the game, just joined ;) Also not sure about the PI yet, but some UART controllers all you to send a BREAK which is I think what you're asking for. – kenny May 27 '17 at 12:04
  • Not an answer, but a similar question and answer here: stackoverflow.com/questions/14714995/send-uart-break – kenny May 27 '17 at 12:17
2

hey I want to try the same thing. I red the aplication note "avr322: LIN v1.3 Protocol Implementation on Atmel AVR Microcontrollers". There is defined that the Sync Delemiter can be in range from 1 to 4 Tbit. So it should be possible to set the baud rate to 9/13 of the original and send 0x00. That should result in a 13bit low and a 1.444 bit long stop bit (given that you used 1 stop bit in config). Then set the baudrate back to the original one and start sync. I havened tested this yet but i think thats the way to go.

1

I have used Lin togheter with Arduino. There the solution is to use a software serial port on one of the digital I/O's. In order to get the start sequence of 13 low bits, the serial connection is stopped, and the pin is put low for a defined amount of time, after which the serial connection is started again. Maybe the pyserial van be used in the same way.

0

if you don't have extended UART to put this break, try to switch baud rate. Send break on half the baud rate, then switch back to normal baud rate. I'm using this princip on ATMEL ATmega chips. It worx.

  • This is what BobNob explains in their answer, with much better spelling, reference to AN source and specific numbers. – Dmitry Grigoryev Apr 12 '18 at 13:33
0

You could implement a logical AND between the TX pin and a regular GPIO, then use the GPIO to generate the LIN break:

schematic

simulate this circuit – Schematic created using CircuitLab

A basic AND game can be made with a resistor and two diodes.

Sending a LIN frame would look like this:

# setup
serial = Serial("/dev/serial", 19200);
GPIO.setup(BRK_PIN, GPIO.OUT)
GPIO.output(BRK_PIN, GPIO.HIGH)

# sending
GPIO.output(BRK_PIN, GPIO.LOW)
time.sleep(0.001)
GPIO.output(BRK_PIN, GPIO.HIGH)
serial.write(LIN_FRAME)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.