element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Energy Harvesting Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Energy Harvesting Design Challenge
  • More
  • Cancel
Energy Harvesting Design Challenge
Blog A Very Compact Guide to Energy Harvesting - Part 032
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: COMPACT
  • Date Created: 30 Apr 2013 9:10 PM Date Created
  • Views 452 views
  • Likes 1 like
  • Comments 1 comment
  • energy_harvesting
  • energy_harvesting_challenge
Related
Recommended

A Very Compact Guide to Energy Harvesting - Part 032

COMPACT
COMPACT
30 Apr 2013

It's all in the timing!

Configuring the EFM32 to produce the correct timing for the InfraRed signals is easy.

All the fiddly work has been done and hidden from the developer.

All the developer needs to do is include and call upon the Clock Management Unit (CMU) API from the EFM library.

For a 1MHz inbuilt Oscillator Frequency we use,

     CMU_HFRCOBandSet(cmuHFRCOBand_1MHz);

         

To derive the carrier frequency we can allocate and configure Timer 0 to produce a 50% duty cycle by counting the desired number of 1MHz cycles for 38-41kHz;

  • Total Timer Time
  • Active Portion Time

 

The calculation is 1,000,000/38000 is about 26 so we can use 26 for the Total Timer Period and half that 13 for the active portion time.

This is done in code using;

  CMU_ClockEnable(cmuClock_TIMER0, true);                              // Enable Timer0 Clock

  TIMER0->ROUTE = TIMER_ROUTE_LOCATION_LOC3 |  TIMER_ROUTE_CC0PEN;     // Route Timer 0 CC0 output to LOC3(which is PD1)

  TIMER0->CC[0].CTRL = TIMER_CC_CTRL_MODE_PWM;                         // Configure as PWM Generator

  TIMER0->CC[0].CCV  = 13;                                             // Active Timer Time

  TIMER0->TOP        = 26;                                             // Total Portion Time

 

We require another timer to produce desired lengths carrier frequency bursts. This is done by Timer1.

It is configured to 1 microsecond resolution by using;

  TIMER1->TOP = length_us;
  TIMER1->CMD = TIMER_CMD_START;

  while (!(TIMER1->IF & TIMER_IF_OF));                                 // Wait configured time

 

  // Stop Timer
  TIMER1->CMD = TIMER_CMD_STOP;
  TIMER1->CNT = 0;
  TIMER1->IFC = ~0;

 

All easy stuff.

 

The NEC IR protocol for TVs

This is a very simple protocol.

This protocol consists of sending a sequence of 38kHz carrier bursts in a known fashion that is understood by the remote device.

The protocol is asynchronous meaning that IR command can be sent at anytime and is not synchonised to any other signal such as a clock signal.

The TV waits for a Start of Sequence burst to commence decoding the incoming signal.

 

This is defined as a 9ms active carrier burst followed by a 4ms inactive pause.

Logical bits are defined as;

  • '0' - 562.5uS active burst followed by a 562.5uS inactive pause
  • '1' - 562.5uS active burst followed by a 1675uS inactive pause

(or thereabouts - There are some slight timing variations around.)

 

image

Since the bit transmission times are different in duration to keep the datagrams identical in duration the datagram has an equal number of logical '0' bits and logical '1' bits.

This is done by sending the desired byte value followed by its one's complement value ensuring an equal number of '1' and '0's.

 

The data bits are arranged in 8 bit bytes and are sent LSB (Least Significant Bit) first.

 

The actual datagram sent to the TV is nothing more than;

  • Start Condition
  • DeviceID
  • Command
  • A trailing '0' bit to signify the end of datagram
  • An inactive period to make the total time equal 108mS before sending another datagram.

With one exception - the repeat command which is just;

  • a 9ms burst
  • followed by a 2.2ms inactive period
  • with a trailing '0' bit
  • and inactive time to make up 108mS transmission time.

 

The DeviceID is an 8 bit value assigned to the remotely controlled device by the Manufacturer. For my TV it is 0x50.

The Command is an 8 bit value representing the requested command. The actual function assigned to the Command varies from manufacturer to manufacturer

For my TV the commands include;

     0x17 = Power

     0x15 = Volume Down

     0x12 = Volume Up

 

This was determined by observing the output waveforms on an oscilloscope.

It was also an opportunity to ensure that the output of the EFM matched the original remote.

From observation the specified timings were slightly different. The code was tuned to match it.

 

Sending the bits is easy. All that is done is the PWM output is turned on and off as desired using programmed combinations of;

    onModulation(8520); Delay(4150);   // Send Header

    onModulation(560);  Delay(450);    // Send '0'

    onModulation(560);  Delay(1527);   // Send '1'

to formulate the valid datagrams.

 

The provided parameters are in microseconds.

  • Sign in to reply
Parents
  • DAB
    DAB over 12 years ago

    Hi Monte,

     

    Good post.  I really appreciate the large type for the code.  Some of us older types do not have the vision we used to. image

     

    Thanks

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • DAB
    DAB over 12 years ago

    Hi Monte,

     

    Good post.  I really appreciate the large type for the code.  Some of us older types do not have the vision we used to. image

     

    Thanks

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube