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

Thread: Teensy 3.5 and multiple AS5048A Rotary Encoders wont work

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    6

    Teensy 3.5 and multiple AS5048A Rotary Encoders wont work

    Hey,im having trouble getting my SPI devices to work properly.
    My situation:
    I need to connect 6 As5048a to my teensy 3.5 to read angle values. to accomplish this I use a simple library : https://github.com/ZoetropeLabs/AS5048A-Arduino
    and this works fine if i have only one sensor connected to my teensy.
    but it just doesnt work if i have more than one connected and i cant figure out why, i thought i just solder all MOSI MISO CLK 5V GND pins together from my sensors, (like this: https://www.youtube.com/watch?v=_p6m2WwF2Jk )
    and connect those to my teensy, but it wont work.
    and by it wont work i mean that i dont get correct angle values. its then just 0 all the time

    has someone done this before and might tell me how? it seems so simple but i cant get it to work

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,246
    How are the chipselects connected?
    (And sorry, I don't watch such videos - I hate to watch long videos when I can read the same in 30 seconds from a better source or have a simple diagram)
    Does the library support more than one sensor?

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    6
    yeah np, im not new to electronics and everyone always wants to know everything thats why i added the vid.
    and yes it supports multiple sensors. i did some more testing and i think its an power issue, is that possible?

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,246
    - So, tell us how the chipselects are connected.
    - Sure, can be a power issue. How much current draw them? Voltage? Edit: Did you measure the voltage on each sensor?
    - It can be a cabling-issue, too. How long are the connections (in sum) ? - 1MHz is not much, but if the cable are very long and not terminated it can be a bit too much. In this case, I'd just try to reduce the speed to 10kHz in the library code - just to test if it works with the reduced speed. Edit: Uhh.. does SPI support less than 1MHz?... forget that... do you have a scope or logic analyzer?
    - post your code?

  5. #5
    Junior Member
    Join Date
    Dec 2018
    Posts
    6
    chip select are connected correctly, for now pins 0-3 but dw about that.
    no cabling-issue because they work all if connected alone. my code is just the one in the library- so nothing special- just testing

    the cables are about 2m max

    i dont have analyzers sadly.

    i dont rly know how much they draw.

    but: i have one connected that runs good, and 2 more, but i havent plugged the power in for the extra 2 chips. if i do, the first chip im reading the angle from gets this weird behaviour again, so maybe its really power.

    currently trying to make one work with external powersource

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,246
    so.. cables are 6x2m ? 12m? or 2m in sum?
    even 2m sounds a bit long (for me) for 1MHz SPI.. others can you tell more about this, I'm out when it comes to cable-length.

  7. #7
    Junior Member
    Join Date
    Dec 2018
    Posts
    6
    each cable is 2m.. but thats not the problem as they work fine on their own.

    now i have an external power supply to power the chips, but this didnt help- still the same issue.

    maybe i need a capacitor or what could help? i dont know anymore

  8. #8
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,246
    "each cable is 2m.. but thats not the problem as they work fine on their own."
    i don't think so.. but ok.
    Give it a try and try 10cm instead, for 2 sensors perhaps - just to be sure it#s not the cable length. 6x2 m in a star topology with 1Mhz SPI sounds not good. But ok, as i've said I'm not an expert on this.

  9. #9
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,174
    Frank is right, that’s ways too much wiring capacitance since the clock and data pins will see all these wires in parallel. And that’s not what SPI was designed for. SPI is (like I2C) a protocol to transmit data from IC to IC on the same PCB, not for connections over longer distances. Sometimes, that can be compensated using additional drivers and buffers, and/or by adding series resistors but an oscilloscope and knowledge in analog RF technology and impedance matching is definitively required.

  10. #10
    Junior Member
    Join Date
    Dec 2018
    Posts
    6
    oh okay. thanks everyone. yes i figured the initial problem out. somehow, if i read the error every iteration it works, and if i dont do that it doesnt- i also added a delay in the library. i tried that with short cables, that worked good- but now i need the long cables, what can I do?

    I need these encoders for my robotic arm to obtain the jointangle data. and the cables need to be ~2m to give it room to move

    Edit: i think i just put a arduino mini on my robot arm and read the angles- and send that via Serial to my teensy.
    that should work right?
    Last edited by RWTH_MASCHI; 12-29-2018 at 01:58 PM.

  11. #11
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,174
    Quote Originally Posted by RWTH_MASCHI View Post
    oh okay. thanks everyone. yes i figured the initial problem out. somehow, if i read the error every iteration it works, and if i dont do that it doesnt- i also added a delay in the library. i tried that with short cables, that worked good- but now i need the long cables, what can I do?

    I need these encoders for my robotic arm to obtain the jointangle data. and the cables need to be ~2m to give it room to move

    Edit: i think i just put a arduino mini on my robot arm and read the angles- and send that via Serial to my teensy.
    that should work right?
    Yes, a small local MCU like a Teensy LC or an Arduino mini might capture and concentrate the data and transmit it via Serial/RS232/RS485 or any other technology which is designed to support longer wiring to the main MCU.

  12. #12
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,246
    The robotic Arm - What size is it? How strong are the motors?
    I'm asking, because that's another source for problems.. perhaps use a shielded cable, CAT7 with unused pairs connected to the shield, too, for the serial transmission. If that's not enough, try RS422. And make it as slow as possible.
    Last edited by Frank B; 12-29-2018 at 03:32 PM.

  13. #13
    Junior Member
    Join Date
    Dec 2018
    Posts
    6
    about 80cm and i use nema 17 and nema 23

    i try it with serial now. i used a cat6 LAN cable for the spi cables before, but that didnt seem to be enough. also the lan plug made many problems etc.. very annoying. i try it now with a arduino pro mini and send that to my teensy

  14. #14
    Junior Member
    Join Date
    Oct 2018
    Location
    Poland, Cracov
    Posts
    10
    I used AS5048A encoders.

    Arduino Due, 10Mz clock, 2m cable long, and similar to your problem when I used one device it was ok, but when I connected more (4 device) I was getting transmission errors. And I am pretty sure it was cable related problem.

    My solution was: one Arduino Uno with two encoders connected on short cables (15cm max). And then Arduino Uno -> Arduino Due via UART.

Posting Permissions

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