What am i doing wrong with my gyro?
Magnus
Posts: 18
I am trying to interface a GWS PG-03 gyro to my Stamp, but i can't get it to work.
* The Gyro woks fine connected to my RC receiver with a servo on the output.
* The gyro works fine with the input connected to the stamp and the output to a servo
When i try to measure the gyro puls with the PULSIN command i don't get any values at all. the code i'm using is attached below.
I have tried attaching the gyro with and without a 10Kohm pulldown resistor but without luck.
What am I missing???
/Magnus
Stamp code:
' {$STAMP BS2e}
' {$PBASIC 2.5}
servo PIN 15
gyro PIN 6
time VAR Word
i VAR Byte
i=0
Main:
i=i+1
PULSOUT servo,750 ' give gyro input
PULSIN gyro, 1, time ' read gyro pulse length
IF i=10 THEN GOSUB print ' print value to debug, only once every tenth time if there is a
' timing problem
GOTO main:
print:
DEBUG "gyro=", DEC time
i=0
RETURN
* The Gyro woks fine connected to my RC receiver with a servo on the output.
* The gyro works fine with the input connected to the stamp and the output to a servo
When i try to measure the gyro puls with the PULSIN command i don't get any values at all. the code i'm using is attached below.
I have tried attaching the gyro with and without a 10Kohm pulldown resistor but without luck.
What am I missing???
/Magnus
Stamp code:
' {$STAMP BS2e}
' {$PBASIC 2.5}
servo PIN 15
gyro PIN 6
time VAR Word
i VAR Byte
i=0
Main:
i=i+1
PULSOUT servo,750 ' give gyro input
PULSIN gyro, 1, time ' read gyro pulse length
IF i=10 THEN GOSUB print ' print value to debug, only once every tenth time if there is a
' timing problem
GOTO main:
print:
DEBUG "gyro=", DEC time
i=0
RETURN
Comments
Try triggering with another stamp or 555 timer, or at least measure the output of the receiver with the stamp and then using the stamp on the output side of the gyro to measure it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I connected the gyro to a servo controller and now everything works. Now it's just programming the stamp to do something useful with the input i get. Has anyone done any integrating of a gyro signal to keep track of current angle/heading?
/Magnus
When you get an application going, have the gyro stay still at the start of the program so you can get the drift over time.
The problem with using the Stamp is that integrating a gyro depends on taking readings at regular intervals . On a PIC (which is what a Stamp is), this is usually done by using one of the CCP (Capture and Compare) timer units to interrupt the program at regular intervals to take the readings. The Basic Stamp programming language has usurped all the timers for use with program commands like PULSIN, PULSOUT, RCTIME, COUNT, etc. You, as the user, have no direct access to the timers. (BS3?)
Even the units with polled interrupts won't do you much good because they won't respond to an interrupt until the current command is done.
To do the integrations properly, I think you need to dedicate a PIC or SX chip to the integrations, where you have control of the timers. I don't use SX basic, so I don't know if it gives you control of the timers, so you may need to code in assembler.
·Still, If you can do the calculations and get back to the PULSIN command· in less than the 20 or so microsecconds before the next time the gyro triggers, you might stand a chance. You will be depending on the regular timing of the servo controller to·establish ·the time iterval, and you won't be able to do much else.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Larry) : 11/29/2005 3:25:06 AM GMT