![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
I should have put some notes out to the side of the program. When I fix it later I'll write a lot of side notes. Here's my logic
transmitter: Do ADC. Send a fixed IR signal followed by a minimum gap for whenever you send a value close to zero. (if not the IR receiver will turn up the gain and stop receiving) wait an amount of time based on the ADC, then send another IRpulse to tell the receiver to stop counting. receiver: listen for the IR receptor to drive the pin low, wait for pin to be high again and start counting. First count the minimum gap time, then start counting the value to be used in the main program. When the pin is driven low again stop counting. Do PWM. So I hope that helps this to be clearer. Now I'm doing two channels...send a pulse then data1 then a pulse then data2 then a pulse.....but now I need some kind of really long pulse to lead the data to let the receiver know to start counting data1 then data2.
__________________
jeremy |
|
|
|
|
|
|
(permalink) |
|
Hi jeremy are you with me?
Yes I think you are with me.I have written a code for you specially the transmitter part.But I haven't checked it yet. I'm sending a data packet through IR LED.Don't know whether you like it or not but I have to do.Just go through it. Code:
GP0=button (active low) GP1=IR TX LED ;************************************* ;Che_But - sends one packet at a time ;************************************* Che_But btfss GPIO,GP0 ;has the button pressed? goto $+2 ;yes, goto Che_But ;no,then wait until press call Transmit ;transmit the packet btfss GPIO,GP0 ;button still pressed? goto $-1 ;yes, goto Che_But ;no,has released, ;******************************************************** ;Transmit - routine sends data in the packet (brightness) ;******************************************************** Transmit call Check_AD movlw .8 movwf Counter ;makes counter for 8 bit Loop3 bcf STATUS,C rlf Brightness,F btfss STATUS,C goto Do_Zero goto Do_Ones Do_Ones movlw d'22' movwf Highpulse ;makes 600uS high time goto $+3 Do_Zero movlw d'12' ;makes 300 + low time movwf Highpulse call Do_Logic ;transfer the logic call Do_Gap ;transfer fix gap time decfsz Counter,F ;repeat for other bits goto Loop3 return ;************************************** ;Check_AD returns the brightness value ;************************************** Check_AD bsf ADCON0,GO btfsc ADCON0,GO goto $-1 movf ADRESH,W movwf Brightness ;brightness contains dim level return ;******************************************** ;Do_Logic - logic high time > logic low time ;******************************************** Do_Logic Loop1 BSF GPIO,1 ;27 commands makes 38khz goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 BCF GPIO,1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz Highpulse,F goto Loop1 return ;***************************************** ;Do_Gap - a fix gap time min 300us needed ;***************************************** Do_Gap movlw D'12' ;makes a fix gap after burst = 300uS movwf Lowpulse Loop2 nop ;27 commands makes 38khz goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 nop goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz Lowpulse,F goto Loop2 return |
|
|
|
|
|
|
(permalink) |
|
very nice. I like the roll folder left to transmit exactly the value you want. Looks like a good way to get a precise number. I'm just counting the gap, whereas you are sending the 8 bit number one bit at a time. One thing I see is that you need to send a unique pulse before the whole thing so the receiver knows that it's the beginning of the packet being sent. I see that you have the button so that it only sends one packet at a time, but if it catches it in the middle or gets the first bit of interference from a light in the house it will be out of sequence. I'm crazy busy at work lately, but I'm going to build your code and try it when I get a moment. Also, I've almost got my two channel code going. Big long IR pulse to mark the start of the packet then gap, small pulse, gap, small pulse. Then I'm going to use a lightened micro servo to turn it. Soon I'll have control of this foam, pager motor pulling, scotch tape, toothpick braced junker.
__________________
jeremy |
|
|
|
|
|
|
(permalink) | |
|
Quote:
A similar technic that I used in my IR projects.Thats a clever technic.So you no need to worry about the resolution or time takes to transfer. 8 bit resolution is more than enouth to dim a LED smoothly or to speed control a DC motor. |
||
|
|
|
|
|
(permalink) |
|
it's been a while since I could work on this, but now it works pretty well. It was really difficult to figure out the pwm to run two motors with varying speeds at the same time. Maybe there is a better way that someone knows. Please feel free to criticize if you know about that. The problem I'm having now is that the motor pulses about 5 times per second. Which as far as I can tell doesn't coincide with my interrupt timing. Right now that is my biggest problem, Any ideas?
The goal eventually with the second channel is to run an actuator. I only know a little about them so it's going to be a while before I figure them out. Here are the codes for the transmitter and the receiver. The receiver is 12f629 because I only had one 12f675 in my collection. It doesn't need to do adc so I went with it on the receiver. Cool thing is it runs with the 12f675's code so I didn't have to do anything to it. There is some redundancy that can be removed from the code and I'm on that right now, but I'm really interested in making it stop pulsing the motor. Code:
;1 channel receiver using IR and ADC on a 12f629 list P=12f629 #include <p12f629.inc> __config _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _CP_OFF ERRORLEVEL -302 cblock 20h longpulse, pause, pulseontime, pulsegap, pulsegap2, pwmhighcounter, pwmlowcounter, pwmhighcounter2, pwmlowcounter2, pwmtimer endc ORG 0000h goto start1 ORG 0004h call readpulsegap BCF PIR1,0 RETFIE start1 bsf STATUS,RP0 ;bank 1 movlw 0x08 movwf TRISIO ;set I/O BSF PIE1,0 ;something for interrupts bcf STATUS,RP0 movlw 0x07 ;turn off comparitors movwf CMCON movlw 0xc0 movwf INTCON ;set interrupt time movlw 0x21 movwf T1CON start call pwm ;runs motor the whole time while waiting for the interrupt call pwm ;that will read the IR signal call pwm call pwm call pwm call pwm goto start pwm movlw 0xff ;sets the length of pwm interval movwf pwmtimer pwm2 movf pulsegap,0 ;takes the pulse gap read in the interrupt and puts in in the pwm counter movwf pwmhighcounter movf pulsegap2,0 movwf pwmhighcounter2 pwmrun bsf GPIO,1 ;turn pwm on bsf GPIO,0 decfsz pwmhighcounter,1 goto $+2 ;count dowm channel 1 if still counting skip turning it off bcf GPIO,1 ;if done counting turn off channel 1 decfsz pwmhighcounter2,1 goto $+2 ;count down channel 2 if still counting skip turning it off bcf GPIO,0 ;if done counting turn off channel2 decfsz pwmtimer,1 ;count down rest of time to make 256 cycles total goto pwmrun return readpulsegap ;start reading pulse gap clrf pulsegap movlw 0x28 ;sets value that counts IR pulse length that makes sure the movwf longpulse ;pulse length is the long one that signals start of data readpulsegap1 goto $+1 ;wait at least 29 commands goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 btfsc GPIO,3 ;keep testing the IR reveiver to make sure it is constantly reading a pulse goto readpulsegap;if the pulse isn't long enough start counting the next pulse decfsz longpulse,1 goto readpulsegap1 wait btfss GPIO,3 ;wait for pulse to stop being sent goto $-1 movlw 0x0e movwf pause leadpause NOP ;27 commands makes 38khz goto $+1 ;count off minimum pause goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 NOP goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz pause,1 goto leadpause wait2 btfss GPIO,3 ;if still no pulse then start counting the length of the pulse gap goto betweenchannels goto $+1 ;keep counting until pulse starts again goto $+1 goto $+1 ;goto commands used to recompress the long pause into an 8 bit number goto $+1 goto $+1 goto $+1 goto $+1 incf pulsegap,1 goto wait2 betweenchannels ;wait until pulse stops to continue btfss GPIO,3 goto $-1 nop nop wait3 ;count second pulse same as counting the first pulse btfss GPIO,3 return goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 incf pulsegap2,1 goto wait3 return end Code:
;1 channel transmitter using IR and ADC on a 12f675 list P=12f675 #include <p12f675.inc> __config _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _CP_OFF ERRORLEVEL -302 cblock 20h datauno, datados, temp, irpulse, datagap, datagap2, min, trimpwm, trimpwm2, pwmcounter endc ORG 0000h goto start1 ORG 0004h call adc BCF PIR1,0 RETFIE start1 bsf STATUS,RP0 ;bank 1 movlw 0x34 movwf ANSEL movlw 0x1c movwf TRISIO ;set I/O BSF PIE1,0 bcf STATUS,RP0 movlw 0x07 ;turn off comparitors movwf CMCON movlw 0x09 movwf ADCON0 ;set to read first pot of controller movlw 0xc0 movwf INTCON ;set interrupt timers movlw 0x21 movwf T1CON ;set interrupt timers call adc start btfss GPIO,3 ;check if test button is pushed call trim call leadIRpulse ;send long pulse to let receiver know code is starting call data1 ;make a gap in the pulse to be counted by receiver for channel 1 call IRpulse ;send normal length pulse to to tell receiver data for first channel has ended call data2 ;make a gap in the pulse to be counted by receiver for channel 2 call leadIRpulse ;tells receiver that data for the second channel has ended and new data is coming call data1 ;repeats same stuff as before call IRpulse call data2 call leadIRpulse call data1 call IRpulse call data2 call IRpulse ;send normal pulse this time to only tell the receiver that data for channel 2 has ended goto start adc movlw 0x09 ;set to read channel 1 potentiometer movwf ADCON0 bsf ADCON0,1 ;start adc waiting btfsc ADCON0,1 ;wait for adc to finish goto waiting movf ADRESH,0 ;move adc reading to a file to use later movwf datauno goto $+1 ;give time to let adc charge for channel 2 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 movlw 0x0d ;change to read channel 2 potentiometer movwf ADCON0 bsf ADCON0,1 waiting2 btfsc ADCON0,1 ;waiting for adc goto waiting2 movf ADRESH,0 movwf datados ;move data to second channel return IRpulse ;set value for length of minimum gap time movlw 0x0f ;this way there is always a gap even if the movwf min ;data being sent is zero movlw 0x1e ;set time for the IR pulse length movwf irpulse IRpulse2 BSF GPIO,1 ;27 commands makes aprox. 38khz goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 BCF GPIO,1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz irpulse,1 ;count down pulse length goto IRpulse2 minpause NOP ;27 commands makes 38khz goto $+1 ;this is the pause that precedes every data pause or pulse gap goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 NOP goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz min,1 ;count down minimum gap time goto minpause return leadIRpulse ;set length of unique lead IR pulse to let receiver know that movlw 0x0f ;the data is about to start movwf min movlw 0x28 movwf irpulse leadIRpulse2 BSF GPIO,1 ;27 commands makes aprox. 38khz goto $+1 ;same IR pulse deal as before goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 BCF GPIO,1 goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz irpulse,1 goto leadIRpulse2 minpause2 NOP ;27 commands makes 38khz goto $+1 ;same minimum gap deal as before goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 NOP goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz min,1 goto minpause2 return data1 movf datauno,0 ;move the adc information from the channel one potentiometer to movwf datagap ;a counter to send the gap between pulses which will be counted by the receiver dataa goto $+1 ;goto commands used to make gap much longer than just the 8 bit adc value would goto $+1 ;if it were counted down by it self goto $+1 goto $+1 goto $+1 decfsz datagap,1 goto dataa return data2 movf datados,0 ;data gap being sent for channel 2 movwf datagap2 datab goto $+1 goto $+1 goto $+1 goto $+1 goto $+1 decfsz datagap2,1 goto datab return trim ;there is a switch in the circut that can be pushed to allow call adc ;the adc to be trimed using extra 5k pots movlw 0x20 ;note only trims channel one movwf pwmcounter pwmstart movf datauno,0 movwf trimpwm movwf trimpwm2 pwm bsf GPIO,5 decfsz trimpwm,1 goto $-1 bcf GPIO,5 incfsz trimpwm2,1 goto $-1 decfsz pwmcounter,1 goto pwmstart btfss GPIO,3 goto trim return end
__________________
jeremy |
|
|
|
|
|
|
(permalink) |
|
I received my free helicopter (promo from Energizer battery company) about a week ago.
What a riot! It uses IR remote control for up, down, left and right. It speeds up when turning right and slows down when turning left so it is tricky to make it hover. It is more convenient than my RC airplane because it flies in the house and in the yard in the evenings when the wind is low. It flies for about 6 minutes per charge. It cools for 10 minutes after a flight then charges for 20 minutes. It is a Spinmaster Air Hogs Havoc Heli available at Wal-Mart. It is made in China so it is very inexpensive. I bought one for my son. It was dead but Wal-Mart replaced it for a good one.
__________________
Uncle $crooge |
|
|
|
|
|
|
(permalink) |
|
AG,
Those are always great fun. I managed to find an inexpensive (used) Air Hogs Aerosoar (which isn't the best micro plane, unlike the Aero Ace which is quite excellent) and I plan to use the parts in my own scratch-built planes. You should see some of the stuff people have designed using Air Hogs parts! -Omar |
|
|
|
|
|
|
(permalink) |
|
Any links, Omar?
__________________
Agustín Tomás In theory, there is no difference between theory and practice. In practice, however, there is. |
|
|
|
|
|
|
(permalink) |
|
That's an awesome little chopper. I got a set of two that have IR leds on them and you can shoot the other chopper and it's tail will stop working for about 3 seconds. It's a lot of fun for 5 minutes. I got another one and that is what I'm destroying to take the battery and motor. Here is a picture of my test setup it's pretty disgusting. I've got the guts of a playstation controller hooked to a pic and some IR leds then hooked to the second board with the receiver and a mosfet and motor just to suck all the power form a USB wire. There are wires connecting them but it's just for power. It's been a lot of fun to put it together.
__________________
jeremy |
|
|
|
|
|
|
(permalink) |
|
At a hobby show I saw the home-made indoor gym airplanes controlled with the parts from those cheap micro RC cars.
The Air Hogs airplanes are flying on the edge of a stall with the nose pointing up. They are probably extremely fragile since you can't pick them up without reading the warnings in the instructions. My helicopter is strong. It has crashed into the ceiling, walls, furniture, my wife, other things, my son's helicopter, my car. the driveway, a couple of trees and the eavestrough on my home. It is still like new.
__________________
Uncle $crooge |
|
|
|
|
|
|
(permalink) |
|
Sure, there are tons on RC Groups, a rather popular RC forum (check the micro section).
Here is a link to a thread regarding building with Aeroace (Air Hogs) guts: http://www.rcgroups.com/forums/showthread.php?t=535921 One favourite micro plane that is the standard beginner plane is the "BUMP"-- RCG has the plans up in the sticky. Once I get my Aerosoar (and I convert the battery to a smaller LiPo), I'll build a BUMP. Another fun design is the traditional IFO plane(shaped like a tiny flying disk-- really fun to fly!) -Omar |
|
|
|
|
|
|
(permalink) |
|
My son bought 3 no-name-brand helicopters because he couldn't find a Wal-Mart store that had the Air Hogs one. They were all defective.
The Wal-Mart store near me had about 30 of the Air-Hogs one. Maybe half of them work properly.
__________________
Uncle $crooge |
|
|
|
|
|
|
(permalink) | |
|
Quote:
The conversion requires a range increase and some sort of gearbox but otherwise it is quite possible. Ah yes, midway through this reply I went through my old favourites and here is the website: http://members.aol.com/rchelicam/microszr/microszr.htm -Omar |
||
|
|
|
|
|
(permalink) |
|
I've seen those airplanes built form small cars. They can be fun but the control is what we can "bang bang" full on or full off for the left and right rudder. Like you said they are so fragile that it's more frustrating than fun (for me) to fly them. What I'm trying to do now is build an airplane that you can slam like a airhogs chopper.
I had the same problem with the choppers not working it was my third one that finally worked well. For me the carbon butterfly design for microflyers is the toughest micro. However it's a little expensive to buy the carbon.
__________________
jeremy |
|
|
|
|
|
|
(permalink) |
|
My son found a hobby store where the owner was flying an RC "butterfly" airplane inside. It was $120.00.
My much bigger and faster Chinese RC airplane was $70.00. My Air Hogs was free but Wal-Mart sells them for $29.92.
__________________
Uncle $crooge |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| where to buy test equipment | notwist | General Electronics Chat | 5 | 30th March 2008 09:37 PM |
| Test Equipment | abbarue | General Electronics Chat | 3 | 10th November 2007 04:59 AM |
| Good Electronic Supply's Sites, Everyone Come On In! :P | Electric Rain | General Electronics Chat | 44 | 27th August 2007 11:05 PM |
| more test equipment! | HiTech | Chit-Chat | 5 | 15th September 2006 05:41 PM |
| High speed switch in psu..I have better test equipment now | heathtech | General Electronics Chat | 26 | 11th July 2005 05:15 PM |