Rawcoco

From SGMK-SSAM-WIKI
Jump to: navigation, search

Overview

A capacitive touch sensing USB device.

A 32-bit version/descendant of the Cocomake7.

A work in progress prototype to learn more about ARM dev, STM32 peripherals and compare results with the AVR and teensy based versions.

The goal is to make a versatile, affordable and playful interface device, that can be used as a creative basis for interactive (non-usb) playthings, DIY projects and electronics/interaction/game dev workshops.

Hardware (Electronics)

General Notes

Microcontroller:

  • STM32F042F6P6
  • Crystal-less USB with integrated USB (fullspeed) PHY
  • Capacitive touch sensing peripheral
  • Cost: ~$2 on Aliexpress (Chips Store)


Revision 0.03(/0.04)

A test PCB with 6 touch pads lined up in a row. Easy to breakout, by cutting the PCB traces...

No USB (ESD) protection, no line termination resistors (D+/-), no filtering, optimized for simplicity, size and cost.

Features

  • 6 touchpads
  • micro USB port
  • debug LED
  • I2C / SWD connector

Circuit

Rawcoco rev0.04 schematics 2016-03-27.png

BOM

Reference	Value		Digikey				Comment		Count	Unit Cost	SUM

rawcoco:U1	STM32F042F6Px	STM32F042F6P6-ND		not available	1	1.48 EUR	1.48 EUR
rawcoco:U2	TLV70033DDCR	296-27937-1-ND					1	0.48 EUR	0.48 EUR
							
rawcoco:C1	100n		490-10777-1-ND					1	0.09 EUR	0.09 EUR
rawcoco:C8 C9	1u		490-6423-1-ND 					2	0.09 EUR	0.18 EUR
rawcoco:C10 C11	1n		490-6349-1-ND					2	0.09 EUR	0.18 EUR
							
rawcoco:D1	LED		511-1651-1-ND					1	0.41 EUR	0.41 EUR
							
rawcoco:R1	470R		CR0402-FX-4700GLFCT-ND 		470 Ohm		1	0.09 EUR	0.09 EUR
rawcoco:R7-R12	1k		R0402-FX-1001GLFCT-ND				6	0.09 EUR	0.54 EUR
							
rawcoco:CON1	1	1	WM17141CT-ND					1	0.91 EUR	0.91 EUR
							
rawcoco:K1 K2	CONN_3								2	0.00 EUR	0.00 EUR
rawcoco:P1 P2	CONN_4								2	0.00 EUR	0.00 EUR
rawcoco:P4-P6	CONN_1								3	0.00 EUR	0.00 EUR

								SUM		22			4.36 €

REMARK: That price is the actual price on DigiKey for all the parts on the PCB. It is obvious, that 41 cents for an LED is way too much, so that the price can probably be lowered to about 3 Euros. The MCU is certainly the most expensive part...


Digikey BOM (MCU not included):

1,296-27937-1-ND,rawcoco:U2
1,490-10777-1-ND,rawcoco:C1
2,490-6423-1-ND ,rawcoco:C8 C9
2,490-6349-1-ND,rawcoco:C10 C11
1,511-1651-1-ND,rawcoco:D1
1,CR0402-FX-4700GLFCT-ND ,rawcoco:R1
6,CR0402-FX-1001GLFCT-ND,rawcoco:R7-R12
1,WM17141CT-ND,rawcoco:CON1

Rawcoco rev0.01 DSCN0453b.JPG

PCB

Get it at: OSHPark

Rawcoco rev0.03 8db25feb4bdb9d79a32d1499c6479c02.png

Rawcoco rev0.03 7d0b0ff9e7c1d2c46295176494bc5194.png

Rawcoco rev0.03 5b5ea8a04a42be6a5e3fb8afb65494fe.png

Rawcoco rev0.03 A7e1a0047420d7dc076a6a2175629a03.png


KiCad project with gerbers. BOM spread sheet and schematics (rev0.04 but it's actually the same as rev0.03): rawcoco_rev0.04_local.zip

Pinouts

SWD Pinout (topview, USB plug on the left):

  • VDD
  • SWCLK
  • VSS
  • SWDIO

Rawcoco swd pinout.png


Touchpad (TSC) order (topview, USB plug on the left):

  • G1_IO4
  • G1_IO3
  • G1_IO2
  • G2_IO4
  • G2_IO3
  • G2_IO2

Rawcoco rev0.01 tsc pinout.png

Errata / Known Bugs

  • tie PB8 to ground -> BOOT0


Hardware (Enclosure)

Rawcoco case1 onshape.jpg

OnShape project

STLs: rawcoco_case1_2016-03-27.zip

Software

Currently used/evaluated tools and sources to get the board up and running:

  • Free tools for ARM development (gcc-none-eabi toolchain, OpenOCD)
  • STM32CubeMX and sample code by ST
  • Code::Blocks as an IDE

More notes are collected here...


USB HID Device

Status: Mouse, Keyboard, Gamepad HID devices are working.


The generated code from STM32CubeMX was helpful. Basically only the HID report descriptors had to be modified in order to get keyboard and gamepad recognized by the OS.

This tutorial was also quite insightful: http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/

The official doc USB HID as well: http://www.usb.org/developers/hidpage/HID1_11.pdf

The HID Descriptor Tool there comes with good examples and a validator plus exporter (header file...): http://www.usb.org/developers/hidpage/


Keyboard Test

This is the current test setup to send out keyboard keys from A-F. All six keys can be pressed at once... Funny, that the Keyboard HID descriptor can store six keys at max...

Current problem: The sensitivity of the keys and fine tuning of the TSC peripheral needs to be investigated more...

Rawcoco rev0.03 tsc test pads.jpg


Here's the still very messy test project (Code::Blocks with Makefile): rawcoco_cb_touchHID6_2016-03-27.zip

USB MIDI

Not working (yet). USB MIDI devices are more complicated to implement (USB Audio Device Class, MIDIstreaming)...

USB Serial (CDC)

Characters can be sent!


Notes

Remarks / Conclusions

The STM32's Touch Sensing Controller (TSC) peripheral can be handled without too much effort, and gives stable and fast measurements. A good explanation of the principles behind that charge transfer acquisition technique can be found in that presentation... Nicely explained. It can acquire multiple channels at the same time (not tested yet), and can be configured to run independently of the main program using interrupts. Also, pin mapping and code generation in STM32CubeMX is very useful. It should also be possible make a "device independent" library that can be used on different STM32s, that have a TSC built in...

STM32 tsc doc0.jpg

TODOs

  • USB MIDI (maybe)
  • Test multiplexing with 4051 to increase the number of touch channels.
  • Read more about tuning the clock settings and various parameters to tune the TSC.
  • Clean up code, throw unnessary things out. Make library...
  • Combine USB HID and Virtual Serial Port (CDC), and try to write a boot loader that reprograms the flash over USB serial.
  • Demos.

Info

Links

Various links...