Go to Post I have a feeling this is going to be a really good year.:) - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-03-2012, 23:01
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Controlling Jaguar with c code

I am using a jaguar for a different project. I am using an atmega32 as my micro controller for the project. I am not really sure how the jag uses the pwm to drive it.
  #2   Spotlight this post!  
Unread 21-03-2012, 23:33
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Controlling Jaguar with c code

A 50% duty cycle is mid-range, less than that is backwards, more than that is forwards. Is that what you were looking for?

HTH
__________________
Fast, cheap or working - pick any two!
  #3   Spotlight this post!  
Unread 21-03-2012, 23:46
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

Yes I think that should be all I need, I will get that set-up and tested tomorrow
  #4   Spotlight this post!  
Unread 22-03-2012, 11:22
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Controlling Jaguar with c code

Quote:
Originally Posted by wireties View Post
A 50% duty cycle is mid-range, less than that is backwards, more than that is forwards. Is that what you were looking for?
That's not true. It uses a servo style PWM with expanded limits. See the jaguar datasheet at ti.com/jaguar for more details.
  #5   Spotlight this post!  
Unread 22-03-2012, 15:21
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

I see that in the data shee but I do not know how to code for a servo either. what i am running right now is not working.
  #6   Spotlight this post!  
Unread 22-03-2012, 15:25
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

This is the PWM code we are currently running



// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 7.813 kHz
// Mode: Fast PWM top=0x00FF
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0xA1;
TCCR1B=0x0D;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0xFF;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC disabled
ADCSRA=0x00;

// SPI initialization
// SPI disabled
SPCR=0x00;

// TWI initialization
// TWI disabled
TWCR=0x00;

while (1)
{
//XBEE Transmit & Receive
//delay_ms(10);

//PORTB = 0x1C;

USART_Receive();
//delay_ms(1000);

//PWM Drive Code
if(rxData == 0x31)
{
OCR1AL = 0x00; //set 0% duty cycle
//OCR1BL = 0x00; //set 0% duty cycle
}
else if(rxData == 0x33)
{
OCR1AL = 0x9E; //set 62% duty cycle
//OCR1BL = 0x66; //set 40% duty cycle
}
else if(rxData == 0x44)
{
OCR1AL = 0xB2; //set 70% duty cycle
//OCR1BL = 0x80; //set 50% duty cycle
}
else if(rxData == 0x55)
{
OCR1AL = 0xCC; //set 80% duty cycle
//OCR1BL = 0x9E; //set 62% duty cycle
}
else if(rxData == 0x66)
{
OCR1AL = 0xE6; //set 90% duty cycle
}
else if(rxData == 0x77)
{
OCR1AL = 0xFF; //set 100% duty cycle
}
//Reverse drive
else if(rxData == 0x35)
{
OCR1AL = 0x9E; //set 62% duty cycle
}
else if(rxData == 0x36)
{
OCR1AL = 0xB2; //set 70% duty cycle
}
else if(rxData == 0x37)
{
OCR1AL = 0xCC; //set 80% duty cycle
}
else if(rxData == 0x38)
{
OCR1AL = 0xE6; //set 90% duty cycle
}
else if(rxData == 0x39)
{
OCR1AL = 0xFF; //set 100% duty cycle
}
else
{
//OCR1AL = 0x00; //set 0% duty cycle
}

}
}
  #7   Spotlight this post!  
Unread 22-03-2012, 15:45
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Controlling Jaguar with c code

Quote:
Originally Posted by Joe Ross View Post
That's not true. It uses a servo style PWM with expanded limits. See the jaguar datasheet at for more details.
I stand corrected - sorry to give you bad advice (must have been thinking about model trains or something). The Jags use pulse widths, something like 1-2ms every 20ms.
__________________
Fast, cheap or working - pick any two!
  #8   Spotlight this post!  
Unread 22-03-2012, 16:03
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

Yeah we figured it out, set a Bunch of values up on a joystick and cycled through them until we got motion, by doing this we were able to find the range of inputs that the jaguars can accept.
  #9   Spotlight this post!  
Unread 22-03-2012, 16:19
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

well, perhaps not, I found a range where we get motion but we cannot seem to find where the middle/neutral is. a value from 12-48 is giving us full foraward or reverse so i figured somewhere in the middle should be neutral but i am not finding it.
  #10   Spotlight this post!  
Unread 22-03-2012, 17:44
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Controlling Jaguar with c code

Quote:
Originally Posted by Modder man View Post
well, perhaps not, I found a range where we get motion but we cannot seem to find where the middle/neutral is. a value from 12-48 is giving us full foraward or reverse so i figured somewhere in the middle should be neutral but i am not finding it.
If you'd rather not go through the trouble of producing the exact signals that the Jaguar takes by default, you can recalibrate the Jaguar to take the signal range that your output is delivering.

To do so:

Quote:
To calibrate the servo-style PWM input for a specific range, connect a PWM source, then:
1. Hold down the USER switch with a straightened paperclip for 5 seconds.
2. The LED flashes Red and Green to indicate Calibration mode.
3. Instruct the controller to send a full-forward signal for one or more seconds.
4. Instruct the controller to send a full-reverse signal for one or more seconds.
5. The LED flashes Green and Yellow quickly to indicate a successful calibration.
The MDL-BDC24 samples these signals and centers the speed range and neutral position
between these limits. A calibration failure signals if an out-of-range signal is detected. This
condition is indicated by flashing the LED Red and Yellow.
If you want to reset the calibration to factory settings, just power up the Jaguar while holding down the USER button until a slow-flashing red and green pattern appears.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #11   Spotlight this post!  
Unread 22-03-2012, 18:31
Doc543's Avatar
Doc543 Doc543 is offline
Electrical, Pneumatics, Driver
AKA: Eric
FRC #1891 (BullBots)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Meridian Idaho
Posts: 63
Doc543 is an unknown quantity at this point
Re: Controlling Jaguar with c code

I have have an Arduino and I have just been using the regular old servo library for it and it runs great! I'm looking in the c file for that library and it says its minimum pulse width is 544 and its max is 2400 in microseconds, default says it is 1500.
__________________

"Its just a prototype."
2011 Chairman's Award Utah Regional
2010 Gracious Perfectionism Utah Regional
2009 Gracious Perfectionism Portland Regional
  #12   Spotlight this post!  
Unread 24-03-2012, 01:08
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

Well we got to the the code on our bot today and it works....sometimes. Without changing the values it would move sometimes and not others I am at a bit of a loss as to what is going on. I don't see how the same value is producing different results.
  #13   Spotlight this post!  
Unread 27-03-2012, 00:58
Modder man Modder man is offline
Registered User
FRC #1806
 
Join Date: Mar 2012
Location: Missouri
Posts: 8
Modder man is an unknown quantity at this point
Re: Controlling Jaguar with c code

which pwm frequency do I want? 7k or 31k?
  #14   Spotlight this post!  
Unread 27-03-2012, 01:40
Dale(294engr]'s Avatar
Dale(294engr] Dale(294engr] is offline
Mentor/Sponsor since '98
FRC #0294 (Beach Cities Robotics)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Redondo Beach, CA
Posts: 92
Dale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of lightDale(294engr] is a glorious beacon of light
Re: Controlling Jaguar with c code

try 50Hz rep rate of 1-2 mS positive pulse 0-5v

20 ms period = 50 Hz PWM frequency but this can vary and is NOT critical

kHz may be way too high might produce weird result such as you have

traditional PWM R/C signal is 1ms to 2ms with 1.5ms as neutral.

Servos swing 90 degrees on either side of neutral

-90 deg = 1 mS
neutral = 1.5mS (define a +-few% say 20 - 40 us deadband to avoid chatter)
+90deg = 2.0 mS

For a 555 based hardware driver solution:
http://pcbheaven.com/wikipages/How_RC_Servos_Works/
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:09.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi