Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Creating pulse 5us width

  1. #1
    Senior Member
    Join Date
    Oct 2014
    Posts
    154

    Creating pulse 5us width

    well all, this is more likely my last project for work before I retire. (unless they want me to work from home which will be somewhere in Arizona and out of cold Utah.)
    I'm thinking of using the Teensy 3.2(3.1 I have to play with) and or using the teensy 3.5 which we have in our current products and has worked since 2015 (3.2 2015 to 2017. 3.5 current) and still going strong.

    The issue at hand is a wired remote that sends Manchester Code to the system. I'm not willing to bother much on using a library for the Manchester code, but it does have a preface to tell the system that it is a handset.
    I have scoped the output and see the common signal that is sent and to the data (button function) is a total of 185 us. The signal repeats at 75 ms intervals.

    20 possible codes are from 10011111 (no key) to 10000000 the 1st button action. Thus 20 different conditions (4 are spares)

    Since the 1st 20 are binary, I'm thinking of using case then send the code somehow (still thinking on a way of doing) XOR or shift.

    Usually when I type stuff out I start thinking I can do that, but can I..... (Brain Pause)

    So I can maybe do the preamble 1st and then trail the key code and repeat 75 ms later.

    Well actually about the retirement.. Work has put me into a semi retirement... But moving to Arizona in the very near future.. faster if they don't put me back into full time.. So I'm here Mon/Tues.

    So ideas will help.
    In the meantime I will do some timing stuff on my teensy 3.1 or 3.2.. And maybe try the 3.5 I have.. Scope in hand..

    Thanks a head of time..

    Wayne

  2. #2
    Senior Member
    Join Date
    Oct 2014
    Posts
    154
    So I tried both my Teensy 3.1 and the 3.5 and found the 3.5 can produce a accurate 5 us square wave.

    I'm will now look into using SPI. I think I might be able to create 10000110 code or like to send. I looked at it yesterday, if I can make it 5 us wide.

    wish there was something like sendcode(11100011, width, interval) or something like that.. Off to play somemore.

    Wayne

  3. #3
    Junior Member
    Join Date
    Jan 2019
    Posts
    19
    What was the shortest accurate interval on the 3.1?

  4. #4
    Senior Member
    Join Date
    Oct 2014
    Posts
    154
    Using Micros, and setting up for 5 off/5 on, I could never get to 5 us. It was like 6.9 us and would change width every so often. I set speed to 120 overclock and faster with pure code and LTO. The 3.5 handled it great.
    I'm playing with ShiftOut now but moving to SPI. Seeing if I can just output a signal thats like 20 or so bits wide. Thats what I need I think for the start and button code.

  5. #5
    Senior Member
    Join Date
    Oct 2014
    Posts
    154
    I have so far created the actual code. Still hard coded. Need to figure out how to do it with not using delayMicroseconds option. Elapsetimer I think I need to use.

    Scratch the above..
    I was looking over Delay and Timings Functions and saw noInterrupts(); mentioned. So I know I'm not using interrupts at all, and I added the statement in my loop.
    The jitters has disappeared. Timing is at 5.2 us, but I will try some options on speed and flashing.
    Last edited by Wayne; 01-17-2019 at 04:03 PM.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,489
    Maybe some of the jitter reduction ideas here can help?

    https://forum.pjrc.com/threads/27690...ll=1#post64142

  7. #7
    Senior Member
    Join Date
    Oct 2014
    Posts
    154
    Thanks Paul,

    Looking into now.. Accuracy a bit off on what I'm doing, like 5 us is 5.2 us.. I was called back into work today for something else and I can stay and play.

  8. #8
    Senior Member
    Join Date
    Oct 2014
    Posts
    154
    So I decided to try a SAMD21 type board using the same routine.. Wow what a difference.. It did not work as well, in fact it was pretty bad.. I could not get the pulse to 5 us at all. The waveform did a bit of breathing.. Kind of a wave at a game.
    I even tried all sorts of times and elapsemillis.. no avail. So if this goes through, be doing some actual testing on a table system..

  9. #9
    Senior Member
    Join Date
    Oct 2014
    Posts
    154
    Well, I just compared the original to the teensy emulated device waveforms.
    I have 17 conditions in a IF and ese if's after 1st if statement. The action call voids to complete the waveform.
    So I have a start waveform and if no action of a button, defaults to a void nokey.
    If you press a button, it will act in the if statement and go to some other void (start waveforms and then void (related to a button action)
    What I found out, as the program grew, the start waveform last bit changed in timing.. Slightly in microsecs, but it did.. Actually got longer.

    For some reason, at the beginning of the voids is the nokey one. This is called last in the if statements. I change that last pulse timing at the end of the start to a minimal time is micros (2us) HIGH
    In the nokey I had to add a new high out of 6 us. to correct the timing of the start of the 1st bit (pulse of the code).

    So the alteration is that I partially construct the HIGH pulse at the end of the Start pulse routine and fix the rest at the beginning of the other routine.

    So the nokey which is the last of the loop is at the top of the voids.

    Now the strange part. As I go down the voids, the construction of that one high pulse in timing kind of reduce in timing..
    I started off with adding a 3 us pulse at the top of the voids and near the bottom it goes down to 1 us.

    The top voids are the earlier buttons on the teensy position on the board. Like 0, 1, 2, etc 3 on up to 15 (13 is skipped to 16 due to led on 13.). (12, 16, 14 instead of 12, 13, 14)

    This is the 3.1/3.2 teensy which I will use in this system. The 3.5/3.6 is a slight overkill.

    All this over 1 pulse that was too fat (should of been 5 us but was like 7 us or 8 us) and it changed on the selection of button.

    I'm glad I caught it..
    The program runs with nointerrupt.

    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •