Show Posts
Pages: [1] 2 3 ... 5
1  Community / Exhibition / Gallery / Re: Futaba SBUS reverse engineered to work with Arduino on: April 20, 2013, 06:11:21 pm
Thanks Mike.

So should the code you have posted above still use the FUTABA_SBUS.h library?

I haven't used the map function before, so should the variables in_min & in_max be the expected PWM frequencies such as 1023 for example from the Rx?

I think I can work my code, I'm just trying to understand how the S_Bus channels are defined etc.

Could you expand a little more please :-)

Thanks again Mike,

Steve
2  Community / Exhibition / Gallery / Re: Futaba SBUS reverse engineered to work with Arduino on: April 18, 2013, 08:08:07 am
Michael,

Thank you so much for your detailed response, its really appreciated.

I always seem to jump straight into the deep end.

Is there a reason the code will not run on a ATMega328 Pro Mini?

I have posted my code below to hopefully give you an idea of what I am trying to achieve.  Instead of using the normal output from my RC receiver, I would like to adapt the code to use the S-BUS instead and thereby freeing up at least one of the normal Rx channels.

You will see from the code below that if the PWM input is detected between certain frequencies, then it outputs accordingly, in this case utilising an IR Led.

In addition, I would like to use another S-Bus channel for the Arduino to switch on landing lights for example if again a switch on the Tx is 'on'.  Chances are I won't need it to control servos, just some auxiliary devices.

So my need is not to generate a PWM signal from the Arduino, but to interpret the S-BUS signal and have set routines depending on the channel input.

Hope that makes sense and thank you again for your assistance.

Steve
Code:
#include <multiCameraIrControl.h>

int x=50, y=300, z=100;
int ledPin = 13;
int IRPin = 2;
int RxInput = A0;
int pic_pause = 5000;
Sony Nex5(IRPin);

void setup()
{
Serial.begin(9600);      //
  pinMode (IRPin, OUTPUT);  // Output pin for IR LED
  pinMode (RxInput, INPUT);    // Input pin for PWM from Rx
}

void loop () {
z = pulseIn(RxInput, HIGH, 20000);
if (z<1400) {
  digitalWrite(IRPin, 0);
  Serial.println(z);
  delay(y); 
  }
//if (z>1401 && z<1599) {

  if (z>1155 && z<1170) {
    digitalWrite(IRPin, 1);
    Nex5.shutterNow();
  //  Nex5.shutterDelayed();
  //  delay(500);
    digitalWrite(IRPin, 0);
    Serial.println(z);
  //  delay(y);
    }
 
  if (z>1780 && z<1820) {
    digitalWrite(IRPin, 1);
    Nex5.shutterNow();
  //  delay(500);
    digitalWrite(IRPin, 0);
    Serial.println(z);
    delay(pic_pause);
    }

  if (z>1430 && z<1500) {
    digitalWrite(IRPin, 1);
    Nex5.toggleVideo();
    delay(500);
    digitalWrite(IRPin, 0);
    Serial.println(z);
  //  delay(y);
    }
 
  if (z>1600)   { 
    digitalWrite(IRPin, 1); delay (x); digitalWrite(IRPin, 0); delay (x);
    digitalWrite(IRPin, 1); delay (x); digitalWrite(IRPin, 0); delay (x);
    delay(y);
    Serial.println(z);
    }
  }
3  Community / Exhibition / Gallery / Re: Futaba SBUS reverse engineered to work with Arduino on: April 17, 2013, 11:12:08 am
Thanks Mike.

Sorry, you're right, I wasn't very clear.

Basically I have a Futaba R6208SB S-BUS receiver which I am using on a multi-rotor.

I have one of the outputs from this receiver going to an Arduino MiniPro which is programmed to detect the PWM signal and use an IR LED to control a Sony NEX5 camera.  This works very will and I can switch the camera modes between video and stills and take manual or automatic interval pictures.

As this is connected to one of the main outputs of the Rx and I have a Futaba 14 channel Tx (T8FG), I would like to move auxiliary functions such as this to the S-Bus.

So the code on the MiniPro will read the S-BUS and perform a function (either servo based or logic based) on say 4 channels.

I know this device (FUTM4191 SBD-1 S.Bus Decoder) is available to decode the S-Bus signal to PWM, however I would still need the MiniPro to perform certain functions, so I was looking at cutting out the middle man if possible.

http://www.futaba-rc.com/sbus/

I would need to define the channel on the MiniPro which corresponds to the channel on the Tx, for example channels 9 - 12.

Does that make sense or have I made it worse :-D

Steve
4  Using Arduino / Programming Questions / Re: How to program APM 2 board to read Futaba R6014HS Receiver Signal on: April 17, 2013, 11:00:14 am
I think your best bet is to post this on the http://diydrones.com/ forum as it is more specific to the ArduCopter APM.

The APM should already be programmed for the receiver and you will need to download the MissionPlanner to calibrate the APM once it is connected to USB.

Hope that helps a little.

Steve
5  Community / Exhibition / Gallery / Re: Futaba SBUS reverse engineered to work with Arduino on: March 18, 2013, 02:32:33 pm
Fantastic work on this Mike  smiley-cool

I have a Futaba 14 channel transmitter (T8FG) with the R6208SB S-BUS receiver.

I would like to use the S-BUS channel to control 4 PPM outputs via the Arduino.  Just probably simple switched outputs not servos at all.

One appplication is two create a different output depending on the PMM input range from the transmitter.

Is it possible to use your code for this 4 channel application, or is it designed for just one channel.

Many thanks and great work again.

Steve
6  Using Arduino / Networking, Protocols, and Devices / Helium Balloon GPS & RTTY on: December 28, 2012, 01:26:47 pm
A friend and I are trying to launch a Helium balloon using the Arduino as the flight computer and transmitting its GPS coordinates back to earth via RTTY.

The code sort of works, but after sometimes 30 transmissions, the they seem to "lock" and the same GPS coordinates are transmitted each time.

I'm not sure if it is a buffer issue, but i am now stuck.

The GPS receiver works fine and talks to the Arduino via the hardware Tx / Rx.

Can anyone cast their eye over the code and see if there is any obvious mistakes please.

Unfortunately the code is too long to post here :-(

Many thanks,
7  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: November 19, 2012, 04:51:27 pm
Thanks for taking time to reply Marco, it's appreciated.

I've reduced the timeout as suggested and also it would appear the serial.begin command was causing an issue.  All works now, well, sort of ;-)......

Is there a way that you know of to keep the LEDs flashing whilst the Arduino performs another function.

At the moment when the pulseIn command is between the preset values and it goes off and calls another command, obviously this stops the LED pattern.

It's essentially an IR remote for a Sony Camera on a drone helicopter.  So I want the LED pattern to continue whilst the camera functions are being actioned.

Do you know of a way I can achieve this?

I can post the entire code if necessary, but its just a small sequence to flash an IR LED at different rates depending on what is being called.

Thank you again for your help :-)
8  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: November 17, 2012, 10:29:31 am
Anyone able to assist in the above please.

I'm trying to maintain the blinking LEDs, but also respond to a PWM input by activating an infrared LED for an IR remote.

I think i'm getting the "multitasking" bit round my neck!
9  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: November 07, 2012, 05:56:41 am
Having got the LED pattern working (and huge thanks to Marco), I wanted to add a little more hardware to the Arduino.

I wanted to add a little more code that listens to one of the pins for various PWM signals and if they are within a certain range, action by calling a subroutine.

However it seems to lock out some of the LED patterns.  I essentially want to the LED pattern to continue if that is possible ?

Can anyone suggest where I have gone wrong please ?

Code:
#include "Multi_Blink2.h"  // type definitions
#include <multiCameraIrControl.h>

Sony Nex5(9);
int z=100;

// Blink Table T - Modify this table to suit whatever the output requirements are
// Add or delete lines as required to achieve the desired effects.
// To add additional states the structure in the header file needs to be modified
//
ledTable  T[] =
//Pin  St Lopp  State 0          State 1            State 2          State 3         State 4          Wkup
{

  { 11, 0, 0, {{MB_LOW, 1500, 0}, {MB_HIGH, 35, 0}}, 0 },  //
  { 0, 0, 0, {{MB_HIGH, 20, 0}, {MB_LOW, 50, 0}, {MB_LOOP, 3, 0}, {MB_HIGH, 250, 0}, {MB_LOW, 450, 0}}, 0 },  //
  { 1, 0, 0, {{MB_HIGH, 20, 0}, {MB_LOW, 50, 0}, {MB_LOOP, 3, 0}, {MB_HIGH, 250, 0}, {MB_LOW, 450, 0}}, 0 },  //
  { 5, 0, 0, {{MB_LOW, 450, 0}, {MB_HIGH, 20, 0}, {MB_LOW, 50, 0}, {MB_LOOP, 3, 1}, {MB_HIGH, 250, 0}}, 0 },  //
  { 7, 0, 0, {{MB_LOW, 450, 0}, {MB_HIGH, 20, 0}, {MB_LOW, 50, 0}, {MB_LOOP, 3, 1}, {MB_HIGH, 250, 0}}, 0 },  //
  { 2, 0, 0, {{MB_HIGH, 35, 0}, {MB_LOW, 1500, 0}}, 0 }, 
 
};

// Self adjusting constants for loop indexes
#define  MAX_STATE  (sizeof(T[0].state)/sizeof(stateDef))
#define  MAX_LED    (sizeof(T)/sizeof(ledTable))

#define FADE_IN 0
#define FULL_BRIGHT 1
#define FADE_OUT 2

#define FADE_DELAY 45 //ms
#define FULL_DELAY 70 //ms

#define FRONT_LED 11

#define FADE_MAX 30 // max PWM value
#define FADE_MIN 1

void setup()
{
  Serial.begin(9600);      // Debug via serial window
  delay (2500);
  pinMode(FRONT_LED, OUTPUT);
  pinMode (11, OUTPUT);    // On board status LED
  pinMode(A0, INPUT);      // RC PMM Signal input
//  pinMode(LED_PIN2, OUTPUT);
 
  for (int i=0; i < MAX_LED; i++)
  {
    pinMode(T[i].ledPin, OUTPUT);
   
    T[i].nextWakeup = 0;
    digitalWrite(T[i].ledPin, LOW);
    T[i].currentLoop = LOOP_UNDEF;
  }
}

void loop()
{
  z = pulseIn(A0, HIGH, 20000);

if (z>1155 && z<1170) {
  Nex5.shutterNow();
  }
 
if (z>1780 && z<1820) {
  Nex5.shutterNow();
  delay(1500);
  }

if (z>1430 && z<1500) {
  Nex5.videoToggle();
  delay(500);
  } 

  for (int i=0; i < MAX_LED; i++)
  {
    // check if the state active time has expired (ie, it is less than current time)
    if (millis() >= T[i].nextWakeup)
    {
      T[i].nextWakeup = millis() + T[i].state[T[i].currentState].activeTime;

      switch (T[i].state[T[i].currentState].activeVal)
      {
        case MB_LOW:
        case MB_HIGH:    // Write digital value
          digitalWrite(T[i].ledPin, T[i].state[T[i].currentState].activeVal == MB_HIGH ? HIGH : LOW);
          T[i].currentState = (++T[i].currentState) % MAX_STATE;
          break;
         
        case MB_LOOP:  // loop back to specified state if there is still count left
          // first time in this state set the loop counter
          if (T[i].currentLoop == LOOP_UNDEF)
          {
            T[i].currentLoop = T[i].state[T[i].currentState].activeTime;
          }

          // loop around or keep going?         
          if (T[i].currentLoop-- > 0)
          {
            T[i].currentState = T[i].state[T[i].currentState].nextState;
            T[i].nextWakeup = 0;  // do it immediately
          }
          else
          {
            T[i].currentLoop = LOOP_UNDEF; // set up loop counter
            T[i].currentState = (++T[i].currentState) % MAX_STATE;
          }
          break; 
         
        default:  // just move on - handles NULL and any stupid states we may get into
          T[i].currentState = (++T[i].currentState) % MAX_STATE;
          break;
      }
    }
  }
}


10  Using Arduino / Displays / Re: ITDB02 + Shield 2.0 = Touch not working on: October 17, 2012, 07:09:06 pm
Thanks ever so much Guix, it has been solved by generating an additional character in the font.

To make it easier for others that may come across this, I have linked to the ammended DefaultFonts.c file leaving the original font in tact.  Just change the font name in your main code from 'SevenSegNumFont' to 'SevenSegNumFontSpace'.  

http://www.networkedsolutions.co.uk/arduino/DefaultFonts.c

Thanks again for your help and guidance smiley

11  Using Arduino / Displays / Re: ITDB02 + Shield 2.0 = Touch not working on: October 17, 2012, 03:57:09 pm
Many thanks for the reply.

I was using the ITDB02_Graph16 library where I am now using the latest UTFT library.

I do however, seem to be experiencing some artifacts left behind when the numbers shrink from 3 characters to 2 for example.

It can be seen here:



Full code:

Code:
#include <UTFT.h>
//#include <ITDB02_Graph16.h>
#include <ITDB02_Touch.h>


// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];


//myGLCD(RS,WR,CS,RST,ALE,mode);
UTFT myGLCD(ITDB32S,A1,A2,A0,A3,A5);    // Remember to change the model parameter to suit your display module!
//ITDB02 myGLCD(A1,A2,A0,A3,A5,ITDB32S);
//myTouch(TCLK,TCS,DIN,DOUT,IRQ);
ITDB02_Touch  myTouch(13,10,11,12,A4);


void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
 
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.drawLine(0, 14, 319, 14);
  myGLCD.print("S.TISSEYRE - 2012", CENTER, 1);
  myGLCD.setBackColor(0, 0, 0);

  myGLCD.setColor(0, 255, 0);
  myGLCD.setFont(SevenSegNumFont);
}

void loop()
{
  while (myTouch.dataAvailable() == true)
    {
      int x,y;
      x = myTouch.getX();
      y = myTouch.getY();
      myGLCD.printNumI(x, CENTER, 50, 1, ' ');
      myGLCD.printNumI(y, CENTER, 120, 3);
            myTouch.read();

    }
}
12  Using Arduino / Displays / Re: ITDB02 + Shield 2.0 = Touch not working on: October 17, 2012, 01:09:37 pm
Having just bought a similar touch screen LCD, how do you stop old number staying on screen when refreshed with a new number.

For example if you are going from a 3 digit number to a 2 digit number, you can still see some of the old number behind.

Hope that makes sense smiley
13  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: September 06, 2012, 03:11:32 pm
Sorry to be pop up again, I wanted to add another LED onto another PMW pin, such as IO3.

The below code works, but is this method the most efficient to achieve the same PWM pattern on 2 IO pins ?

Many thanks for your help,

Code:
#define FADE_IN 0
#define FULL_BRIGHT 1
#define FADE_OUT 2

#define FADE_DELAY 45 //ms
#define FULL_DELAY 70 //ms

#define LED_PIN1 5
#define LED_PIN2 3

#define FADE_MAX 30 // max PWM value
#define FADE_MIN 1

Void Beacon()
{
  static uint32_t nextWakeup = 0;
  static uint8_t currentState = FADE_IN;
  static uint8_t fadeValue1 = FADE_MIN;
  static uint8_t fadeValue2 = FADE_MIN; 

  if (millis() <= nextWakeup)
    return;  // do nothing as time has not expired

  switch (currentState)
  {
    case FADE_IN:
      analogWrite(LED_PIN1, fadeValue1++);
      analogWrite(LED_PIN2, fadeValue2++);     
       if (fadeValue1 >= FADE_MAX)
      {
        currentState = FULL_BRIGHT;
        fadeValue1 = FADE_MAX;
      }
       if (fadeValue2 >= FADE_MAX)
      {
        currentState = FULL_BRIGHT;
        fadeValue2 = FADE_MAX;
      }     
      nextWakeup = millis() + FADE_DELAY;
    break;

    case FULL_BRIGHT:
      digitalWrite(LED_PIN1, HIGH);
      digitalWrite(LED_PIN2, HIGH);     
       currentState = FADE_OUT;
      nextWakeup = millis() + FULL_DELAY;
    break;

    case FADE_OUT:
      analogWrite(LED_PIN1, fadeValue1--);
      analogWrite(LED_PIN2, fadeValue2--);     
       if (fadeValue1 <= FADE_MIN)
      {
        currentState = FADE_IN;
fadeValue1 = FADE_MIN;
      }
       if (fadeValue2 <= FADE_MIN)
      {
        currentState = FADE_IN;
fadeValue2 = FADE_MIN;
      }
     
      nextWakeup = millis() + FADE_DELAY;
    break;

    default: // error catch all - restart the sequence
      currentState = FADE_IN;
      fadeValue1 = FADE_MIN;
      fadeValue2 = FADE_MIN;     
    break;
  }
  return;
}
14  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: September 05, 2012, 04:01:20 pm
Spot on, I obvioulsy included your code as soon as you posted it and didn't realise it had been changed.

Thanks very much, does exactly what i want and looks very cool smiley
15  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: September 05, 2012, 09:42:51 am
I thought that would be the case but wanted to check as the beacon LED just illuminates and stays on without any dimming.

Any ideas please.

Kind regards,

Steve
Pages: [1] 2 3 ... 5