Magnetic axis keyboard, I did a little test. Using CH32V307, usb2.0 high-speed mode, the sampling rate runs at 8KHz (currently the entire cycle from sampling to publishing takes 98us). It can support the RT function. There is still a little interference problem. The trigger key travel is at least 0.3mm and it can be stable. Different magnetic axes may require Hall elements with different sensitivities. My Hall detects the magnetic axis of Jiadalong, and the ADC result is around 1000~2000. If Yiqian's magnetic axis requires a higher sensitivity Hall element.
Regarding the issue of whether analog and digital ground are separated, I tried one version and found that there is not much difference. It seems that only by installing a four-layer board can the last bit of interference be reduced. Rich friends can try a four-layer board. Then I tried the reference voltage 431 chip CJ431 from the jlc basic library, and it was very noisy. I don’t know what it was. This problem won't happen if I replace it with the original TL431. Okay, I want to spend a little more money this time to post all
the lights, but I don’t really want to complete the dynamic refresh program. At present, I only fixed the color at startup, and then completed the PWM+DMA refresh LED program. Dynamic lighting will fluctuate a bit, so it’s not easy to handle for the time being. Note that the small silk screen corner of the lamp on the PCB is not a pin, but a small notch corresponding to the front of the lamp.
Then the power consumption of this lamp is a bit high. I set it to the highest setting at the beginning, and the 5V was directly pulled to 3.6V (...?)
The program is attached. It is relatively simple to debug and write. After all, I built it from scratch. Then there is a calibration process for each axis. I use the official MountRiver IDE. For calibration, change the comment on line 220 of key.c to #if 1, then swd enters the debug interface, and after letting it sit for a while, copy the min_value array to the key_top array. Then press each key to the end and copy the min_value array to the key_bottom array. (If it is an axis with opposite polarity such as the Yiqian magnetic axis, you need to copy the max_value array, both times.) Then restore the comments and it will almost run. If you set the trigger-sensitive keys yourself, you may accidentally touch them. You need to fine-tune the key_top. value.
Day 2023/08/07
I tested the dynamic lighting and found that several signal lines of the lamp were too close to the analog circuit. Dynamic lighting can cause 100+ interference. If I cut both ends of the wires and re-fly the wires, there will be no problem. . When wiring, I didn't consider that this is also a high-frequency line. The PCB was changed, and the pins of the lamp were modified. I temporarily used the PA15 pin to light up with PWM+DMA, and the program has also been modified. At the same time, considering that the lighting power consumption is a bit high, two 22UF capacitors are added to the 5V power supply.
After thinking about it, I decided to put the project in gitee, a DIY magnetic axis keyboard project.