Embedded/Arduino

아두이노(Arduino) Flex Sensor 2.2 (SEN-10264) 테스트

변화의 물결1 2024. 4. 20. 00:03

 

 

안녕하세요.

 

  휘어짐 정도를 확인해 볼 수 있는 센서를 테스트해 보도록 하겠습니다. 플렉스 센서라고도 하고 밴드 센서라고도 합니다. 구매하기 전에는 폴더처럼 확 접히면 어떻게 될까 궁금했는데, 테스트해 보면서 느낀 것은 그렇게 하면 고장 난다입니다.

 적당하게 휘어짐 정도를 확인할 수 있다고 보셔야 합니다. ^^

 


 

1. Flex/bend Sensor 원리

 

  A flex sensor is a kind of sensor which is used to measure the amount of defection otherwise bending. The designing of this sensor can be done by using materials like plastic and carbon. The carbon surface is arranged on a plastic strip as this strip is turned aside then the sensor’s resistance will be changed. Thus, it is also named a bend sensor. As its varying resistance can be directly proportional to the quantity of turn thus it can also be employed like a goniometer.

 

 

 

 

  센서의 한쪽면에는 전도성 입자가 들어 있는 폴리머 잉크가 프린트되어 있습니다. 센서가 평평할 때는 이 전도성 입자들이 약 30kΩ의 저항 값을 줍니다. 센서가 잉크에서 휘어지게 되면 입자들이 서로서로 떨어지게 되고 저항값을 증가(90도 정도 굽혔을 때 약 50kΩ-70kΩ) 시키게 되는 원리입니다.

[출처] 휨 검출 센서(Flex Sensor) 아두이노와 사용하기, 가치 창조

 

  실제 측정해 보니 제품마다 달라서 그런지 가만히 두었을 경우 34kΩ~38kΩ가 나왔고, 이렇게 저렇게 휘어보면 120kΩ이상이 나왔습니다.

 

 

2.  테스트 준비물

 

  저항 (10kΩ), 아두이노 나노, Flex Sensor, 점퍼 케이블 2개

  저항은 10kΩ~47kΩ 정도 가지고 있는 것을 사용하시면 됩니다. 테스트 당시 10kΩ을 가지고 있어서 사용했으며 소스 코드 상에서 조금 수정해주면 됩니다.

 

 

 

 

 3. 연결하기

  Flex Sensor는 극성이 없으므로 어느 방향으로도 연결하시면 됩니다.

 

 

 

 

4. 소스 확인

 

  Sparkfun 소스에서 휘어짐 각도 등이 정확하지는 않겠지만, 구부러지는 각도와 저항값을 계산해 주고 있습니다.

  - 좀 더 정확한 값을 원한다면 소스상 몇 가지 값을 회로에 맞게 수정해 줍니다.

    -- R_DIV 실제 장착한 저항 여기서는 10kΩ을 장착했으므로, 10,000 + 500 (5%)

    -- 평평하게 있을 때 저항값,  STRAIGHT_RESISTANCE = 37300.0; // resistance when straight

    -- 90도 휘었을 때 저항값,  const float BEND_RESISTANCE = 90000.0; // resistance at 90 deg

 

 

const int FLEX_PIN = A0; // Pin connected to voltage divider output

// Measure the voltage at 5V and the actual resistance of your
// 47k resistor, and enter them below:
const float VCC = 4.98; // Measured voltage of Ardunio 5V line
const float R_DIV = 10500;//47500.0; // Measured resistance of 3.3k resistor

// Upload the code, then try to adjust these values to more
// accurately calculate bend degree.
const float STRAIGHT_RESISTANCE = 37300.0; // resistance when straight
const float BEND_RESISTANCE = 90000.0; // resistance at 90 deg

void setup() 
{
  Serial.begin(9600);
  pinMode(FLEX_PIN, INPUT);
}

void loop() 
{
  // Read the ADC, and calculate voltage and resistance from it
  int flexADC = analogRead(FLEX_PIN);
  float flexV = flexADC * VCC / 1023.0;
  float flexR = R_DIV * (VCC / flexV - 1.0);
  Serial.println("Resistance: " + String(flexR) + " ohms");

  // Use the calculated resistance to estimate the sensor's
  // bend angle:
  float angle = map(flexR, STRAIGHT_RESISTANCE, BEND_RESISTANCE,
                   0, 90.0);
  Serial.println("Bend: " + String(angle) + " degrees");
  Serial.println();

  delay(500);
}

 

 

  아니면 간단하게 RAW 값을 받아서 출력해서 사용합니다. 평평할 때 기준으로 앞뒤로 휘어질 때 값이 나옵니다.

//Constants:
const int flexPin = A0; //pin A0 to read analog input

//Variables:
int value; //save analog value

void setup(){
  pinMode(ledPin, OUTPUT);  //Set pin 3 as 'output'
  Serial.begin(9600);       //Begin serial communication
}

void loop(){
  value = analogRead(flexPin);         //Read and save analog value from potentiometer
  Serial.println(value);               //Print value
  delay(100);                          //Small delay
}

 

 

5. 동작 확인

 

  끝에서만 구부려도 값이 크게 변하기도 하기 때문에  중간 마디에서 구부릴 때 값과 휘어지는 정도 값이 조금씩 달라서 사용 시 어떤 부분에서 휘어지는 값을 사용할지 생각해서 보정을 해주어야 하지 않을까 합니다.

 

  많이 휘어져서 끊어지지는 않는 것 같지만 접힐 정도로 구부리면 플라스틱 재질이라 원상복구가 어렵습니다. 폴더처럼 접어서 사용하겠다고 생각하시면 무리가 있습니다.

 

 

 

 

 

감사합니다.

 

 

<참고사이트>

1. 휨 검출 센서(Flex Sensor) 아두이노와 사용하기

https://blog.naver.com/ubicomputing/220736703838

2. Flex Sensor Working and Its Applications

https://www.elprocus.com/flex-sensor-working-and-its-applications/

3. How to use a Flex Sensor

https://www.ardumotive.com/how-to-use-a-flex-sensor-en.html

4. Flex Sensor Hookup Guide

https://learn.sparkfun.com/tutorials/flex-sensor-hookup-guide/introduction  

반응형