Skip to content

Digital caliper (Linear encoder) on STM32L4 自作デジタルノギス

License

Notifications You must be signed in to change notification settings

keshikan/CurematicCaliper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Caliper on STM32 "CurematicCaliper"

Overview(概要)

This repository shows digital caliper application on STM32.

STM32を使用した自作デジタルノギスです。リニアエンコーダ部から自作しています。

hall sensor

Features(特徴)

  • 3D printed body (本体は3Dプリンタ製)
  • 0.01mm resolution (分解能0.01mm)
  • Self calibration (自己校正機能)
  • Dual power supplies (二系統の電源に対応) :CR2016 or USB Type-C
  • Data output function via USB (USB経由で測定値を出力可能)

Principles(原理)

Position detection(位置検出)

The position is calculated by sensing magnetic field of the sheet magnet with Hall sensors.

シート磁石の磁界をホールセンサで測定することで、位置を検出しています。

hall sensor

Sheet magnet have alternating N-S blocks. When a linear output Hall sensor moves on a sheet magnet, nearly sine wave is output. Assuming: Let y be the sensor output value and θ be a position of the sensor. Then .

シート磁石は、N極とS極が交互に並んでおり、リニア出力のホールセンサを滑らせるとsin波に似た信号が出力されます。そこで、センサ出力をy、位置をθとして、に従うと仮定します。

Now, install the two sensors with their positions shifted so that the output as following.

いま、2個のセンサを、位置をズラして設置し、出力が次に従うようにします。

region

Then, the graph area can be divided into A to D regions as shown in upper figure depending on .

このとき、の値によって、図のように領域A,B,C,Dに分けることができます。

  • A:
  • B:
  • C:
  • D:

Next, consider how to detect the moving direction and calculate the rough position. Let be the number of passes through the A-D region. Add 1 to if the region changes forward as A→B→C→D→A and subtract 1 from if the region changes reverse as A→D→C→B→A. Where is the magnet pitch (between N-N pole), the rough position is as follows.

次に、方向検出し、大まかな位置を計算します。領域を周回する回数をとし、A→B→C→D→A と正転すればに1を加え、A→D→C→B→Aと逆転すればに1を減じます。1周期分の磁石ピッチ(N極とN極の間)をとすれば、大まかな位置は、次の通りです。

In addition, calculate the accrate position from . Where

さらに、から正確な位置を計算します。ただし、の範囲で考えます。

Therefore, position is as follows.

以上より、位置は次のように求まります。

Position error compensation(位置ずれ補償)

Ideally, the sensors output values are , but the actual sensor output has error because of the position error of sensors. Hence:

センサ出力がとなるのが理想ですが、実際のセンサ位置にはずれが存在するので、次のように書けます。

If we estimate from and calculate from , the accracy of is improved. Please refer to this tweet (written in japanese)

からを推定しを求めると、の精度向上に寄与します。具体的な方法論はツイートの通りです。

Hardware

See Schematic, and 3Dmodel.

回路図はこちら、3Dモデルはこちら

Software

Install STM32CubeIDE, import Project files. If you have successfully imported, you can build the project without error and the binary file will be created in /cubeide_project/Debug/.

STM32CubeIDEをインストールし、プロジェクトファイルをインポートして下さい。インポートに成功していれば、CubeIDE上でプロジェクトをビルドするだけで、/cubeide_project/Debug/フォルダにバイナリファイルが生成されるはずです。

NOTICE(注意)

VID/PID

Vendor ID(VID) and Product ID(PID) in <usbd_desc.c> should be unique pair for each USB devices. Default VID 0x1209 and PID 0x0001 is experimental IDs from http://pid.codes .When distributing or selling, you must get your own IDs, and change to your own IDs in order to avoid conflicting to other USB devices.

USBのVendor ID(VID)とProduct ID(PID)は、<usbd_desc.c>内に記述します。 デフォルトのVID(0x1209)/PID(0x0001)ペアは、http://pid.codesで定められている実験用IDです。そのため、本機器を配布したり販売したりする場合には、別途固有のIDペアを取得し、書き換えてご使用いただく必要があります。

References(参考文献)

Copyrights(著作権)

Author

(c) 2019 Keshikan ( Website, Twitter )

License

See also LICENSE.md

About

Digital caliper (Linear encoder) on STM32L4 自作デジタルノギス

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages