Hi, I would like to ask about LIN Bus ı want to led blink with using LIN Bus between to PIC18F25K80 in MPLAB can you help me about this situtaion.
@ahmedeldeep
9 ай бұрын
You can take a look at my example, it should be easily ported to any other microcontroller.
@humanrightsshow
5 жыл бұрын
Did you use this LIN serial analyzer? APGDT001 : uk.farnell.com/microchip/apgdt001/lin-serial-analyzer-dev-tool/dp/1676245 Thanks!
@pusatberk4193
5 жыл бұрын
Allah razı olsun (:
@Galal0110
6 жыл бұрын
Hi again. I have a small question. I know that this example is just for demo purpose and not production level code, but I wanted to ask instead of hard coding the PID of the frame the slave is interested in, is there a better way to make a slave subscribe to a set of PID's and how to check if the received PID is in this list? Thanks.
@ahmedeldeep
6 жыл бұрын
Hi, You can make the slave subscribe to a set of PID's by for a basic example adding them to switch-case logic, then decide which call back function to call. You can also make a pointer array for all callback functions, then you can have an offset from the PID to your index of the array for example you recieve PIDs from 0x30 to 0x35 PID 0x30 - idx 0 PID 0x31 - idx 1 and so on, with this the index_callback = PID - 0x30 First check if PID inside the range reange if inside then call the callback function like this array[index_callback]; otherwise when outside do nothing.
@ahmedeldeep
6 жыл бұрын
For production also i suggest having FIFO buffer for incoming and outgoing messages to be decoupled from processing stage.
@Galal0110
6 жыл бұрын
so you mean that every slave has its own array of callbacks (which could be different sizes depending on the number of PIDs each slave is interested in?)
@ahmedeldeep
6 жыл бұрын
A Throbbing Peanuts yes of course, each slave means a totally different node device hardware with its own software. Master node can communicate for example with temperature sensor and with motor controller. It can be that each slave can respond to only some set of frame, so we can define range for each one and in the software of each slave we define the callbacks
@Galal0110
6 жыл бұрын
good idea. I will try to implement this. I already implemented something similar to your example code here with hardcoded frames and PIDs..etc. It would be nice also to separate the core driver itself from the configuration, since it can change between different applications of course.
@Galal0110
6 жыл бұрын
If you don't mind, I had another question concerning the sync byte. I don't really understand the point of it and feel as though it is just another data byte. I understand this is part of the protocol but is there another reason behind it? I mean if all nodes are configured to have the same baudrate, then it is just another data byte. I think the trick is that it helps a node define the bus baudrate if it doesn't know this prior. But I think it's an extremely complicated algorithm to adjust the baudrate depending on the 0x55 byte, dont you think?
@ahmedeldeep
6 жыл бұрын
A Throbbing Peanuts sync byte as you said can be used for automatic baud rate detection, its not very hard. If you want to implement automatic baud rate detection you will need to have an extra predefined byte at the beginning to calculate the bit timing the you can easily figure out the baud rate and reconfigure the uart then continue receiving bytes normally
@AhmedSalem-uz9yx
5 жыл бұрын
thanks for the video. what is your LIN lin transceiver? and another question please. how could you send to the master if the µC just support 11 bit break field?
@ahmedeldeep
5 жыл бұрын
This is the link to the LIN-Bus breakout board I used, it has Microchip MCP2004A transceiver skpang.co.uk/catalog/linbus-breakout-board-p-1417.html the break field is sent only by master and detected by the slave
@humanrightsshow
5 жыл бұрын
@@ahmedeldeep Thank you very much for your support. The lin breakout board in the link is sold out and not available. Is there any other board you suggest instead? It is also helpful if you can attach the connections between all used components in the example? Thank you again. Baraka Allah feek
@ahmedeldeep
5 жыл бұрын
Amer Al-Nather Sorry, I don’t know any other board to suggest. You can a least get the transceiver or search for other breakout board. The connection will be to the uart pins you are using, also written in the example
@Galal0110
6 жыл бұрын
ممتاز!! ممكن لينك لل لوجيك اناليزر اللي بتستعمله و هل ترشحه ولا لأ؟
@ahmedeldeep
6 жыл бұрын
this is the link www.az-delivery.de/products/saleae-logic-analyzer?variant=27889816521its very useful also cheap
@Galal0110
6 жыл бұрын
Ahmed Eldeep thanks a lot.
@Galal0110
6 жыл бұрын
Also there is something I dont understand. The master task only sends the pid. What if the master wants to send data to the slave? shouldnt it also send data after the pid? Another question... is there any kind of acknowledgment sent by the slave if it receives a frame from the master? Thanks!
@ahmedeldeep
6 жыл бұрын
Master node has a master task and slave task, the master task transmit only the header (berak, sync and PID). The slave task (inside the master node) transmit or receiev data based on the PID. for example if the master wants to send data, first the master task sends the header, the slave task inside the master node receives the header and understand what is required, then transmits the data and the checksum at the end. For the acknowledgment from the slave its user defined, you can implement another frame for the slave response as its used in diagnostics frames, the master sends the request frame with data and sends also response frame with data to be updated by the slave.
@Galal0110
6 жыл бұрын
Aaah I get it now. So does that mean that a slave NODE will also have a master task and slave task? such that when the slave node needs to send a frame back to master, master task of slave node sends the pid and then the slave task of slave node sends the data to master node? OR.... does the slave node only reply to master node only through in-frame response initiated by the master node?
@Galal0110
6 жыл бұрын
I'm sorry I checked the previous video and it says that a slave node only has a slave task. So is my second suggestion still valid?
@ahmedeldeep
6 жыл бұрын
LIN bus has only one master node (master task and slave task) and many slaves (has only slave task), the slave node can not transmit data without a header comming from the master node, so as you said its only replying to the master node through in-frame response.
@ahmedeldeep
6 жыл бұрын
You can check my previous video, I was talking about this in details kzitem.info/news/bejne/k2ycqm2gfmmeZJg
Пікірлер: 29