Shop OBEX P1 Docs P2 Docs Learn Events
Infrared Sensor with Javelin Stamp — Parallax Forums

Infrared Sensor with Javelin Stamp

klddxklddx Posts: 8
edited 2008-05-02 20:50 in General Discussion
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.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-24 01:42
    According to setFrequency
    · /**
    ·· * 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

    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-24 01:57
    Addition,

    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
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-24 06:04
    Add the following method to class Freqout.java

    · /**
    ·· * 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
    ·
  • klddxklddx Posts: 8
    edited 2006-03-25 20:01
    Thanks peter, you are right it does give a frequency of 38Khz however, this does not satisfy the requirement for the PWM signal to be at 50 percent duty cycle. Using the code you provided, the infrared sensor still did not work. Is there any possible way to get a 50 percent duty cycle and a 38-40kHz PWM signal with the javelin? Or any way to use the infrared sensor with the javelin? I have read the forums about the Jbot but Parallax seems to have taken the documentation off their website. Does anyone have the code on how they used their infrared sensor with their Javelin? Thanks again.

    PS: Is it necessary to even have a 50 percent duty cycle for the infrared transmitter?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-25 20:31
    I don't know if 38.4kHz is suitable for your IR tranceiver, neither
    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
  • SpaceCowboySpaceCowboy Posts: 1
    edited 2006-03-27 20:20
    I also have the same problem using Javelin with IR sensors that I brought (PNA4601M & 350-00018). Does anyone know how to make them work?
  • klddxklddx Posts: 8
    edited 2006-03-28 22:02
    Thanks again Peter, we were able to get the IR sensors to work using the JBOT documentation. The file called IrRangeTest1.java should work.
  • klddxklddx Posts: 8
    edited 2006-04-01 20:27
    BTW, we have found that the program above works best if you remove the capacitors that is connected to the DAC pin.
  • HueyHuey Posts: 23
    edited 2008-05-02 02:15
    When I look inside the JBot.zip i find the pdf's in chapters. When i look at the chapter regarding the topic of using a DAC and PWM to determine distance, there is no pictures. Just blank boxes.·
    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
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-05-02 05:39
    Get the Robotics v2.2 text from here:
    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
    ·
  • HueyHuey Posts: 23
    edited 2008-05-02 20:19
    Now Im worried my stamp is gone.

    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
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-05-02 20:50
    A javelin is always getting warm because it draws 80mA or so when nothing
    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
Sign In or Register to comment.