Process Control, Activity 2
Hi All,
StampPlot is not plotting or receiving data for Activity 2, Chapter 6. I successfully plotted Activity 1. Activity 2 uses the same circuit (Fig-1). I loaded the program AdcSpanOffset.bs2 and used the macro sic_pc_adc_span_offset.spm and StampPlot Pro V3_7.
I performed the following sequence:
1. Loaded and ran AdcSpanOffset.bs2
2. Closed Debugger
3. Verified "ADC Span" is set to 5 and ADC Offset' is set to 0 in StampPlot
4. Pressed connect and plot in StampPlot
The lower left "T' turned to green, but the "R" did not flash red as in Activity 1. No plotting occurred.
I checked and double checked my circuit wiring and the code after cut & paste as shown below:
Thanks for taking the time to look at this. Any help is appreciated.
Ocean Bill
StampPlot is not plotting or receiving data for Activity 2, Chapter 6. I successfully plotted Activity 1. Activity 2 uses the same circuit (Fig-1). I loaded the program AdcSpanOffset.bs2 and used the macro sic_pc_adc_span_offset.spm and StampPlot Pro V3_7.
I performed the following sequence:
1. Loaded and ran AdcSpanOffset.bs2
2. Closed Debugger
3. Verified "ADC Span" is set to 5 and ADC Offset' is set to 0 in StampPlot
4. Pressed connect and plot in StampPlot
The lower left "T' turned to green, but the "R" did not flash red as in Activity 1. No plotting occurred.
I checked and double checked my circuit wiring and the code after cut & paste as shown below:
' -----[ Title ]-----------------------------------------------------------
' Process Control - AdcSpanOffset.bs2
' Tests the spanning and offset input range of the ADC 0831 using PWM
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Declarations ]----------------------------------------------------
ADC_ByteValue VAR Byte ' Analog to Digital Converter data
V_Offset VAR Byte ' Offset voltage read from StampPlot
V_Span VAR Byte ' Span voltage read from StampPlot
TempF VAR Word ' Calculated temp in hundredths of degree F
ADC_CS PIN 13 ' ADC Chip Select pin
ADC_Clk PIN 14 ' ADC Clock pin
ADC_Dout PIN 15 ' ADC Data output
ADC_VRef PIN 10 ' Pin for PWM to set ADC voltage span
ADC_Vminus PIN 11 ' Pin for PWM to set ADC Offset
' -----[ Initialization ]--------------------------------------------------
PAUSE 1000 ' Allow connection stabilization
' -----[ Main Routine ]----------------------------------------------------
DO
GOSUB ReadSP
GOSUB SetADC
GOSUB ReadADC
GOSUB CalcTemp
GOSUB UpdateSP
GOSUB PlotPoint
PAUSE 100
LOOP
' -----[ Subroutines ]-----------------------------------------------------
ReadSP:
DEBUG CR,"!READ [(txtADCoffset),*,10]",CR ' obtain offset volt. in tenths
DEBUGIN DEC V_Offset
PAUSE 50
DEBUG "!READ [(txtADCspan),*,10]",CR ' obtain span voltage in tenths
DEBUGIN DEC V_Span
PAUSE 50
RETURN
SetADC:
PWM ADC_Vminus, V_Offset * 255/50,100 ' Apply PWM to set offset volt.
PWM ADC_Vref, V_Span * 255/50,100 ' Apply PWM to set span voltage
RETURN
ReadADC: ' Read ADC 0831
LOW ADC_CS ' Enable chip
SHIFTIN ADC_Dout, ADC_Clk, MSBPOST,[ADC_ByteValue\9] ' Clock in ADC data
HIGH ADC_CS ' Disable ADC
RETURN
CalcTemp: ' y = mx + b
' where y=temp,
' m = (change in output)/(change in input) = voltage Span/255
' x = ADC value read, b = offset, y = temperature in hundredths
' temperature = (Span/255)Byte + Offset
TempF = (V_Span * 1000)/255 * ADC_ByteValue + (V_Offset * 1000)
RETURN
UpdateSP:
DEBUG "!O txtByteBin = ", BIN8 ADC_ByteValue,CR, ' Update w/ binary ADC val
"!O txtByte = ", DEC ADC_ByteValue,CR ' Update w/ decimal ADC val
DEBUG "!O txtTemp = [", DEC TempF,",/,100]",CR ' Update w/ temperature/100
RETURN
PlotPoint:
DEBUG "!FCIR (txtByte),(txtTemp),0.3A,(WHITE)",CR ' Plot white circle at
PAUSE 100 ' byte, Temp as X,Y
DEBUG "!FCIR ,,,(BLUE)",CR ' Plot again in blue
RETURN
Thanks for taking the time to look at this. Any help is appreciated.
Ocean Bill

Comments
Give it a shot, let me know how it goes,
-Martin
That bit of code did the trick and StampPlot is receiving and plotting data. I suppose as computer processing gets faster and faster, adjustments have to be made from when the original code was written.
Ocean Bill