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
Infrared communications between 2 Pyboard
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Infrared communications between 2 Pyboard
The Pyboard can do that using one of the onboard timers.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Infrared communications between 2 Pyboard
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
https://www.ebay.com/itm/5V-IR-Infrared ... SwGYVXBLQW
Re: Infrared communications between 2 Pyboard
So, for example:pythoncoder wrote: ↑Tue Jan 23, 2018 5:16 pmThe Pyboard can do that using one of the onboard timers.
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
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Infrared communications between 2 Pyboard
I think that's right.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Infrared communications between 2 Pyboard
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
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Infrared communications between 2 Pyboard
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
Index to my micropython libraries.
Index to my micropython libraries.