|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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
|
||||||
|
||||||
|
Re: Controlling Jaguar with c code
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Controlling Jaguar with c code
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.
|
|
#8
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Controlling Jaguar with c code
Quote:
To do so: Quote:
|
|
#11
|
||||
|
||||
|
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.
|
|
#12
|
|||
|
|||
|
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
|
|||
|
|||
|
Re: Controlling Jaguar with c code
which pwm frequency do I want? 7k or 31k?
|
|
#14
|
||||
|
||||
|
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/ |
|
#15
|
|||
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|