Infrared Sensor with Javelin Stamp
I recently bought a Javelin Stamp along with the IR Transmitter Assembly Kit/IR Receiver and I was wondering how to use the Freqout command to generate the appropriate PWM signal between 38kHz and 40kHz.
So far I've only been able to produce a PWM signal of 28.8kHz and 56kHz but I have not been able to produce a signal in between this range, which is the range the IR transmitter requires to function.
This is the code that I have come up with in order to test the PWM signal using my university's oscilliscope:
import stamp.core.*;
public class freq {
static Freqout freq= new Freqout(CPU.pin12,5700);
public static void main() {
while (true) {
switch ( Terminal.getChar() ) {
case 'q':
freq.setFrequency(5760);
freq.start();
break;
case 'w':
freq.setFrequency(5765);
freq.start();
break;
}
}
}
}
Using the set.Frequency syntax at 5760 gives 28.8kHz and the 5765 gives 57.6kHz. I need the source which will enable me to create a PWM signal of frequencies between 38kHz and 40kHz.
Thanks in advance.
So far I've only been able to produce a PWM signal of 28.8kHz and 56kHz but I have not been able to produce a signal in between this range, which is the range the IR transmitter requires to function.
This is the code that I have come up with in order to test the PWM signal using my university's oscilliscope:
import stamp.core.*;
public class freq {
static Freqout freq= new Freqout(CPU.pin12,5700);
public static void main() {
while (true) {
switch ( Terminal.getChar() ) {
case 'q':
freq.setFrequency(5760);
freq.start();
break;
case 'w':
freq.setFrequency(5765);
freq.start();
break;
}
}
}
}
Using the set.Frequency syntax at 5760 gives 28.8kHz and the 5765 gives 57.6kHz. I need the source which will enable me to create a PWM signal of frequencies between 38kHz and 40kHz.
Thanks in advance.
Comments
· /**
·· * Set output frequency. Accurate only to 8.68us timebase.
·· *
·· * @param frequency frequency in hertz/10 (1 - 12k)
·· */
· public void setFrequency(int frequency) {
··· if ( frequency < 1 ) {
····· frequency = 1;
··· } else if ( frequency > 11521 ) {
····· frequency = 11521;
··· }
··· int halfCycleTime = 11521 / frequency;
··· update(halfCycleTime, halfCycleTime);
· }
you may have values 1-11521 representing freq 10-115210
So for 38.64kHz (38640) you would use value 3864
Notice 11521/5760 = 2
11521/5765 = 1
11521/3864 = 2
11521/3840 = 3
So I suggest to use 3840 to generate 38.4kHz
The halfCycleTime equals the number of 8.68uS
these are the same numbers as for Uart.speed57600 (2) and Uart.speed38400 (3)
regards peter
·
it may be the sum of both halfCycleTime that must equal 3 for 38.4kHz
Try update(1,2) or update(2,1)
The pwm has no 50% dutycycle then.
regards peter
· /**
·· * Set output frequency. Accurate only to 8.68us timebase.
·· *
·· * @param high Number of 8.68uSec ticks output high
·· * @param low Number of 8.68uSec ticks output low
·· */
· public void setFrequency(int high, int low) {
··· update(high,low);
· }
This allows you to set the exact number of ticks for the pwm period.
regards peter
·
PS: Is it necessary to even have a 50 percent duty cycle for the infrared transmitter?
if the dutycycle must be 50%. This is the only freq in the 38-40kHz
range that the javelin can generate.
You can find·the·JBot package here
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/JBot/
regards peter
I thought it might be a bad download so i did it again, but to no success.
The reason i am interested in it is because the setup that i have is not working as i designed it to.
Here it is, I have a 555 timer on a separate circuit that feeds a 38kHz signal to three ir leds. (I've hooked it up to an o-scope and tested it) Left, right, front.
Then i have three IR detectors sitting besides the ir leds, making 100% sure that there is no IR leakage going to the detector.
In the schematics on Parallax it says there is no additional components to connect when using the ir detector. i.e. resistors or such. But when i connect the pins as per the diagram, the chip heats up a little. (So naturally i check, recheck everything, even put an amp meter on the different parts to measure the flow).
I'm thinking that i will drop this 555 circuit and go with the JBot configuration. The hitch is that when I look at the chapter, no pictures so it makes it a little more difficult.
Is there anyway I could get those chapters with the pictures?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Huey
Double Bachelor of Science
CPET - Computer Engineering Technologies
CIS - Computer Information Systems
MSU-Northern
Chair of MSU-Northern IEEE Student Branch
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/JBot/
This is pretty much the same text but targets the basic stamp and has pictures.
Parallax never updated the preliminary version of the JBot text.
regards peter
·
With nothing connected to any pins on the stamp, i measured the current draw (from the battery) and got a whopping 103mA. Which explains why it is getting warm. I re-socketed the stamp and got the same results. I am 100% sure that i protected all pins when connecting circuits to the stamp. Any suggestions?
Buying a new one is kinda out of the question as my presentation is on Monday at 3:00
Kinda thinking im royally screwed here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Huey
Double Bachelor of Science
CPET - Computer Engineering Technologies
CIS - Computer Information Systems
MSU-Northern
Chair of MSU-Northern IEEE Student Branch
is connected. Check your multimeter battery. My multimeter always shows
wrong resistor values when its battery is going bad, but before signaling it
as such. Perhaps it affects current measurements too.
As long as you can reprogram your javelin I don't think you need to worry.
regards peter