Data Storage Tool Display Human Input Protocol Math Motor Control Sensor Signal Generation & Processing Speech & Sound Fun View all Objects


Quick Links
Contact Us
Forums
Support

Register
Login

This object is provided under license. By downloading this object, you are agreeing to the terms of the MIT License.

Simple Radio Control Capture & Repeat to Servo

This demo connects a PropStick USB to a radio receiver and a servo. It receives the incoming signal from
the radio receiver and re-transmits it to the servo. It outputs the incoming servo position setting and the
position being transmitted to the servo to the Parallax Serial Terminal (via FullDuplexSerial).
It also flashes the LEDs to indicate the program is running.

Note: The output to the servo is a bit jerky. I tried several other Servo control objects from OBEX, but
I couldn't figure out the timing relationship between PULSIN and and any other Servo control objects.
If you can figure out how to get rid of the jerkiness, please post it in the forum or comments. Thanks!

Objects used:

Debug : "FullDuplexSerial" 'standard from propeller library
SERVO : "Servo32v3" 'standard from propeller library

Version:
  1.0

Type:
  Object

Attributes:


Author:
  Travis

Categories:
  Motor Control

Downloads:
  615

Last Updated:
  2009-01-10


Other Downloads:
  • Auxiliary Files:
    Photo of Circuit on Breadboard
    Photo of PST Output


  • User Reviews:

  • rubrchicken commented:
    I'll post the new code in the forums. (I took out debug because I didn't need it, you can put it back if you want) No idea here, but it may be the fact that you're using the raw pulsins and pushing them to the servo object. Have you tried just using pulsout? Hmmm... I just tried pulsout, and it is accurate, but slow as heck and is jerky, but not like before. OOPS. Get rid of the .25 waitcnt and it is fixed!! Your new code: (No line breaks allowed. Uggh) {{ Origional Code: Travis Modded By: Forrest (rubrchicken) }} CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 'Pin on Prop Chip for LED Indicator PIN_LED = 15 'Pins on Prop Chip for Servo Input/Output PIN_SERVO_IN = 0 PIN_SERVO_OUT = 1 var long us OBJ 'Debug : "FullDuplexSerial" 'standard from propeller library SERVO : "Servo32v3" 'standard from propeller library PUB Begin(in,out) | x,y,z us := clkfreq / 1_000_000 ' Clock cycles for 1 us 'SERVO.Set(out,1422) 'SERVO.Start y := PULSIN(in,1) 'SERVO.Set(out,(y * 2)) PULSOUT(out,y) 'waitcnt(clkfreq / 4 + cnt) '0.25 seconds PUB PULSIN (Pin, State) : Duration | usa usa := clkfreq / 1_000_000 ' Clock cycles for 1 us Duration := PULSIN_Clk(Pin, State) / usa / 2 + 1 ' Use PulsinClk and calc for 2uS increments \ PUB PULSIN_Clk(Pin, State) : Duration DIRA[pin]~ ctra := 0 if state == 1 ctra := (%11010 << 26 ) | (%001 << 23) | (0 << 9) | (PIN) ' set up counter, A level count else ctra := (%10101 << 26 ) | (%001 << 23) | (0 << 9) | (PIN) ' set up counter, !A level count frqa := 1 waitpne(|< Pin, |< Pin, 0) ' Wait for opposite state ready phsa:=0 ' Clear count waitpeq(|< Pin, |< Pin, 0) ' wait for pulse waitpne(|< Pin, |< Pin, 0) ' Wait for pulse to end Duration := phsa ' Return duration as counts ctra :=0 ' stop counter PUB PULSOUT(Pin,Duration) | clkcycles {{ Produces an opposite pulse on the pin for the duration in 2uS increments Smallest value is 10 at clkfreq = 80Mhz Largest value is around 50 seconds at 80Mhz. BS2.Pulsout(500) ' 1 mS pulse }} ClkCycles := (Duration * us * 2 - 1250) #> 400 ' duration * clk cycles for 2us ' - inst. time, min cntMin dira[pin]~~ ' Set to output !outa[pin] ' set to opposite state waitcnt(clkcycles + cnt) ' wait until clk gets there !outa[pin]
    March 20, 2009 5:35 p.m.




  • Comments on this Object:


    Post a comment:




    Please contact obex.support@parallax.com with comments or questions.

    Copyright 2011 by Parallax, Inc.