Following a rather ‘trial and error’ process, I managed to use some of the maths features of StampPlot Pro. The example code below generates ramping data to which StampPlot applies maths before plotting, thus avoiding any PICAXE maths.
The maths used is for the following typical application. An accelerometer produces an output of 0 to 5V over the range -8G to 8G. Which corresponds to ADC(8-bit)readings of 0 at –8G and 255 at 8G (with zero G being about 128). In order to plot this raw data in engineering units StampPlot must therefore first subtract 128 and then divide by 16.
This single channel example could form the basis of many common analog offset and scaling tasks. However, does anyone have any ideas about how best to extend the technique to deal with multiple channels using common offset and scaling parameters?
'RAMP TO STAMPPLOT PRO WITH MATHS EXAMPLE
pause 2000
setfreq m8
serout 4, N1200,("!RSET",cr)
serout 4, N1200,("!SAMT 90",cr)
serout 4, N1200,("!TMAX 50",cr)
serout 4, N1200,("!SPAN -8,8",cr)
serout 4, N1200,("!SHFT ON",cr)
serout 4, N1200,("!FLSH ON",cr)
serout 4, N1200,("!PLOT ON",cr)
serout 4, N1200,("!RSET",cr)
start:
for b0 = 0 to 255
serout 4, N1200, ("[[", #b0, " - 128] / 16]",cr)
pause 200
next
goto start
The maths used is for the following typical application. An accelerometer produces an output of 0 to 5V over the range -8G to 8G. Which corresponds to ADC(8-bit)readings of 0 at –8G and 255 at 8G (with zero G being about 128). In order to plot this raw data in engineering units StampPlot must therefore first subtract 128 and then divide by 16.
This single channel example could form the basis of many common analog offset and scaling tasks. However, does anyone have any ideas about how best to extend the technique to deal with multiple channels using common offset and scaling parameters?
'RAMP TO STAMPPLOT PRO WITH MATHS EXAMPLE
pause 2000
setfreq m8
serout 4, N1200,("!RSET",cr)
serout 4, N1200,("!SAMT 90",cr)
serout 4, N1200,("!TMAX 50",cr)
serout 4, N1200,("!SPAN -8,8",cr)
serout 4, N1200,("!SHFT ON",cr)
serout 4, N1200,("!FLSH ON",cr)
serout 4, N1200,("!PLOT ON",cr)
serout 4, N1200,("!RSET",cr)
start:
for b0 = 0 to 255
serout 4, N1200, ("[[", #b0, " - 128] / 16]",cr)
pause 200
next
goto start