Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   Controlling Jaguar with c code (http://www.chiefdelphi.com/forums/showthread.php?t=104924)

Modder man 21-03-2012 23:01

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.

wireties 21-03-2012 23:33

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

Modder man 21-03-2012 23:46

Re: Controlling Jaguar with c code
 
Yes I think that should be all I need, I will get that set-up and tested tomorrow

Joe Ross 22-03-2012 11:22

Re: Controlling Jaguar with c code
 
Quote:

Originally Posted by wireties (Post 1147659)
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.

Modder man 22-03-2012 15:21

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.

Modder man 22-03-2012 15:25

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
}

}
}

wireties 22-03-2012 15:45

Re: Controlling Jaguar with c code
 
Quote:

Originally Posted by Joe Ross (Post 1147789)
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.

Modder man 22-03-2012 16:03

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.

Modder man 22-03-2012 16:19

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.

slijin 22-03-2012 17:44

Re: Controlling Jaguar with c code
 
Quote:

Originally Posted by Modder man (Post 1147894)
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.

Doc543 22-03-2012 18:31

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.

Modder man 24-03-2012 01:08

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.

Modder man 27-03-2012 00:58

Re: Controlling Jaguar with c code
 
which pwm frequency do I want? 7k or 31k?

Dale(294engr] 27-03-2012 01:40

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/

Brian Holford 02-04-2012 20:45

Re: Controlling Jaguar with c code
 
I just finished messing around with this...
https://sites.google.com/site/0123ic..._jaguar/jagwii
Control a Jaguar with a WiiNunchuck through the Arduino Platform

https://sites.google.com/site/0123ic...arduino_jaguar
has code with references at the bottom of the page


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

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