Shop OBEX P1 Docs P2 Docs Learn Events
Radio control of a — Parallax Forums

Radio control of a

BritannicusBritannicus Posts: 98
edited 2010-11-24 12:35 in BASIC Stamp
:freaked:Hi there -

I'm hoping to pick up input from a radio control receiver - So i figure it'll be generating an output pulse of X milliseconds depending on the position of the joystick.

my intention is to use a BS2 STAMP to control a series of servos to walk a quadruped robot around. I can generate the necessary 8 servo sequence, but want to use STAMP to pick up a simple forward, backward, left right signal on 2 of the Ports - 8 run the servos.

Now here's the Question - how can I pick up a value of an RC pulse so I can store it in a variable and use it to Gosub a step routine?

I thought that Pulsin was the correct command (believing that it simply recorded a value for the pulse length, but reading the manual i notice that

1/ it won't record a long enough pulse 131 Ms max when I need between 350 and 1200 Ms

2/ I seem to get some random values on the port when I rig a rudimentary circuit

I'm sure someone out there has tried to control a stamp with a RC input - what's the secret ??

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2010-11-23 16:42
    Radio control pulses are typically from about .900 milliseconds long to 2.100 milliseconds long. For a BS2 that equals values of 450 and 1050.

    350 milliseconds is over 1/3 of a second while 1200 milliseconds is 1.2 seconds long. Way too long for an RC pulse. I think you are missing a decimal.

    PULSIN is the correct command for reading an RC pulse.

    Rich H
  • BritannicusBritannicus Posts: 98
    edited 2010-11-24 07:46
    Thank you for that - is there any way of screening out "stray pulses ?
  • W9GFOW9GFO Posts: 4,010
    edited 2010-11-24 10:40
    Thank you for that - is there any way of screening out "stray pulses ?
    Something like;
    '-----Exclude out of range pulses----
    IF pulse < 400 OR pulse > 1100 THEN pulse = lastpulse
    

    Or
    '-----Limit the amount of change between pulses and limit range----
    IF pulse - lastpulse > 20 THEN pulse = lastpulse + 20 MAX 1100
    IF lastpulse - pulse > 20 THEN pulse = lastpulse - 20 MIN 400
    

    This code should come before the others if you decide to use it;
    '---Reduce jitter, ignore pulses that are too similar to lastpulse-----
    IF ABS pulse - lastpulse < 2 THEN pulse = lastpulse
    

    Rich H
  • BritannicusBritannicus Posts: 98
    edited 2010-11-24 12:35
    Ah I get the idea - just make it a bit less sensitive - Got an SRF04 ultrasonic rangefinder - same principles apply i guess

    this isn't as hard as I thought it would be (famous last words) - I really appreciate your help - these STAMPS are brilliant !
Sign In or Register to comment.