Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 33 of 33

Thread: Need a code to use the Teensy 4.0 board to supply 6 square waves using the PWM ports

  1. #26
    Senior Member
    Join Date
    Jul 2020
    Quote Originally Posted by devanshshukla View Post
    So, as suggested by Frank and JBeale, I made the changes to my circuit and connected it. But I did not get any response to it. The IR LEDs were not blinking at all.
    Firstly change one of the IR LEDs to a visible LED during testing so you can be sure if its working without needing some sort of
    near IR camera.

    Use 330 ohm resistors, not 220, those will overload the T4 pins I think. Since the load is 70mA or so you only need
    4 to 7mA into the transistor base.

    Which transistors are you using? Have you got the pinout correct?

    From the photo it looks like most of your connections to the T4 are not made properly, just a loose fitting
    pin through the unsoldered T4 through-holes - that's no good, must be soldered. Normally for breadboard use
    you solder male header pins to the Teensy.

  2. #27
    Hi Mark,
    Thank You for your suggestion. I will replace the 220 ohms resistors and use 330 ohms resistors and update you further.

    Also, as suggested by you, I will use a visible LED to test the circuit out first and update you.

    Also, I am using the NPN transistor- 2N 3904 H331.

    And yes, I have got the pinout of the transistors right.

    I have made the connections to T4 properly, tightly fitted, and will make changes to the circuit as mentioned by you and test it out and update you once I get it done.

    Thank You So Much for all the help!

  3. #28
    So, firstly, I realized that when the Teensy 4.0 board is connected to the computer using the USB cable, I do not need to externally supply +5 V to the board, which I used to. Is that right?
    But I will need to supply some voltage externally for the LEDs to glow like how I did supply 5V in the below figure(1).

    Also, when I connect the below circuit, which is supplying square wave pulse using a function generator and not teensy board 4.0, I get the output on the oscilloscope, and the IR LED also glows.
    Here is that circuit: figure (1)
    Click image for larger version. 

Name:	Screenshot 2021-08-25 124452.jpg 
Views:	7 
Size:	117.2 KB 
ID:	25654

    Now coming to using the Teensy 4.0 board to supply square wave;
    Using the suggestions given by Mark, Ed, Frank, JBeale, Paul, I fixed the Teensy board 4.0 with male solder header pins as shown below in the breadboard figure.

    Also, as suggested by Frank, I added the following line to my code to see the internal LED light blink as well:" analogWriteFrequency(13, 10); analogWrite(13, 128);."
    And the internal LED at pin 13 does blink as well. But the IR LEDs, which are being supplied with the square pulse from ports 2,4,5, and 6, don't blink.

    Here is the new circuit diagram with the changes that I made mentioned above, including changing the 220 ohms resistor to 330 ohms resistor:
    Click image for larger version. 

Name:	Screenshot 2021-08-25 125100.jpg 
Views:	14 
Size:	133.8 KB 
ID:	25655
    Click image for larger version. 

Name:	Screenshot 2021-08-25 124730.jpg 
Views:	19 
Size:	89.4 KB 
ID:	25656
    Click image for larger version. 

Name:	Screenshot 2021-08-25 124535.jpg 
Views:	17 
Size:	95.0 KB 
ID:	25657

    I don't know what I am struggling with within this circuit, and I really appreciate all the help I have received from everyone on this forum.

    I hope I can figure this out soon. Any help is greatly appreciated!

  4. #29
    Senior Member
    Join Date
    Oct 2012
    Portland OR
    Using a phone camera to see IR is kind of a "hack" or a cheat, which sometimes works, but it will probably not work in this case.

    I see from your datasheet you are using 940 nm LEDs. I have done similar experiments and found my cellphone camera can see 850 nm LEDs, but it will NOT see 940 nm *at all* even right up against the LED.
    All silicon-based color cameras need an IR-block filter to be able to produce decent color. Many phone cameras still see a little bit of 850 nm because the filter doesn't have a sharp enough cutoff, but 940 nm is simply too far and it is blocked.
    You can use a basic photodiode to see it, or you can use an actual IR-type camera like a security camera in night mode, that would not have the IR-cut filter in place.

    For checking a 940 nm optical system, I recently used an old Sony "nightshot" type camera to see the emitter, sometimes you see them used at around $100 and they are handy for this job.

    At work we used an Edmund Optics handheld IR viewer that is about 20x more expensive, but for this application it works about the same.
    Last edited by JBeale; 08-25-2021 at 05:21 PM.

  5. #30
    Hi JBeale,
    Thank You for your suggestion.
    I used an oscilloscope as well to see if the square is being supplied to the IR LED or not. As shown in the above figure, I even replaced the IR LED with a normal LED with the breadboard.

    Thank You!

  6. #31
    Join Date
    Jul 2014
    Currently Odessa, Ukraine
    Here is my suggestion to get to the bottom of the challenge.
    Start with disconnecting the base resistor from the teensy and connecting it to the other output of your DC power supply, then adjust the output to 3.3vdc.
    Measure the voltages at the base, emitter, collector of the transistor, the anode of the LED, and the voltage at the other side of the 100 ohm resistor.
    Post these voltages here for the rest of us to see, then we will probably have a better chance of guiding you forward.

    Last edited by sbfreddie; 08-25-2021 at 05:33 PM. Reason: typo

  7. #32
    Senior Member
    Join Date
    Oct 2012
    Portland OR
    Glad you have a scope, that is the right tool for this job. Have you probed the metallized ring around the hole at each output of the T4 board itself to see if the signal is present there?

    From what I can see in the photo, you have used the header pins in a non-standard way. If you have not actually soldered those header pins to the T4 board, it may or may not be making electrical connections at each point.
    Simply mechanically staking the board to the breadboard through the holes with the header pins, does not necessarily work. Sometimes it does work briefly and then stop working, because any tiny shift in position can break the contact between the pin and the annular metal ring. Soldering the pin is the only reliable method for making a good electrical connect between header pins and those holes.

  8. #33
    Senior Member
    Join Date
    Oct 2012
    Portland OR

    pins soldered to Teensy board

    I did a sloppy job of soldering the pins on this old Teensy board (and by now it's also covered with dust) but hopefully you see how the pins are soldered to the board here.
    Click image for larger version. 

Name:	T3_20210825.jpg 
Views:	14 
Size:	226.4 KB 
ID:	25660

Posting Permissions

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