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

Thread: Need help troubleshooting

  1. #1

    Need help troubleshooting

    Hi guys,

    So, I'm building a multi-effects box with the Teensy 4.0 as my major project of my audio engineering bachelor's degree and I've hit a bit of an issue. Please note that a mandatory requirement for the major project was to explore and learn a new skill that would take up at least 300 hours of work, so before I started this project, I had no prior experience with Teensy/Arduino. So, if there are any blatant/obvious errors here, please forgive me.

    I'm using the Teensy 4.0 with the Rev. D audio shield, as well as a few hardware components: LCD screen, three rotary encoders, an ultrasound distance sensor, a joystick and one throw switch. All of this hardware stuff is 5V, so I've also got four bi-directional logic level converters from SparkFun, which all of the hardware stuff goes through before going into the Teensy. In preparation for this project build, I tried all of the hardware pieces with an Arduino Uno and compiled code for each individual item, which I had planned to just throw into the Teensy to test that everything was working. To my great dismay, it seems as though nothing is working. Everything is getting power (LCD screen lights up, for instance), but nothing works as it's supposed to (and no I2C devices recognised when running the i2c_scanner from the Arduino forums).

    When I try to run the rotary encoder code that I have saved, which worked flawlessly with the Arduino Uno, I get such weird results. The code prints to serial whatever is happening with the encoder (counts clockwise turns, counter clockwise turns and button clicks and then prints to serial), but with the Teensy, it always registers a button click and then a clockwise turn. No matter what is done to the physical encoder, it's always a button click and a clockwise turn that registers with the code (if I rotate it fast, in either direction, it registers a button click and then clockwise scrolling). I also tried using the Encoder.h library by Paul, but the there's no change: it doesn't register different directions. With the Encoder.h library, it even reads one step as a couple dozen increments (with the basic example from the library).

    As this is my first big project of this sort, I'm having real trouble figuring out what could be wrong. I'm 99% confident that all of my soldering is perfectly fine and that everything is soldered to the right pins. The 5V VCC is daisy chained to all of the hardware components and so is the GND. I've tested continuity from the first 5V VCC pin to the last pin in the chain and there doesn't seem to be a problem with continuity. Same goes for the GND.

    My main theory of what might potentially be the issue is that I may have soldered to a pin that I'm "not allowed to use" because of the audio shield. The pins that I've soldered onto are: 0-6, 9-17 and 22 (with pins 14-17 & 22 being the analog pins used for the LCD and the joystick). Going over the audio shield data sheet, these were the pins I thought would be safe to solder over, since I thought they wouldn't be in use for my project. Other than that, I have no idea what could be causing this.

    If anyone could take the time to help me out, I would be so grateful as there is so much on the line with this project (basically my BA-degree is on the line).

  2. #2
    Senior Member
    Join Date
    Jan 2020
    Location
    Toscana
    Posts
    134
    Post schematics, please.
    For example: The issue with the rotary encoder looks like you mixed up pins. This can happen quite easily, because the logical numbering of pins does not correspond to the coordinate of the physical pin at the board. So have a look at the labels and the pinout diagrams.

    Also, look at the documentation of the Audio Shield Rev D and the schematics and compare the pins used for this with the pins you use. The I2C bus may be shared, but if you use a level shifter, the connection has to be Teensy >> Audio Shield >> level Shifter >> 5V part. Also, the wires must be kept as short as possible to the audio board, because this is especially picky about signal quality.

  3. #3
    Hi flashburn! Thanks so much for the advice.

    Unfortunately, I don't have any nice looking schematics, only ones that I drew on paper and may look super stupid to anyone else but me. Do you know of any programs or something like that where I could draw proper schematics?

    Regarding the rotary encoder: I've double or triple checked the pins and I'm certain they're right. I also tried changing the pins up in the code, but the results remain exactly the same in the serial monitor. I'm going to try the other encoders and see if I run into the same exact problem with those two.

    I did go over the schematics for the audio shield rev. D to try to make the most informed decision on which pins to use, but due to my lack of experience with the Teensy (and the whole Ardruino/MCU field), I'm worried that I may have soldered onto a pin and not realising that it was a pin that I couldn't use. These are the specific pins I used that were pre-occupied by the audio shield:

    6 - MEMCS (Chip Select (SPI) for Memory Chip
    10 - SDCS (Chip Select (SPI) for SD Card)
    11 - MOSI (Data Storage (SPI) from Teensy to SD/MEM)
    12 - MISO (Data Storage (SPI) from SD/MEM to Teensy)
    13 - SCK (Data Storage (SPI) Clock)

    Regarding the I2C problems, I think I just realised what the problem is there. I soldered the SDA and SCL pins from the LCD to A1 and A0, respectively, instead of to A3 and A2 (SDA1 and SCL1), as it seems they should've been soldered to, according to the Teensy pinout.

    Regarding the wires: how long is too long for Teensy? Mine are probably too long, as I wanted to be able to detach the top plate to get into the device and disconnect the headers (I have everything soldered to two separate 14 pin long header strips that I can somewhat easily plug in and out of the headers on the Teensy) for disassembly. I'd say each of my wires is about 8 cm long. I just ordered more wires in different colours (as everything except the GND chain is just red wiring right now) and I'm going to redo all of the soldering and shorten the wires as I can and use more colours for an easier and more visual way of making sure everything is going to the right pins everywhere.

    Thanks again for the help. It is very greatly appreciated!

  4. #4
    Senior Member
    Join Date
    Jan 2020
    Location
    Toscana
    Posts
    134
    If you do not use the onboard memory and SD and have not populated the memory chip, these pins are usable for other things, but keep in mind there are 10kΩ pull-up resistors to 3.3V on pin 6 and pin 10.
    Also, if you ever want to use higher speed signals, keep in mind there are unused dead-end traces (called stubs) that should be avoided with high speed or timing-critical signals. So if you do not use these parts of the Audio Board, just do not connect the pins between Teensy and audio board, if possible.

    For schematics can use Fritzing https://fritzing.org/ or if you ever want to make printed circuit board, it is worth the effort to learn KiCad https://kicad-pcb.org/

  5. #5
    Senior Member
    Join Date
    Jan 2020
    Location
    Toscana
    Posts
    134
    Ah, I forgot one thing: The rotary encoder, did you use a breakout with filtering or build a debounce filter around it? Teensy 4 is so fast, it easily triggers on contact crackle and bounce, resulting in false readings. Alternatively, there is the possibility to debounce in software.
    https://forum.pjrc.com/threads/57685...-Missing-Steps
    https://forum.pjrc.com/threads/58478...ncoder-Library

  6. #6
    Hey flashburn,

    Sorry for the late reply! Things have been pretty hectic and I've been going over all of your feedback. I'm still waiting for those wires to come in so that I can fix my soldering of the SDA and SCL pins, as well as shorten all of my wires and colour code them better. I'll post back once I've progressed further with this and have been able to try all of your ideas and solutions! I'm confident that some, if not all, of my issues will be resolved with the feedback you've given me. A lot of stuff I was not aware of prior.

    In the mean time, I'm going to try to read up about dead-end traces and figure out which pins that may be in my particular project.

    Regarding the rotary encoder: I honestly don't know. I used the Keyes KY-040 rotary encoders and just tried the Encoder Library - Basic Example script from the Example.h library from Paul. But, I just came across another PJRC forum thread labeled Teensy 4.x H/W Quadrature Encoder Library. I'm going to try digesting some of that thread and maybe try out that code and see if I get any different results, since that specific code was developed with the T4.0 and the KY-040 encoders.

    Thanks again!

Posting Permissions

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