View Full Version : KOP Gyro
John Gutmann
11-12-2005, 14:03
How would I program a BASIC stamp to read the signal from a KOP gyro. Is the signal analog or digital?
How would I program a BASIC stamp to read the signal from a KOP gyro. Is the signal analog or digital?
Erm, the way I understand analog/digital is that digital is either true or false (one or zero) and analog is anywhere in a range of numbers. It would be a pretty horrible gyro if it read back 1 or 0 :rolleyes:
I would google the gyro manufacturer/part number and try to find the datasheet for it. You would need to find the rateout, ground and positive in pins. Then you would have to make sure that your board can provide the amount of power needed. You also need to have an analog-to-digital converter. This converts the voltage returned from the gyro to a number (number size depends on ADC, an 8bit ADC is sufficient.) Then you just read it as you would anything else.
John Gutmann
11-12-2005, 16:42
Erm, the way I understand analog/digital is that digital is either true or false (one or zero) and analog is anywhere in a range of numbers. It would be a pretty horrible gyro if it read back 1 or 0 :rolleyes:
I would google the gyro manufacturer/part number and try to find the datasheet for it. You would need to find the rateout, ground and positive in pins. Then you would have to make sure that your board can provide the amount of power needed. You also need to have an analog-to-digital converter. This converts the voltage returned from the gyro to a number (number size depends on ADC, an 8bit ADC is sufficient.) Then you just read it as you would anything else.
well I was looking at somethings on some website that sold gyros and some of them sent out a serial signal in digital form. I know how to hook it up, asked how to make the BS read it.
I don't know the manufacturer or part # or anything of the sort.
Andrew Blair
11-12-2005, 19:21
The BEI kit gyro is an analog device. On the basic stamp, I believe that there are macros (thats BASIC talk ;) i think...) that point to built in ADC's, and you just uncomment them to access them. Be careful, on the STAMP brain, you'll prolly have to comment some unused variables in. Its very limited on usable variable space. Then, using a scaling factor, convert the output number into a angle measurement. Sorry, can't tell you the exact math, but if you obtain Kevin Watson's gyro code it either explains it, or you can reverse engineer it. You can PM him (http://www.chiefdelphi.com/forums/member.php?userid=1028) and he might be able to help with the concept.
http://kevin.org/frc/ <<Gyro Code
Remember, gyro's output angular rate, not absolute position/angle.
Good luck!:)
John Gutmann
11-12-2005, 21:37
If it helps anyone, or ^ i am using a BS 2 the one that comes with the BOE-bot. I am trying to get it to work on that before i put it into my robgot which uses the older IFI BS microprocessor.
I have no idea how to read an analog signal with a BS2. If you knew that could really help, i have looked around the editor and in the help but i will try a few websites
Pat Fairbank
11-12-2005, 22:25
Looking through the Basic Stamp manual (http://www.parallax.com/dl/docs/prod/stamps/BasicStampMan2_0.pdf), it seems to me the POT command is the one to use to take analog readings. It's intended to measure potentiometers with resistences from 5 Kohms to 50 Kohms.
I'm no electrical engineer, so I can't tell you if this will work with the gyro (whose datasheet (http://www.chiefdelphi.com/forums/attachment.php?attachmentid=3711) says something about a 1 Kohm impedence). Is there an EE or someone else around who can enlighten us?
John Gutmann
11-12-2005, 23:14
Looking through the Basic Stamp manual (http://www.parallax.com/dl/docs/prod/stamps/BasicStampMan2_0.pdf), it seems to me the POT command is the one to use to take analog readings. It's intended to measure potentiometers with resistences from 5 Kohms to 50 Kohms.
I'm no electrical engineer, so I can't tell you if this will work with the gyro (whose datasheet (http://www.chiefdelphi.com/forums/attachment.php?attachmentid=3711) says something about a 1 Kohm impedence). Is there an EE or someone else around who can enlighten us?
That is only for the BASIC stamp not the BASIC Stamp 2, I thought about that too.
Pat Fairbank
11-12-2005, 23:24
That is only for the BASIC stamp not the BASIC Stamp 2, I thought about that too.
Oh, sorry, didn't notice that.
I suppose RCTIME would work, then, but it looks as if you need to throw a capacitor into the mix as well.
sciguy125
12-12-2005, 00:04
I think you need a true ADC for this. I don't know of any specific devices, so you'll have to consult google.
The problem with using RCTIME is that it's checking for a charge rate, not an actual voltage. I'd have to think about it a little more, but I think it's possible to make it work, but it wouldn't be very pretty. For one thing, it wouldn't work if the input drops below 1.5V. Secondly, caps have an exponential charge rate. I suspect that would introduce some interesting math. That's also ignoring the calibration you would need because of the usual +-20% tolerance of capacitors.
Anyway, try to find an ADC.
John Gutmann
12-12-2005, 18:12
Ok, I will check at school and see if we have any ADCs. If not does any one know of somewhere I can get one without paying a couple dollars for shipping?
Joe Johnson
12-12-2005, 20:27
Ok, I will check at school and see if we have any ADCs. If not does any one know of somewhere I can get one without paying a couple dollars for shipping?
If $2 is going to kill your project, I am not sure I can help you ;-)
Seriously though, there are some tolerably easy to implement shift in/shift out ADC's -- I think the old controller Eric Rasmussen (http://www.chiefdelphi.com/forums/ufh.php?action=honoreedetail&id=49) designed used to have one. Let me see what I can dig up... ...checking... ...found it! It was an ADC0838CCN $2.63 from Digikey (http://rocky.digikey.com/scripts/ProductInfo.dll?Site=US&V=14&M=ADC0838CCN) I remember interfacing a the BASIC Stamp2 to it. It was easy as pie -- the old PBASIC default is probably lurking out there somewhere if you dig around... ...checking... ...HA! -- man I am good! ;-) I had to use the waybackmachine.org but here it is (http://web.archive.org/web/19991113030607/www.usfirst.org/1999comp/Manual/RXSLAVE.BS2) a copy of the Pre-IFI PBASIC Default Code (it used to be called RXSLAVE.BS2 -- for all you old time FIRST folk)
Anyway, Below are the important bits of the PBASIC code to interface to the serial in/serial out ADC:
'
' PROGRAM: RXSLAVE.BS2
' Program run by User Programmable CPU in 1998 FIRST Receiver Board
' Written by: Eric Rasmussen
' Date: 12/11/97
'
'
' Declare variables
'
'skip
sensor1 VAR byte
sensor2 VAR byte
sensor3 VAR byte
sensor4 VAR byte
'skip
'
' Define Constants
'
'skip
ADC_SO CON 12 ' Analog to Digital Converter (ADC) data output pin
ADC_SCLK CON 13 ' ADC Clock Pin
ADC_CS0 CON 14 ' Pin to initialize/reset ADC
ADC_SI CON 15 ' Pin used to send data to ADC
'skip
'
' Initialize Hardware and Variables on Power Up or Reset
'
' All pins default to low (ground) & input (floating) on powerup or reset.
' PWM outputs are automatically set to 127 on powerup or reset by the SSC
'
'skip
Output ADC_SI
Output ADC_SCLK
'skip
High ADC_CS0
'skip
'
' Main Program
'
Loop:
'skip
' Read Receiver Analog Sensor Inputs into sensor1-4
Gosub ReadSensors
'skip
Goto Loop ' Start over at Loop:
End ' It should never actually get here!
'
' Subroutines
'
'skip
ReadSensors: ' Read receiver sensor inputs into variables sensor1-4
' Read Channel 1 (Comment out next 4 lines if not using sensor1)
Low ADC_CS0 ' Initialize ADC
Shiftout ADC_SI, ADC_SCLK, msbfirst, [12\4] ' Select Channel 1
Shiftin ADC_SO, ADC_SCLK, msbpost, [sensor1] ' Read Channel 1
High ADC_CS0 ' Reset ADC
' Read Channel 2 (Comment out next 4 lines if not using sensor2)
Low ADC_CS0 ' Initialize ADC
Shiftout ADC_SI, ADC_SCLK, msbfirst, [14\4] ' Select Channel 2
Shiftin ADC_SO, ADC_SCLK, msbpost, [sensor2] ' Read Channel 2
High ADC_CS0 ' Reset ADC
' Read Channel 3 (Comment out next 4 lines if not using sensor3)
Low ADC_CS0 ' Initialize ADC
Shiftout ADC_SI, ADC_SCLK, msbfirst, [13\4] ' Select Channel 3
Shiftin ADC_SO, ADC_SCLK, msbpost, [sensor3] ' Read Channel 3
High ADC_CS0 ' Reset ADC
' Read Channel 4 (Comment out next 4 lines if not using sensor4)
Low ADC_CS0 ' Initialize ADC
Shiftout ADC_SI, ADC_SCLK, msbfirst, [15\4] ' Select Channel 4
Shiftin ADC_SO, ADC_SCLK, msbpost, [sensor4] ' Read Channel 4
High ADC_CS0 ' Reset ADC
Return
'skip
I can't help you with the $2 but I hope the above helped some.
Joe J.
Astronouth7303
12-12-2005, 21:04
/me once again has a greater appreciation for C
John Gutmann
12-12-2005, 21:59
If $2 is going to kill your project, I am not sure I can help you ;-)
Seriously though, there are some tolerably easy to implement shift in/shift out ADC's -- I think the old controller Eric Rasmussen (http://www.chiefdelphi.com/forums/ufh.php?action=honoreedetail&id=49) designed used to have one. Let me see what I can dig up... ...checking... ...found it! It was an ADC0838CCN $2.63 from Digikey (http://rocky.digikey.com/scripts/ProductInfo.dll?Site=US&V=14&M=ADC0838CCN) I remember interfacing a the BASIC Stamp2 to it. It was easy as pie -- the old PBASIC default is probably lurking out there somewhere if you dig around... ...checking... ...HA! -- man I am good! ;-) I had to use the waybackmachine.org but here it is (http://web.archive.org/web/19991113030607/www.usfirst.org/1999comp/Manual/RXSLAVE.BS2) a copy of the Pre-IFI PBASIC Default Code (it used to be called RXSLAVE.BS2 -- for all you old time FIRST folk)
Anyway, Below are the important bits of the PBASIC code to interface to the serial in/serial out ADC:
I can't help you with the $2 but I hope the above helped some.
Joe J.
I don't want to pay 6$ shipping for a .35$ part. It is absurd.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.