Displaying pH readings in a PINK HTML page
foodgod
Posts: 13
I'm currently working on a project where I'm reading pH readings from a water reservoir into a propeller. As the pH value goes outside a set pH range, solenoid valves release an acidic or alkaline liquid concentrate depending on the current pH value. I'm trying to display the current pH value in an HTML page using PINK but I'm not sure if it's possible. Does anyone know if variables can be displayed this way? If so how would this be achieved? Thank you!
Comments
Any variable up to 64 characters long can be displayed in a web page. Please see the PINK documentation for more details. While many of the examples are for the BASIC Stamps, the web server functions are identical regardless of the connected microcontroller.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Pin_PinkTX = 6 'tx pink
Pin_PinkRX = 7 'rx pink
VAR
byte buffer[noparse][[/noparse]64]
OBJ
Pink : "PinkV2"
term : "tv_text"
delay : "clock"
PUB Start | status,read
term.start(12)
' Initialize Pink (uses 1 cog)
Pink.PinkV2("0", Pin_PinkRX, Pin_PinkTX) 'Pink Baud 9600
DELAY.PauseSec(3)
Pink.writeVar(Pink#Nb_var01,@WriteTest)
DELAY.PauseSec(3)
repeat
status := Pink.getStatus
{{____________________________________________________}}
Pink.writeVar(Pink#Nb_var01,@status) {{This is where I'm trying to write the variable, status, to PINK}}
{{____________________________________________________}}
term.dec(status)
term.out(13)
read := Pink.readVar(Pink#Nb_var01, @buffer)
term.str(@buffer)
DELAY.PauseSec(3)
DAT
WriteTest BYTE "Welcome to Pink",13,0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
(If you write 64 or more non-zero bytes, adjacent pink variables
will be overwritten).
The statusbyte returned by pink is a binary value.
When you try to write the statusbyte to a pink variable,
it will write bytes starting from @status until·it encounters
a binary 0. So this is pointless.
First convert the statusbyte to an asciiz string, then write
the asciiz string to the pink variable.
regards peter
·
I took your suggestion and was able to display the pH readings in an HTML page. After doing so, I was next confronted with the problem of displaying the pH value in decimal form. I am currently able to display the decimal value in the Debug terminal but when I assign this value to the value being displayed in the HTML page, the value shows up as only 0 or 255, no intermediate values. My question regarding this is: How can I display the decimal value in the HTML page? Below is the code I'm working with. The byte size variable, buffer_2 is being assigned the result from the function "DisplayValue" which displays the decimal valued pH reading. If I remove the assignment operator,buffer_2 :=, the Debug terminal displays correctly but I can't seem to assign this changing value to a variable. Any suggestions?
Thank you.
pub Start| data
'Initialization section
Initialize
Pink.PinkV2("0", Pin_PinkRX, Pin_PinkTX)
DELAY.PauseSec(3)
repeat
data := AcquireValue
value:= AcquireValue ' Assign current A/D readings to byte value
{{Code below is attempt to display decimal value}}
buffer_2:= DisplayValue(AcquireValue,2,2) 'This is used to display pH in decimal notation
{{fmt.sprintf(@buffer,string("value is %03.3d "),buffer_2)}}
fmt.sprintf(@buffer,string("Current pH: %03.3d "),value)
Pink.writeVar(Pink#Nb_var01,@buffer)
Pink.readVar(Pink#Nb_var01,@buffer)
pH_Adjustment(data) 'If pH is outside set parameters activate 'solenoid valves
DELAY.PauseSec(1) ' 1 second wait