Driving an LED with a CAN transceiver??   - Page 1
Forum section: electronics / projects

author: max_torque
author_rank: Super Contributor
timestamp: May 25, 2017, 01:13:40 pm
content: OK, this isn't (quite) as stupid as it sounds (promise)I have a remote device that is controlled by a hardwired PWM (~1KHz, 5 ->95% duty) input to an optocoupler in that device. That device is about to move to CAN bus based control, but i would like to protect for being able to control the old level devices as well as the new CAN ones without changing ECU hardware that much. I am also looking for very low (MIL) RFI emissions, so a differential output is a good idea.So, i think, i could use a CAN transceiver to drive that remote optocoupler, as they are usually rated to drive 5v into around 50 ohms minimum, that way, a simple jumper on the pcb could configure the output to suit either type of device, and being differential, the usual CAN common mode chokes etc will help for reducing EMI (in conjunction with twisted pair wires in the loom etc)As this is pretty outside the usual usage for such transceivers i will of course have to test it out properly, but can anyone think why it shouldn't work at a first glance??(not sure of the exact current with which the opto is being driven at the moment, but i'd guess it's pretty low current (<5mA i suspect) as its output is just driving an IC pin in the device)

author: Bendba
author_rank: Regular Contributor
timestamp: May 25, 2017, 01:52:16 pm
content: Hi,Will CAN controlled devices be connected to the bus at the same time as will PWM devices?If so, how is the PWM controlled device going to discriminate a CAN transmission from a PWM input?

author: max_torque
author_rank: Super Contributor
timestamp: May 25, 2017, 05:57:22 pm
content: No, it will be a strict OR situation. Current slaves just take a PWM signal, and obviously don't report any info back to the master. The new slave is going CAN so bi-directional info can now flow. The main thing is that drive both options with the smallest possible hardware change, so i could wire the PWM output pin to the CAN TX wire, and just tri-state the appropriate pin to chosse between CAN and PWM output. i think....... ;-)

author: Bendba
author_rank: Regular Contributor
timestamp: May 25, 2017, 09:53:32 pm
content: Hi,Would you have a diagram of how you are thinking of wiring it?Are you talking about TX wire between CPU and CAN transceiver? If so, you will need to add a CAN transceiver on the other end for the PWM device to turn the differential signal back into PWMJust to make sure I got it right, you want to do this:PWM generator\/CAN transceiver\/CAN bus\/CAN transceiver\/Optocoupler

author: max_torque
author_rank: Super Contributor
timestamp: May 26, 2017, 01:05:36 pm
content: No, mean directly drive the LED in the remote optocoupler with the differential output of the CAN transceiver!When output is Recessive (both lines at 2.5v) the optocoupler LED will be off, when Dominant, the LED is driven onI would simply PWM the TX input to the transceiver from a normal GPIO pin, instead of driving it with the CAN TX line from the controller.

author: mikerj
author_rank: Super Contributor
timestamp: May 26, 2017, 01:55:56 pm
content: Sounds reasonable to me. The only snag I can think of right now is that some transceivers have a built in timeout to ensure a dominant state can not be continuously asserted. Either use a transceiver without this protection or ensure the timeout is somewhat larger than your 1ms PWM period.

author: max_torque
author_rank: Super Contributor
timestamp: May 26, 2017, 02:12:28 pm
content: Typical transceiver like MCP2551 has a 1.25ms maximum dominant state time out, which looks like it fits with my 1KHz current PWM frequency (although i can easily bump that up if necessary)http://ww1.microchip.com/downloads/en/DeviceDoc/21667f.pdf