Infrared communications between 2 Pyboard

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
scardig
Posts: 13
Joined: Wed Jan 10, 2018 8:32 am

Infrared communications between 2 Pyboard

Post by scardig » Tue Jan 23, 2018 3:56 pm

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

User avatar
pythoncoder
Posts: 2889
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Infrared communications between 2 Pyboard

Post by pythoncoder » Tue Jan 23, 2018 5:16 pm

The Pyboard can do that using one of the onboard timers.
Peter Hinch

OutoftheBOTS_
Posts: 377
Joined: Mon Nov 20, 2017 10:18 am

Re: Infrared communications between 2 Pyboard

Post by OutoftheBOTS_ » Tue Jan 23, 2018 9:26 pm

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

scardig
Posts: 13
Joined: Wed Jan 10, 2018 8:32 am

Re: Infrared communications between 2 Pyboard

Post by scardig » Thu Jan 25, 2018 9:41 am

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

User avatar
pythoncoder
Posts: 2889
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Infrared communications between 2 Pyboard

Post by pythoncoder » Thu Jan 25, 2018 6:30 pm

I think that's right.
Peter Hinch

scardig
Posts: 13
Joined: Wed Jan 10, 2018 8:32 am

Re: Infrared communications between 2 Pyboard

Post by scardig » Fri Jan 26, 2018 10:27 am

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

User avatar
pythoncoder
Posts: 2889
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Infrared communications between 2 Pyboard

Post by pythoncoder » Sat Jan 27, 2018 6:36 am

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.
Peter Hinch

Post Reply