Shop OBEX P1 Docs P2 Docs Learn Events
Is it possible? — Parallax Forums

Is it possible?

Thierry DonzeThierry Donze Posts: 4
edited 2005-11-23 05:40 in BASIC Stamp
I have to find an interface to transform in RS232 format an analogic format supplying 200 pulses per nautical mile. This means that if we start from a minimal speed of 0,1 Knot,·a pulse are coming every 180 seconds, is there any function able to measure this and if not if there any possibility to make Stamp 2 working with a background task?

Thansk for your answers

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-22 11:22
    The BASIC Stamp 2 can't do "background tasks" as it's a single-threaded device. Can you give more details on the conversion? What is coming into the device, and what is going out? Do you have a conversion formula?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-11-22 14:31
    If the following scenario will work for you, then yes, the BS2 can do it.

    1. Measure the time between a pulse.

    2. Report the time via RS-232 to some RS-232 terminal device.

    3. Go back to 1 and repeat.

    It sounds like your device is generating pulses every 180 seconds, 200 seconds, etc based on the speed the boat is going -- 200 pulses per nautical mile, with the spacing between pulses depending on speed.

    The BS2 does NOT have a 'background' task, or a multi-tasking operating system. However, 180 seconds is a very long time for the BS2, so it can be doing something in the background while measuring the time between two pulses.

    Now, it also has the 'PULSIN' command, which is accurate to 2 micro-seconds, and while doing that it can't do anything else (like do a SEROUT command). However, your timing needs seem to be much wider than that.

    You might try the 50 mSec 'tick' generator IC at http://www.rhombus-tek.com/co-processors.html

    This will give you an accurate 'tick' clock you can use to time long duration events like the 180 seconds between pulses. And they talk about a PBasic level multi-tasking approach you can use.
  • Thierry DonzeThierry Donze Posts: 4
    edited 2005-11-22 17:15
    While thinking I found a trick, I will use the count argument andd with the BS2, I will base the delay on 0,1 second, if no answer, I will loop and increment a counter ie A, when I will receive the pulse, i will just have to calcule the time between 2 pulses with the Counter A. Then I can calculate the speed of the unit, based on 200 pulses per knots.

    For sure during the test, I will have maybe to separate the calculation, when the speed will become too high around 30 Knots

    I will check it asap, and will keep you inform as you were answering me.

    Thanks and regards for your help
  • bubbleheadbubblehead Posts: 36
    edited 2005-11-23 05:40
    A few ideas:

    1. Does the length of the pulse change with speed? If it does, maybe you can measure the length of the pulse at low boat speeds, and measure the time between pulses at high speeds.

    2. You could use an external clock/calendar chip. There are app notes on how to interface to one. If the time between pulses it so long that the FREQIN statement times out, then use the time from the calendar chip to calculate the interval.
Sign In or Register to comment.