- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
最近、めっきりセンサ・ハンターと化している私の為に知人が面白いセンサを見つけたよと知らせてくれました。
少し前に AK9750 という赤外線を使用したリモートセンサのプロジェクトを作成してみましたが、
今回はタッチエンスというメーカーから出されているタッチエンス・ショッカクポットという触覚センサを動かしてみました。
タッチエンス・ショッカクポット POTU−001−1: センサ一般 秋月電子通商-電子部品・ネット通販
As recently, I've been quite busy hunting new sensors, my friend found a new one.
A little ago I tried AK9750, which is an IR remote sensor, but this time it's a touch motion sensor,
named Shockaku Pot.
タッチエンス・ショッカクポット POTU−001−1: センサ一般 秋月電子通商-電子部品・ネット通販
このセンサはホストと UART で通信を行います。
PSoC Creator の回路図はこんな感じになります。
This sensor communicate with the host via UART.
So the schematic is something like below.
MCU基板としては CY8CKIT-044 を使用しました。
ピンアサインは以下のようにしました。
Using CY8CKIT-044 as the host, pin assignment is like below.
Tera Term の画面は下記のようになります。
Tera Term log follows.
プニプニとスポンジをいじるとセンサの値が変わるのが新感覚のセンサですね。
ゲームのコントローラ的な用途やロボット的なアプリケーションでのユーザーインターフェースなどに
使えるのではないでしょうか?
後、手を放すと割と正確にセンター(0, 0, 0, 0) に戻るのが印象的でした。
The texture of sponge gives us somewhat new user experience.
I think that this could be used for a controller of a game machine or human interface of a robot like application.
I was also impressed that the sensor values returns to (0, 0, 0, 0) when I released my finger.
main.c
===============
#include "project.h"
#include "stdio.h"
#include "vt100.h"
#define SENSOR_PACKET_SIZE 8
uint8_t rx_buf[16] ; /* packet is 8 bytes */
int rx_index = 0 ;
int packet_received = 0 ;
char str[128] ; /* print buffer */
CY_ISR(shockaku_isr)
{
sensor_int_ClearPending() ;
SHOCKAKU_ClearRxInterruptSource(SHOCKAKU_INTR_RX_NOT_EMPTY) ;
if (SHOCKAKU_SpiUartGetRxBufferSize()) {
rx_buf[rx_index++] = SHOCKAKU_UartGetByte() ;
if (rx_index > SENSOR_PACKET_SIZE) {
sensor_int_Disable() ;
packet_received = 1 ;
}
}
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
Sensor_Reset_Write(0) ;
CyDelay(500) ;
Sensor_Reset_Write(1) ;
CyDelay(500) ;
UART_Start() ;
sensor_int_ClearPending() ;
sensor_int_StartEx(shockaku_isr) ;
SHOCKAKU_Start() ;
}
void measure(void)
{
SHOCKAKU_UartPutChar(0x6d) ;
}
void get_data(uint16_t ch[])
{
ch[0] = ((rx_buf[0] << 😎 | rx_buf[1]) & 0x3FF ;
ch[3] = ((rx_buf[2] << 😎 | rx_buf[3]) & 0x3FF ;
ch[1] = ((rx_buf[4] << 😎 | rx_buf[5]) & 0x3FF ;
ch[2] = ((rx_buf[6] << 😎 | rx_buf[7]) & 0x3FF ;
}
void print_data(uint16_t ch[])
{
locate(20, 3) ;
sprintf(str, "%6d %6d %6d %6d", ch[0], ch[1], ch[2], ch[3]) ;
print(str) ;
}
void plot_data(uint16_t ir_data[])
{
static int prev_x = 30, prev_y = 13 ;
int x, y ;
int radius_x, radius_y ;
int center_x, center_y ;
center_x = 30 ;
center_y = 14 ;
radius_x = 20 ;
radius_y = 8 ;
sprintf(str, "%4d", ir_data[0]) ;
put_str(center_x, center_y - radius_y, str) ;
sprintf(str, "%4d", ir_data[1]) ;
put_str(center_x - radius_x, center_y, str) ;
sprintf(str, "%4d", ir_data[2]) ;
put_str(center_x, center_y + radius_y, str) ;
sprintf(str, "%4d", ir_data[3]) ;
put_str(center_x + radius_x, center_y, str) ;
if ((ir_data[0] == 0) && (ir_data[2] == 0)) {
y = center_y ;
} else {
y = center_y + (radius_y * (ir_data[0] - ir_data[2])) / (ir_data[0] + ir_data[2]) ;
}
if (y > (center_y + radius_y)) { y = center_y + radius_y ; }
if (y < (center_y - radius_y)) { y = center_y - radius_y ; }
if ((ir_data[1] == 0) && (ir_data[3] == 0)) {
x = center_x + 3;
} else {
x = center_x + (radius_x * (ir_data[3] - ir_data[1])) / (ir_data[1] + ir_data[3]) ;
}
if (x > (center_x + radius_x)) { x = center_x + radius_x ; }
if (x < (center_x - radius_x)) { x = center_x - radius_x ; }
put_char(prev_x, prev_y, ' ') ;
put_char(x, y, '*') ;
prev_x = x ;
prev_y = y ;
locate(1, 20) ;
}
void splash(void)
{
cls() ;
locate(20, 1) ;
sprintf(str, "Shockaku Sensor Test (%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
locate(24, 2) ;
sprintf(str, "ch1 ch2 ch3 ch4") ;
print(str) ;
}
int main(void)
{
uint16_t ch[4] ;
init_hardware() ;
splash() ;
for(;;) {
measure() ;
if (packet_received) {
get_data(ch) ;
print_data(ch) ;
plot_data(ch) ;
packet_received = 0 ;
rx_index = 0 ;
SHOCKAKU_SpiUartClearRxBuffer() ;
sensor_int_Enable() ;
CyDelay(100) ;
measure() ;
}
CyDelay(100) ;
}
}
===============
moto
- Labels:
-
PSoC 345 LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note: Although the power of this sensor is 5V, it's I/O is 3.3V.
So please set J-9 of CY8CKIT-044 to 3.3V mode (1-2 short)
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
本サンプルは CQ出版 インターフェース 2019年11月号に
ふえる今どきセンサNote
その20 3次元方向の変位を検出できる触覚センサ「ショッカクポット」
として掲載されました。
I contributed this sample project to a Japanese technical magazine
"Interface" Nov/2019 edition.
moto