Closed axeless closed 1 year ago
hi Iliyas,
both LIN transceivers should do. I assume that you just haven't switched the transceiver to "normal mode" (tja1020), respectively "operation mode" (mcp2004a). Basically you first have to fully activate the LIN transceiver. Of course this is assuming that the electrical connections are correct...?
For details please see pages 3, 4 and 14 in tja1020 datasheet, respectively pages 1, 4 and 7 in mcp2004a datasheet.
hi Iliyas,
both LIN transceivers should do. I assume that you just haven't switched the transceiver to "normal mode" (tja1020), respectively "operation mode" (mcp2004a). Basically you first have to fully activate the LIN transceiver. Of course this is assuming that the electrical connections are correct...?
For details please see pages 3, 4 and 14 in tja1020 datasheet, respectively pages 1, 4 and 7 in mcp2004a datasheet.
I connected everything according to the datasheet, there are no problems with that. I didn’t find in your examples, sending and reading the bus
Works! I didn't connect the tja1020 fault pin correctly. Now I see messages in lin. But now I have another question, how to correct the CRC?
This sends esp32
This is via Lin Hacker
As you can see, the checksums are different, but the message is the same.
And 1 more question, as you can see in the first image there is ID B4, with data. When I press a button on the device, the first byte changes. How can I read its state, and change the sendMasterRequest message.
example: ID B4 | 02 00 00 00 00 00 00 --> non press ID B4 | 02 23 00 00 00 00 00 --> where 23 button press ID 78 | 02 00 00 00 00 00 00 --> change on press button ID B4 --> ID 78 | 02 11 00 00 00 00 00
@gicking Help please
Hi Iliyas,
Ad 1) This just seems to be a LIN version mismatch. You can check here that 0x63 is the frame checksum for LIN2.x, and 0xDB is the checksum for LIN1.x. Just change “LIN_Master::LIN_V2” to “LIN_Master::LIN_V1” in your ESP32 code. Please let me know if this solves the checksum issue.
Ad 2) before I can (hopefully) answer your question, I have some of my
If the answer to both questions is yes, then it depends whether you use blocking or non-blocking calls:
Blocking: (see this example)
LIN.receiveSlaveResponseBlocking(Version, Id, NumData, Data[])
Non-Blocking: (see this example)
LIN.receiveSlaveResponse(Version, Id, NumData)
LIN.getFrame(Type, Id, NumData, Data[])
Georg
PS: sorry for the 12h response time. I wish I didn't have a day job, then I could be faster... ;-)
Hello. Пlad to hear from you.
I will check the checksum as soon as I buy a new essp 32. I connected it incorrectly and broke it :(
I am sending 2 messages. ID 78, I send with bytes, and B4 I send as a master without bytes, only ID. The bus has a button device that responds to ID B4.
Could you write a small example of how I can read the state of B4, where it changes by pressing the D1 buttons. And if D1 == 23 then change the message in ID 78.
Sorry for my English ;)
sure, just one question: which LIN version do the devices "speak"?
Lin v2
Here is a small example. It does compile, but of course I cannot check whether it works. Let me know if it does.
Thank you for helping. Doesn't work, even stopped sending data to LIN. I think maybe the problem is in LIN(Serial2, PIN_LIN_RX, PIN_LIN_TX, "ESP32");
In the previous one, where simply sending two IDs worked, it was LIN_Master_HardwareSerial_ESP32 LIN(Serial2, PIN_LIN_RX, PIN_LIN_TX, "LIN_HW");
I tried to change it, but nothing worked. There is still silence in the bus.
I checked everything and I have LINv1 Sorry for misleading you
can you please send me your project that (almost) worked?
When I started after many reboots esp32. Still, a message went into the bus. But there is an error in the console.
can you please send me your project that (almost) worked?
I used your example with LIN_HardwareSerial_ESP32_Background.ino. I only changed the message IDs
pins Rx and Tx are the same as in the example?
Yes that's right.
Now he is sending messages to the bus. But it doesn’t respond to pressing
what have you changed that it works now?
and what is the console output for button pressed and not pressed?
what have you changed that it works now?
I changed LIN_Master_HardwareSerial_ESP32 LIN(Serial2, PIN_LIN_RX, PIN_LIN_TX, "LIN_HW");
And filled it in again. After being idle for 1 minute, it started working.
The console still shows error 0x4
WTF?
WTF?
If you don’t know, then neither do I))
0x04 = timeout
to me that smells like the Tx path is ok, but receiving doesn't work
for a master request frame 0x04=timeout can only happen if the LIN echo is not received. But you already confirmed that sending works
which transceiver are you using?
I used this diagram
with ESP32 you should increase R1 to 50k. It is less robust that ATTiny. I assume VD3 is a 3.3V Zener diode?
I installed the resistor and now the RX is working. But now there are no messages in LIN
with button pressed? Why is response D[1]=0x03?
D[1]=0x03 - not pressed. D[1]=0x23 - pressed
How do you supply the ESP32? Like in the above picture?
do you have Teamviewer?
yes
can you launch it and give me your ID?
just a sec. Seems like Teamviewer suddenly requires an account
trzkzmv3 new password
I can see your screen :-) Can we phone via Teamviewer?
as requested here's a small project to switch through states 0..3 via a button. To add debouncing I adapted the example found here
You just have to set the master request value D[1] according to countPress sketch_sep26a.zip
Thank you very much for your help.
@gicking Hello again. I figured out why the analyzer did not see the message. The period was too fast.
After adding: unsigned long timeLast = millis(); timeLast = millis();
Everything has returned to normal.
I have other difficulties now. I'm not good at programming, but even chatGPT couldn't help me.
Since I read button presses on a car device, your example does not suit me. If you can help me: I would really appreciate it.
I have the following: When you press the button, 0x23 comes. When you release 0x03. When you press it once, you need to constantly send a message with ID78 and the first byte 33. If you press the button again, then send it with byte 22, and again 11. The fourth time send 00. In this case, the message must be sent constantly. I tried this:
switch(messageCount) { case 0: memset(dataTx, 0x00, 8); dataTx[0] = 0x02; dataTx[1] = 0x33; error = LIN.sendMasterRequestBlocking(LIN_Master::LIN_V1, 0x78, 8, dataTx); Serial.println("1 press"); break; case 1: memset(dataTx, 0x00, 8); dataTx[0] = 0x02; dataTx[1] = 0x22; error = LIN.sendMasterRequestBlocking(LIN_Master::LIN_V1, 0x78, 8, dataTx); Serial.println("2 press"); break; case 2: memset(dataTx, 0x00, 8); dataTx[0] = 0x02; dataTx[1] = 0x11; error = LIN.sendMasterRequestBlocking(LIN_Master::LIN_V1, 0x78, 8, dataTx); Serial.println("3 press"); break; default: Serial.println("END"); break; }
But it didn't work out for me. I don't understand how to send a message all the time. help me please
ad 1) yes, you are correct, I forgot timeLast = millis();
. Darn!
ad 2) can you please try LIN_Example_ESP32.zip and let me know if it works
It works!! Thank you.
you're welcome. Happy Coding!
issue solved
Greetings. Please tell me which transceiver to use? I have a mcp2004a and tja1020. But I can’t figure out how to send a message to the bus. I would be grateful if you write to send and read messages from the bus.