Shop OBEX P1 Docs P2 Docs Learn Events
reading Servo signals? — Parallax Forums

reading Servo signals?

Delus123Delus123 Posts: 9
edited 2006-12-21 06:35 in Propeller 1
Now that I've got my robot running I'm wondering if it would be possible to read a signal comming from a servo controller whith the prop. ·i have an rc remote which i would like to use to control my robot the recever has eight servo chanels and i whould like to use at least two to control the movments of my quadroped.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-20 04:59
    You could use two Propeller pins, one for each servo, and measure the pulse width. Usually with a multi-channel receiver, each servo channel pulses at a different time. You could use a cog to run a SPIN routine that waits (with WAITPNE) for one of the two pins to become non-zero, identifies the pin, saves the current time (CNT), then waits for that pin to become zero again (with WAITPEQ), computes the time difference and converts to whatever units you need (with a range roughly from 0.5ms to 2.5ms). It can then repeat the whole process. Each servo signal timing is stored in a variable which your main program can read and act upon. If you have lots of extra cogs, you could do each servo signal with the same routine running in each of two cogs, passing the pin# and address of a variable to store the pulse width to the SPIN method started by a COGNEW.
  • JavalinJavalin Posts: 892
    edited 2006-12-20 09:36
    Try this,

    its a work in progress (so many cool things - so little time), it uses some ASM to read the pulses on pins and outputs them serially to a PC console (hypertrm).· It would be easy to modify to use a tv interface or similar

    James
  • Delus123Delus123 Posts: 9
    edited 2006-12-20 19:54
    ok, this is the code i've been using Its all in spin as i havent got around to tinkering with ASM yet but it's been giving me farly reliable results whith the exceptions of:
    1. when the remote is turned of i get random values usualy below 90_000

    2. i get 960 returned quite regularly and i have no idea why

    3. every once and a while it quits updating the value returned(when the value should be different and > 90_000) for a while but continues when i move the stick on the remote again.

    and on top of all that it works with the simple test(test3.spin) program I've made but is some what random when i try to run my robot whith it(test2.spin) (it keeps giving lower values than it should be. whith the stick centered the value acording to test3.spin is ~200_000).· i'll try your code but i like using thing's i understand so i guess i'll have to start learning some asembly.


    Post Edited (Delus123) : 12/20/2006 7:59:11 PM GMT
  • acantostegaacantostega Posts: 105
    edited 2006-12-21 06:35
    There's also a pulsin command in the BS2 object (it's in spin, it uses waitpeq/waitpne).
Sign In or Register to comment.