Shop OBEX P1 Docs P2 Docs Learn Events
Urgent help with code — Parallax Forums

Urgent help with code

jtaylor408jtaylor408 Posts: 15
edited 2009-03-04 23:27 in BASIC Stamp
I am having some problems with the 433 MHz receiver. Let me first give you a rundown of my project. I am building an avalanche search bot. The victim of the avalanche has a separate board with the transmittter that is constantly transmitting a signal. My robot has a receiver that is made directional, so only a signal that is pretty close to head on willl be received. I am trying to make it wait for a signal for 1 second. If it doesn't receive it I want it to turn a few degrees clockwise. The problem with this is I can't get the waiting for 1 second part to work. Here is a small snippet of the code:


x VAR Word
y VAR Word
counter VAR Word

DO
LOW 1 'turn led off
SERIN 0, 16468,1000,Left, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
HIGH 1 'turn led on
DEBUG ? x
DEBUG ? y
LOOP

END


Left:
FOR counter = 1 TO 100 ' turn a few degrees
PULSOUT 12, 650
PULSOUT 13, 850
NEXT
RETURN


The way I test it is by turning of the transmitter and seeing if it moves. However nothing happens, but when I plug it in, it starts to receive again.

I would really appreciate any help I can get.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-03-04 01:51
    Nowhere in the do loop do you tell it to do anything but send x and y to the debug screen. Is it doing that?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • jtaylor408jtaylor408 Posts: 15
    edited 2009-03-04 02:36
    Well the code for SERIN command tells me to put in the timeout and a tlabel which is what the 1000, Left means
    It should be waiting for one second when no signal comes goes down to the subroutine Left and execute that. But it is not doing that.
  • JomsJoms Posts: 279
    edited 2009-03-04 03:06
    EDIT:
    I am beginning to think that you can't use the wait command and the timeout command in the same line.· I don't see them doing that anywhere in the help file...

    ORIGINAL MESSAGE:
    The only thing I see different between yours and the help files is 2 things... One is try adding spaces, although I don't think that will fix it... Two, try changing the 'RETURN' line to a 'GOTO' and add something above your main program.... (See below)

    x VAR Word
    y VAR Word
    counter VAR Word

    Main:
    DO
    LOW 1 'turn led off
    SERIN 0, 16468, 1000, Left, [noparse][[/noparse]WAIT ("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
    HIGH 1 'turn led on
    DEBUG ? x
    DEBUG ? y
    LOOP

    END


    Left:
    FOR counter = 1 TO 100 ' turn a few degrees
    PULSOUT 12, 650
    PULSOUT 13, 850
    NEXT
    GOTO Main






    Post Edited (Joms) : 3/4/2009 3:11:33 AM GMT
  • jtaylor408jtaylor408 Posts: 15
    edited 2009-03-04 04:37
    I have discovered something interesting. For the pin number I put 2 when it is connected to P0 and it would jump down to the left subroutine. Its obviously not receiving since its not connected t that pin. I have no idea why my code would not work. I did try your suggestion Joms but to no avail
  • FranklinFranklin Posts: 4,747
    edited 2009-03-04 23:27
    I think the timeout will JUMP to the label and not return because it was not called with a gosub. It probably is getting a signal so it is looping. do you get x,y values in the debug screen?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.