JP1 Remotes Forum Index JP1 Remotes


FAQFAQ SearchSearch 7 days of topics7 Days MemberlistMemberlist UsergroupsUsergroups RegisterRegister
ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in

Correct way of generating a modulated IR pulse

 
Post new topic   Reply to topic    JP1 Remotes Forum Index -> JP1 - General Forum
View previous topic :: View next topic  
Author Message
Barf
Expert


Joined: 24 Oct 2008
Posts: 1402
Location: Munich, Germany

                    
PostPosted: Tue Apr 18, 2017 3:05 am    Post subject: Correct way of generating a modulated IR pulse Reply with quote

There is a discussion here on the correct way of generating an ON-pulse (called "flash" or "mark" in different communities) in software. The problem is that using the common on-off modulation, it may happen that the target time does not end with the light on, in which case the pulse will effectively be too short, and the leading silence will effectively be added to the following gap. I ("bengtmartensson") originally suggested the following algorithm (somewhat edited)

(micros() is a function generating the time since system start, in micro seconds, periodTime is the desired period time of the carrier, and periodOnTime the desired onTime (thus duty cycle = perioOnTime/periodTime))

Code:

    unsigned long start = micros();
    unsigned long stop = start + time;
    unsigned int count = 0U;
    while (micros() < stop) {
            count++;
            unsigned long now = micros();
            int onTime = min(periodOnTime, (int) (stop - now));
            if (onTime > 0) {
                    TURN_ON;
                    delayMicroseconds((unsigned) onTime);
            }
            TURN_OFF;
            unsigned long targetTime = min(start + count * periodTime, stop);
            int timeOff = (int) (targetTime - micros());
            if (timeOff > 0)
                    delayMicroseconds((unsigned) timeOff);
    }


So, what do the experts here say? What is the correct ("correctest"?) way to generate an flash (or mark) when the times do no match up? What are the UEI executors doing?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
3FG
Expert


Joined: 19 May 2009
Posts: 3365

                    
PostPosted: Tue Apr 18, 2017 11:07 am    Post subject: Reply with quote

I think the correctest way is to always generate full length on pulses for each modulation period. Regarding the UEI executors, the approach used in MAXQ and CC254x processors (the newest micros used by UEI) is similar to Pronto Hex-- typically On durations are expressed in units of the modulation period, so the question does not arise. I think S3F80 executors which are of recent vintage make an attempt to give the same behavior even though these are timer based.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic       JP1 Remotes Forum Index -> JP1 - General Forum All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

Powered by phpBB © 2001, 2005 phpBB Group
Top 7 Advantages of Playing Online Slots The Evolution of Remote Control