Rc Control IBT 2 Control

Afternoon All,

Been trying to build a linear drive unit from a Radio Control input for a project I’m working on.

Had a search on here but could find want i looking for but sorry if it’s already been asked.
Not sure if the IBT 2 is damaged or if it something in the code.

the unit powered of a 6v battery and then 5 v from the arduino.

here is the basic’s of the project.

#include <EnableInterrupt.h>
#define SERIAL_PORT_SPEED 57600
#define RC_NUM_CHANNELS 1 
#define RC_CH1 0
#define RC_CH1_INPUT A0 
#define EE 2 // enable pin on ibt 2 forward
#define EF 4// enable pin on ibt 2 reverse
#define ME 3 //motor forward 
#define MF 5 // motor reverse
#define LE 6 //limit switch empty currently not used
#define LF 7 //limit switch full 

uint16_t rc_values[RC_NUM_CHANNELS];
uint32_t rc_start[RC_NUM_CHANNELS];
volatile uint16_t rc_shared[RC_NUM_CHANNELS];
//------------------------------------------------------------

void rc_read_values() {
  noInterrupts();
  memcpy(rc_values, (const void *)rc_shared, sizeof(rc_shared));
  interrupts();
}

void calc_input(uint8_t channel, uint8_t input_pin) {
  if (digitalRead(input_pin) == HIGH) {
    rc_start[channel] = micros();
  } else {
    uint16_t rc_compare = (uint16_t)(micros() - rc_start[channel]);
    rc_shared[channel] = rc_compare;
  }
}

void calc_ch1() {
  calc_input(RC_CH1, RC_CH1_INPUT);
}


void setup() {
  Serial.begin(SERIAL_PORT_SPEED);

  pinMode(RC_CH1_INPUT, INPUT); // rc input
  enableInterrupt(RC_CH1_INPUT, calc_ch1, CHANGE);
 // pinMode(LE, INPUT_PULLUP);
 // pinMode (LF,INPUT_PULLUP);
 pinMode(EE, OUTPUT);
 pinMode(EF, OUTPUT);
 pinMode(ME, OUTPUT);
 pinMode(MF, OUTPUT);
 pinMode(LE, INPUT);
 pinMode(LF, INPUT);
  }

void loop() {
  rc_read_values();
 
 {
  if (rc_values[RC_CH1] < 1350)  //// Tank Empty
analogWrite(ME, 255);
analogWrite(MF, 0);
digitalWrite(EF, LOW);
digitalWrite(EE, HIGH);
 
  }
  {
    if ((rc_values[RC_CH1] > 1300) && (rc_values[RC_CH1] < 1750))// Stop Tank
    analogWrite(ME, 0);
    analogWrite(MF, 0);
    digitalWrite(EF, LOW);
    digitalWrite(EE, LOW);
   }
     {
      if (rc_values[RC_CH1] > 1800) //Fill tank
      analogWrite(MF, 255);
      analogWrite(ME, 0);
      digitalWrite(EF, HIGH);
      digitalWrite(EE, LOW);
        }  
          

}

many thanks

You haven't provided links to the datasheets for the hardware you mention, you're much
more likely to get useful answers if you provide full information up-front about the
devices you have.

What MarkT said plus...

Is there a question in your post? You mention the possibility of broken components or bad code. Is there something that you see that leads you to this possibility?

A good way to describe poor behavior of a project like this is to:

  • Describe what you expected to happen
  • Describe what actually happened
  • Explain how those two differ

Thanks vinceherman and MarkT,

Sorry thought i had but this info in the post, Was rushing.

This is the motor controller board.

What I’m trying to do is,

when RC Model Transmitter stick it at the top or bottom, the motor will turn one way or the other and in the middle it stops the moter.

this is to work a pistion tank on my rc submarine.
Noramlly this code has worked great on other projects but can’t figure out why is not on this one.

At the moment, once i go to to the top >1800 ms or less than 1300ms nothing happens,
so not sure if its the BTS7960 board is damage or I’ve got a error in the code.
I’ve tested it and its reading the input from recevier fine and can see it changing value correctly.
one thing i did notice was the capistor on the board has a dent on the top.
one thing that might make sence to test is conect up a led to both the enable pins and too motor pins to confirm the ardunio / code is working as excepted ?

hope this make sense.

Cheers

Tim

What values is your arduino receiving?

Why the Arduino ? Why not just drive the cylinder with a servo , or mount a pot on your actuator and use the internals of a normal servo , via a H bridge, to drive the motor and connected to the pot