6 Replies Latest reply on Jun 16, 2015 12:21 PM by hmoore

    Infra red communication

      Is there a way to create a 38kHz signal from WICED platform for infrared packet transmission? I would normally prefer to do this sort of programming on a separate MCU which is not running any OS/framework so that I can have control over timings. Is there any specific way time-accurate functions can be implemented in such environments?


      The idea is that there are two states for the output:

      ON = toggled at 38kHz (freq changeable by the program)

      OFF = Not toggled.


      The communication will take place based on the lengths of ON and OFF. The timings need to be accurate to nearest microsecond.

       

      The problem is that WICED has a thread-based OS, which may not be able to deliver exact timings. I thought of two ways this can be approached.

       

      1) Using native MCU timers to achieve the above mentioned requirements (devboard based on STM32F2xx MCU)

       

      2) Using SPI to transmit required data as a stream.

       

      The problem with SPI is that I cannot define clock rate below 234kHz due to some prescalar limitation. And even if I use >235kHz clock speed, there is no guarantee that clock will always be at this speed (thus affecting the timings)

       

      As for using Timer functionality of the MCU, I am not sure how to approach it. There is a STM32F2xx peripheral library which provides functions for output compare using TIM1 and TIM8. My approach in this case will be to use these Timers with DMA to output required waveform with accurate timings. Now the question is, are these timers being used by some other functions? Will defining them cause any problem on the system, and how to use them under WICED environment?

       

      Also, has anyone been able to successfully use the Timers or implemented IR control on WICED platform? It would be quite helpful you can share your experience.

       

      Message was edited by: Omair Suria

        • 1. Re: Infra red communication
          GregG_16

          Sorry for the delay.  This is a little bit outside the scope of this forum, since we don't have the tools we need to test this and time to implement.

          If you run into SDK issues when you try to implement this, maybe we can help you along at that time?

          • 2. Re: Infra red communication

            I was able to use SPI and DMA to perform IR transmission.

             

            Just used SPI to transmit highs or lows for a required length of times and used external oscillator to modulate the IR signal at required frequency (38kHz).

             

            I will upload my strategy at a later stage, once I get time to finalize it. But, I was looking for something more elegant, like using timers and DMA to achieve the same.

             

            --

            Omair

            • 3. Re: Infra red communication

              Hi,

              Were you able to use the native timer?

              • 4. Re: Infra red communication

                Sorry for the late reply.

                 

                No, I was not able to use the native timers. It would be great if someone could help with that, as that would greatly help in controlling the infrared transmission.

                 

                As for infra-red communication, the way it works is there are periods of highs and lows modulated with a certain frequency (38kHz) in my case.

                 

                Reading IR Comm: I'm using an infra-red receiver of 38kHz which is gives high or low based on whether it is receiving the modulated signal or there is silence. This signal is inputted to the SPI on MCU and clocks are counted for highs and lows (i.e. duration of highs and lows).

                 

                Transmitting IR: Similarly, transmission is carried out using SPI as well. Using the same clock speed, the SPI buffer is filled with 0's and 1's and transmitted through DMA. Before going to the transmitter it is modulated at 38KHz.

                 

                Hence, a timer would significantly reduce the memory usage when transmitting and receiving. When receiving, all I need to know is the duration of highs and lows. And same for transmitting, all I need to provide is the duration of highs and lows.

                 

                Additionally, it would be great if I could clock the received signal at higher frequency than modulation (at least twice) to detect the frequency of the received signal. And similarly be able to modulate the signal internally, rather than requiring additional circuitry outside of the MCU.

                 

                If anyone has better ideas, it would be appreciated?

                 

                Thanks

                Omair

                • 5. Re: Infra red communication

                  I'm using the SN8200 platform based on the STM32F103 MCU. I  managed to use the native timer with the normal procedure:

                   

                  - Enable the clock and configure the timer

                  - Configure the priority and sub-priority (NVIC configuration)

                  - Enable the timer and the interrupt

                  - Clear the interrupt bit in the handler

                   

                  It's very important that you use the correct name for the handler (located in the interrupt vector table in the startup code).

                  • 6. Re: Infra red communication

                    Discussion is being locked. If you have any follow-up, please start a new discussion.