ClubRobotInsat / firmware-color-detection

The firmware for the color detection board
0 stars 0 forks source link

Implement PWM measurement for the stm32f103xx #1

Open gbip opened 6 years ago

gbip commented 6 years ago

Our RGB sensor returns a PWM to indicate the color intensity.

We need a way to measure this PWM, either using a dedicated component and an adc, or using a timer in PWM measure mode.

To write the firmware of this board we need to have some kind of high-level interface with the timer. This is usually done through a Hardware Abstraction Library.

If you want to tackle this issue you have to

  1. Design an application interface (API) such that is idiomatic and user-friendly to configure a timer in PWM input mode
  2. Validate this API either with the embedded-hal team or the stm32f103xx-hal team by opening an issue in their repo with your API
  3. Upon validation, implement this API for the stm32f103 in the stm32f103xx-hal repository

A few tips and tricks for the API design :

dotsumae commented 6 years ago

I still beleive the TCS3200 color sensor outputs a square wave, and gives the color information by changing the frequency of the output, not its duty cycle. Source : this arduino tutorial I tried

gbip commented 6 years ago

Timer can also measure PWM frequency :wink: In fact they do both at once : they measure the frequency and the duty cycle.