Problems with R/C 6ch transmission

So, if i have understand you well, for use mode variable, the gMode is a variable that I must declare before setup or is something that I can use becouse the library have it.
And when I use if stament I understand that I am allowing to read and copy, but when I am out the flags from rc control will change but the arduino don´t go becouse gMode != RC_CONTROL but Will I need to change gMode to oder value in the code,not? which value/state is this??

You have the idea mostly right.

You mentioned that you have a menu and in two menu options you want RC Control - you could represent each of your menu options as a mode - MODE_MANUAL, MODE_RC_NORMAL, MODE_RC_XXX etc

Then you can have a 'switch case' statement inside loop which does different things depending on the value of gMode -

switch(gMode)
{
 case MODE_MANUAL:
  // put your manual control code here
 break;
 case MODE_RC_NORMAL:
  // put your manual control code here
 break;
 case MODE_RC_XXX:
  // put your manual control code here
 break;
}

If you modes are very different, one way that I have done this in the past is to have the code I want for each mode in a separate function -

switch(gMode)
{
 case MODE_MANUAL:
  doModeManual();
  break;
 case MODE_RC_NORMAL:
  doModeRCNormal();
 break;
 case MODE_RC_XXX:
 doModeRCXXX();
 break;
 // etc etc etc
}

This might also help - http://www.arduino.cc/en/Reference/SwitchCase

Duane B

rcarduino.blogspot.com

Yes,i have use switch/case stament for built the menus, and the thing is gMode tath is a variable that i don´t need to define becouse is created by library which values can take( mode_manual,mode_rc,rc_control....)

do you know what I mean?? where can I see the values that i can espect from gMode or i need to define the variable gmode and decide whitch values will contain... and in this case witch kind of variables are this?

Hi,
gMode was just a suggestion, its not in the library ,if you already have a switch/case set up with your modes, add the RC Code to the modes you need it in and leave it out of the others, thats enough to achieve what you want.

Duane B

sorry I am not understanding well, what kind of variable will be gMode(int,boolean...)?
becouse I am understanding that will be one that I can define the spected values (RC_MODE,NO_RC_MODE)

Thanks!!!

Hi,
Can you PM me your sketch so that I can make a suggestion based your current structure ?

Duane B

Good morning,
the sketch have 49 pages of code,i was looking in github and google proyect for upload there but it was a little dificult for me( i supposo that it will be easy like a dropbox or something like this....)
if you sendme one email to alehop@mononokeproducciones.com I´ll send you the .pde code.
i am using in this code:

1 arduino Mega 2560
1 4x3 matrix keypad
1 lcd
1 sd21 servo controller
3 thumb joystick (6 potentiometers)
8 buttoms
1 udrive microSDcard (2gb uSD card)
1 RGB led

and now I am changuin to only 1 thumb joystick and 5 buttoms and 6 chanels r/c control.

the structure is:

one menu with 3 posibilities:

PLAY
REC
Config

and inside of this posibilities you have more posibilioties:

Play:

play from memory,
play from the joysticks
and now i want to add here another posibility from RC

Record:

record move (here I need to add the rc control too)
record a secuence of pre recorder movement
erase movement
erase secuence

config:
Format sd card
calibrate joystick

I explain all this becouse went I send you the code you will see that is uncoment, only have comment for me and in spanish...
When I finnish I want to document it in a blog but now... is a little unreadable... sorry

For this reason I only need that arduino hear the RC control in two moments.what i am thinkin is the gMode variable for me only have two posibilities so it is a boolean variable,but how can i create one tath have more posibilities(Manual,RC1,RC",RC)

thanks for your interest!!!!!

Hi,
This weekend I was studying the diference between a class,a structure,and another posibility that is only define a int variable(gMode), and define no_RC =0;RC1=1;RC2=2.....;
and I could use Mode names.
But the thing is allways the calc rutine will be stopping for do the micro second pulse count independently if this is needed or not, so I would try to implement all together and see what happend if I have problems I should try to use detachInterrupt;and see how many times I can use before arduino´s memory is full,and when this happend make a reset.

A better approach is to disable the interrupts at a hardware level.

I have been busy getting two blog posts and videos out this weekend but will get to modes and switching the signal source in a day or two.

I will suggest the ability to temporarily enable and disable interrupts on specific pins to the pin change int guys, if they are not keen i will add it as n externala helper class.

Duane B

When you say disable the interrupt at a hardware level, you mean that power off the transmitter no?? only when you are inside of the rc_mode power on.

Duane I want to understand better how to work with class, do you recomend me some thing for read or see??? becouse I was reading the book beguining with processing but i think the classes in arduino are a little bit diferent.

thanks!!!!

Hi, no transistors, the arduino has a set of registers which enable or disable each pin for generating pin change interrupts. If you disable the interrupt at this level you can leave interrupts attached and disable specific pins until you need them. You can then enable/disable as often as you want with no overhead when they are not in use and no memory leaks from attach/detach

Im in Ethiopia today so no time to dig out the register names.

Duane B

Hi,

Here is a link to the thread where we have been disussing the problem with using detach in pinchangeint. As you can see greygnome has confirmed the issue and is planning to add support for the enable/disable mechanism i suggested as a fix.

http://arduino.cc/forum/index.php/topic,87195.0.html

Duane B

rcarduino.blogspot.com