На сервере РадиоКот появилась новая версия протокола j1850 pwm

На сервере РадиоКот появилась новая версия протокола j1850 pwm

VPW (Variable Pulse Width) is a variable pulse width modulation vehicle bus communication method, commonly used in American Ford, General Motors, Chrysler and other vehicles, the main purpose is for vehicle information Center, instrument display, fault detection and diagnosis, etc.

1. Ordinary programmer: Huh? This is not very simple. One IO is pulled high or low, and the middle delay (x us) can be sent. One IO is set as an external interrupt pin. When there is a level change, the interrupt is entered, and then a TIM is turned on. Flip and then interrupt, read the time, OK and finish work!

2. Literary and artistic programmers: Huh? The upstairs is weak, basically at the level of elementary school students. The delay loop is so low, how can it be done? How can I open a TIM for timing to be accurate.······

3. The second program apes: You all get out of the way, this forced me to set it up today! ··· ···

That’s right, I’m the second program ape. I took over the company’s literary and artistic youth code from a colleague who left the company. It’s inefficient and error-prone. I really can’t stand it anymore. I’ll do it today. Don’t take the usual path, take a good look at the implementation of this VPW driver.

First look at the circuit diagram, vpwin is the input pin, j1850+ is the output pin, BUS P and N are actual buses, and j1850- and pwmin are not needed.

На сервере РадиоКот появилась новая версия протокола j1850 pwm

Протокол SAE (Сообщество автомобильных инженеров от англ. Society of Automotive Engineers) J1850 PWM. Существует два вида протокола J1850. Первый из них является высокоскоростным и обеспечивает производительность в 41,6 Кбайт/с. Данный протокол носит название PWM (Pulse Width Modulation — модуляция ширины импульса). Он используется в марках Ford, Jaguar и Mazda. Впервые такой тип связи был применен в автомобилях Ford. Протокол SAE J 1850 PWM сложнее, чем ISO 9141, и требует применения специальных коммуникационных микропроцессоров, в то время как для поддержки ISO 9141 нужны обычные последовательные коммуникационные микросхемы, которые нетрудно приобрести в магазинах. В соответствии с протоколом PWM сигналы передаются по двум проводам, подсоединенным к контактам 2 и 10 диагностического разъема.

На сервере РадиоКот появилась новая версия протокола j1850 pwm

Формат сигнала протокола J1850

SOF – Start of Frame (начало кадра, высокий импульс на 200uS) Header – заголовок длинной 1 байт CRC –  Cyclic Redundancy Check (циклический избыточный код, 1 байт) EOD – End Of Data (окончание данных, низкий импульс на 200uS)

Подробные технические данные протокола Вы можете найти здесь (на английском языке)

11 | 192 | 128 | 320

As can be seen from the above table, the difference between vpw and pwm is that its cycle will change, and the cycle of pwm is fixed. Therefore, if you want to simply use pwm to achieve output No, but since I chose not to take the usual path, then I definitely can’t use a simple method, otherwise, I just use the method of the literary youth directly, and what else to force!

Talk about the general idea: Sending part: 1. Start a timer TIM1 and configure it in PWM comparison output mode. The channel I use is CC1. 2. Turn on two DMA channels, the trigger source is TIM1_DMA_update and TIM1_DMA_CC1 3. Open 2 arrays of the same size, one is the period, the other is the pulse width, the size is 8 times the longest data you want to send, (one data is 1 bit) 4. Divide the data you want to send into groups of 2 bits in order, and convert the period and pulse width to the timer’s PWM period and pulse width value according to the above relationship diagram, and fill in Enter the table, don’t forget the start and end pulses 5. Configure 2 DMAs, send data volume and data source address, the address is two array addresses, turn on the DMA sending completion interrupt, turn on TIM1 CC1, 6. The remaining thing is to make TIM and DMA hi, wait until the program itself enters the dma transmission complete interrupt is the transmission is completed

Receiving part: 1. Start a timer TIM4, configure it to input capture mode, channel CC1 and CC2 2. Turn on two DMA channels, the trigger sources are TIM_DMA_CC1 and TIM_DMA_CC2 3. Open two arrays, same as the sending part 4. Start tim’s input capture and DMA, and wait for the vpw pin signal to arrive, DMA will put the period and pulse width of the signal into the opened array by itself 5. Compare the above relationship diagram, restore the captured pulse width and period to the original data, and get the job done!

In addition to data splitting and restoring in the above methods, all sending and receiving processes are completed by the hardware itself. As long as the timer is configured accurately, the sent waveform will be very precise and beautiful. The accuracy is also very high, and will not occupy the CPU time.

A lot of nonsense, you can say JB without code! According to the international example, let’s add some code, the last most important configuration code, the others have been played by themselves, for reference only, and no responsibility for the consequences!

The function that needs to be realized is that the PC serial port communicates with epm1270 at 115200 baud rate, and realizes two bit-encoded bus transmission and reception of VPW and PWM of the J1850 protocol.

Note: 1. Bus transmission arbitration

2. Validation shielding of bus data frames

3. Setting and enabling of IFR

4. Selection of bit coding VPW and PWM

5. Correction of one frame of data

На сервере РадиоКот появилась новая версия протокола j1850 pwm

The picture above is to design the peripheral circuit for PWM transceiver

На сервере РадиоКот появилась новая версия протокола j1850 pwm

The picture above is the peripheral circuit designed for VPW

На сервере РадиоКот появилась новая версия протокола j1850 pwm

The pin connection of CPLD is as shown above

Note: The circuit diagram generated by 5V and 12V power supply is omitted.

Код ошибки:  Диагностика Рено Сандеро своими руками: где находится диагностический разъем, программа и советы мастера
Оцените статью
Добавить комментарий