Shop OBEX P1 Docs P2 Docs Learn Events
BS2p, Piher A15 and LTC1298 CN8 — Parallax Forums

BS2p, Piher A15 and LTC1298 CN8

JonJTJonJT Posts: 2
edited 2008-04-06 20:13 in BASIC Stamp
Hello everyone.
Before I get into the specifics of my project I'd like to say that I am a complete notice with no electrical engineering background and no hardware programming experience (although I use matlab extensively in my mechanical properties of matter and dynamics courses). Before last Wednesday, I knew nothing of Pbasic or how ADC chips work. I'm a mech-e student trying to incorporate a micro controller into a project for a design class.

Basically what I need to do is track the motion of a spinning shaft and actuate solenoids based up the position of that shaft. I have a BS2p stamp, a Piher A15 continuous rotation rotary sensor and an LTC1298CN8 ADC chip.
The first step I took was to wire the ADC to the stamps module, which I think I did correctly. The data sheet is for the ADC is very straight forward as to what pin is what so I doubt my source or error lies in the physical connections.
Next I connected a 550ohm resistor to the channel0 pin and a 330K resistor to the channel1 pin and then connected both resistors to the 5v source. I wrote some code to see if I could get the ADC chip to read the difference between the channels and then have the BS2p output that value to a debug window on my computer.
Code:
' {$STAMP BS2p}
' {$PBASIC 2.5}
'------[noparse][[/noparse]Initial Comments]------
'Pin0 is connected to pin 7 on the ADC which is the Clock pin
'Pin1 is connected to pin 1 on the ADC which is the chip select pin
'Pin2 is connected to pin 6 on the ADC which is the data out pin
'Pin3 is connected to pin 5 on the ADC which is the data in pin

'I/O declarations and Initialization of variables
clk CON 0 'ADC clock
cs CON 1  'Chip Select
dot CON 2 'Data out pin
din CON 3 'Data in pin
adcBITS VAR Word 'This is the variable that stores the measured values from the ADC chip
config VAR Nib    'Configuration bits for the ADC
config=config | %1001
HIGH cs   'Turns the chip off
HIGH din
HIGH dot
Again:
GOSUB Convert 'Goes to the convert subroutine
DEBUG HOME, "12 Bit Binary Value: ", BIN adcBits 'writes the result on a debug window in binary numbers
DEBUG CR, CR, "Decimal value:", DEC adcbits 'Writes the result below the binaries in decimals
GOTO Again    'Indeffinate loop
'--------ADC Subroutine--------------
Convert:
LOW cs
SHIFTOUT dot, clk, LSBFIRST, [noparse][[/noparse]config\4]
SHIFTIN din, clk, MSBFIRST, [noparse][[/noparse]adcBITS\12]
HIGH cs
RETURN



There were two problems with this. First was that no matter the voltage on the 2 input pins, the ADC would always return 111111111111 as its initial value. That value would hold for a few seconds, then it would drop significantly to 0111111111111 and hold that value indefinitely.
Using google, I found this:
'
' {$STAMP BS2p}
'************************************************************************
'*  Basic Stamp Activity Board Sample Program                 LTC-1298  *
'*  9 September, 1997                                           (BS-2)  *
'*                                                                      *
'*  This program shows how to use the LTC-1298 from Linear Technology.  *
'*  Insert the LTC-1298 into Socket A and remove the jumpers in 'X4'.   *
'*  Apply the analog inputs according to the drawing depicted in the    *
'*  Basic Stamp Activity Board Notes. Power it up and hit 'Alt-R' to    *
'*  download. The analog input voltages must be 0-5Vdc.                 *
'************************************************************************

CS  CON  1    ' Chip select (low true)
CLK  CON  0    ' ADC Clock
Din  CON  3    ' ADC Data input
Dout  CON  2    ' ADC Data output
config  VAR  Nib    ' Configuration bits for ADC
ADres  VAR  Word    ' Variable to hold 12-bit AD result
startB  VAR  config.BIT0  ' Start bit for comm with ADC
sglDif  VAR  config.BIT1  ' Single-ended or differential mode
oddSign  VAR  config.BIT2  ' Channel selection
msbf  VAR  config.BIT3  ' Output 0s after data xfer complete

INIT        ' Initialization code
  HIGH CS      ' Deactivate ADC to begin
  HIGH Din    ' Set up data lines
  HIGH Dout
START        ' Main loop
  FOR oddSign = 0 TO 1  ' Toggle between input channels
  GOSUB convert    ' Get data from ADC and display it
  DEBUG "Ch:",DEC oddSign, " ", DEC ADres,CR
  PAUSE 500    ' Wait a half second
NEXT        ' Change channels
  GOTO START    ' Repeat forever
convert        ' Convert subroutine start here
  config = config | %1011  ' Set all bits except oddSign
  LOW CS      ' Activate the ADC
  SHIFTOUT Din,CLK,LSBFIRST,[noparse][[/noparse]config\4]  ' Send config bits to ADC
  SHIFTIN Dout,CLK,MSBPOST,[noparse][[/noparse]ADres\12]  ' Get data bits from ADC
  HIGH CS      ' Deactivate the ADC.
RETURN        ' Return to main program



Which (to me anyway) differs only in the use of a for loop to sample each channel separately. This program exhibits the same behavior as mine does. Does anyone know what is wrong here?


Once that problem is resolved, I need to find a way to replace the voltage splitter with the A15 position sensor. This .pdf document shows that the position sensor needs a logical input to output an absolute measurement. Getting the ADC to sample one pot, turn the tap pin high, measure the other pot and return an absolute measurement value is a bit beyond me right now. Plus I'm worried that a long cycle would be needed to get an absolute measurement and even though the shaft speeds in question aren't going to be high (5 rotations per second is probably on the high side), the micro controller might take to long to return a useful value.
I don't think all that is necessary, honestly. Before I found that .pdf I just assumed the sensor had 2 pot pins and did the following to determine what was what. I hooked up a +5v source to what I thought was the +5v pin and measured the potential between ground and the other 3 pins to determine what was what. 2 of the pins varied by about 3 volts throughout 360 degrees of rotation with the absolute difference between those potentials being non constant with respect to position. So, cant I just hook up one pin to channel0 and the other pin to channel1 and use differential mux mode to compare the two? The output should be unique to position so I will have all the data I need to know when to energize what solenoid. Does this sound reasonable?

Thank you.

JonJT

Post Edited (JonJT) : 4/6/2008 1:14:57 AM GMT

Comments

Sign In or Register to comment.