i am writing a program for my IR sensor
and i need
some help with programming
will the program below
drive an IR sensor that has no slave IC
the only servo for it is one little servo that pan the sensor ,right,left, ect.
main
T_IR var word
pan_left var word
pan_right var word
R_IR var word
T_IR = pulsout p1,100
R_IR = pulsin p2,T_IR
pan_left = servo p4,1500
pan_right = servo p4,1500
mid var word
mid = servo p4,0
low p1
low p2
low p4
high p1
pulsout p1
pulsin p2
if ((R_IR<100) then pan_left *R_IR)
endif
if ((R_IR>100) then pan_right *R_IR)
endif
if ((R-IR =100) then mid *R_IR
endif
goto main
end
well, wat Micro are you using? also, i thought u said u were getting an Ultrasonic Ping))) sensor, also, the code wont work, you dont have the mirco getting information for the sensor, the if then is just empty, because there is no info to go off of
well, idk how well that would work, and are u sur its an IR sensor?
im having a bit of trouble deciphering your code, do you think you could tell us what each of the variables are for? also, the variables are defined outside of “Main” and you dont need and “end” command because its just a continuous loop
What sort of an IR sensor is it?
Is it an integrated sensor/decoder, such as those used for IR remote control of TVs and VCRs? Those are sometimes used in PCs for media-control purposes.
Is it a slot-type detector, used to detect the presence of something blocking the gap between an emitter and detector? They can be found in old floppy drives for reading disk alignment marks and write-protect tabs.
Is it, as Eddie suggested, and IRDA module, used for “beaming” data to a PDA?
Is it a reflection-type detector? I’ve seen those used in drives too, but not for a long, long time.
As others have noted, without more information about your detector and code, it’s difficult to know what you’ve got, how you would interface it to your micro, and what you’re trying to do with it.
Using comment lines to document your code as you write it not only makes it easier for others to help you should you request it, but it makes it a lot easier to figure out what’s going on when you return to your code at a later date. It can really save you from reinventing the wheel in the long run, since you can cherry-pick your old programs for routines and code snippets, so you don’t need to develop everything from scratch each time you want to do something.
Comments and remarks are ignored when you compile, and don’t take up any room in the micro’s memory, so feel free to document, document, and document some more.
It is most likely an IRDA module, a legacy thing for allowing a laptop or programmable calculator to exchange files over the serial port using an infrared signal. Problem is of course that it is just an IR LED and PIN photodiode and no amplifier. So at the simplest level to use it you will probably need an op-amp and comparator and then a transistor to drive the LED. After that it’s all software.
Well you might be able to just amplify the PIN diode output and then use an a/d input on the uC to read and process from there. I was thinking that you might be better off to average the amplifier output and then use the comparator to look for spikes above that average when you pulse the LED, sort of a poor-mans synchronous detection algorithm. If the uC is fast enough you could just do it all in software.
Here is something similar to what I have described. If you can extract a part number from the one on your board you may be able to google it. infrarotport.de/tfd_4.pdf
yea i think thats it
so now about the programming
it keeps saying this when i try to program it
Compiling...
C:\DOCUMENTS AND SETTINGS\BRANDON\MY DOCUMENTS\BASIC.BAS
Error: FILE C:\DOCUMENTS AND SETTINGS\BRANDON\MY DOCUMENTS\BASIC.BAS(LINE 8) : [TOKEN P4] : Unexpected token type
Errors Detected
is there a typing error???
main
T_IR var word
pan_left var word
pan_right var word
R_IR var word
pan_left = servo p4,1500
pan_right = servo p4,-1500
mid var word
mid = servo p4,0
high p1
pulsout p1
pulsin p2
if ((R_IR<100) then pan_left *R_IR)
endif
if ((R_IR>100) then pan_right *R_IR)
endif
if ((R-IR =100) then mid *R_IR
endif
goto main
Aha - I see now. Come to think of it, I have worked with/on a few notebooks that had IRDA ports on the back of them - the computer that this came out of was a notebook, wasn’t it? Probably would have helped to have known that, as I had pictured a “computer” to imply a desktop-type system.
Information is good - especially when you’re trying to get help with something.
Well, without analyzing the entire block of code, the thing that immediately jumps out at me is that your line:
main
…you are using “main” like a keyword, instead of a label.
…and in your line:
if ((R-IR =100) then mid *R_IR
…you use a hyphen between R and IR within the IF, rather than an underscore, which will probably confuse it, though it’s returning an error far above that point.