Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Is IR transmitter possible with ch582F chip in Rust? #4

Open
happytm opened this issue Jan 6, 2024 · 7 comments
Open

Comments

@happytm
Copy link

happytm commented Jan 6, 2024

As you know I am very new to Rust language. With your help I just setup Rust environment couple of days ago.

Now I have new feature request. I was searching for IR transmitter solution for CH582F in Rust but could not find any. But came across a repository which implements IR transmitter for ATTiny13A micro controller and goes into detail of it's functionality. I think he uses timer functionality of ATTiny13A to create any custom IR protocol codes. The repository is linked below:

https://github.com/wagiminator/ATtiny13-TinyRemote?tab=readme-ov-file

He also have IR receiver implemented on ATTiny13A chip in another repository:

https://github.com/wagiminator/ATtiny13-TinyDecoder

His blog linked below is treasure trove for ATTiny devices:

http://www.technoblogy.com/show?24A9

One benefit of CH582F is it's builtin BLE. This makes it possible to use smartphone instead of buttons in above project to control any device in vicinity of IR transmitter. That can make very low cost home automation system.

Is it possible to implement this in Rust?

Thank you.

@happytm happytm changed the title Feature request: Is IR transmitter possible with ch582F chip possible Rust? Feature request: Is IR transmitter possible with ch582F chip in Rust? Jan 12, 2024
@andelf
Copy link
Contributor

andelf commented Feb 3, 2024

I'll update this when Timers are implemented.
Currently, a bit-bang implementation is possible.

@happytm
Copy link
Author

happytm commented Feb 4, 2024

OK thanks. I will be waiting.

@andelf
Copy link
Contributor

andelf commented Feb 4, 2024

Thanks. Could you provide a similar example in C/CPP?
For the IR transmitter, I think the following API should be sufficient for sending a well-formed protocol:

  • PwmOut::send(data: &[u16]) for sending a series of pulses(duty) using current frequency
  • PwmIn::read(data: &mut [u16]) for receiving. with edge trigger support.

@happytm
Copy link
Author

happytm commented Feb 7, 2024

I have no similar example in C/CPP but there is a project in assembly linked below:

https://www.sbprojects.net/projects/ir-repeater/index.php

At the end of that page there is download link to download code and circuit schematic for PIC micro controller.

Thanks.

Thanks.

@imi415
Copy link

imi415 commented Feb 8, 2024

Hi @happytm,

At the end of that page there is download link to download code and circuit schematic for PIC micro controller.

This project you shared is using an NE555 to generate the 38kHz carrier frequency and doing a ASK modulation using a MOSFET. On MCUs with PWM output capabilities, the circuit can be further simplified and the time base circuit can be removed.

To control your IR diode using a PWM capable pin, set the PWM parameter to 20% duty with 38kHz frequency, then modulate the carrier signal output by configuring GPIO AF to GPIO/TIMER according to the baseband signal.

You have already shared the specifications of the IR remote protocol:

His blog linked below is treasure trove for ATTiny devices:

http://www.technoblogy.com/show?24A9

So what you have to do next is implementing the protocol by looking at the "Protocols" chapter of the above blog post.

Regards,
Yilin Sun

@happytm
Copy link
Author

happytm commented Feb 8, 2024

@imi415 He is not using 555 timer at all. He is saying 555 timer is bad and reliable so he used PIC microcontroller.

I am new to Rust so if you can provide sample code for encoder/decoder I will appreciate it.

Thanks.

@happytm
Copy link
Author

happytm commented Feb 8, 2024

There is IR implementation for Rust but for other microcontrollers if it is any help to port it to CH582 chip.

https://github.com/jkristell/infrared

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants