Community
Search
Notices
RC Robotics and Autonomous Robots Discuss autonomous and radio control robots and anything related to robotics in here

converting air to electric retracts.

Thread Tools
 
Search this Thread
 
Old 01-16-2014, 03:38 PM
  #26  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike, I would use an arduino to control your retracts and the sequencing. The arduino motor controller only has two outputs to attach the retract motors. I have a main leg and the nose leg attached to one output and the other main leg attached to the other. In the code I write I higher motor cut out value for the output controlling two legs. With the arduino you will also be able to send a signal to operate the door sequence. Have a play with some arduino code. It will open up a whole new world off control for you.
Old 01-21-2014, 07:48 AM
  #27  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

Mustang, thanks for your input on using the Arduino to control electric retracts, I decided to bite the bullet and purchased the Arduino uno and shield, as I mentioned before this is all new to me and I am trying to get get my head around the code,(" I'm retired now and certain things take longer to grasp"). I am hoping that most of your code will work for my system,albeit somewhat different to your own in that your servo's which have feedback wires I believe are going to pin 7 and 4 to use as a signals from your door servo's.
I am not using servo's for the doors, I have small actuators I made to operate the doors, which work in the same way as the retracts do, ie two wires to power the motors with no signal wire, these would have to operate in the same way as the actual retracts, two wire motor control with over-current trip at end of travels, I was planning to operate the three retracts on one motor output on the shield,
with door actuators on the second output of the shield, with some adjustment in the code for the value of the current sensing for three motors in each of the two outputs. however
The confusion to me is, how can I send signals in the code, and what pins to use to send these signals, in your code, I believe you indicate pins 7 and 4 for signals from servo's to do this function.
I'm not sure what pins I need to use, or how to modify your code to allow me to use my door actuators in place of the servo's you are using which have signal wires, I would appreciate any help you can offer which would help me to set up the Arduino to suit this application.
Specs. for the units I have are:-
The motors for retracts :- pololu 1091 HP 30/1- gear ratio - 350 rpm @ 6v 70Ma free run current @ 6v with a stall current @ 6v 1500Ma 2o oz-in @ 6v
The motors for doors :- pololu 1093 HP 30/1- gear ratio - 1000 rpm @ 6v 120Ma free run current @ 6v with a stall current @ 6v 1600Ma 9 oz-in @ 6v


I chose these motors on the basis of torque required and the speed required for actuation.
ie:- retract speed - distance of threaded nut travel = (25 mm) - divided by seconds to retract ( 6 ) - divided by thread pitch of 4mm rod (0.75) - x seconds per min. (60) = 333 rpm motor speed @ 6 volts

ie:- door speed - distance of threaded nut travel = (25 mm) - divided by seconds for doors (3 ) - divided by thread pitch 3mm rod (0.50) - x seconds per min. (60) = 999 rpm motor speed @ 6 volts
The above suited my needs, however the distance of travel and the seconds to retract can be changed to suit individual requirements.
Hope you can help.
Mike

Last edited by freelander-rider; 01-21-2014 at 08:02 AM.
Old 01-21-2014, 09:06 AM
  #28  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike at first glance i can't see why using one output for gear doors and one for the retracts won"t work. sounds like a good plan. It's been a while since I wrote the code for this but it would be simple enough to edit it. Have you attempted to writ any code yourself yet? I started with a simple 'bread board' and a couple of LEDs from maplins and played with some of the tutorials by Massimo Banzi, he invented the thing. Take a look on you tube and search for Arduino tutorial Massimo Banzi. You need to get a handle on the basics so you can understand what the code is saying. Once you have that basic understanding you won't need my help to modify the code. Also you'll need to have a good understanding of the code because you'll need to play with the settings in the code once you start to operate the gear with G effects and wind resistance. Have a go and when I get a bit more time i'll take a look at it again myself for you. Don't forget to look at the you tube videos links I put up, they explain what pins do what..

Further thought on this, you won't need to worry about how long it takes for the gear doors to open or close. the code will need to be written to actuate the gear doors first, once those motors have have hit the end stops and shut down then the retracts can operate. once they hit end stops (overload) then the gear doors can close if required.

Mustang

Last edited by mustang493; 01-21-2014 at 09:44 AM.
Old 01-23-2014, 01:46 PM
  #29  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

hi Mustang,
Thank you for your replies, I am starting to figure out parts of the code for Arduino and research with the constants and function to familiarise myself with the code words used, and the actions they can command when applying them within a code.
I have had a go at editing parts of your code to try and suit my particular retract system ie, all actuators in place of servo's.
I need to open doors or half doors first, then lower retract legs and lock, then close half doors,( other half doors attached to retract legs), and then of course reverse the sequence.
Had planned on using output A for doors and output B for retracts, but I suppose it could be vice or versa on the outputs as long as there defined in the code.
In the editing of the code I have tried to omit the servo commands but it can get a little confusing with all the variables used, so I am not at all sure if it will actually work.
I'll post the edited code shortly, if you manage to find time to have a look, can you let me know if at all this may work, or am I long way off yet.
Thanks
Mike
Old 01-23-2014, 02:45 PM
  #30  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

Mustang,
This is the edited code:-
// Arduino uno with R3 motor shield // RC retract under-carriage sequencing
// door actuators and under-carriage retract actuators


int Abrake=8; // brake signal for motor A doors actuators
int Bbrake=9; // brake signal for motor B retract actuators
int motorspdA=11; // PWM speed signal for motor A doors actuator
int motorspdB=3; // PWM speed signal for motor B retract actuators
int ch5; // Receiver retract channel
int motorA=12; // motor initiate door actuators
int motorB=13; // motor initiate retract actuators
int sensorPinA= A0; // select the input pin for the current door actuators
int sensorPinB= A1; // select the input pin for the current retract actuators
int switchpin =2;
int sensorValueA =0; // variable to store the value coming from the sensor
int sensorValueB =0; // variable to store the value coming from the sensor


void setup() {


pinMode (6, INPUT);
pinMode (12,OUTPUT); // motor A enable and direction HIGH or LOW
pinMode (13,OUTPUT); // motor B enable and direction HIGH or LOW
pinMode (8, OUTPUT); // brake motor A doors
pinMode (9, OUTPUT); // brake motor B retracts
pinMode (switchpin, OUTPUT);

}
void Ioop () {


int limitA = 550; // this is the current limit for motor A doors
Int limitB = 300; // this is the current limit for motor B retracts
sensor ValueA = analogRead(sensorPinA); //this reads the value of current for motorA and sets the variable sensorValueA , doors
sensorValueB = analogRead(senserPinB); //this reads the value of current for motorB and sets the variable sensor valueB , retracts
int iA =0; // this creates and sets a variable named iA which we will use to make sure the motors stop once they reach overcurrent condition
int iB = 0; // this creates and sets a variable named iB which we will use to make sure the motors stop once they reach overcurrent condition
ch5 = pulseIn(6, HIGH);
If(ch5 < midlimit) {
digitalWrite(switchpin, HIGH);
}
else {
digitalWrite(switchpin, LOW);
}
int updwn = digitalRead(switchpin); // this sets the value of the variable updwn which is read from transmitter switch
int updwn2 = digitalRead(switchpin); // this sets the value of the variable updwn which is read from transmitter switch
while (updwn = = updwn2 { // the while loop here knows the current state of the switch updwn. During the while loop it will continually check
//the state of the switch by setting updwn2 therefore once the state of the switch changes it will exit the while loop


if (updwn = = updwn 1 && senserValueA < limitA && iA = =0)
{
analogWrite (motorspdA,255);
digitalWrite (A,HIGH);
digitalWrite(Brake,LOW);
}
else if (updwn = =0 && sensorValueA < limit A && iA = =iA = =0)
{
analogWrite (motorspdA,255);
digital Write (motorA,LOW);
Digital Write (Brake,LOW);
}
else
{
analogWrite ( motorspdA ,0);
digitalWrite (Brake,LOW);
iA++;
}
delay(300);
if (updwn = =1 && sensorValueB < limitB&& iB = =0)
{
analogWrite (motorspdB,255);
digital Write (motorB,HIGH);
digital Write (Bbrake,LOW);
}
else if (updwn = =0 && sensorValueB < limitB && iB = =0)
{
analogWrite (motorspdB,255);
digitalWrite (motorB,LOW);
digitalWrite (Bbrake.LOW);
}
else
{
analogWrite (motorspdB,0);
digitalWrite (Bbrake,LOW);
iB++;
}
delay(200);
sensorValueA = analogRead(sensorPinA);
sensorValueB =analogRead(sensorPinB);
int ch5 = pulseIn(6,HIGH);
If (ch5 < midlimit)
{
digitalWrite(switchpin,HIGH);
}
else
{
digitalWrite(switchpin, LOW);
}
Updwn2 = digitalRead(switchpin);
delay(100);
}
}

basically I have re-arranged the outputs on A and B, and omitted the servo commands, but I may have made mistakes doing this I'm not really sure.
Mike

Last edited by freelander-rider; 01-30-2014 at 12:12 PM. Reason: CORRECTING ERRORS
Old 01-23-2014, 03:51 PM
  #31  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Have you tried loading it to the arduino. And if it loaded have you tried to run it.
Old 01-31-2014, 04:21 PM
  #32  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

I have copy and pasted the edited code, but when I upload it lists error on line 34 " void loop function not in scope" and many errors on most lines after this.
I'm not sure but it would seem by removing the header "# Servo h" which I believe is from the servo library, and I assume contains commands and variables which are possibly required for the code, this may be one of the problems,
in your setup you are using servo's which have a feedback signal to operate the doors, in my setup I want to use actuators on output B for the doors rather than servo's," ie actuators 2 wire no feedback".
Would I still need the " #Servo h" header even though I wont use servo's, just to allow "#Servo h" library to send the signals and variables to action the actuators on output B.
I am still confused with other parts of the code, ie"if( updwn= =1 && senserValueB < limitB &&iB= =0)", what is this and where do the sensor values come from,I know this works with your original code.
I feel like I'm driving onto a roundabout without knowing which exit to use, I have trawled through many examples of codes and meanings, but finding it hard to correlate the various commands and variables required,to do these functions in the correct sequence.
I could do with some help with this,as I seem to be going round in circles looking for a solution.
Mike
Old 01-31-2014, 06:03 PM
  #33  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike I'll take a look for you. It's 2 in the morning here so I'll do it in the morning
Old 01-31-2014, 06:22 PM
  #34  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike you've got loads of syntax errors. you need to verify your code and work through the errors line by line. i've made a start for you..


// Arduino uno with R3 motor shield // RC retract under-carriage sequencing
// door actuators and under-carriage retract actuators


#define midlimit 1700
int Abrake=8; // brake signal for motor A doors actuators
int Bbrake=9; // brake signal for motor B retract actuators
int motorspdA=11; // PWM speed signal for motor A doors actuator
int motorspdB=3; // PWM speed signal for motor B retract actuators
int ch5; // Receiver retract channel
int motorA=12; // motor initiate door actuators
int motorB=13; // motor initiate retract actuators
int sensorPinA= A0; // select the input pin for the current door actuators
int sensorPinB= A1; // select the input pin for the current retract actuators
int switchpin =2;
int sensorValueA =0; // variable to store the value coming from the sensor
int sensorValueB =0; // variable to store the value coming from the sensor




void setup() {




pinMode (6, INPUT);
pinMode (12,OUTPUT); // motor A enable and direction HIGH or LOW
pinMode (13,OUTPUT); // motor B enable and direction HIGH or LOW
pinMode (8, OUTPUT); // brake motor A doors
pinMode (9, OUTPUT); // brake motor B retracts
pinMode (switchpin, OUTPUT);


}
void Ioop () {




int limitA = 550; // this is the current limit for motor A doors
int limitB = 300; // this is the current limit for motor B retracts
sensorValueA = analogRead(sensorPinA); //this reads the value of current for motorA and sets the variable sensorValueA , doors
sensorValueB = analogRead(sensorPinB); //this reads the value of current for motorB and sets the variable sensor valueB , retracts
int iA =0; // this creates and sets a variable named iA which we will use to make sure the motors stop once they reach overcurrent condition
int iB = 0; // this creates and sets a variable named iB which we will use to make sure the motors stop once they reach overcurrent condition
ch5 = pulseIn(6, HIGH);
if(ch5 < midlimit) {
digitalWrite(switchpin, HIGH);
}
else {
digitalWrite(switchpin, LOW);
}
int updwn = digitalRead(switchpin); // this sets the value of the variable updwn which is read from transmitter switch
int updwn2 = digitalRead(switchpin); // this sets the value of the variable updwn which is read from transmitter switch
while (updwn == updwn2) { // the while loop here knows the current state of the switch updwn. During the while loop it will continually check
//the state of the switch by setting updwn2 therefore once the state of the switch changes it will exit the while loop


//if (updwn==1 && sensorValueB < limitB && iB==0)
if (updwn==updwn2 && sensorValueA < limitA && iA ==0)
{
analogWrite (motorspdA,255);
digitalWrite (A,HIGH);
digitalWrite(Brake,LOW);
}
else if (updwn = =0 && sensorValueA < limit A && iA = =iA = =0)
{
analogWrite (motorspdA,255);
digital Write (motorA,LOW);
Digital Write (Brake,LOW);
}
else
{
analogWrite ( motorspdA ,0);
digitalWrite (Brake,LOW);
iA++;
}
delay(300);
if (updwn = =1 && sensorValueB < limitB&& iB = =0)
{
analogWrite (motorspdB,255);
digital Write (motorB,HIGH);
digital Write (Bbrake,LOW);
}
else if (updwn = =0 && sensorValueB < limitB && iB = =0)
{
analogWrite (motorspdB,255);
digitalWrite (motorB,LOW);
digitalWrite (Bbrake.LOW);
}
else
{
analogWrite (motorspdB,0);
digitalWrite (Bbrake,LOW);
iB++;
}
delay(200);
sensorValueA = analogRead(sensorPinA);
sensorValueB =analogRead(sensorPinB);
int ch5 = pulseIn(6,HIGH);
If (ch5 < midlimit)
{
digitalWrite(switchpin,HIGH);
}
else
{
digitalWrite(switchpin, LOW);
}
Updwn2 = digitalRead(switchpin);
delay(100);
}
}
Old 01-31-2014, 06:31 PM
  #35  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

here you go Mike i've cleared your errors which were mainly simple typos or use of caps when it should be lower case. good effort. i've not examined it to see if it will work but try it and see what happens.


// Arduino uno with R3 motor shield // RC retract under-carriage sequencing
// door actuators and under-carriage retract actuators


#define midlimit 1700
int Abrake=8; // brake signal for motor A doors actuators
int Bbrake=9; // brake signal for motor B retract actuators
int motorspdA=11; // PWM speed signal for motor A doors actuator
int motorspdB=3; // PWM speed signal for motor B retract actuators
int ch5; // Receiver retract channel
int motorA=12; // motor initiate door actuators
int motorB=13; // motor initiate retract actuators
int sensorPinA= A0; // select the input pin for the current door actuators
int sensorPinB= A1; // select the input pin for the current retract actuators
int switchpin =2;
int sensorValueA =0; // variable to store the value coming from the sensor
int sensorValueB =0; // variable to store the value coming from the sensor




void setup() {




pinMode (6, INPUT);
pinMode (12,OUTPUT); // motor A enable and direction HIGH or LOW
pinMode (13,OUTPUT); // motor B enable and direction HIGH or LOW
pinMode (8, OUTPUT); // brake motor A doors
pinMode (9, OUTPUT); // brake motor B retracts
pinMode (switchpin, OUTPUT);


}
void loop () {




int limitA = 550; // this is the current limit for motor A doors
int limitB = 300; // this is the current limit for motor B retracts
sensorValueA = analogRead(sensorPinA); //this reads the value of current for motorA and sets the variable sensorValueA , doors
sensorValueB = analogRead(sensorPinB); //this reads the value of current for motorB and sets the variable sensor valueB , retracts
int iA =0; // this creates and sets a variable named iA which we will use to make sure the motors stop once they reach overcurrent condition
int iB = 0; // this creates and sets a variable named iB which we will use to make sure the motors stop once they reach overcurrent condition
ch5 = pulseIn(6, HIGH);
if(ch5 < midlimit) {
digitalWrite(switchpin, HIGH);
}
else {
digitalWrite(switchpin, LOW);
}
int updwn = digitalRead(switchpin); // this sets the value of the variable updwn which is read from transmitter switch
int updwn2 = digitalRead(switchpin); // this sets the value of the variable updwn which is read from transmitter switch
while (updwn == updwn2) { // the while loop here knows the current state of the switch updwn. During the while loop it will continually check
//the state of the switch by setting updwn2 therefore once the state of the switch changes it will exit the while loop


//if (updwn==1 && sensorValueB < limitB && iB==0)
if (updwn==updwn2 && sensorValueA < limitA && iA ==0)
{
analogWrite (motorspdA,255);
//digitalWrite (A,HIGH);
digitalWrite(Bbrake,LOW);
}
else if (updwn ==0 && sensorValueA < limitA && iA ==iA ==0)
{
analogWrite (motorspdA,255);
digitalWrite (motorA,LOW);
digitalWrite (Abrake,LOW);
}
else
{
analogWrite ( motorspdA ,0);
digitalWrite (Bbrake,LOW);
iA++;
}
delay(300);
if (updwn ==1 && sensorValueB < limitB && iB ==0)
{
analogWrite (motorspdB,255);
digitalWrite (motorB,HIGH);
digitalWrite (Bbrake,LOW);
}
else if (updwn ==0 && sensorValueB < limitB && iB ==0)
{
analogWrite (motorspdB,255);
digitalWrite (motorB,LOW);
digitalWrite (Bbrake,LOW);
}
else
{
analogWrite (motorspdB,0);
digitalWrite (Bbrake,LOW);
iB++;
}
delay(200);
sensorValueA = analogRead(sensorPinA);
sensorValueB =analogRead(sensorPinB);
int ch5 = pulseIn(6,HIGH);
if (ch5 < midlimit)
{
digitalWrite(switchpin,HIGH);
}
else
{
digitalWrite(switchpin, LOW);
}
updwn2 = digitalRead(switchpin);
delay(100);
}
}
Old 02-01-2014, 03:14 AM
  #36  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike this code will make your motors run and stop according to the transmitter switch. but it needs to be edited for the doors and retracts to work in sequence with the motors.
try this and your doors and retracts will operate at the same time. i've put more explanations for you in the code. You need to separate this code into separate 'while' loops, one for the up sequence and one for the down sequence. in these sequences you will need to change the order of the motors depending on which needs to run first and you will also need to declare when one motor has finished in the loop before starting the other. have a play and see how you get on. when i get a chance i'll have a look at it as well.


//this version designed for Mike.




#define midlimit 1700//pwm signal from the reciever has a value usually ranging from 600us to 2400us so when switch is in the middle the value would be around 1500. 1700 is inbetween 2400 and 1500


int Bbrake=8;//brake signal for motor B
int Abrake=9;//brake signal for motor A
int motorspdB=11;//PWM speed signal for motor B
int motorspdA=3;//PWM speed signal for motor A
int ch5;
int motorA=12;
int motorB=13;
int sensorPinA = A0; // select the input pin for the current
int sensorPinB = A1; // select the input pin for the current
int switchpin = 2;
int sensorValueA = 0; // variable to store the value coming from the sensor
int sensorValueB = 0; // variable to store the value coming from the sensor


void setup () {


pinMode (6, INPUT);
pinMode (13, OUTPUT);//motor B enable and direction HIGH or LOW
pinMode (12, OUTPUT);//motor A enable and direction HIGH or LOW
pinMode (8, OUTPUT);//Brake motor B
pinMode (9, OUTPUT);//Brake motor A
pinMode (switchpin, OUTPUT);
}
void loop () {


int limitA = 700; //this is the current limit for motor A
int limitB = 300; //this is the current limit for motor B
sensorValueB = analogRead(sensorPinB); //this reads the value of current for motorB and sets the variable sensorValueB
sensorValueA = analogRead(sensorPinA); //this reads the value of current for motorA and sets the variable sensorValueA
int iB = 0; //this creates and sets a variable named iB, its just a variable value it has no pin assigned to it. We will use to make sure the motors stop once they reach overcurrent condition
int iA = 0; //this creates and sets a variable named iA its just a variable value it has no pin assigned to it. We will use to make sure the motors stop once they reach overcurrent condition
ch5 = pulseIn(6, HIGH); //measures an interger value of the pwn signal from the reciever. so if you're using a 3 position switch it will probably be around 600, 1500, or 2400


if (ch5 < midlimit) { //this next part changes the integer value of the pwm signal into a digital HIGH LOW by comparing the pwm value with the midlimit value defined at the beginning of the script
digitalWrite(switchpin, HIGH);
}
else {
digitalWrite(switchpin, LOW);// end of pwm signal to on/off (HIGH/LOW) script
}
int updwn = digitalRead(switchpin); //this sets the value of the variable updwn which is read from transmitter switch
int updwn2 = digitalRead(switchpin); //this sets the comparison value of updwn which is read from transmitter switch


while (updwn == updwn2) { //This means while updwn is exactly equal to updwn2. the while loop here knows the current state of the switch updwn. during the while loop it will continually check
//the state of the switch by setting updwn2 therefore once the state of the switch changes it will exit the while loop


if (updwn==1 && sensorValueB < limitB && iB==0) // this determines the direction is up and that the motor is not in overload
{
analogWrite (motorspdB,255);
digitalWrite (motorB,HIGH);
digitalWrite (Bbrake,LOW);
}
else if (updwn==0 && sensorValueB < limitB && iB==0) // this determines that the direction is down and the motor is not in overload
{
analogWrite (motorspdB,255);
digitalWrite (motorB,LOW);
digitalWrite (Bbrake,LOW);
}
else
{
analogWrite (motorspdB,0); // the motor is in over load and so the motor stops and there is no more power on the motor
digitalWrite (Bbrake,LOW);
iB++; // this adds 1 to the value of iB once the motor has finished. now when we re-enter the while loop the value of iB is no longer 0 and so the motor doesnt run. this value continues to count up each time through the loop until the loop is broken by a change in the switch state.
}
delay(200);
if (updwn==1 && sensorValueA < limitA && iA==0) // this determines the direction is up and that the motor is not in overload
{
analogWrite (motorspdA,255);
digitalWrite (motorA,HIGH);
digitalWrite (Abrake,LOW);
}
else if (updwn==0 && sensorValueA < limitA && iA==0) // this determines that the direction is down and the motor is not in overload
{
analogWrite (motorspdA,255);
digitalWrite (motorA,LOW);
digitalWrite (Abrake,LOW);
}
else
{
analogWrite (motorspdA,0); // the motor is in over load and so the motor stops and there is no more power on the motor
digitalWrite (Abrake,LOW);
iA++; // this adds 1 to the value of iA once the motor has finished. now when we re-enter the while loop the value of iA is no longer 0 and so the motor doesnt run. this value continues to count up each time through the loop until the loop is broken by a change in the switch state.
}
delay(100);


sensorValueB = analogRead(sensorPinB);
sensorValueA = analogRead(sensorPinA);


int ch5 = pulseIn(6, HIGH);
if (ch5 < midlimit)
{
digitalWrite(switchpin, HIGH);
}
else
{
digitalWrite(switchpin, LOW);
}
updwn2 = digitalRead(switchpin);
delay(200);


}
}
Old 02-01-2014, 03:35 AM
  #37  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike try this. i'm sure you know this but if you've been copying the code in these threads by hand into the arduino interface you can just copy all the below and paste it into the arduino interface, saves typing...



//this version designed for Mike.




#define midlimit 1700//pwm signal from the reciever has a value usually ranging from 600us to 2400us so when switch is in the middle the value would be around 1500. 1700 is inbetween 2400 and 1500


int Bbrake=8;//brake signal for motor B
int Abrake=9;//brake signal for motor A
int motorspdB=11;//PWM speed signal for motor B
int motorspdA=3;//PWM speed signal for motor A
int ch5;
int motorA=12;
int motorB=13;
int sensorPinA = A0; // select the input pin for the current
int sensorPinB = A1; // select the input pin for the current
int switchpin = 2;
int sensorValueA = 0; // variable to store the value coming from the sensor
int sensorValueB = 0; // variable to store the value coming from the sensor


void setup () {


pinMode (6, INPUT);
pinMode (13, OUTPUT);//motor B enable and direction HIGH or LOW
pinMode (12, OUTPUT);//motor A enable and direction HIGH or LOW
pinMode (8, OUTPUT);//Brake motor B
pinMode (9, OUTPUT);//Brake motor A
pinMode (switchpin, OUTPUT);
}
void loop () {


int limitA = 700; //this is the current limit for motor A
int limitB = 300; //this is the current limit for motor B
sensorValueB = analogRead(sensorPinB); //this reads the value of current for motorB and sets the variable sensorValueB
sensorValueA = analogRead(sensorPinA); //this reads the value of current for motorA and sets the variable sensorValueA
int iB = 0; //this creates and sets a variable named iB, its just a variable value it has no pin assigned to it. We will use to make sure the motors stop once they reach overcurrent condition
int iA = 0; //this creates and sets a variable named iA its just a variable value it has no pin assigned to it. We will use to make sure the motors stop once they reach overcurrent condition
ch5 = pulseIn(6, HIGH); //measures an interger value of the pwn signal from the reciever. so if you're using a 3 position switch it will probably be around 600, 1500, or 2400


if (ch5 < midlimit) { //this next part changes the integer value of the pwm signal into a digital HIGH LOW by comparing the pwm value with the midlimit value defined at the beginning of the script
digitalWrite(switchpin, HIGH);
}
else {
digitalWrite(switchpin, LOW);// end of pwm signal to on/off (HIGH/LOW) script
}
int updwn = digitalRead(switchpin); //this sets the value of the variable updwn which is read from transmitter switch
int updwn2 = digitalRead(switchpin); //this sets the comparison value of updwn which is read from transmitter switch
int motorBfinished = 0;
int motorAfinished = 0;


while (updwn == updwn2 && updwn == 1) { //This means while updwn is exactly equal to updwn2. the while loop here knows the current state of the switch updwn. during the while loop it will continually check
//the state of the switch by setting updwn2 therefore once the state of the switch changes it will exit the while loop


if (sensorValueB < limitB && iB==0) // this determines the direction is up and that the motor is not in overload
{
analogWrite (motorspdB,255);
digitalWrite (motorB,HIGH);
digitalWrite (Bbrake,LOW);
}
else
{
analogWrite (motorspdB,0); // the motor is in over load and so the motor stops and there is no more power on the motor
digitalWrite (Bbrake,LOW);
motorBfinished = 1;
iB++; // this adds 1 to the value of iB once the motor has finished. now when we re-enter the while loop the value of iB is no longer 0 and so the motor doesnt run. this value continues to count up each time through the loop until the loop is broken by a change in the switch state.
}
delay(200); // delay between motorB starting and MotorA starting
if (motorBfinished == 1 && sensorValueA < limitA && iA==0) // this determines the direction is up and that the motor is not in overload
{
analogWrite (motorspdA,255);
digitalWrite (motorA,HIGH);
digitalWrite (Abrake,LOW);
}
else
{
analogWrite (motorspdA,0); // the motor is in over load and so the motor stops and there is no more power on the motor
digitalWrite (Abrake,LOW);
iA++; // this adds 1 to the value of iA once the motor has finished. now when we re-enter the while loop the value of iA is no longer 0 and so the motor doesnt run. this value continues to count up each time through the loop until the loop is broken by a change in the switch state.
}
delay(100);


sensorValueB = analogRead(sensorPinB);
sensorValueA = analogRead(sensorPinA);


int ch5 = pulseIn(6, HIGH);
if (ch5 < midlimit)
{
digitalWrite(switchpin, HIGH);
}
else
{
digitalWrite(switchpin, LOW);
}
updwn2 = digitalRead(switchpin);
delay(200);


}
while (updwn == updwn2 && updwn == 0) { //This means while updwn is exactly equal to updwn2. the while loop here knows the current state of the switch updwn. during the while loop it will continually check
//the state of the switch by setting updwn2 therefore once the state of the switch changes it will exit the while loop


if (sensorValueA < limitA && iA==0) // this determines the direction is up and that the motor is not in overload
{
analogWrite (motorspdA,255);
digitalWrite (motorA,HIGH);
digitalWrite (Abrake,LOW);
}
else
{
analogWrite (motorspdA,0); // the motor is in over load and so the motor stops and there is no more power on the motor
digitalWrite (Abrake,LOW);
motorAfinished = 1; // once the motor stops this variable is set to indicate tht the next motor can begin to run
iA++; // this adds 1 to the value of iB once the motor has finished. now when we re-enter the while loop the value of iB is no longer 0 and so the motor doesnt run. this value continues to count up each time through the loop until the loop is broken by a change in the switch state.
}
delay(200); // delay between motorB starting and MotorA starting
if (motorBfinished == 1 && sensorValueB < limitB && iB==0) // this determines the direction is up and that the motor is not in overload
{
analogWrite (motorspdB,255);
digitalWrite (motorB,HIGH);
digitalWrite (Bbrake,LOW);
}
else
{
analogWrite (motorspdB,0); // the motor is in over load and so the motor stops and there is no more power on the motor
digitalWrite (Bbrake,LOW);
iB++; // this adds 1 to the value of iA once the motor has finished. now when we re-enter the while loop the value of iA is no longer 0 and so the motor doesnt run. this value continues to count up each time through the loop until the loop is broken by a change in the switch state.
}
delay(100);


sensorValueB = analogRead(sensorPinB);
sensorValueA = analogRead(sensorPinA);


int ch5 = pulseIn(6, HIGH);
if (ch5 < midlimit)
{
digitalWrite(switchpin, HIGH);
}
else
{
digitalWrite(switchpin, LOW);
}
updwn2 = digitalRead(switchpin);
delay(200);


}
}
Old 02-01-2014, 04:19 AM
  #38  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by freelander-rider
I have copy and pasted the edited code, but when I upload it lists error on line 34 " void loop function not in scope" and many errors on most lines after this.
I'm not sure but it would seem by removing the header "# Servo h" which I believe is from the servo library, and I assume contains commands and variables which are possibly required for the code, this may be one of the problems,
in your setup you are using servo's which have a feedback signal to operate the doors, in my setup I want to use actuators on output B for the doors rather than servo's," ie actuators 2 wire no feedback".
Would I still need the " #Servo h" header even though I wont use servo's, just to allow "#Servo h" library to send the signals and variables to action the actuators on output B.
I am still confused with other parts of the code, ie"if( updwn= =1 && senserValueB < limitB &&iB= =0)", what is this and where do the sensor values come from,I know this works with your original code.
I feel like I'm driving onto a roundabout without knowing which exit to use, I have trawled through many examples of codes and meanings, but finding it hard to correlate the various commands and variables required,to do these functions in the correct sequence.
I could do with some help with this,as I seem to be going round in circles looking for a solution.
Mike

You don't need servo library if you're not using servos. The servo library allows you to ask the servos to move to a set value or position. this is usually a value between 600 and 2400. 600 being one end of the servo travel and 2400 the other end.

( updwn= =1 && senserValueB < limitB &&iB= =0) shouldn't be a space between the 2 equals... ==. what it says is updwn must exactly equal 1 and (&&) the sensorValueB (not [COLOR=#000000]senser) must be less than(
Old 02-01-2014, 06:23 AM
  #39  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

"Wow Mustang you really are an inspiration" after I have digesting this I will feel more confident than ever, it would seem I can find an exit off that roundabout now with the help you have given.
Apart from myself I'm sure there will be more forum members doing similar projects that this can be utilized for.

Thanks again for the support.
Mike
Old 02-04-2014, 12:46 PM
  #40  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

hi Mustang,
Thanks again the code verifies, haven't loaded it yet I am setting up a board jig with the retracts and door actuators in place, so I can check the system will work as intended.
Have wired up the motor actuators, doors output A and retracts output B, lipo 2s 7.4 battery on vin and grd on shield, and nicad battery plugged in receiver, now I see from your U tube wiring the shield
I need to fit the plug, to the receiver retract channel, signal - power - and grd, and then attach wires, signal to pin 6 and black ground pin, now is the black ground wire connected to grd which says power or next to, which states grd and 5volts, also on the vidio, I can see the white signal wire to pin 6 and the black wire to ground, but I cant see a red power wire connected,( Center pin on receiver retract channel) does this need to be connected to a vin on the shield.
Mike
Old 02-04-2014, 01:53 PM
  #41  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Mike is this clearer
Attached Thumbnails Click image for larger version

Name:	image.jpg
Views:	518
Size:	1.41 MB
ID:	1965472  
Old 02-04-2014, 01:58 PM
  #42  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Gnd from receiver connected to gnd on arduino motor shield or arduino. Live from receiver is not used as I power my receiver from a different power supply. Connecting the receiver gnd to the arduino or motor shield puts the different power supply's all on the same gnd (earth). This stops potential glitching.
Old 02-05-2014, 03:15 AM
  #43  
freelander-rider
Junior Member
 
Join Date: Jan 2014
Location: Grantham
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Default

Thanks for that, the image makes the connections much clearer,
I meant to ask earlier, how are you progressing with your Mick Reeves Lightning, one of the great British jets of all time, are you anywhere near completion?, is it to be turbine or electric fan, it would be interesting to see how your progressing with this.
Myself, most of my build is carried out in the garage where dust and mess is containable, but it gets too cold at this time of year, and the wife complains about heating a brick building besides the house, so I tend to spend my time in the winter in the study working on the cleaner parts of the build.
Mike
Ps. It suddenly dawned on me there was a P38 they called a Lightning, a twin prop aircraft with a twin boom tail arrangement,is this the type of aircraft your building, or is it the jet.
Old 02-05-2014, 12:56 PM
  #44  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

The lightning is built and flying. has a wren 180 in it and it goes like stink. let me know how you get on. are you going to put up some pictures when your built.?
Old 03-21-2014, 05:48 PM
  #45  
motorhd
Senior Member
My Feedback: (15)
 
Join Date: Nov 2004
Location: Gresham, OR
Posts: 140
Likes: 0
Received 0 Likes on 0 Posts
Default

Nice work, Do you think we could control this; http://www.youtube.com/watch?v=0D5mDvk_GtY or search youtube for cessna retracts
Jim
Old 03-21-2014, 10:15 PM
  #46  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Yes it would work for this
Old 03-22-2014, 09:44 AM
  #47  
motorhd
Senior Member
My Feedback: (15)
 
Join Date: Nov 2004
Location: Gresham, OR
Posts: 140
Likes: 0
Received 0 Likes on 0 Posts
Default

On ebay there are some good prices for ardruino boards and the motor shield boards. If they look like they would work could you please recommend which ones?
Thanks, Jim
Old 05-07-2014, 09:16 AM
  #48  
essyou35
My Feedback: (11)
 
Join Date: Dec 2009
Location: Central Midwest
Posts: 1,946
Received 25 Likes on 22 Posts
Default

Cool project, did something similar a while ago.

I would not not use pulseIn fo reading the Rx. You need to write a custom handler and read the radio 3 times. I found the arduino can "jump" around in the values. By reading 3 times and taking the average you get a much better read. Would hate for a small glitch in the timer or something else cause the retracts to suck up or go down. The timers can be querky especially if you get a clone unit.

I originally made a sequencer for my canopy on a turbine jet using an arduino. I evnetually switched it over to a switch instead. Didnt want to chance it opening in flight if I bump the switch.

https://www.google.com/url?q=http://...Hspz5sNwhebllw

I also used an arduino to operate a custom turreton my b-25 with random 360 degree motions!
https://www.google.com/url?q=http://...g2ULSmfMCNrrEg

These are real fun to play with but I just cant trust them yet in a turbine aircraft for the landing gear.
Old 09-02-2015, 11:43 AM
  #49  
Grumpy Monkey
My Feedback: (7)
 
Grumpy Monkey's Avatar
 
Join Date: Feb 2002
Location: Bridgewater, NJ
Posts: 448
Likes: 0
Received 0 Likes on 0 Posts
Default

So I know this is an old thread but it has great info. I am trying to implement an arduino into an 80" skyaider. I have converted the gear mechanically already but the Arduino is a bit of a learning curve and was hoping I can get some help. I spent 2 nights reading Arduino for dummies and watching some vids but I am a bit pressed for time. I am in school full time at night and runnning a business during the day and my free time to learn Arduino is small at the moment. I did manage to buy an Uno and a motor shield and was able to diagram the layout of what I am trying to do. Just need some help with the code if someone can.

The goal is to use channel 5 from the radio to the Uno. This will use one servo to operate the retractable tailwheel and one motor for each retract leg. The main gear on a skyraider go up at the same time so no stagger. The tailwheel follows when the mains are up.
The motor shield will use a 3S Lipo and the Uno and Rx will share a NiMh. Is this wise or should I go with a separate batt for the Uno and RX also? I have a Taranis and need to pull the servo endpoints off the radio still but I can edit the code with that later.

It looks like I can use what has been posted already with some editing. Thanks for any all all thoughts and help.

Dub.

Attached Thumbnails Click image for larger version

Name:	Skyraider Gear Layout.JPG
Views:	1949
Size:	90.9 KB
ID:	2117835  
Old 09-02-2015, 12:11 PM
  #50  
mustang493
Member
Thread Starter
 
Join Date: Jan 2013
Location: cambridge, UNITED KINGDOM
Posts: 42
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by Grumpy Monkey
So I know this is an old thread but it has great info. I am trying to implement an arduino into an 80" skyaider. I have converted the gear mechanically already but the Arduino is a bit of a learning curve and was hoping I can get some help. I spent 2 nights reading Arduino for dummies and watching some vids but I am a bit pressed for time. I am in school full time at night and runnning a business during the day and my free time to learn Arduino is small at the moment. I did manage to buy an Uno and a motor shield and was able to diagram the layout of what I am trying to do. Just need some help with the code if someone can.

The goal is to use channel 5 from the radio to the Uno. This will use one servo to operate the retractable tailwheel and one motor for each retract leg. The main gear on a skyraider go up at the same time so no stagger. The tailwheel follows when the mains are up.
The motor shield will use a 3S Lipo and the Uno and Rx will share a NiMh. Is this wise or should I go with a separate batt for the Uno and RX also? I have a Taranis and need to pull the servo endpoints off the radio still but I can edit the code with that later.

It looks like I can use what has been posted already with some editing. Thanks for any all all thoughts and help.

Dub.

I would power the uno and the motor shield with the lipo. Better if your neutrals are from the same source. use an independent supply for RX. Can't see why it won't work


Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service -

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.