Page 1 of 1

how to use digital out (Dout)

Posted: Wed 14. Apr 2021, 03:28
by rixccaptv
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...

Re: how to use digital out (Dout)

Posted: Wed 14. Apr 2021, 08:15
by M.Heidemann
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

Re: how to use digital out (Dout)

Posted: Wed 11. Aug 2021, 08:36
by PEAK-Support
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);

Re: how to use digital out (Dout)

Posted: Mon 13. Dec 2021, 10:42
by rixccaptv
Thank you.
My doubt is resolved and I'm able to use the Dout now. :)