Shop OBEX P1 Docs P2 Docs Learn Events
Magnetic Encoder Project (AS5055) - Page 3 — Parallax Forums

Magnetic Encoder Project (AS5055)

13»

Comments

  • RS_JimRS_Jim Posts: 1,764
    edited 2013-01-10 15:29
    Thanks Duane, I will look forward to it. In the meantime I will have to figure out a stable way to mount the magnet.
    Jim
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-01-10 16:36
    Jim,

    Attached is the code demonstrated in post #1 of this thread. It uses a three wire SPI interface and does not include any averaging to smooth out the readings.

    I'm pretty sure I have a three wire version with the averaging filter but I'm not sure which version I have is the one that works. If you want a three wire version with the filter let me know, and can probably figure out which one to use.

    I don't have an encoder setup with a Prop right now so I'm not able to test the various versions. I try to keep notes to myself in comments about which version does what but I'm not always as detailed in my descriptions as I should be.

    Edit(3/11/15): I have deleted the archive AS5055Demo120318g - Archive [Date 2013.01.26 Time 17.15].zip (97 views)
    I plan to upload this program or an improved version to my GitHub account.
    If there isn't a replacement on GitHub send me a message and I'll make sure to upload the replacement code.
  • agnitejaagniteja Posts: 1
    edited 2013-06-14 05:56
    Hi Duane
    I was working on AS5145 chip. I wanted to ask two things.
    1. I was curious about calibration of AS5145 chip. I'm getting the output at an accuracy of 0.6 degrees (plus-minus) max. Were you able to calibrate the readings for AS5145 chip. If so what accuracy were able to get the output. My target is 0.1 degree max(plus-minus)

    2. My application demands that the magnet shall be placed at min. of 3mm air gap. which is far more than 1.5mm max suggested in the data sheet. Even at that air gap I'm targeting the accuracy to be 0.1 degree max. Did you try any of your experiments in this direction. kindly share your results and your valuable experience.

    I'll post the pics of the assembly in couple of day.
    Thanks
    Agni
  • RS_JimRS_Jim Posts: 1,764
    edited 2013-06-14 06:19
    Agni
    2. My application demands that the magnet shall be placed at min. of 3mm air gap. which is far more than 1.5mm max suggested in the data sheet. Even at that air gap I'm targeting the accuracy to be 0.1 degree max. Did you try any of your experiments in this direction. kindly share your results and your valuable experience.
    To get .1 degree you need a 16 bit value being returned from the chip. IIR the chip you are describing is 12bit.
    Jim
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-06-14 10:06
    RS_Jim wrote: »
    Agni

    To get .1 degree you need a 16 bit value being returned from the chip. IIR the chip you are describing is 12bit.
    Jim

    Hi Jim,

    When I divide 360 degrees by 4096 units of resolution (12-bits right?) I get 0.08789 degrees per unit resolution. So it seems 12 bits should be enough to get 0.1 degree resolution?


    @Agni, I haven't tried calibrating these encoders yet. I figure I'd need some other encoder to accurately measure the position of a knob/axle in order to know what differences there are between the two measuring methods. While I haven't measured the actual position of the knob in various positions, I was able to move the knob to any arbitrary value desired. It took a bit of effort to get the knob in the exact desired position since a very small movement would change the reading of the encoder.


    I think my biggest problem with this project is my attempt how to learn to solder these tiny chips.

    I have some small PCBs to use with these (AS5055) encoders. I'm hoping using these encoders on a small PCB will allow me to replace a servo potentiometer with an encoder using the same location inside the servo housing as the original potentiometer occupied.
  • RS_JimRS_Jim Posts: 1,764
    edited 2013-06-14 16:43
    Duane,
    You are absolutely correct. I looked up the data sheet and it has the resolution you calculated. I am sure he will have a problem with his distance.
    Jim
  • Duane, since you seem to have the most experience with these magnetic encoders I'd like to pick your brain a bit.
    I am using a HH-12 encoder that uses the AS5045 12 bit chip mounted in a potentiometer sized housing. It is a 3 wire device (Data, Clock, CS, +, and -) and I was attempting to run using your code using it. I have the following pin connections:
    CS pin (equivalent to your SsPin) tied to P0
    CLK pin (SckPin) tied to P1
    Data pin (MisoPin) tied to P2
    MosiPin linked to P4 and tied to Hi
    IntPin linked to P5 and tied Lo

    What I am finding is that there is a large number of errors being generated but worse is the data that does output. The encoder data itself is wildly variable, without the shaft moving the output changes several hundred counts, the equivalent to a 30+ degree swing of the shaft. I understand if there is some minor variation when the shaft is static but not this amount. I was going to try your 3 wire SSI code and see if that made a difference but I couldn't find it on the GetHub page.

    Any suggestions are welcome!
  • Hi DiverBob,

    I'm a huge fan of your giant robot and I'd really like to help anyway I can but I'm insanely busy right now.

    I should have time to track down the three wire code the by the second of November. I'll try to find it sooner but no promises. I found it. It's attached to this post.

    The GitHub comment was added when the forum was being upgraded and Parallax said the old posts would be read only. Since I wouldn't have been able to update code in these old posts I deleted the code with the intention of adding the code to GitHub. As you found, I never got around to adding the code.

    I thought RC_Jim successfully used the code with an AS5045 chip but I may not be remembering this correctly.

    I think I have an AS5045 chip. If I do, I'll try to find to wire it up and test it with my code.

    As you may have seen, I tried to make a PCB small enough to fit in a pot case but I've had a heck of time soldering these tiny smt packages. I hope to make an updated version of my small PCBs and use a solder stencil to lay down solder paste. I've had much better luck soldering smt packages with a proper stencil.

    Again, I'll try to give a better reply when I'm a bit more caught up with work. Feel free to continue to ask questions, it just might take me awhile to answer them.
  • Thanks for the quick response, I'll give your code a run later today. I have high hopes that these encoders will give me a stable output that will improve my leg motion.

    Bob
  • RS_JimRS_Jim Posts: 1,764
    edited 2016-10-27 15:31
    Bob,
    I believe that I have Duane's on a memory stick. I will try and find it when I can fire up the laptop.
    Jim
    Edit: UTL see link on next large robot thread.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2016-10-27 15:17
    DiverBob,

    I just looked back through this thread and I see I don't have any photos of my smaller PCBs here.

    These are some boards I made:

    attachment.php?attachmentid=103008&d=1374727215

    Here's the thread were I relate my attempts to make PCBs for this chip.

    I also considered using a larger board to use with a larger servo. This larger board was to include a Prop and use a sigma-delta circuit to monitor the voltage to the motor. In hindsight I think using a Prop here is overkill. I think an AVR with an UART would have been a better choice for a microcontroller.

  • My initial attempt to use these magnetic encoders inside a servo did not work well. I attached a couple videos to this forum post which shows my experience.

    I did a horrible job of positioning the sensor. I used double sided tape to attach the sensor to a piece of foam board and pushed the foam board into place under the magnet. The magnet could have been over a millimeter out of alignment.

    I hadn't tested to see how well the sensor worked without the servo being powered. It's possible the motor was interfering with the sensor but I think the majority of my problems were caused by poor magnet/sensor alignment.

    While my little PCB was the same diameter as the original pot, the height of the magnet/sensor combo was greater than the original pot so the sensor didn't fit inside the plastic cylinder where the original pot had been positioned.

    I hope to make some PCBs to align the sensor properly.

    I still hope to find a way to reliably use these sensors inside a hobby servo but I'm not sure these sensors are the best tool for this particular application. I've also experimented with optical encoders inside servos.

    attachment.php?attachmentid=105438&d=1386432536

    This optical encoder setup only provided 378 transitions per revolution but this sort of resolution is good enough for a lot of applications.

    I've come to despise potentiometers as input devices for applications which require a lot of use. Pots wear out. I'm pretty sure worn out pots is the cause of the majority of servo failures in my hexapods. It would be really nice to find an inexpensive and relatively simple replacement for potentiometers.
  • I looked over the code you sent and it was the same one I already had for the 4 wire interface. I will continue to test this out and change some of my parameters around to make sure I don't have any wiring issues. Since I'm only running this on a stand alone prop not connected to the robot there shouldn't be any external influences. Another idea will be to get a generic SSI interface from the OBEX and modify it to work.
    Thanks for your help so far!
  • Sorry about that.

    Here's one labeled "3Wire." It's the latest version which compiles but I don't recall how well it works.

  • Thanks for finding the file, I'll try it out and report back later
  • The first test went well, got output without errors but still have inconsistent results. Looking at the output shows some type of pattern, I'm just not sure what it means right now. Unfortunately I didn't get started as early as I had hoped so I didn't have enough time to do a lot of modification to the program. That will have to wait for my next day off, next Tuesday night.
  • Finally got back to testing the code out without any luck, still getting outputs that don't make any sense. Don't know whether to try to start from scratch and write my own code or figure out what is going on with this code. It may be due to the HH-12 device only has 3 connections, clock, cs and data out. I'm not fully following the code but it might be trying to write back to the device (don't really think so but its late and my mind is getting fuzzy!)
  • MikeDYurMikeDYur Posts: 2,176
    edited 2016-11-04 12:49
    DiverBob,

    Just my two cents, but I did notice a comment on line 444 in the demo spin. It is a complicated program for sure, something I may never figure out.

    Mike Y. ;)
    1366 x 768 - 160K
  • MikeDYur wrote: »
    DiverBob,

    Just my two cents, but I did notice a comment on line 444 in the demo spin. It is a complicated program for sure, something I may never figure out.

    Mike Y. ;)

    I saw that line also and commented it out to see what would happen. It appears that the output is constant for several iterations (3-6 loops) before it changes again. Unfortunately the change is fairly drastic each time. I did notice this time that whenever I would move the shaft, the output would fluctuate between 4 to 6 different readings. Make another shaft movement and the numbers would change but always fluctuate between several specific numbers.
    When I have my next day off I will see about writing something simple that just displays the output directly from the device in binary and see what that looks like. The averaging capabilities in the code are nice except they may be masking a problem and the complexity of the code isn't helping me figure out what is going on!
Sign In or Register to comment.