Shop OBEX P1 Docs P2 Docs Learn Events
Displaying pH readings in a PINK HTML page — Parallax Forums

Displaying pH readings in a PINK HTML page

foodgodfoodgod Posts: 13
edited 2009-03-14 20:36 in Propeller 1
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

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-03-09 21:21
    Hello,

    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
  • foodgodfoodgod Posts: 13
    edited 2009-03-10 15:03
    Chris, thanks for the explanation. I'm still having difficulty trying to to display an integer value in PINK. Below is the code I'm using to understand PINK. In the repeat section of this code, I've placed a Pink.write function which initially displayed a string from DAT. what I'm attempting to do is display the integer stored in the status variable. I've tried many different methods of doing this to no avail. What I see displayed is garbage. I think the problem is the format but I'm not sure. What would the proper format be to display the status variable properly?Do I need to convert the status variable to a string? The examples I find on line show only strings being displayed. I'm only using this code for testing purposes so the variable, status, is just a test variable. I'd eventually like to display a variable into the HTML page which comes from voltage readings of an A/D converter. Any help would be greatly appreciated. Thanks

    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-03-10 19:44
    Okay, I just realized you’re using an object for the PINK I have not yet looked at.· But before you were trying to display pH values and it seems you're trying to use the status value?· That will actually be the status of the flag bits.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-10 20:00
    You can write up to 63 non-zero bytes to a pink variable.
    (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
    ·
  • foodgodfoodgod Posts: 13
    edited 2009-03-10 21:55
    Initially I was trying to read pH value but I figure I should start at a more basic level. I was using the status register more as an example plus it happened to be a variable already available in the program.I just wasn't understanding the means by which to display a variable that was anything other than a string. I'll trying converting the variable to an ASCII string and then to a PINK variable as suggested. If I'm able to get this to work then I'll try it with the pH value. Thanks for the help.
  • foodgodfoodgod Posts: 13
    edited 2009-03-14 20:36
    Peter (or anyone who may have a solution),
    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
Sign In or Register to comment.