how to use digital out (Dout)

Universal Programmable Converter for CAN FD and CAN
Post Reply
rixccaptv
Posts: 1
Joined: Wed 14. Apr 2021, 03:23

how to use digital out (Dout)

Post by rixccaptv » Wed 14. Apr 2021, 03:28

Hi.

I want to install a small buzzer in a vehicle build and control it via the Dout pin.
I did not find any code example of how to set this up (for example, how to set output voltage) and trigger it...

M.Heidemann
Sales & Support
Sales & Support
Posts: 673
Joined: Fri 20. Sep 2019, 13:31

Re: how to use digital out (Dout)

Post by M.Heidemann » Wed 14. Apr 2021, 08:15

Hello,

Please have a look at the example 03_TIMER_IO, this example
uses a CAN-message to set the low side switch:

Code: Select all

// catch ID 334h to control the low-side switch
			if ( RxMsg.id == 0x334  &&  RxMsg.msgtype == CAN_MSGTYPE_STANDARD)
			{
				uint32_t  dig_out;
				
				
				// default OFF
				dig_out = 0;
				
				if ( RxMsg.data8[0] & 1)
				{
					// switch load to GND e.g. relay
					dig_out |= 1;
				}
			
				HW_SetDOUT ( &dig_out);
			}
			
			// forward message to CAN2
			CAN_Write ( CAN_BUS2, &RxMsg);
		}
For more information on the digital output please
have a look at the PCAN-Router FD documentation on page 32:

https://www.peak-system.com/produktcd/P ... an_eng.pdf

Best Regards

Marvin

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1262
Joined: Fri 10. Sep 2010, 19:34

Re: how to use digital out (Dout)

Post by U.Wilhelm » Wed 11. Aug 2021, 08:36

Her some additional Information for using the IO´s on the Router FD

The Router FD have 3 IO Pins. They could be used as 1Dout and 2Din, or 3 Din.

reading
Din0 --> Value 1 Read Din0 as High
Din1 --> Value 2 Read Din1 as High
Din2 --> Value 4 Read Din2 as High

write
Dout0 --> Value 1 Set active --> activate low-side switch (pull low)
Dout0 --> Value 0 Set inactive --> de-activate low-side switch
(other values will be ignored)

how to use:

Code: Select all

uint32_t  buff, din0, din1, din2;

HW_GetDIN ( &buff);
din0 = ( buff >> 0) & 1;  // bit 0
din1 = ( buff >> 1) & 1;  // bit 1
din2 = ( buff >> 2) & 1;  // bit 2

For HW_SetDOUT() only bit 0 is used.

uint32_t  buff;

// activate low-side switch (pull low)
buff = 1;
HW_SetDOUT ( &buff);

// de-activate low-side switch (high-Z)
buff = 0;
HW_SetDOUT ( &buff);
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Post Reply