Page 1 of 1

Infrared communications between 2 Pyboard

Posted: Tue Jan 23, 2018 3:56 pm
by scardig
Hello,

We are asked to develope an infrared data link between 2 Pyboard and we think of using a Microchip MCP2122 + TFDU4101 as a solution. As per MCP2122 datasheet the baud rate is determined by the frequency of a 16XCLK signal such that, for a baudrate of 9600 bps, we need to feed the MCP2122 with a PWM of 9600*16=153600 Hz.

Can the Pyboard feed the MCP2122 with such signal ? Any advice ?

Thanx

Re: Infrared communications between 2 Pyboard

Posted: Tue Jan 23, 2018 5:16 pm
by pythoncoder
The Pyboard can do that using one of the onboard timers.

Re: Infrared communications between 2 Pyboard

Posted: Tue Jan 23, 2018 9:26 pm
by OutoftheBOTS_
You know there are these little modules that you can just serial write to and the the other end can just serial read from and at juts over a $1 each pretty cheap

https://www.ebay.com/itm/5V-IR-Infrared ... SwGYVXBLQW

Re: Infrared communications between 2 Pyboard

Posted: Thu Jan 25, 2018 9:41 am
by scardig
pythoncoder wrote:
Tue Jan 23, 2018 5:16 pm
The Pyboard can do that using one of the onboard timers.
So, for example:

from pyb import Pin, Timer

p = Pin('X1')
tim = Timer(2, freq=153600)
ch = tim.channel(1, Timer.PWM, pin=p)

It results in:

>>> tim.freq()
153846.2

Am I on the right way ?

Thanx

Thanx

Re: Infrared communications between 2 Pyboard

Posted: Thu Jan 25, 2018 6:30 pm
by pythoncoder
I think that's right.

Re: Infrared communications between 2 Pyboard

Posted: Fri Jan 26, 2018 10:27 am
by scardig
pythoncoder wrote:
Thu Jan 25, 2018 6:30 pm
I think that's right.
ok. In the docs I read:

"Each channel can be configured to perform pwm, output compare, or input capture. All channels share the same underlying timer, which means that they share the same timer clock."

So may I use UART2 on (X3,X4) and, at the same time, generate a PWM at 153600Hz at X7 with timer13,CH1 ? (ie no conflicts for CH1?)

Thanx

Re: Infrared communications between 2 Pyboard

Posted: Sat Jan 27, 2018 6:36 am
by pythoncoder
Yes, the Pyboard peripherals are independent. Using pin X7 for timer 13 channel 1 will only preclude the use of SPI(1) and one of the 16 ADC channels (because they use that pin). You can use any or all the other peripherals.