one of the critical technologies for that flying gizmo are the rate gyro's on it basically they fly the craft and your controll inputs tell it what you want to do the design for them that i saw dosent look like it would be at all stable without active controll ----- Original Message ----- From: "Scott Pierce" To: Sent: Monday, January 27, 2003 2:05 PM Subject: R/C Timing > Okay, now that I have my program working the way I think it should on the > target device (20Mhz 16F84A), I need some help in tweaking it. To give you > a bit of a background on my project, I saw the Dragonfly 3 on RCToys.com > and was very impressed with it. It is a quad rotor radio controlled > helicopter. The only problem is they want $750 for it. Since I work for a > CNC Machining shop, I have all the tools to make one myself for a fraction > of the cost. I have a few radio controlled airplanes so I will be using a > standard Futaba radio for the project. I will be using a PIC to input four > channels from the R/C Receiver, mix the values to control each of the four > motors on the helicopter, then generate four PWM signals to drive each > motor depending on the R/C Transmitter stick positions. So far I have > built a quad half-H-Bridge circuit to drive the motors and planned out each > of the software modules to complete the system. I am currently working on > reading the PWM length from a single channel from the R/C Receiver. Source > code for what I have done is below. As this is my first *real* program > that I have written for a PIC MCU, I am still in the learning process (Easy > Pic'n, Pic'n Up the Pace, and a couple of Myke's books), I realize I'm > using the TRIS statement which I should not be using, but hey...for now, > it's easy, right? :) > > Anyway, what this program does is it sets all of PortA to inputs, all of > PortB to output (for use with an LED bar graph, which will be changed later > to driving PWM), then it waits for the current packet from the receiver to > finish. After that it waits for the next packet to come in, then starts > counting the number of cycles it is high for. I realize this method > doesn't give me the values I am looking for. An R/C pulse is between 1ms > to 2ms long. The way I am doing this only gives me how many cycles the PIC > went through before the packet finished. So, this is where you guys come > in. Can anyone describe how I could go about finding the length of the > pulse coming in? Preferably I'd like to have a value from 0 to 100, 0 > being the transmitter stick is all the way one direction, 100 being all the > way to the other direction. Since the pulse is 1-2ms, I figure I could > subtract the first ms to give me a range from 0 to 1ms which might be > easier to handle. How would I go about setting up a loop so that each time > through it, it's a tenth or a hundredth of a millisecond? I will be using > a 20Mhz 16F84A for the project. Thanks in advance. > > Sincerely, > Scott Pierce > > P.S. > Here is the source code I have so far. It is simply a test to see if I was > on the right track. > > ;===== RC Test.asm =============================================== > ; PROGRAM TO TEST THE OUTPUT SIGNAL OF A R/C AIRPLANE RECEIVER > ; SCOTT PIERCE 1-25-2003 > ; PORTB HAS 330 OHM RESISTORS IN SERIES WITH 8 LEDS. > ; PORTA,0 IS CONNECTED TO AN OUTPUT FROM THE R/C RECEIVER. > ; PORTA,1,2,3 WILL BE USED FOR OTHER R/C CHANNELS LATER. > ; 20MHZ PIC 16F84A > ;================================================================= > LIST P=16F84A > RADIX HEX > INCLUDE "P16F84A.INC" > ERRORLEVEL -224 ; SUPRESS TRIS WARNING MESSAGE > __CONFIG _PWRTE_ON & _HS_OSC & _WDT_OFF &_CP_OFF > ;================================================================= > CH1 EQU 0x0C > ;CH2 EQU 0x0D > ;CH3 EQU 0x0E > ;CH4 EQU 0x0F > ;================================================================= > ORG 0x000 > > MOVLW 0XFF ;LOAD W WITH 0XFF > TRIS PORTA ;MAKE ALL PINS IN PORTA INPUTS > MOVLW 0X00 ;LOAD W WITH 0X00 > TRIS PORTB ;MAKE ALL PINS IN PORTB OUTPUTS > MOVLW 0x00 > MOVWF PORTB ;CLEAR PORTB > > CH1A CLRF CH1 ;CLEAR CH1 COUNTER > CH1B BTFSC PORTA,0 ;LOOP UNTIL PORTA,0 PIN IS CLEARED > GOTO CH1B > > CH1C BTFSS PORTA,0 ;LOOP UNTIL PORTA,0 PIN IS SET > GOTO CH1C > CH1D INCF CH1 ;INCREMENT CH1 COUNTER > BTFSC PORTA,0 ;LOOP UNTIL PORTA,0 PIN IS CLEARED > GOTO CH1D > MOVF CH1,W ;LOAD W WITH CH1 > MOVWF PORTB ;LOAD PORTB WITH VALUE OF CH1 > GOTO CH1A ;START COUNTING > > END > ;================================================================= > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads