AaronInSpace 4 Posted September 30, 2011 Share Posted September 30, 2011 Has anyone ever controlled a hobby rc car's Electronic Speed Controller before? It seems like its simple PWM same as the car's servo but mine doesn't behave. Sometimes it runs sometimes it doesn't. It may be that I am using a programmable high-end ESC that doesn't like something about my signal. I'm using the Fusion Novak ESC by the way. Quote Link to post Share on other sites
xmob 26 Posted September 30, 2011 Share Posted September 30, 2011 Have you tried connecting your output to a servo? If the servo moves predictably, at least you have some confirmation that your code is on the right track. AaronInSpace 1 Quote Link to post Share on other sites
HylianSavior 37 Posted October 1, 2011 Share Posted October 1, 2011 Here's the basic method of using an ESC (make sure you're sending servo signals and not just any old PWM signal!): -Connect ESC to live power (you may or may not hear beeping) -After a bit, send a neutral servo signal - i.e. it would keep a servo dead center at 90 degrees -Sending signals above neutral should move it forward, while sending signals below neutral should move it backwards. At least that's how it works from what I remember. There's always a signal you need to send first to "arm" it. Try a program that does a sweep of a bunch of different PWM values. AaronInSpace 1 Quote Link to post Share on other sites
AaronInSpace 4 Posted October 1, 2011 Author Share Posted October 1, 2011 Hey Hylian, you may have nailed it. I'm gonna test that now. Yes my code does work as expected as I use it on a servo just fine. I just have problems reliably controlling the ESC. Sometimes it responds (thought not always in the correct direction or speed) but not always. Thanks Quote Link to post Share on other sites
bluehash 1,581 Posted October 1, 2011 Share Posted October 1, 2011 Make sure you calibrate your controller first.STEP6: http://www.teamnovak.com/download/instr ... fusion.pdf Before beginning this step, the speed control should be connected to the receiver and to a charged 6 or 7 cell battery pack, and the transmitter should be adjusted. Adjustment of your Fusion speed control is required for proper operation. When the status LED is red, the speed control is in the neutral position (no throttle or brake). When the status LED is green, the speed control is either at the full throttle or full brake position. 1. CONNECT THE BATTERY Plug the speed control into a fully charged 6 or 7 cell nickel-cadmium battery pack. 2. TURN ON TRANSMITTER THEN THE SPEED CONTROL 3. PRESS AND HOLD ESC Quote Link to post Share on other sites
AaronInSpace 4 Posted October 1, 2011 Author Share Posted October 1, 2011 Thanks Blue. I have that manual and have previously done that procedure half a dozen times but it doesn't seem to work. I apologize for not having mentioned that earlier. I was mostly just checking to see if that is how ESCs are supposed to work in general. Here's my code to do that procedure if your curious: #include #include "common.h" #include "main.h" #include "utility.h" int up = 0; int command_0ccr1; void init_clocks_and_io(void) { // Stop watchdog WDTCTL = WDTPW + WDTHOLD; // Make P1.0 (red led)and P1.6 (green led) an output. SLAU144E p.8-3 P1DIR |= BIT0 + BIT6; // Set clock to 1 MHz DCOCTL= 0; BCSCTL1= CALBC1_1MHZ; DCOCTL= CALDCO_1MHZ; // SMCLK = 1 MHz / 8 = 125 KHz (SLAU144E p.5-15) BCSCTL2 |= DIVS_3; // P1.2 = TA0.1 (timer A's output). SLAS694C p.41 P1SEL |= BIT2; // PWM period = 125 KHz / 2500 = 50 Hz = 20ms periods TA0CCR0 = 2500; // Neutral 1.5 ms (2500/20 = counts per ms) * 1.5ms TA0CCR1 = 188; // Source Timer A from SMCLK (TASSEL_2), up mode (MC_1). // Up mode counts up to TACCR0. SLAU144E p.12-20 TA0CTL = TASSEL_2 | MC_1; // OUTMOD_7 = Reset/set output when the timer counts to TACCR1/TACCR0 // CCIE = Interrupt when timer counts to TACCR1 TA0CCTL1 = OUTMOD_7 | CCIE; __enable_interrupt(); } void forward_fast(void) { command_0ccr1 = 250; } void neutral(void) { command_0ccr1 = 188; } void brake(void) { command_0ccr1 = 162; } void main(void) { // Set up clocks and Timer A init_clocks_and_io(); while (1) { neutral(); P1OUT |= BIT0; P1OUT &= ~BIT6; m_delay(20000); forward_fast(); P1OUT |= BIT6; P1OUT &= ~BIT0; m_delay(20000); brake(); P1OUT |= BIT0 + BIT6; m_delay(20000); } } // This will be called when timer counts to TACCR1. #pragma vector=TIMER0_A1_VECTOR __interrupt void Timer0_A1 (void) { int curr_0ccr1 = TA0CCR1; // Clear interrupt flag TA0CCTL1 &= ~CCIFG; if (curr_0ccr1 != command_0ccr1) { // Wait to set the new TACCR1 until TAR has gone past it, so that we // don't get interrupted again in this period. while (TA0R <= curr_0ccr1); TA0CCR1 = command_0ccr1; } } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.