R/C Tech Forums

Go Back   R/C Tech Forums > General Forums > Electric On-Road

Reply
 
Thread Tools Search this Thread
Old 02-28-2014, 10:21 PM   #1
Tech Rookie
 
ErikP's Avatar
 
Join Date: Feb 2014
Location: Houston
Posts: 6
Questions?? Arduino Control of DYN4925WP

Please help!

I saw a mention of the DYN4925WP, but I didn't find working code, just discussions about it.

I have the ESC working for both forward and reverse, if done alone (one or the other).
When doing one, then the other, the second does not perform.

After the code that makes it go forward, I added this to attemp reverse
(this is after a a good forward movement):

steeringPin.write(Left);
delay(1000);

throttlePin.write(Stop);
delay(2500);

throttlePin.write(RVS); //vereified that value enterred into RVS does work if forward not done first
delay(150);
throttlePin.writeMicroseconds(0);

steeringPin.write(Strait);
delay(1000);

Last edited by ErikP; 02-28-2014 at 10:23 PM. Reason: add comment
ErikP is offline   Reply With Quote
Old 03-01-2014, 07:36 AM   #2
Tech Addict
 
Join Date: Jan 2008
Posts: 706
Trader Rating: 6 (100%+)
Default

Have you calibrated the ESC to the Arduino?



http://arduino.cc/en/Tutorial/Sweep#.UxHysGePKUk

The PWM range for the Sevo library is from 0 to 179. Your ESC probably doesn't know where the Neutral and FWD/REV start, with respect to the dutycycle coming out of the arduino. That can cause all sorts of problems. Write a function, or program that will calibrate the ESC.

What values are you using in your variables?




Shawn.

Last edited by Shawn68z; 03-01-2014 at 07:55 AM. Reason: Spelling
Shawn68z is offline   Reply With Quote
Old 03-01-2014, 01:46 PM   #3
Tech Rookie
 
ErikP's Avatar
 
Join Date: Feb 2014
Location: Houston
Posts: 6
Default Rest of the Code

I don't think I had it callibrated the last time, when it worked. I just looked for what it wanted to hear, so to speak. Last time it took me two weeks of random coding to get it, though. This time I want to do it right.

Well, in my previous version, I had a statement before and after the call to go in reverse. I can not remember how I did it (lost code to bad sectors, keeping everything on flash drives now). Essentially, it paused before and after the reverse to allow switching from forward to reverse and back...I've looked at code others have done, but it is all dependant on using a remote. That is a different project for me. Thank you for your advice. Code follows (with commented out corrections or attempts): Again, thank you all. I am amazed at what some of you have created.

#include <Servo.h>
#include "pitches.h"

//=============
//=============

Servo throttlePin;
Servo steeringPin;

int pos = 86;

const int Stop = 0;//Or Neutral, depending on location
const int FWD = 5;//85 Slowest, 75 Slow Usable, 10 Fast, 5 Fastest
const int RVS = 2000;//Ranged 2000 to 2222
const int Strait = 86;
const int Left = 10;
const int Right = 110;



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

throttlePin.attach(36);//was 36
throttlePin.writeMicroseconds(Stop);
delay(1500);
throttlePin.writeMicroseconds(90);//This may be the neutral? ---- 3-1-2014 1:08am - untested
throttlePin.writeMicroseconds(Stop);//2nd Time to Turn OFF Brakes, maybe ---- 3-1-2014 1:08am - untested
//delay(100);
steeringPin.attach(34);//was 34
steeringPin.write(Strait);
}


void loop()
{


throttlePin.write(FWD);
delay(100);
throttlePin.writeMicroseconds(0);//Stops Movement But does Not Brake
//throttlePin.writeMicroseconds(RVS);//Stops Movement And does Brake


Serial.println(" ");
delay(1000);

//---------------------------------------------------------------------------------------------------------
Reverse();
//---------------------------------------------------------------------------------------------------------

Serial.println(" ");
delay(1000);


throttlePin.write(FWD);
delay(100);
throttlePin.writeMicroseconds(0);


Serial.println(" ");
delay(1000);
}



void Reverse()
{
//---------------------------------------------------------------------------------------------------------
steeringPin.write(Left);
delay(1000);

//throttlePin.write(Stop);
// delay(5000);
throttlePin.writeMicroseconds(2000);
throttlePin.write(RVS);
//throttlePin.writeMicroseconds(2000);
throttlePin.write(Stop);
delay(2500);

throttlePin.write(RVS);
delay(150);
throttlePin.writeMicroseconds(0);

steeringPin.write(Strait);
delay(1000);
//---------------------------------------------------------------------------------------------------------
}
ErikP is offline   Reply With Quote
Old 03-01-2014, 08:44 PM   #4
Tech Rookie
 
ErikP's Avatar
 
Join Date: Feb 2014
Location: Houston
Posts: 6
Default Another Try, still does reverse without the forward first

I took your advice, and did a sweep version of the code. Still trying to find the solution.
ESC - DYN4925WP
ESC properties - Red when Forward, Green when Reverse
Problem: Green and Red light up when attempting reverse after Forward.
The sweeping code and my previous version has the same outcome.
I've also tried Forward, reverse, nuetral, reverse, and variations of that...

This is the new code, with the sweeping calls:

#include <Servo.h>


//=============
//=============

Servo throttlePin;

Servo steeringPin;

int pos = 0;

const int Stop = 0;
const int FWD = 5;
const int RVS = 2000;

const int Strait = 86;
const int Left = 10;
const int Right = 110;



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

throttlePin.attach(36);

steeringPin.attach(34);
steeringPin.write(Strait);
}


void loop()
{

//1500 causes Green Light, but no movement
//1550 nothing
//1575 SLOWEST REVERSE POS
//reverse is 1600Slow to 2222
//throttlePin.write(1575);
//delay(200);




for(pos = 0; pos < 12; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
throttlePin.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

for(pos = 12 ; pos >=1; pos -= 1) // goes from 180 degrees to 0 degrees
{
throttlePin.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

throttlePin.writeMicroseconds(RVS);
throttlePin.writeMicroseconds(0);

delay(3000);



for(pos = 1550; pos < 1700; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
throttlePin.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

for(pos = 1700 ; pos >=1551; pos -= 1) // goes from 180 degrees to 0 degrees
{
throttlePin.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}


delay(3000);

}
ErikP is offline   Reply With Quote
Old 03-01-2014, 10:00 PM   #5
Tech Rookie
 
ErikP's Avatar
 
Join Date: Feb 2014
Location: Houston
Posts: 6
Thumbs up I've got it!

It is a matter of adding the following code before and after the call for reversing. throttlePin is how I defined my throttle servo. For others, it will be different. Both versions of code, in this post, work if these lines are added:

throttlePin.writeMicroseconds(1500);

delay(2400);//2400 bare min. 3000 works well
ErikP is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -7. It is currently 06:48 AM.


We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.
Powered By: vBulletin v3.9.2.1
Privacy Policy | Terms of Use | Advertise Content © 2001-2011 RCTech.net