Another simple lan question ...SORRY

tmack

Member
Ive been busy but I got back around to working on my simple lan project. I had it working before but cant get it going again.Can anyone take a look at it and help me troubleshoot it for once and for all? I believe I have the hardware connected properly.Here is my HTML for the simple lan:

<body bgcolor="#DCDCDC">
<META HTTP-EQUIV="refresh" CONTENT="3; URL=rrlay.html">

<!--
Note: When a port is high, the relay does not conduct - So low=on high=off
-->

<SCRIPT>
function writeStatus(val) {
if (val == 0)
return "ON";
if (val == 1)
return "OFF";
if (val == 2)
return "Cycling";
}

function writeColor(val) {
if (val == 0)
return "#669933";
if (val == 1)
return "#FF3333";
if (val == 2)
return "#FFFF33";
}

function listPort(id, title, val, varname) {
document.write("<TABLE height=50 width=200 BODER=0 CELLSPACING='0'>");
document.write("<TR height=50 bgcolor='");
document.write(writeColor(val));
document.write("'><TD width=30>"+id+"</TD><TD width=100>"+title+"</TD>");
document.write("<TD width=70>");

if (val == 0)
document.write("<a href='rrlay.html?"+varname+"=1'>OFF</a><br>")

if (val == 1)
document.write("<a href='rrlay.html?"+varname+"=0'>Turn on</a>");

if (val == 0)
document.write("<a href='rrlay.html?"+varname+"=2'>ON</a>");

document.write("</TD></TR></TABLE>");
}

</SCRIPT>



<center><font size="24px" color="navy"><b>CAMERA CONTROL</b></font><br><br>

<TABLE BODER=0 CELLSPACING="5">
<script>
document.write("<TR><TD>");
listPort(1,"UP","0","At_var20");
document.write("</TD><TD>");
listPort(2,"DOWN","0","At_var21");
document.write("</TR><TR><TD>");
listPort(3,"LEFT","0","At_var22");
document.write("</TD><TD>");
listPort(4,"RIGHT","0","At_var23");
document.write("</TR><TR><TD>");
listPort(5,"ZOOM IN","0","At_var24");
document.write("</TD><TD>");
listPort(6,"ZOOM OUT","0","At_var25");
document.write("</TR><TR><TD>");
listPort(7,"RELAY 7","0","At_var26");
document.write("</TD><TD>");
listPort(8,"RELAY 8","0","At_var27");
document.write("</TD></TR></TABLE>");
</script>
</TABLE>

<br><br>
<!--
<a href="index.html?At_var20=1&At_var21=1&At_var22=1&At_var23=1&At_var24=1&At_var25=1&At_var26=1&At_var27=1">Turn off all</a><br>
<a href="index.html?At_var20=0&At_var21=0&At_var22=0&At_var23=0&At_var24=0&At_var25=0&At_var26=0&At_var27=0">Turn on all</a><br>
-->






Here is the 28x code that I am using:




picaxe 28x1
setfreq m8 'set frequency to 8mhz

do

timedout1:
SEROUT 0, t1200, ("!AT0R20") '!ATOR=Read 20=position
SERIN [1000,timedout1],0, t1200, #b0 'on timeout try again
SEROUT 0, t1200, ("!AT0R21") '!ATOR=Read 20=position
SERIN [1000,timedout1],0, t1200, #b1 'on timeout try again
SEROUT 0, t1200, ("!AT0R22") '!ATOR=Read 20=position
SERIN [1000,timedout1],0, t1200, #b2 'on timeout try again
SEROUT 0, t1200, ("!AT0R23") '!ATOR=Read 20=position
SERIN [1000,timedout1],0, t1200, #b3 'on timeout try again

if b0 = 2 then
LOW 4
endif

if b0 = 1 then
HIGH 4
endif

if b1 = 2 then
LOW 1
endif

if b1 = 1 then
HIGH 1
endif

if b2 = 2 then
LOW 2
endif

if b2 = 1 then
HIGH 2
endif


if b3 = 2 then
LOW 3
endif

if b3 = 1 then
HIGH 3
endif
'pause 100

loop


Thanks ALOT for any help
 

MORA99

Senior Member
A few questions ...

Do you get any errors on the page (look in bottom of browser, or open error console on firefox) ?
Have you tried a debug after the serial to see what the picaxe gets from simplelan ?
Are the file named rrlay.html ?
Is javascript enabled in the browser ?
 

tmack

Member
Javascript is enabled.

File is saved as rrlay.html

There does not seem to be any errors on the firefox error console (which is cool, Ive never used it before, something new to check out , thanks)

I seem to think (based on the above) the HTML code is correct. If I had to guess I would say the problem is somewhere in the 28x code or my connections.Input Pin0 (from picaxe)is going to P8 on the simple lan,output 0(from picaxe) is going to p4. My LEDS are hooked up porperly.

The baud rate on the simple lan is set at 2400, Im not sure if that's correct or not.

I swear I used the exact same html code and picaxe code before and it worked so that just makes me more confused.


I have not tried debug to see what the picaxe is getting. I hate to say it but Im not sure how to do it.Do I just hit the debug when I have everything running? and it will show me what Im getting in ?
THanks So much for the help.
 

MORA99

Senior Member
Input Pin0 (from picaxe)is going to P8 on the simple lan,output 0(from picaxe)
serout on SL goes to serin on picaxe and vise versa i believe

The baud rate on the simple lan is set at 2400, Im not sure if that's correct or not.
Correct, the picaxe code uses 1200 but at 8mhz thats 2400

I have not tried debug to see what the picaxe is getting. I hate to say it but Im not sure how to do it.
I just use SERTXD("My debug...",#b0,CR,LF)
and then open the terminal, it will then print the text (CR,LF=new line), # before variable sends in ascii
 

tmack

Member
some questions

- Are only the 2 red leds supposed to be on , on the simple lan?

- I sort of remember something had to be done to the simple lan after loading the HTM into it before it will work with the new page. Is there something like that ? I can see the new page but the picaxe doesnt seem to get the serial info from it.

- Can someone help me figure out exactly how to use the debug to see if it is getting anything from the simple lan. I keep re reading about it and I just cant figure out how to use it. If someone can take the time to explain it step by step.

Has anyone done this before using a protoboard.I had it working before so I know Im probably close I just can't figure out whats different now.

As always Thank you very much for any help.
 

lbenson

Senior Member
I've used the Simplelan module on several breadboards. I use hserin on a 28X1 because I found that with an 18X1 or lower part the serin following the serout status request didn't execute quickly enough to catch the response from the Simplelan.

At the top of the program, I issue: hsersetup B2400_4, %1 ' set up background receive (on I7)

Then when I want to get info from the SimpleLan
Code:
  do     ' loop waiting for input from simplelan, but time out if none arrives after 256 attempts
    serout SLANoutpin, t2400, ("!AT0SI")  ' get IP address
    pause 1000
    if hserinflag = 1 then 
      b12 = 0
    else 
      b12 = b12 - 1
    endif
  loop while b12 > 0
  if hserinflag = 1 then 
      pause 1000  ' allow transmission to complete
      hserinflag = 0
  endif
Then get the data. hserptr points to the next available byte in the scratchpad (and is also the number of bytes in the scratchpad).

Code:
  ptr = 0
  sertxd("Data: ")
  do
    b1 = @ptrinc
    sertxd(b1)  ' output the data to the terminal (assumes b1 is printable)
  loop until ptr = hserptr
  sertxd(cr,lf)  ' terminate the display line
  hserptr = 0  ' reset to beginning of scratchpad
I've never used the "debug" statement--I always use "sertxd" to send the output to the program editor terminal. If the characters are unprintable you may have to use "sertxd(#b1) " in order to see the numeric value.
 

tmack

Member
Sorry to be dumb, but would the complete code then look like this for the 28x1?

hsersetup B2400_4, %1 ' set up background receive
do ' loop waiting for input from simplelan, but time out if none arrives after 256 attempts
serout 0, t2400, ("!AT0SI") ' get IP address
pause 1000
if hserinflag = 1 then
b12 = 0
else
b12 = b12 - 1
endif
loop while b12 > 0
if hserinflag = 1 then
pause 1000 ' allow transmission to complete
hserinflag = 0
endif
ptr = 0
sertxd("Data: ")
do
b1 = @ptrinc
sertxd(b1) ' output the data to the terminal (assumes b1 is printable)
loop until ptr = hserptr
sertxd(cr,lf) ' terminate the display line
hserptr = 0 ' reset to beginning of scratchpad

You kinda talking over my head sorry, What I think I understand is: If I load that onto the picaxe I should see the data come in from the simple lan somewhere on my screen?
 
Last edited:

lbenson

Senior Member
The indention of blocks would make the code easier to follow, but yes, I think that should enable you to see the answer for the question asked with "!AT0SI"--what is your ip address? Note that the output is on line 0--change to fit your wiring, and the hserin input on In7 (leg 18).

On reviewing, the last endif needs to be moved to the bottom of the code--you can only get data if the hserinflag indicates that it is available.

Note that "@ptrinc" retrieves the byte in the scratchpad that "ptr" is pointing to (or is the index of), and then increments "ptr".

"sertxd" will print to the Program Editor's terminal.

Use "!AT0ST" to get the Simplelan status, and other "!AT" commands for other data.
 

BCJKiwi

Senior Member
e.g.
Code:
hsersetup B2400_4, %1 ' set up background receive
do            ' loop waiting for input from simplelan, but time out if none arrives after 256 attempts
   serout 0, t2400, ("!AT0SI") ' get IP address
   pause 1000
   if hserinflag = 1 then 
      b12 = 0
   else 
      b12 = b12 - 1
   endif
loop while b12 > 0

if hserinflag = 1 then 
   pause 1000 ' allow transmission to complete
   hserinflag = 0
   ptr = 0
   sertxd("Data: ")
   do
      b1 = @ptrinc
      sertxd(b1)       ' output the data to the terminal (assumes b1 is printable)
   loop until ptr = hserptr

   sertxd(cr,lf) ' terminate the display line
   hserptr = 0 ' reset to beginning of scratchpad
endif
 

tmack

Member
It seems my simple lan isnt putting out any serial data. I remember that there is some procedure I was supposed to do after I loaded the new htm into it. Does anyone know what Im talking about?
 

MORA99

Senior Member
It seems my simple lan isnt putting out any serial data. I remember that there is some procedure I was supposed to do after I loaded the new htm into it. Does anyone know what Im talking about?
You can select the baud rate with the setup program ?
 

MORA99

Senior Member
Not needed, just "add files" enter password and it works.
I hooked up one a few days ago to see if there way anything tricky with it, and it worked with software serial on 40x1@8mhz.
 

tmack

Member
I wonder what Im doing wrong. I haven't figured out how to use debug yet on the pICAXE.. But I hooked up my computer using an rs232 analyser and I cant see any rs232 coming out of the simple lan. If I disconnect the LINE out from the simple lan AND PLUG IT BACK IN AGAIN i SEE A null sysbol gets sent to my analyser. Not sure where to go from here...
 

MORA99

Senior Member
use sertxd instead of debug, easyier to see the values you want.
Then just open terminal (F8)

but if simplelan is sending, maybe you have it connected to the wrong leg or wrong baud rate ?
 
Top