1 / 32

Adding LIN to LED Drive

Adding LIN to LED Drive. Adding LIN to LED Drive. Overview. Setting Up. Building the Application. Running the Application. Adding LIN to LED Drive– LED Drive without LIN. RC filter. PWM(P0.3). Vbat. dim LEDs here. GND. calibrate (P0.5). Vbat = 12VDC. 11/1/2019. Page 3.

jeffreyj
Download Presentation

Adding LIN to LED Drive

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adding LIN to LED Drive

  2. Adding LIN to LED Drive Overview Setting Up Building the Application Running the Application

  3. Adding LIN to LED Drive– LED Drive without LIN RC filter PWM(P0.3) Vbat dim LEDs here GND calibrate (P0.5) Vbat = 12VDC 11/1/2019 Page 3

  4. Adding LIN to LED Drive– LED Drive without LIN generate a PWM singal and transform into a DC voltage through filtering generate a PWM singal to drive the LED drivers, PWM varies depending on POT1 calibration of LED brightness using a ‘coding’ resistor as part of a potential divider use POT1 for dimming

  5. Adding LIN to LED Drive • The Problem: • an existing application needs to be controlled from a remote node in a LIN network • The Solution: • decide on whether the existing application is a LIN master or slave • generate the ‚missing‘ LIN application • add LIN LLD files to the existing non-LIN application • configure both master and slave to work in a LIN network

  6. Adding LIN to LED Drive • adding LIN communication to the existing LED Drive application we need to create two projects, a master and a slave project • slave: previous LED Drive project • master: new Dimmer Control project • Slave: we remove the POT1 control from the previous LED Drive project and add LIN communication to receive a value from another node to replace the POT1 value. POT1 on the slave application will be used for calibration • Master: we create a simple ADC project that reads POT1 and sends this to the slave via LIN

  7. Adding LIN to LED Drive Overview Setting Up Building the Application Running the Application

  8. ADC Adding LIN to LED Drive XC866 – LIN Master TLD5098EL Demo Board LEDs EN/PWMI SET XC866 – LIN Slave CCU6 ADC

  9. Adding LIN to LED Drive calibrate(P0.5) RC filter connect 12.5VDC to all the boards PWM(P0.3) LIN Slave dim LEDs here connect the boards as described here LIN 1 1 X5 connector LIN Master LIN Master LIN Slave

  10. Adding LIN to LED Drive Overview Setting Up Building the Application Running the Application

  11. Adding LIN to LED Drive • Create a new folder called LIN_LED_Slave and extract the files contained in LED Drive KEIL.zip • the following folder will appear • KEIL + LED Drive TLD5098EL XC866.ppt • The KEIL folder contains the project files: • MAIN.C, MAIN.H, ADC.C, ADC.H, CC6.C, CC6.H • LED_DRIVE.ASM, LED_DRIVE.RTF, LED_DRIVE.DPT • LED_DRIVE.RTF • START-XC.A51 • download and extraxt the LIN LLD folder to your chosen directory

  12. Adding LIN to LED Drive • Create a new folder called LIN_LED_Master -> KEIL • start a new DAvE project and select XC866LIN as the device • We only need to read the value of POT1 and send this via LIN • configure ADC: 8-bit resolution, enable arbitration slot 1, permanent arbitration • enable CH6, select Register0 as result register, no trigger, SR0 activated • Parallel: gating line is permanently 1, Low priority, wait-for-start mode, enable autoscan • Result Register: Enable interrupt, reset valid flag register by read access, Interrupt node pointer SR0 acticated • Functions: ADC_vInit, • Functions2: ADC_vStartParReqChNum • Functions3: ADC_uwGetResultData0 We now have the basic function of reading POT1

  13. Adding LIN to LED Drive • next step, set up LIN to be able to send the POT1 value: • select ‚ECU‘ • ECU Page 1: UART Enable, UART transmit pin -> P1.1, UART receive pin -> P1.0, Primary Timer -> T0 • close ‚ECU‘ window • select ‚LDF‘ • Node: click ‚Add‘ next to Slaves • Create Signal1 for Frame ID 0x00 for Master to transmit to Slave: • Signal: click ‚Add‘ below Signal List box, signal type -> Byte Array, Size(bit) -> 16, Subscribers -> Slave1 • Create Signal2 for Frame ID 0x01 for Slave to transmit to Master: • Signal: click ‚Add‘ below Signal List box, signal type -> Byte Array, Size(bit) -> 16, Publisher -> Slave1, Subscribers -> LINMaster

  14. Adding LIN to LED Drive • Assign Frame1 to ID 0x00 for Signal1: • Frame: click ‚Add‘ then click ‚>>‘ • Assign Frame2 to ID 0x00 for Signal2 which is published by Slave1: • Frame: click ‚Add‘, Published By -> Slave1, then click ‚>>‘ • Schedule: under Schedule List click ‚Add‘, under Frame List click ‚Frame1‘, under Schedule click ‚Add‘.This will add Frame1 to the first slot in the schedule table • Next add Frame2 to the second slot in the schedule table: • under Frame List click ‚Frame2‘, under Schedule click ‚Add‘ • Close ‚LDF‘ window • generate the code into the LIN_LED_Master -> KEIL folder • copy all the files from the LIN LLD ‚Source‘ Folder to the LIN_LED_Master -> KEIL folder. DO NOT REPLACE ANY EXISTING FILES

  15. Adding LIN to LED Drive • Open the Master dpt project in Keil: • Project -> Open Project and select the project .dpt file • under Target 1 right click DAvE Files -> Add Files to Group DAvE Files, slect LIN_IIL.C and LIN_LDF.C, click ‚Add‘ • open MAIN.C and add the following code:

  16. Adding LIN to LED Drive • and further down add the LIN LLD initialisation: • we now have the basic LIN communication needs for the Master node. • Later we will come back here to send data across the LIN bus but lets first continue and add LIN to the Slave node.

  17. Adding LIN to LED Drive • open the folder LIN_LED_Slave -> KEIL and open the .dav file with DAvE • next, set up LIN to be able to receive the POT1 value from the Master node: • select ‚ECU‘ • ECU Page 1: UART Enable, UART transmit pin -> P1.1, UART receive pin -> P1.0, Primary Timer -> T0 • close ‚ECU‘ window

  18. Adding LIN to LED Drive • select ‚LDF‘ • Node: click ‚Add‘ next to Slaves • Create Signal1 for Frame ID 0x00 for Master to transmit to Slave: • Signal: click ‚Add‘ below Signal List box, signal type -> Byte Array, Size(bit) -> 16, Subscribers -> Slave1 • Create Signal2 for Frame ID 0x01 for Slave to transmit to Master: • Signal: click ‚Add‘ below Signal List box, signal type -> Byte Array, Size(bit) -> 16, Publisher -> Slave1, Subscribers -> LINMaster

  19. Adding LIN to LED Drive • Assign Frame1 to ID 0x00 for Signal1: • Frame: click ‚Add‘ then click ‚>>‘ • Assign Frame2 to ID 0x00 for Signal2 which is published by Slave1: • Frame: click ‚Add‘, Published By -> Slave1, then click ‚>>‘ • Schedule: under Schedule List click ‚Add‘, under Frame List click ‚Frame1‘, under Schedule click ‚Add‘.This will add Frame1 to the first slot in the schedule table • Next add Frame2 to the second slot in the schedule table: • under Frame List click ‚Frame2‘, under Schedule click ‚Add‘ • Close ‚LDF‘ window • select ‚ECU‘ • ECU Page 1: UART Enable, UART transmit pin -> P1.1, UART receive pin -> P1.0, Interface Mode -> Slave, Secondary Timer -> T0, Interface Node name -> Slave1 • close ‚ECU‘ window

  20. Adding LIN to LED Drive • generate the code into the LIN_LED_Slave -> KEIL folder • copy all the files from the LIN LLD ‚Source‘ Folder to the LIN_LED_Slave -> KEIL folder. DO NOT REPLACE ANY EXISTING FILES • Open the Slave dpt project in Keil: • Project -> Open Project and select the project .dpt file • under Target 1 right click DAvE Files -> Add Files to Group DAvE Files, slect LIN_IIL.C and LIN_LDF.C, click ‚Add‘

  21. Adding LIN to LED Drive • open MAIN.C and add the following code:

  22. Adding LIN to LED Drive • and further down add the LIN LLD initialisation: • we now have the basic LIN communication needs for the Slave node too.

  23. Adding LIN to LED Drive • Now lets add some code so that we can see LIN work for us. • the objective is to send the POT1 value from the Master to the Slave • The Slave receives the POT1 value and uses this to adjust the LED brightness • Open the Master project in Keil • we need a data variable that we can send out on the LIN bus: • Open MAIN.C and add this line of code:

  24. Adding LIN to LED Drive • further down we add this: • in ADC.C we add this line:

  25. Adding LIN to LED Drive • and this line: • the ADC result is placed into the data array to be sent to the slave using LIN_frame_wr(0x00,2,&Tx_Data[0]) in MAIN.C • This concludes adding LIN communication code for the Master node. Lets go to the Slave node on the next slide.....

  26. Adding LIN to LED Drive • Open the Slave project in Keil • we need a data variable for receiving from the LIN bus: • Open MAIN.C and add this line of code:

  27. Adding LIN to LED Drive • further down we add this: • we use LIN_frame_rd(0x00,2,&Rx_Data[0]) to receive the POT1 value from the Master in Rx_Data[0] then we do a little filtering to get an average to avoid LED flicker due to ADC conversion errors at the Master end • The resultant LIN_Val is copied into CCU6_CC63SRL

  28. Adding LIN to LED Drive • in ADC.C we comment out this line since we dont need it anymore, POT1 value now comes from LIN • Now we can build and start running the project on the boards

  29. Adding LIN to LED Drive Overview Setting Up Building the Application with DAvE Running the Application

  30. Adding LIN to LED Drive • Connect the boards as in slide 9 • build both projects to generate a .hex file • connect the mini wiggler to the ocds connector on the Master and load the .hex file into the device using FLOAD, click Execute Flash • connect the mini wiggler to the ocds connector on the Slave and load the .hex file into the device using FLOAD, click Execute Flash • Turn POT1 on the Master node and observe how the LEDs on the Slave node change brightness. You may notice that there are distinct steps. This is due to the Frame delay. • we can change this........

  31. Adding LIN to LED Drive • change the following from this: 100mS • .....to this: 5mS

More Related