Absolute Capacitive Rotary Encoder (ACRE) constructed out of two PCB's - Page 1
Forum section: electronics / projects

author: littleboot
author_rank: Regular Contributor
timestamp: December 24, 2021, 08:03:13 pm
content: Hi,I made something cool and useful that I would like to shareAn Absolute Capacitive Rotary Encoder (ACRE) constructed out of two simple PCB's.After doing lots and lots of research (a few years back) I figured out how to replicate the technology used in electronic calipers.Two weeks back I decided to create an opensource angle sensor using this technology and cheap parts. I have just released it on github:https://github.com/littleboot/ACRE.I was thinking of using it for positional feedback for a NEMA17 stepper motor, to create a servo are something. But I believe it could be used for lots of other projects as well, any ideas?.However I still have a few things I do not fully understand maybe someone here can help me answer these questions.How the transmit signals can be created from scratch? (currently these are replicated using measurement data)Why can't I use the FET as alternative for the analog switch?Kind regards, Tom

author: Alti
author_rank: Frequent Contributor
timestamp: December 25, 2021, 10:10:11 pm
content: Hi. This is quite an interesting idea.Repurposing PCB for something else than a circuit board. We have seen PCB inductors, PCB fuses, PCB resistors but PCB capacitors are quite rare. There are capacitive sensing solutions but this concept (high resolution absolute position sensor)I suspect that the capacitance in between layers might be a critical parameter in practical application. This is set by the distance in between capacitor plates..So if you put a sticky elastomer between your two PCBs then you get the angular acceleration sensor.. It measures the twisting forces over elastomer. Of course yours has rather coarse resolution but I think it is not a problem to design artwork to cover smaller angles, with arbitrary resolution. Or you could make a 2D accelerometer this way.

author: littleboot
author_rank: Regular Contributor
timestamp: December 26, 2021, 12:28:49 pm
content: Hi Alti thank you for your reply, The absolute capacitance value is not that critical, however it is important that the distance between the PCB's is evenly distributed (PCB must be parallel). It is possible to increase the distance between the PCB's or add an dielectric layer between the PCB's, I've tested paper and polyimide tape (kapton) without any issues. Increasing the distance or changing the dielectric layer mostly influences the amplitude of the signal on the receiving electrode, it does not influence the phase shift much so their is a minimum impact on the sensor output resolution. Increasing the distance between the electrodes has an impact on the resolution mostly because of the edge effect of a parallel plate capacitor that contributes to the total error, so placing the electrodes closer together is better.(The distance between the reflector and transceiver PCB's in an electronic caliper is kept constant by the enclosure and a plastic sticker on top of the reflector).

author: LaserSteve
author_rank: Super Contributor
timestamp: December 26, 2021, 05:45:52 pm
content: What tool did you use to physically program the processor?Steve

author: Alti
author_rank: Frequent Contributor
timestamp: December 26, 2021, 08:59:30 pm
content: Quote from: littleboot on December 26, 2021, 12:28:49 pmYes, that is what I was thinking about. This distance must be kept within some tolerance.Am I correct in understanding that this thing works like aVernierscale? I read the description of the linked project but it is hard to imagine technical details. So you feed adjacent plates with same frequency phase shifted sin(t) signal (approximated by PWM-ed 0-1 that is then LP-filtered) and you look for the output phase shift (amplitude is ignored as long as this is within phase algorithm measurement range).I was wondering about technological limitations of the resolution that can be achieved with general purpose PCB technology of such capacitive caliper scale. Imagine trace/clearance 10mils/10mils and the size of the sensor in the order of 2" (50.8mm). This allows etching 100 traces and 100 clearances. Assume capacitor plates separated by 10mil dielectric. How to estimate the working range vs resolution that can be theoretically achieved here?

author: littleboot
author_rank: Regular Contributor
timestamp: December 26, 2021, 09:34:49 pm
content: Hi steve,I used a segger J-link clone from aliexpress to program and debug the GD32F103CB - GigaDevice MCU, I wrote the firmware inside the keil IDE, actually in VScode + keil assistant plugin because the keil editor is not that good.I just did a search on aliexpress and the JLINK clones are still available from multiple sellers:https://aliexpress.com/item/4000182310208.html.I haven't tested it but the GD32F103 is a STM32F103 clone and I believe you will be able to use an STlink V2/V3 however I have not tested this.An FTDI (FT2232) based programmer with Open OCD could also work, but I also have not tested this.I you only want to program the device (no debugging) you could use the ROM bootloader and serial flash tool, I wrote an manual for this that can be found on the github page:ACRE/Firmware/Doc/Using the serial bootloader for programming.pdf

author: littleboot
author_rank: Regular Contributor
timestamp: December 26, 2021, 10:21:44 pm
content: Hi Alti,No it does not work like a venier scale.The theoretical resolution can be calculated by dividing the maximum displacement by the period count of the transmission signal. So generating a transmission signal that uses more periods to modulate the signal should improve the resolution, however it is still not clear to me how the transmit signal can be created from scratch thus I can not test if this works.In my case 360 degrees divided by 512 = 0.7 degrees. Most electronic calipers use the exact same dimensions for the transmission and reflector electrodes. The 8 transmit electrodes have a combined with of 5.08mm dividing this by 512 yields 0.01mm, this is the caliper resolution most often listed on the product page.(One of the non ideal characteristics is the spacing between the adjacent transmission electrodes (ideal is no spacing but that is a short). Smaller is better but this is limited by the pcb manufacturer capabilities.)I did some testing in SPICE a long time ago to validate the working principle using pure sine waves and capacitors, I could only find this image in my notes not the SPICE sim file itself.As you can see here I simulated only whole positions: 1*TX1 + 1*TX2 + 1*TX3 + 1* TX4. I remember it also worked when a signal is party coupled to the receiving electrode. 0.5*TX1 + 1*TX2 + 1*TX3 + 1* TX4 + 0.5*TX5. I used 10pF capacitors in my simulation so in this case for TX1 and TX5 should use 0.5*10pF = 5pF for the coupling. Note I just used 10pF but this value is based on nothing the real capacitance could be calculated using the formula for a parallel plate capacitor.In theory the simulation should yield a infinite resolution because their are no non ideal circuit characteristics. I have not fully tested this, I remember creating a few different static simulations and it seemed to work as expected and left it at that.UPDATE:See attachment to this post for a new SPICE simulation that step trough 360 degrees in 16 steps = 22.5 degrees/step.Plot TX1 and one of the steps to see how the phase is shifting compared to the TX1 signal. (right click on plot -> view -> select steps)

author: littleboot
author_rank: Regular Contributor
timestamp: December 30, 2021, 11:42:58 am
content: I've created a animation that better show the working principle in action, it is based upon the SPICE simulation of the previous post.

author: Saweenbarra
author_rank: Newbie
timestamp: February 12, 2022, 06:10:33 pm
content: Hi Littleboot,Really interesting project!Could you explain a bit more how the period count of the transmission signal affects the theoretical resolution? I don't quite understand how it affects it. My understanding was that the phase shift of the received signal is completely analogue therefore theoretically there is infinite phase resolution.

author: CaptDon
author_rank: Super Contributor
timestamp: February 14, 2022, 06:32:11 pm
content: You have re-created the capacitor rotor and stator (well about 1/4 or 1/2 anyway) of a 360 degree rotating device used in Cathode Ray Tube Plan Position Indicators which were the displays for radio direction finding. The amplitude of the incoming signal determined how far from screen center the trace would extend and a rotating capacitor with 4 sections (one connected to each deflection plate) would create the sine/cosine functions needed to form a circle on the C.R.T. screen. It was called a scanning capacitor used in the military DBM-1 indicator for RDF signal finding.

author: Renate
author_rank: Super Contributor
timestamp: February 14, 2022, 06:54:53 pm
content: Hmm, interesting.Would having two receiver half circles and maybe a rotary transformer work even better (and be more noise resistant)?

author: Neomys Sapiens
author_rank: Super Contributor
timestamp: February 16, 2022, 02:32:30 am
content: Are you aware of the company Netzer?https://netzerprecision.com/#

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 16, 2022, 02:42:09 am
content: Haven't taken a deep look at your design, but being capacitive, is coupled noise not potentially going to be a problem?Capacitive encoders do exist of course, and they include non-trivial circuitry to mitigate this issue.

author: CaptDon
author_rank: Super Contributor
timestamp: February 16, 2022, 02:47:15 am
content: I didn't elaborate one point in my previous post. The rotation of a highly directional YAGI type antenna was synchronized with the scanning capacitor giving a positive directional indication of the incoming signal on the C.R.T. screen. Today it is done with two shielded loops and a sense antenna. You can see these systems on U.S.C.G. ships and base stations and also at airports to help guide lost aircraft to the airport.

author: SilverSolder
author_rank: Super Contributor
timestamp: February 16, 2022, 05:50:09 pm
content: Cool project! have you got one built and working?

author: littleboot
author_rank: Regular Contributor
timestamp: March 01, 2022, 02:10:04 pm
content: Quote from: Saweenbarra on February 12, 2022, 06:10:33 pmHi Saweenbarra,I should check EEVBLOG forum more often, my apologies for the delayed response. If al signals are pure analog sine waves and shifted by 45 degrees perfectly in theory you could have a infinite resolution. however their are some non ideal properties. like the edge effect of the capacitors (The electric field lines bend at the edges of the capacitors). In addition there is an error caused by the gab between the parallel plates.I have good news I found my old hard drive last week and found some missing documents and photo's related to my first endeavor reverse engineering a caliper were on it, one of these is a Chinese paper describing the design of a caliper ASIC I had party translated it to English this should help anybody interested in this technology to get a better way of understanding how it works this includes equivalent circuits and analysis. (I myself skipped the math mostly and tried to make it work). I will add all related documents to the GIT repo later this week.I have a Chinese datasheet of a caliper IC that shows some PCB structures depending on the resolution. (got this datasheet by searching for related manufacturers after decapping a caliper IC and photographing the die to discover the manufacturer name an part number, SyncMos - 100009945).

author: littleboot
author_rank: Regular Contributor
timestamp: March 01, 2022, 02:17:19 pm
content: Quote from: CaptDon on February 14, 2022, 06:32:11 pmHey, That sounds very cool and interesting but sadly I can't find much info after googling, do you know of a website that describes this in more tech in more detail?

author: fcb
author_rank: Super Contributor
timestamp: March 01, 2022, 02:24:15 pm
content: Zettlex Incoder is more complex but pretty accurate.

author: littleboot
author_rank: Regular Contributor
timestamp: March 01, 2022, 02:36:55 pm
content: Quote from: Renate on February 14, 2022, 06:54:53 pmMaybe but I don't quite get what you mean could you explain more? Something like pcb motor stator?I was thinking of using a 4 layer PCB instead of 2 layers so a solid ground plane can be added to protect the circuit from noise. (I went with 2 layer PCB to make it as cheap as possible, and see how well it performed haven't made the 4-layer design). Or enclosing the rotating PCB with a grounded shield. I did some test with grounded shield it did improve the noise level but did not have much effect on the calculated phase angle.

author: littleboot
author_rank: Regular Contributor
timestamp: March 01, 2022, 02:52:28 pm
content: Quote from: Neomys Sapiens on February 16, 2022, 02:32:30 amI was not but now I am thanks, it seems they use a smaller angular sensor structure like one of the structures from the GC7626C datasheet to achieve a higher resolution and keep track of the absolute position and amount of turns in software the same way the caliper chip does.

author: littleboot
author_rank: Regular Contributor
timestamp: March 01, 2022, 02:59:30 pm
content: Quote from: fcb on March 01, 2022, 02:24:15 pmVery cool, I haven't seen these inductive encoders before.

author: littleboot
author_rank: Regular Contributor
timestamp: March 01, 2022, 03:04:36 pm
content: Quote from: SilverSolder on February 16, 2022, 05:50:09 pmYes I have build multiple, Videos are availble on the github repo page.

author: Renate
author_rank: Super Contributor
timestamp: March 03, 2022, 12:06:26 pm
content: Quote from: littleboot on March 01, 2022, 02:36:55 pmWell, your antenna is unbalanced, I'm sure it's picking up a lot of noise. Ok, synchronous detection will clean a lot of that up.Having two antennas would make it balanced. There's also the question of whether you want 360 full of plate or maybe less? Two plates each of 90 degrees would (180 degrees opposite) would still cover 2 sectors of transmitter each.To get the signal to your circuit you could use sliprings, but a rotary transformer would be more elegant.

author: Saweenbarra
author_rank: Newbie
timestamp: April 12, 2022, 08:12:23 pm
content: Thanks for answering my question earlier and thanks for sharing this project. I am undertaking a university group project where we aim to design and manufacture a set of digital "caliper tweezers" which can measure the size of the object they pick up. Your project has helped me so much and I am very thankful!I have attached some photos of our working prototype and here is a link to a video:https://drive.google.com/file/d/1iBrSQDhpW66V-On8mnGhKX4j55pUA9Ge/view?usp=sharingUsing your design as inspiration we designed a capacitive encoder over a smaller angle (16 degrees). This has given us an impressively fine measurement resolution of approximately 0.2% similar to your design.Currently we are just displaying phase angle of the received signal on the LCD screen therefore a change of 1 corresponds to a tweezer angle change of (1/360)*16=0.044 degrees. We hope write the code to do the maths to convert from this phase angle to millimetres soon.To control the tweezers I decided to use the STM32L433RCT6P because it has an integrated LCD driver.One interesting thing to note.Instead of using the analogue switch (74HC1G66GV,125) controlled by the bias signal to periodically ground the receiving electrode, we had success using one of the STM32 GPIO configured as open-drain output. For some reason this method worked when the discrete MOSFET (BSS138W) would not, I am still unsure why this was the case (perhaps MOSFET turn-on time?).If there is interest I hope to upload more project details when the project concludes in May/June.Thanks again for sharing your project and please check out the photos attached and the video linked above.

author: littleboot
author_rank: Regular Contributor
timestamp: May 14, 2022, 10:59:45 am
content: Quote from: Saweenbarra on April 12, 2022, 08:12:23 pmHi Saweenbarra,Thank you for sharing this, reading this makes me happy.Very cool project, I'm very interested in the project details when it is finished please share.I already confirmed the FET was not working as alternative for the analogue switch (I should have added this to the schematic or docs) I think it is not working because of the parasitic capacitance of the external fet (not sure), A simple NPN transistor might work, using the internal GPIO (open drain) switch is a nice and free solution.I hope available docs on the github page were also useful for reference, did you guys find out how to create the transmission signal from scratch?

author: eugene
author_rank: Frequent Contributor
timestamp: May 14, 2022, 11:00:56 pm
content: littleboot, this is a very cool project. I don't know how I missed the thread before; I have a great interest in sensors in general and position sensors in particular. I've been looking through your project on github, figuring it out a little at a time.A few questions:1. How did you obtained the 512 data points for the transmit signals (txBuff[] in your code.) You wrote that it is measured data. What exactly did you measure?2. The answer is probably buried in your code, but what is the update rate of the GPIO pins? Is this what you refer to as 'T' in the comments in your code? What is the actual period/frequency that you use?3. There's a buffer with room for 64 ADC samples. It seems that the ADC is triggered once every 8T (i.e. the buffer is filled every time through the 512 PWM values.) The BIAS_PIN discharges the capacitance for 3T, then allows the capacitance to charge for 5T at which point the ADC is triggered. Is this correct?4. How did you determine those numbers? (3, 5, 8, ...)I'm just trying to make sense of the basic algorithm. Once I understand it I might be able to make meaningful contributions.

author: littleboot
author_rank: Regular Contributor
timestamp: May 18, 2022, 09:47:00 pm
content: Quote from: eugene on May 14, 2022, 11:00:56 pm1.Before I found more information see below, I took multiple cheap calipers apart and measured all signals and set out to replicate the behavior using a stm32 bluepill and a donor caliper PCB but with the ASIC removed so I could connect the bluepill to the sensor structures.Used Saleae logic analyser (china clone) to measure the signal, put everything in excel (Caliper Transmission signals.logicdata & Caliper Signal sample calculation.xlsx), determined the smallest period present in the signal. noticed that I needed 1/4 of this signal period at least to be able to generate the full transmit signal waveform.Also have a look at GC7626C - datasheet chinees.pdf(page 13, the pdf can be found attached to a earlier reply of mine) and caliper ASIC design translated.pdf (github), They both reference to 512T.515T.the code is quite simple to understand but the following explanation of what it is doing might help, a timer is configured to cause a interrupt after T time.In the interrupt all signals to make the sensor work are set in sync by setting the port output control register (OCTL), using a single instruction all GPIO pins of the port are configured (instead of using multiple gpio_write calls, this speeds up the ISR and all signals are perfectly in sync with each other).see main.c and void sensor_generateOctlBuff() function implementation this is were the caliper transmit signal (split into 512 parts and put into a buffer) is used to create the Ouput Control Register values for every output pin at each of the 512 periods.each of the transmits signals are phase shifted by 45 degrees meaning that TX1 starts at buffer location 0 and TX2 start at 512 / 8 * 1 and TX3 at 512 / 8 * 2 ect.2.Have a look at the timer init code.Fcpu = max GD32F103 = 108Mhzprescaler = 460; // 460 Good result with amplifier gain of 11X; // 200 same timebase as caliper ASICperiod = 1;update rate is ~235KHz, but can be changed.the maximum freq is limited by the GBW of the amplifier I used in the design. It also depends on the capacitance of the electrodes (capacitance)3.By trial and error mostly and using a working caliper as reference, (4T high and 4T low also works if I remember correctly, and 2T 6T might also work, I tried everything but wrote down nothing...)I figured out that I needed 64 samples, so this is were the 8T was coming from.I needed to sample at a specified point that matches the transmit signal, In sync with the TX signals I release the sensing electrode so it can charge for 1T period at the second period the ADC is triggered using a external signal which is generated in sync with the TXn signals (no software overhead and easy for debugging), I leave the sensor electrode floating for an other T period so the ADC has ~2T time to sample the signal before the sensing electrode is connected to ground again.I had a working caliper with debug wires attached to it so I could measure all the transmit signals, I also added a unity gain amp to its sensing electrode so I could observe the voltage on the electrode but without influencing it (high impedance). I compared the voltage on the sensing electrode of the caliper, to the voltage of my caliper stm32 clone changed bias signal configuration until both signals looked identical.I hope you will be able to figure out how the transmit signal came to beEdit: I noticed after posting my reply that I mostly repeated what I have stated on the github readme page, sorry for this but sadly I still don't exactly know how it works. I made assumptions and by luck, brute force and trial and error I was able to solve some parts of the caliper sensor puzzle.

author: eugene
author_rank: Frequent Contributor
timestamp: May 19, 2022, 10:05:00 pm
content: Wow, littleboot, thanks for the reply. It's all helpful. I'm just trying to put together in my mind pictures of both how the thing works (the physics) and how your code takes advantage of that (electronics, logic, and software.) I love sensors like this and I'm determined to figure it out. It won't be a full time job, so it'll take a while...

author: Marco
author_rank: Super Contributor
timestamp: June 01, 2022, 10:19:09 pm
content: Wouldn't four sections be enough for the bottom electrode? Wouldn't it be better for the top electrode to cover say 120 degrees instead of 180? Then it won't have won't have a dead space when both it's edges are in gaps between the bottom electrodes.I wonder if you could do everything without any high frequency DAC/ADC too.Lets say you put square waves at 0/90/180/270 degrees phase on the bottom, then you low pass the return signal to an approximate sine, square it back up then measure the phase shift either a micro or by XOR with quadrature square waves.