Introduction: Make a Electrical Ruler

About: I am 24 years old and come from China. I make these projects as a hobby.I want to make some friends to help me learn english.My email is satelives@126.com :)

I make a electrical ruler.

Feature:

  1. Use 32bit microcontroller STM32C8T6.
  2. Use 512 line encoder .
  3. Precision 0.1mm.
  4. unit :mm,cm,meter and km.

Material:

STM32C8T6

512 line encoder

OLED display

etc.

Step 1: Design a STM32 Board

Sorry for my bad english!

I am 24 years old engineering student from Guangxi in China. It's my frist post arcitle.I want to make some friends to help me learn english.:)

Frist,I design a stm32 PCB board,it include some buttons,crystal,and usb to usart IC CP2102,5V to 3V regulator.

And then,I spent 30RMB (about $6) to make PCB board.Make a PCB board is cheap and easy in China,10cm*10cm,10PCS PCB just olny 50RMB (about $8).

Step 2: Solder Your STM32 Board

About a week,PCB factory will send PCB boards to you by experess,so,you can solder your PCB board now.

Step 3: Make a Wheel by CNC

My friends has a CNC machine,so,I use the CNC machine to cut the acrylic board,and make a wheel and some structures.

Step 4: Install Wheel to Encoder

I buy a 512 line incremental encoder from www.taobao.com,taobao.com just like ebay in China.

This mini incremental encoder about $40,and 512 line meaning every one revolution the encoder will output 512 pulses.

The wheel diameter is 16.3mm,so the wheel perimeter is 16.3mm*3.1415926≈51.2

mm,and every one revolution the encoder will output 512 pulses,so,every pulse correspond 51.2 mm/512 pulse=0.1mm length.

Step 5: Add OLED Display and Li-ion Battery

OLED display cost $1.5 in China,3.3V power supply ,SPI interface and 128*64 pix.

Step 6: Program and Testing

I use the saleae logic to show the encoder pulse wave,and I use Keil MDK to program STM32.

This encoder has 4 pins,VCC,PULSE,DIRECTION,and GROUND.if you turn the encoder ,encoder will output some pulses,if DIRECTION pin is High ,meaning direction is foreward,else if DIRECTION pin is Low,meaning direction is backward.

the STM32F103C8T6 has a encoder interface in GPIOA 12,so I connect PULSE to STM32 GPIOA 12,and DIRECTION connect to GPIOA 11.

OLED showing my school name ,project name and software version .Do you know Chinese ? :)

Step 7: Show Time!

when I start measure at 90mm,finish measure at 0mm,the OLED show measurement result is 90.0mm,and when I start measure at 0mm,turn back it to 90mm,the OLED show measurement result is -90.0mm.

you can switch the result unit as:mm,cm,m and km

I define a double variable to save measurement result,so,the limit is 1.79769e+308 ~ 2.22507e-308 mm

I use this ruler to measure a bottle perimeter,OLED show -140.1mm,I think this bottle perimeter maybe is 140mm.

sorry for my bad english .I want to make some friends.

Source code and PCB files please mail to me satelives@gmail.com.

Thanks!