angular speed and gyrometer


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    i know that is possible but what i ask is how i could do
    and if people good in programming (not like me) have some ideas

    thank ' s for your help
    fefenin

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by fefenin View Post
    i know that is possible but what i ask is how i could do
    and if people good in programming (not like me) have some ideas

    thank ' s for your help
    fefenin
    You probably have to get a book on some pretty good math here.
    It's called integration. If I know I've been accelerating for 10 seconds and a rate of 10 feet per second, then I know at the end of 10 seconds I'll be moving 100 feet per second and I'll have travelled 50 ft ('cause I started at 0 and now I'm at 100 and the acceleration was constant).
    The big thing with integration is the speed at which you integrate. It doesn't do any good if you look at a signal once a minute 'cause you may have been going 100 mph for 50 seconds of that minute, but may have started and ended that minute at 0 mph. Make any sense? Same thing goes with an angular sensor. If I know I started the time at 0 degrees position and zero degree per second of rotation, and now I know I'm rotating at 10 degrees per second, and now it's one second later, then I should know that I've rotated 5 degrees and I'm rotating at 10 degrees per second. So, in another second, I'll be at 15 degrees position, and still be rotating at 10 degrees per second, assuming I haven't had a change in rotational speed.

    Problem with this, is that no matter how good you think your math is, over time, your position will be off (especially using integer math like in PBP). You need some way to reset your position to zero (or some known angle). In the Nintendo Wii, the WiiMote uses those 2 IR LEDs from the sensor bar and the small sensor in the front of the WiiMote for just that...to reset the 'level angle' (for lack of a better term).

    So, for this to work effectively, you need, at the very least, a few things:
    A tight A/D with lots of bits, a fast sampling rate of your sensor, good floating point math, fast processing speed (a PIC is ok, but a dsPIC would be much better).
    But if you're just playing around, trying to get something to work...heck ya, a PIC and all it's internals should be perfect. You just have to write some integrating code like I described above and you're set.
    Hope you got a couple of ideas out of this...good or bad

  3. #3
    Join Date
    Mar 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    yes that 's an explaination i'll try to do something with what i have already
    so that would be a pic16f88 a 8mhz and it's internal 10bit adc and i should probably set it up with -vref and +vref for better range
    i ll try to work on it but it very blur for me i m fearly new on it

    thank's again

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by fefenin View Post
    yes that 's an explaination i'll try to do something with what i have already
    so that would be a pic16f88 a 8mhz and it's internal 10bit adc and i should probably set it up with -vref and +vref for better range
    i ll try to work on it but it very blur for me i m fearly new on it

    thank's again
    Well, if you power your PIC and the gyro off the same power supply, you shouldn't need to change your Vref's, since everything will 'drift' together. And on another note, I just bought an Eflight Blade CP Pro. To get a good center, there's a light on the side of the PCB that blinks, tell me not to move the heli while it 'finds it center'. You could easily do the same thing I'm sure, don't move it for X seconds after powering up, or hitting a button or something.

    And a PIC16F88 @ 8mhz (2 MIPS) would probably get you started and in the ball park, but I don't see it accomplishing anything you'd be totally amazed at. Once you get a good basic project working, I'd suggest switching over to a PIC18F1320 (or something similar) and going as fast as you can with it (40mhz), to get some really kickin' results.

    Have you had a look at the ADXL330 (www.sparkfun.com and other sites, same part used in the WiiMote)? X,Y,Z outputs, basically the same thing you've got, but better, and a lot more documentation. And it's relatively cheap.

  5. #5
    Join Date
    Mar 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    yes i had a look a sparkfun.com and the devices they sell seems very good for what i plan to do next, but for the moment i just want to sense the motion of my head and send it by the ppm signal of my radio to get it on my receiver it should move a servo that move a camera who send the signal to my head mounted display(i know that's a long sentence)

    i think that should be enought accurate with the need of a reset button of course.

    the ppm sending part is already running with my equipement (just need to put a value from 0 to 1200 in every channel variable)


    here is my code:
    define OSC 4
    OSCCON=%01100000 'pour f88 pic oscillateur interne config marche pas sans ca
    output portB.0 'suncro led
    output portb.1 'ppm out
    input porta.0 'gyro 1
    output porta.2 'lcd

    ANSEL=%00000001

    ADCON1.7=0 ' Left justified bits (10-bits ADRESH=Left ADRESL=Right)
    PAUSE 10

    ADCON1=%00000000 ' Switch ON an0 A/D's with Vdd as Reference

    ' A/D 0
    ADCON0 = %10000001 ' 20 MHz, Channel 0

    'variable for adc
    AD0H VAR BYTE ' High Byte 0 - 255
    AD0L VAR BYTE ' Low Byte 0 - 255
    AD0 VAR WORD ' AD0 word (10 bits)

    'need to put fosc2-1 = 100 that means r7 and r8 is i/o et xtal is internal
    ch1 var word 'word = 256bit value or 65000 dec val i think
    ch2 var word
    ch3 var word
    ch4 var word
    pan var word
    tilt var word
    ch7 var word
    ch8 var word
    chsyncro var word
    chseparator con 300'296 'with the pauseus it is 0,3ms or 300us
    servotest var word
    A var word
    'change those value for more angles 90° 120°
    servomin con 400'700
    servomed con 1000 'this is med
    servomax con 1600'1700

    'channels goes from 0.7ms to 1.7ms min to max
    'so that's sounds good with the 0.3ms, entire signal varies from 1ms to 2ms
    'neutral without interchannel minipulse is 1,2ms and 1,5ms with minipulse

    'i assume that 1200 would be the neutral 1,2ms with the pauseus instruction

    'initialise servo position
    'put pan servo inthe middle
    ch1 = servomed
    ch2 = servomed
    ch3 = servomed
    ch4 = servomed

    pan = servomed'is ch5
    tilt = servomed'is ch6
    ch7 = servomed
    ch8 = servomed







    gosub lcd_init 'goto lcd init

    ' Send the ASCII value of B0 followed by a linefeed out Pin0 serially at 19200 baud
    SEROUT2 PORTA.2,32,["headtrack ppm adc"]
    pause 1000



    main:

    ReadAD:

    ADCON0.2 = 1 ' Start conversion

    pauseus 10

    AD0H = ADRESH
    AD0L = ADRESL
    AD0=(AD0H*4)+(AD0L/64)
    'ad0=((ad0-460)*10)+ servomed
    pan = ad0
    SEROUT2 PORTA.2,32,[$A3,$01] 'clear alcd and locate in 0,0
    SEROUT2 PORTA.2,32,["value is:",dec pan]
    pause 10





    'is all servo test mode

    'for servotest = servomin to servomax step 5 'start to the min angle and go to max angle progressivly
    'ch1 = servotest
    'ch2 = servotest
    'ch3 = servotest
    'ch4 = servotest
    'pan = servotest
    'tilt = servotest
    'ch7 = servotest
    'ch8 = servotest
    'gosub ppmtrame
    'next

    'for servotest = servomax to servomin step -5 'start to the min angle and go to max angle progressivly
    'ch1 = servotest
    'ch2 = servotest
    'ch3 = servotest
    'ch4 = servotest
    'pan = servotest
    'tilt = servotest
    'ch7 = servotest
    'ch8 = servotest
    'gosub ppmtrame
    'next
    'goto main





    'send ppm trame and high del0 during chsyncro time
    ppmtrame:

    'protection against overrange
    if ch1 > servomax then ch1 = servomax 'protection cannot go upper than servomax value
    if ch1 < servomin then ch1 = servomin 'protection cannot go less than servomin value

    if ch2 > servomax then ch2 = servomax 'protection cannot go upper than servomax value
    if ch2 < servomin then ch2 = servomin 'protection cannot go less than servomin value

    if ch3 > servomax then ch3 = servomax 'protection cannot go upper than servomax value
    if ch3 < servomin then ch3 = servomin 'protection cannot go less than servomin value

    if ch4 > servomax then ch4 = servomax 'protection cannot go upper than servomax value
    if ch4 < servomin then ch4 = servomin 'protection cannot go less than servomin value

    if pan > servomax then pan = servomax 'protection cannot go upper than servomax value
    if pan < servomin then pan = servomin 'protection cannot go less than servomin value

    if tilt > servomax then tilt = servomax 'protection cannot go upper than servomax value
    if tilt < servomin then tilt = servomin 'protection cannot go less than servomin value

    if ch7 > servomax then ch7 = servomax 'protection cannot go upper than servomax value
    if ch7 < servomin then ch7 = servomin 'protection cannot go less than servomin value

    if ch8 > servomax then ch8 = servomax 'protection cannot go upper than servomax value
    if ch8 < servomin then ch8 = servomin 'protection cannot go less than servomin value

    'calcul de chsyncro
    '22000-4 for errors = 21996
    chsyncro =21996-((chseparator*8)+ch1+ch2+ch3+ch4+pan+tilt+ch7+ch8-10)

    'start sending the ppm frame:
    high portb.0 'begining of the syncro del is on
    high portb.1
    pauseus chsyncro
    low portb.1
    low portb.0 'ending of the syncro del is off
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus ch1
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus ch2
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus ch3
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus ch4
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus pan
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus tilt
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus ch7
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    high portb.1
    pauseus ch8
    low portb.1
    pauseus chseparator 'should be 3us low state between channels
    'stop sending the frame
    'return
    goto main



    'the lcd routine initialisation
    lcd_init:
    SEROUT2 PORTA.2,32,[$A3,$01] 'clear alcd and locate in 0,0
    SEROUT2 PORTA.2,32,[$A1,2,0] 'locate in x,y
    SEROUT2 PORTA.2,32,[$A3,$0A] 'stop blinking cursor
    'SEROUT2 porta.1,32,[$A3,$0B] 'blink cursor
    SEROUT2 PORTA.2,32,[$A3,$0C] 'hide cursor
    'SEROUT2 PORTA.1,32,[$A3,$0E] 'show cursor
    return

    end

    fefenin

  6. #6
    Join Date
    Mar 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    if anbody has a piece of code as an example for me that will be nice i found it hard to do

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by fefenin View Post
    if anbody has a piece of code as an example for me that will be nice i found it hard to do
    Apparently, you've only been at it for a day.
    Jeeze...nobody finishes a project in a matter of hours. Give it some time...

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts