Shop OBEX P1 Docs P2 Docs Learn Events
PINK module online with test code — Parallax Forums

PINK module online with test code

TimCTimC Posts: 77
edited 2006-02-03 17:18 in BASIC Stamp
Hi all,

I just got my Pink module this Saturday. This pup is FAST. Thought it would be best to share for a FEW days.

Have a look at:

71.192.248.146



Attached to the BS2p stamp is:
- One LED which can be changed from the web page (does work.. but slowly)
- TSL230 light sensor working great
- SHT1x TEMP/HUMID sensor. Working well but seems to pick up the warm regulator
- HTML links to webcams, weather in Boston MA


I have attached my code that changes the variables, Not great code but it works and includes mail and UDP broadcast example.

I would love to see a flag added to tell if the web page has been hit, the Red-i web server had this feature. Also since the SB70 has so much power why not add a HTTP GET function to feed to the serial port?? This way the stamp could search for tags within remote web pages.


Regards
Tim

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-29 18:00
    Tim,

    ·· I'm surprised your equipment and even yourself can operate at such extreme temperatures!

    The Temperature in the room is: 1139 Fahrenheit·· <
    From your page!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • TimCTimC Posts: 77
    edited 2006-01-29 18:17
    Amazing. I think this is called the demo factor. Everything works until you show it to someone!

    The temp was showing 75-80F for the last 24 hours.

    Last thing it did was delete the TMP* files on the FTP part of the PINK module because the ON/OFF icon was not showing.

    The icon now shows on the web page but the temp and humid are bad within the Stamp variables.

    Tim

    ADDED: It's working. Just needed a little smack on the table.

    Post Edited (TimC) : 1/29/2006 6:21:20 PM GMT
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-01-29 21:19
    You could make an image to indicate an LED that is on, one that is off, and have the graphic tag change (via a PINK register) to have the status of the light reflected graphically.

    [noparse]:)[/noparse]

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • TimCTimC Posts: 77
    edited 2006-01-29 22:37
    Ryan,
    You should see two different images that change with the LED status. They are the same ones from the old Red-i demo. Once or twice I have seen a small bar when the ON or OFF image does not get downloaded to the client browser.
    What are you seeing?

    Perfection would be if the user pressed change and the web page LED status would change without a redisplay. (:

    Regards
    Tim
  • stamptrolstamptrol Posts: 1,731
    edited 2006-01-30 01:22
    Tim,

    Thanks for sharing! You're way ahead of me. I'm working to get only the data to be refreshed so the page doesn't have to be redrawn each time.

    Tom
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-01-30 13:22
    Tim ,do you ever receive an udp message?

    In my pink it is status bit5 that is set when an udp
    message is received, and it is received because I continuesly
    read out the status and Nb_varBM and I see the message appear.
    Status is then %00100001.

    Can you confirm it IS bit4 of the status byte that is set after udp reception?

    I noticed that status bit4 gets set after sending an email (I assume an empty udp message
    is received from the smtp server, because Nb_varBM value is 0 bytes),
    Whenever I send an udp message from the pc, status bit5 gets set (bit5 is undocumented).

    I use the attached program to send udp messages to my pink.

    regards peter
  • TimCTimC Posts: 77
    edited 2006-01-30 22:17
    Peter,
    No I have not tried to recieve a UDP message on my PINK.

    I downloaded your udpclient.exe and could not get it to work becasue I get a message box every time that says:

    Message not set!


    Check the variable update bit just in case there is an alignment problem in your status field. I assume you are showing a 1 on position 0 and 5:

    %00100001

    No this does not make sense to me either. When I send a UDP message no flag bits are set.

    Regards
    Tim
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-01-30 23:41
    Tim,
    Ryan Clarke once responded with:
    · There is a separate status bit for UDP message waiting, vs. register updated.
    · I'll give more detail when I get into the office (not in there yet, still at home!)
    but he never got back to it. Perhaps he can answer it now.

    The udpclient requires·Framework .NET v2.0
    You can download this runtime package here
    http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&DisplayLang=en

    regards peter
  • TimCTimC Posts: 77
    edited 2006-01-31 02:06
    Peter,
    One idea to break the logjam would be to download and try my code at the top of this message.
    The code worked fine with the Red-i web server, I just changed the tags to work for the PINK. So the UDP subroutines should work [noparse]:)[/noparse]


    I will find or write a Java UDP messager to test the code as well.

    Maybe there is someone out there who has tried UDP on the PINK sucessfully??

    Regards
    Tim
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-01-31 02:18
    Hi Tim,

    I tried to receive UDP with the pink, and that works (sending udp also works btw).
    I just noticed it was bit5 of the status byte that was
    set upon receiving udp, not bit4 (and it is not misaligned).
    Unfortunately I don't have a basic stamp available right now. I used a javelin.

    regards peter
  • TimCTimC Posts: 77
    edited 2006-01-31 02:37
    Hi Peter,
    Confirmed!
    It is status bit 5 NOT 4. I sent up a trap for both and the 5th bit fired.

    The Message: Hi Peter! is on the PINK Web site Now 9:30pm Eastern

    Regards
    Tim
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-01-31 03:13
    Hi Tim,

    Thanks for confirming that.
    Now, can you also confirm that status bit4 gets set
    after the pink sends an email? I noticed that too.
    Wether that is a confirmation that the email has
    been sent and accepted, or just sent, I don't know.

    Nice website btw.
    regards peter

    Post Edited (Peter Verkaik) : 1/31/2006 3:16:01 AM GMT
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2006-01-31 14:44
    TimC. I think i've already posted this but intead of using 2 webpages to show the status of the LED why not do something like:

    <img src="<Nb_var10>.gif"> (I assume <Nb_var10> means display value)

    That way you could have ON.gif and OFF.gif on your server and the browser would only see the picture you want(IE. only one webpage)
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-01-31 15:38
    DiablodeMorte said...
    TimC. I think i've already posted this but intead of using 2 webpages to show the status of the LED why not do something like:


    <img src="<Nb_var10>.gif"> (I assume <Nb_var10> means display value)



    That way you could have ON.gif and OFF.gif on your server and the browser would only see the picture you want(IE. only one webpage)

    That is the scheme I prefer- the problem (potentially) is that you need a refresh for the new graphic to be displayed- be aware of that...

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • TimCTimC Posts: 77
    edited 2006-01-31 19:46
    Post not needed
    Deleted
    See my comments directly below
    Tim

    Post Edited (TimC) : 1/31/2006 9:15:22 PM GMT
  • TimCTimC Posts: 77
    edited 2006-01-31 20:31
    Thanks everyone for the help.
    I have been populating Nb_var10 with On.gif and Off.gif from the beginning.
    This is the -FORM- part of the HTML I am currently using:
    <form method="POST" action="random.htm">
    <center>
    <font face="Comic Sans MS"> Signal LED will change after a HTML refresh. Aprox
    Total Changes: <Nb_var20> . </font>
    <pre><img src="<Nb_var06>" width="20" height="20" border="0"></pre>
    <font face="Comic Sans MS">
    ON <input type="radio" name="Nb_var10" value="ON">
    OFF <input type="radio" name="Nb_var10" value="OFF">


    <input type="submit" value="Change">
    </font>
    </center>
    </form>

    The problem as Ryan mentioned is I almost always have to do a redisplay.
    So I added a 3rd web page that forces a redisplay and in javascript does the increment for the total LED changes
    Now my Stamp code is smaller and faster because the LED count stays within the PINK.

    On average it works about 95% of the time even WITHOUT a redisplay [noparse]:)[/noparse]

    DiablodeMorte you were the one that gave me the idea because I was using 2 web pages.
    When I went back to 1 web page it got worse!


    Regards
    Tim
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-01-31 21:31
    Tim,

    You say:
    On the debug console sometimes the stamp is just not seeing the variable change flag.
    I am not sure if I should be speeding up the status query [noparse][[/noparse]"!NB0ST"] or waiting longer.

    There is an issue with status I know off:
    using Telnet I noticed the following:
    When ready to send email I issue the send email command. Telnet says:

    Received from Stamp: [noparse][[/noparse]!NB0SM]
    Setting up to send E-Mail
    Received from Stamp: [noparse][[/noparse]!N] Missformed message
    Received from Stamp: [noparse][[/noparse]B]
    Received from Stamp: [noparse][[/noparse]0]
    Received from Stamp: [noparse][[/noparse]S]
    Received from Stamp: [noparse][[/noparse]T]

    Apparently Pink does not recognize the first getStatus command after sending an email,
    and therefore the command getStatus will timeout, returning a timeout value to my main program.

    Even a 1 second delay between the send email command and the getStatus command
    does not resolve the error. The fastest way I have found is to force a Missformed message
    by sending '!','X' directly after the send email command.
    Following telnet session illustrates:

    Diagnostic display of Stamp to Netburner I/O
    type logout to exit the monitoring session
    Received from stamp:[noparse][[/noparse]!NB0WEV:smtp.zonnet.nl<CLS>]
    Set Var [noparse][[/noparse]EV] to [noparse][[/noparse]smtp.zonnet.nl]
    Received from stamp:[noparse][[/noparse]!NB0WEC:directly typed text 2<CLS>]
    Set Var [noparse][[/noparse]EC] to [noparse][[/noparse]directly typed text 2]
    Received from stamp:[noparse][[/noparse]!NB0WES[noparse]:p[/noparse]ink email test 2<CLS>]
    Set Var [noparse][[/noparse]ES] to [noparse][[/noparse]pink email test 2]
    Received from stamp:[noparse][[/noparse]!NB0WEF:verkaik6@zonnet.nl<CLS>]
    Set Var [noparse][[/noparse]EF] to [noparse][[/noparse]verkaik6@zonnet.nl]
    Received from stamp:[noparse][[/noparse]!NB0WET[noparse]:p[/noparse]eterverkaik@boselectro.nl<CLS>]
    Set Var [noparse][[/noparse]ET] to [noparse][[/noparse]peterverkaik@boselectro.nl]
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 01
    Sent to Stamp:[noparse][[/noparse]]
    Received from stamp:[noparse][[/noparse]!NB0SM]
    Setting up to send E-Mail
    Received from stamp:[noparse][[/noparse]!X] Missformed message
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 05
    Sent to Stamp:[noparse]/noparse
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 01
    Sent to Stamp:[noparse][[/noparse]]
    Received from stamp:[noparse][[/noparse]!NB0RBM]
    Read Var [noparse]/noparse]BM] value is [noparse][[/noparse
    Send to Stamp:[noparse][[/noparse]<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0RBI]
    Read Var [noparse]/noparse]BI] value is [noparse][[/noparse
    Send to Stamp:[noparse][[/noparse]<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0REV]
    Read Var [noparse][[/noparse]EV] value is [noparse][[/noparse]smtp.zonnet.nl]
    Send to Stamp:[noparse][[/noparse]smtp.zonnet.nl<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0REC]
    Read Var [noparse][[/noparse]EC] value is [noparse][[/noparse]directly typed text 2]
    Send to Stamp:[noparse][[/noparse]directly typed text 2<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0RES]
    Read Var [noparse][[/noparse]ES] value is [noparse][[/noparse]pink email test 2]
    Send to Stamp:[noparse][[/noparse]pink email test 2<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0REF]
    Read Var [noparse][[/noparse]EF] value is [noparse][[/noparse]verkaik6@zonnet.nl]
    Send to Stamp:[noparse][[/noparse]verkaik6@zonnet.nl<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0RET]
    Read Var [noparse][[/noparse]ET] value is [noparse][[/noparse]peterverkaik@boselectro.nl]
    Send to Stamp:[noparse][[/noparse]peterverkaik@boselectro.nl<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 11
    Sent to Stamp:[noparse]/noparse
    Received from stamp:[noparse][[/noparse]!NB0RBM]
    Read Var [noparse]/noparse]BM] value is [noparse][[/noparse
    Send to Stamp:[noparse][[/noparse]<CLS>]
    logout
    GoodBye

    The 1st status read after send email command returns status bit2 set (not ready to send email)
    The 2nd status read after send email command returns status bit2 clear (ready to send email)
    The 3rd status read after send email command returns status bit4 set (manual states received udp message)


    Please check your telnet session very carefully for any missformed messages or if the variable change flag
    is not set when you are sure that it must.

    regards peter
  • TimCTimC Posts: 77
    edited 2006-01-31 22:49
    Peter,
    What I did was to increase the ALL serial recieve timeouts to the SB70 to 250
    Such as:
    SERIN FromNB,Baud,250,Main_Loop,[noparse][[/noparse]RiStatus]

    I also got rid of any delays in other parts of the code.
    Overall the Web page is working a lot better than just 2 hours ago.

    I see about 4 lines a second go by on the Telnet console, all status, variable requests and updates.
    So I watched for about 10 minutes and I did not see a single problems. -phew-


    I have now changed the app to send an e-mail when a UDP message is received.
    Can start testing tonight or tomorrow without ever taking the web site down [noparse]:)[/noparse]

    Regards
    Tim
  • TimCTimC Posts: 77
    edited 2006-02-01 05:54
    Peter
    I have not been having any problem SENDING email but it is clear that we have a small problem from the telnet logs
    Also my Subject line is not working.
    Will take a fresh look at it in the morning.
    Regards
    Tim



    My stamp debug output is as follows:
    Got RiStatus: 100001 .
    UDP Rec! (bit5)
    Entered Mail routine
    mail command to send (SM) finished
    Got RiStatus: 101 .
    Email Buzzy.. (Bit 2)
    Got RiStatus: 10001 .
    Email Sent (bit4)!


    Telnet log: (the cross outs and bolding came from the PINK LOGS!)

    Sent to Stamp:[noparse]/noparse
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 01
    Sent to Stamp:[noparse]/noparse
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 21
    Sent to Stamp:[noparse][[/noparse]!]
    Received from stamp:[noparse][[/noparse]!NB0BM!N] Missformed message
    Received from stamp:
    Received from stamp:[noparse][[/noparse]0]
    Received from stamp:[noparse][[/noparse]W]
    Received from stamp:[noparse][[/noparse]E]
    Received from stamp:
    Received from stamp:[noparse][[/noparse]:]
    Received from stamp:[noparse][[/noparse]H]
    Received from stamp:[noparse][[/noparse]e]
    Received from stamp:[noparse][[/noparse]l]
    Received from stamp:[noparse][[/noparse]l]
    Received from stamp:[noparse][[/noparse]o]
    Received from stamp:[noparse][[/noparse]:]
    Received from stamp:[noparse][[/noparse] ]
    Received from stamp:[noparse][[/noparse]0]
    Received from stamp:[noparse][[/noparse]<CLS>]
    Received from stamp:[noparse][[/noparse]!NB0WEC:yes.txt<CLS>]
    Set Var [noparse][[/noparse]EC] to [noparse][[/noparse]yes.txt]
    Received from stamp:[noparse][[/noparse]!NB0SM]
    Setting up to send E-Mail
    Received from stamp:[noparse][[/noparse]!N] Missformed message
    Received from stamp:
    Received from stamp:[noparse][[/noparse]0]
    Received from stamp:
    Received from stamp:[noparse][[/noparse]T]
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 05
    Sent to Stamp:[noparse]/noparse
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 01
    Sent to Stamp:[noparse]/noparse

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-02-01 06:30
    Hi Tim,
    Sending email is no problem. The problem is the command following the sendEmail command.
    This generates a missformed message response. My workaround is to enforce such a response
    by using !NB0SM!X instead of !NB0SM as the sendEmail command. Any next command
    then does not generate the missformed message response. Especially if the next command
    is the getStatus command you can be assured you get the new status.

    Also noticed your log confirms status bit4 gets set after sending email
    whereas the manual states that bit4·identifies udp received (we already know
    bit5 gets set for udp received).

    regards peter
  • TimCTimC Posts: 77
    edited 2006-02-01 19:28
    Peter,
    Confirmed: Status Bit 4 means the email has been sent.
    Confirmed: Status Bit 2 is working as expected - set when busy sending e-mail
    Confirmed: After the send mail command is issued the next command will fail. So to workaround the problem send a dummy message. (!X seems like a good choice)


    In addition I found a new (small) problem:
    SEROUT NBReceive, Baud, [noparse][[/noparse]"!NB0WES:Hello:",CLS] 'Load Subject
    Will not work and will send a BLANK Subject line because of the final ":"
    PINK seems to have a parse problem because
    [noparse][[/noparse]"!NB0WES:Hello:There",CLS] Works Fine


    TELNET LOG:
    Received from stamp:[noparse][[/noparse]!NB0WES:Hello<CLS>]
    Set Var [noparse][[/noparse]ES] to [noparse][[/noparse]Hello]
    Received from stamp:[noparse][[/noparse]!NB0WEC:yes.txt<CLS>]
    Set Var [noparse][[/noparse]EC] to [noparse][[/noparse]yes.txt]
    Received from stamp:[noparse][[/noparse]!NB0SM]
    Setting up to send E-Mail
    Received from stamp:[noparse][[/noparse]!X] Missformed message
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 05
    Sent to Stamp:[noparse]/noparse
    Received from stamp:[noparse][[/noparse]!NB0ST]
    Write Status value = 01

    Regards
    Tim
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-02-01 22:46
    Hi Tim,

    The closing ':' problem is new to me. I wonder if this only applies to
    Nb_varES·or if it applies to all variables (I think it·applies to all vars).
    Will a starting : also give problems: "!NB0WES::Hello",CLS

    A possible·workaround is to use a replacement character for :
    for example ; or the single quote.

    So if your data contains a : then use ;

    Upon reading the variable, you can change a ; back to :

    regards peter
  • TimCTimC Posts: 77
    edited 2006-02-02 18:01
    All,

    Just added a LIVE webcam image FTP'd to the PINK every 15 sec.


    During the day the LED is very hard to see - but it is possible.
    Do a redisplay to see LED change.
    The power LED is to the left of the changing LED and can be seen all the time

    Since my laptop is doing the upload, the FTP images will not be 24/7

    Enjoy

    Regards
    Tim
  • steve_bsteve_b Posts: 1,563
    edited 2006-02-02 21:06
    That's cool!!

    Anychance of sharing some code? I'd be interested to see how you got the camera image referenced or actually in the PINK!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-02-02 21:30
    He uses Webcam32 (http://www.surveyor.com/) to ftp a new picture (dynamic.jpg) to the PINK, the html code for the page is availible via View>Source in IE.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • TimCTimC Posts: 77
    edited 2006-02-03 00:51
    Yes Paul you are right.
    Using Webcam32 is the easy part. All I have to do is tell Webcam32 where the website is to send the jpg to. My Pink as a result gets pounded with all the inbound FTP traffic.

    Steve, to do this yourself you would add a line like this:

    <img src="dynamic.jpg" width=233 height=175 border=2 alt="Live Web Cam into PINK">

    Regards
    Tim
  • steve_bsteve_b Posts: 1,563
    edited 2006-02-03 13:04
    Very cool.
    Did you have to buy their product to use their server?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • TimCTimC Posts: 77
    edited 2006-02-03 17:09
    Yes Steve I purchased Webcam32 about 3 years ago.
    I would choose a different product since the company no longer supports or updates the software.
    In addition, Webcam32 needs a running PC which means lots of electricity to run 24/7.

    If I were to start over again and had a little more cash I would try:
    www.axis.com/products/video/camera/index.htm

    Or for about $100 US you could get a D-Link DCS-900 10/100TX Internet Camera
    www.dlink.com/products/?pid=270

    Or for a real hobby experience this camera rocks:
    www.acroname.com/robotics/parts/R245-CMUCAM2-PLUS.html

    Have Fun!
    Tim
  • steve_bsteve_b Posts: 1,563
    edited 2006-02-03 17:18
    I've got an AXIS camera. Haven't set it up....but it's direct TCP so it'll not require a pc!

    At work we use a Flexwatch camera server. You can plug in your normal video feeds and it will display it on its built in webserver.
    TCP configured as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Sign In or Register to comment.