Connecting ADC to Stamp
k
Posts: 7
Hi, we are trying to use the LTC1298 for analog to digital conversion. The manual says that the ADC connects to P0, 1, and 2 of the Stamp. Sorry this is probably a silly question, but just wondering if we can use other pinouts? Or are these special pins that the ADC has to connect to?
The reason I ask is because we eventually want to send the converted data to eb500 bluetooth transmitter. And according to the eb500 manual, the transmitter uses P0, 1, 5, 6 for transmitting, receiving and displaying status. I'm assuming they can't use the same pinouts?
Thanks in advance for any info.
The reason I ask is because we eventually want to send the converted data to eb500 bluetooth transmitter. And according to the eb500 manual, the transmitter uses P0, 1, 5, 6 for transmitting, receiving and displaying status. I'm assuming they can't use the same pinouts?
Thanks in advance for any info.
Comments
A good programming practice is to assign symbolic names to all of the pins and then write the code to use the names. So for your project, if you connected the ADC to pins 4, 7 and 8 you would have a block of code like:
BT_TX········· PIN· 0
BT_RX········ ·PIN· 1
BT_RTS······· PIN· 2
BT_CTS······· PIN· 3
ADC_CS····· · PIN· 4
BT_Status···· PIN· 5
BT_mode······ PIN· 6
ADC_Data··· · PIN· 7
ADC_CLK···· · PIN· 8
Using this method, any future changes in the layout of the curcuit only require you to change the symbolic definitions and the rest of the code will remain unchanged.
You will have to use the designated pins on the eb500 the different pins depend on what Stamp board or kit you are going to use... Board of Education, comes with the double row header so you can plug the eb500 to it. In this case you would have to use the pins specified.
If you use the Stamp Basic Activity kit you can use the breadboard area and
assign what ever pin you want to use as long as connect to the proper pin on the eb500. The eb500 uses pins 3,4,8,9
Pinout
1 3 5 7 9 11 13 15 17 19
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?
2 4 6 8 10 12 14 16 18 20
1 VSS 2 VSS
3 TX 4 RX
5 NC 6 NC
7 NC 8 STATUS
9 MODE 10 NC
11 NC 12 NC
13 NC 14 NC
15 NC 16 NC
17 NC 18 NC
19 NC 20 VCC
This is the example from one of the books like MSDtech said you can use the names and the stamp will do the rest..
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Declarations ]
adcBits VAR Byte
v VAR Byte
r VAR Byte
v2 VAR Byte
v3 VAR Byte
'
[noparse][[/noparse] Initialization ]
CS PIN 0
CLK PIN 1
DataOutput PIN 2
'Change the pins to what ever pin number you want to use as long as the eb500 pins are not connected to it when installed on the double row recepticles or sockets that come in the Board Of Education and the other Stamp boards with that feature.
CS PIN 4
CLK PIN 5
DataOutput PIN 6
'
[noparse][[/noparse] Main Routine ]
DO
GOSUB ADC_Data
GOSUB Calc_Volts
GOSUB Display
LOOP
'
[noparse][[/noparse] Subroutines ]
'What ever pin you use the Stamp will execute the code using symbolic definition on that pin
' number. This will make it easy to change your circuit if needed without having to rewrite a lot of code
ADC_Data:
HIGH CS ' This will set CS high on what ever pin you designate
LOW CS
LOW CLK
PULSOUT CLK, 210
SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
RETURN
Calc_Volts:
The bottom line is you can use any pin you want with the LTC1298.
The eb500 you have to use the designated pins on the header since it is pre-wired to use pins 0, 1, 2, 3, 5, and 6 in the appmod connector, Board of Education ect.. you can't change its pinouts but you can still use the other pins that are not used on the LTC1298.. The Basic Stamp HomeWork Board does not have the double row connectors and you would have to use the breadboard area to connect both the eb500 and the LTC1298 and assign what ever pins you want to use them both...
I am currently designing an optical sensor system and using LTC1298 as part of my design. When I measure the input of my ADC (output of optical sensor)·using multimeter, the measurement shows a very constant voltage until unit of milivolt. However, when I connect the output of my ADC to BS2 and debug the result on screen, the measurement shows signal that keep fluctuating about 20 to 30 steps up and down. I wonder why this happen whereas the measurement using multimeter shows other wise. I hope to receive any suggestion on why this may happen. And how to overcome it, to get a smooth signal. Is there any program line·that may help? With this email, I attached the sample measurement using stamp plot lite.
Thanks so much in advance
Fairuz
'Program
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.
HIGH LED
PAUSE 1000
LOW sensor
LOW LED
HIGH CS ' Deactivate ADC to begin.
HIGH DIO_n ' Set data pin for first start bit.
again: ' Main loop.
GOSUB convert ' Get data from ADC.
DEBUG ? resultMax ' Display data.
PAUSE 500 ' Wait a half second.
GOTO again ' Endless loop.
convert:
resultMax = 0 ' initial maximum = zero
FOR idx=1 TO 200
config = config | %1011 ' Set all bits except oddSign.
LOW CS ' Activate the ADC.
SHIFTOUT DIO_n,CLK,LSBFIRST,[noparse][[/noparse]config\4] ' Send config bits.
SHIFTIN DIO_n,CLK,MSBPOST,[noparse][[/noparse]AD\12] ' Get data bits.
resultMax = AD MIN resultMax
NEXT
HIGH CS ' Deactivate the ADC.
RETURN ' Return to program.