Simple SimpleLAn

tmack

Member
I finally got my simpleLan/ 28x1 running. I am using code that Mora was kind enough to provide to me on another thread.(Thanks Mora!). It is working ,so I am now sure that all of my connections etc are correct. My problem now is that even though it may be a simple program, to me it is still too complicated to follow. I was wondering if anyone has ever used the simplelan in a very BASIC way. Like just to turn on and off an led/relay. Im looking to eventually be able to write a html and code that turn leds on or off in a toggling fashion and/or be able to have it so that when I press the "button" the led will go on for a second and then right back off again until the next time it is depressed. I get confused fast if there are variables in code. Thanks for any help/ideas.
 

tmack

Member
This is what I have so far (for my Simple LAN): Id like it to simply send a "1", "2","3","4" when the buttons are pressed or a "0" if they arent. Im not sure how to add the serial out.

This is the code I have so far for my HTML form:

<body bgcolor="#dcdcdc">
<META HTTP-EQUIV="refresh" CONTENT="3; URL=testtest.htm">

<!--
Note:
-->



<center><font size="24px" color="navy"><b>TEST</b></font><br><br>
<br>
<br>
<button type="button">ONE </button>
<br>
<br>
<center><button type="button">TWO </button>
<br>
<br>
<center><button type="button">THREE</button>
<br>
<br>
<center><button type="button">FOUR </button>

<br><br>
 
Last edited:

marcos.placona

Senior Member
First you need to have a form, that will be submited, and will submit the values as well.

You also need to have a javascript function to get the button value and send it. I'm not sure, but isn't there any sample file with the server you got?
 

tmack

Member
There are examples but they are with a Stamp and they really aren't basic enough for me to understand, unfortunately. I am just looking for an example of the most basic, simple lan out to 28x1 to toggle an led/relay on/off. Then hopefully, I can understand how that works and build on it to do what I want in the end.If anyone has such an example I would greatly appreciate it.
 

steliosm

Senior Member
Here is some code that might do the trick. I haven't got any time to test it. The PicAxe code is a strip down version of a program I'm running on a 28X1 which works fine.


The HTML calls the index.htm page passing some variables (At_var20) and a values (1 or 0).

Save the page as index.htm in the SimpleLan module
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title></title>
</head>
<body>
Led Control Page<br>
<br>
Click <a href="index.htm?At_var20=1">here</a> to
turn LED ON<br>
Click <a href="index.htm?At_var20=1">here</a> to
turn LED OFF
</body>
</html>

The following code will check (check_webdata) every minute if there is an update from the Web site. If there is an update it will read (Do_Something) the Var20 (4bytes) from the SimpleLan module. According to the value of the variable will either turn On the LED of Off. I haven't test the code the way is provided here, you will need to do some debugging yourself.


Code:
'
' Define the symbols
'
#picaxe 28X1
symbol LoopCounter = b12
symbol webByte = b1
symbol Data_Loc = b10
symbol Data_Var = b11

'
' The MAIN part
'
main:
	' The main loop.
	' Pause and count the Pulses
	let LoopCounter = 1
	do
	pause 60000 ‘ Wait 60 second
	 gosub check_webdata ' Check if web variables were updated
	 inc LoopCounter
	loop while LoopCounter < 6 ' Loop delay is 5min
	goto main ‘ Loop!
'
' SimpleLan procedures
'
check_webdata:
	' Get the status register from SimpleLan
	' Might need to change the hsersetup bits
	hserout 0, ("!AT0ST")
	' Receive the data at Scratchpad location 100
	hserin [1000,cont_0],100,1
	cont_0:
	' Move ptr to location 100
	ptr = 100
	' Get the data into variable b1
	let webByte = @ptr
	' Check if bit 1 (bit9) has been set
	if bit9 = 1 then
	 gosub Do_Something
	endif
	return

Do_Something:
	'
	' Do something with the data arrived at the SimpleLan
	'
	' Using the info from the datashet page 10
	' Read the variable 20 (4 bytes)
	hserout 0,("!AT0R20")
	hserin [1000,cont_1], 0, 4
	cont_1:
	let Data_Loc = 0
	get Data_Loc, Data_Var
	if Data_Var = 1 then gosub Led_On
	if Data_Var = 0 then gosub Led_Off
	return

Led_On:
	'
	' Turn on the LED
	'
	high 1
	return

Led_Off:
	'
	' Turh off the LED
	'
	low 1
	return

steliosm
 
Top