Shop OBEX P1 Docs P2 Docs Learn Events
ModBus Master with Web-Server front end. Questions. — Parallax Forums

ModBus Master with Web-Server front end. Questions.

ShawnaShawna Posts: 508
edited 2011-10-15 09:25 in Accessories
Hello,

I'm not sure where to start with this so I will probably ramble a little bit. This is my first post and I'm sorry if I don't follow the right protocol. When I first started with micro controllers I started with the basic stamp and it was fun to play with. After electronics school I moved to PICs using PicBasic Pro. I have made a ModBus slave controller and programmed it in PicBasic Pro. My front end is an Ilon Web server which is an overkill and too expensive. I install small control systems and a $800.00 front end for web access seems to be a killer. I looked into building one with a PIC and an ENC ethernet controller but it seemed like to much of a task, with very little info in the PicBasic forum. While I was looking for small web servers I found the spinneret server. So on with the rambling.

What I do with the Ilon web server is link network points together because it is the ModBus Master. Anything that needs to be scheduled is also done on the Ilon and stored on the Ilon. And of coarse the web pages are all stored on the Ilon. I like using graphis on my web pages and allot of them are animated gif's that change depending on the state of a network variable. The Ilon web server has 64MB of Flash memory so I thought it was really cool that the spinneret has a SD card holder.

What I want with my spinneret
1. I need to have the capability of storing 500 to 1000 network variables in Ram so that I can display them on web pages. I do not want to store them on flash because some will be written to every second and that would destroy the Flash memory.
2. I need a ModBus Master incorporated in the spinneret also.
3. I need to display the points dynamicly without refreshing the whole web page.

How I thought I would accomplish this.
I have bought a prop chip and played with it and I have also bought and played with a spinneret and went through Mike G's examples. Nice Job Mike.

While going through the examples and looking at available space left in Ram I do not think I can do this with just a spinneret. My thought was to hook up another prop on a daughter board and use it as the ModBus Master and have it do all tasks for the ModBus network. I would hook the spinneret up to this prop chip and have the 2 controllers constantly spitting variable values back and forth, but i think this would take a dedicated core on the spinneret chip and my Modbus Master Prop and I'm not sure how many cores the spinneret runs at any given time.
I probably will think of something I forgot after I hit submit but what do you guys think, is this doable?
I looked at the different objects in Mikes examples and tried to find some that I could do without to save Ram space but I'm not real sure if I can get rid of any. It doesn't really look like it.
When is the Prop 2 coming out it looks like it might have enough ram to do it all?
Anyways Thanks
Shawn

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-10-10 14:04
    Shawna, minimal and base drivers can be found in the Google repository.
    http://code.google.com/p/spinneret-web-server/source/browse/#svn%2Ftrunk%2FMultiSocketServer_MikeG
  • ShawnaShawna Posts: 508
    edited 2011-10-10 18:51
    hey
    Thanks for the link, I had not found all of that yet. I haven't decided where to start. I think I am going back to the prop and trying to get a ds1307 running. Then I can dump the rtc code from the spinneret. I will feed the time to the spinneret from my modbus master that is on the daughter board. I understand bits and pieces from the spin code but I don't understand it all yet. There is some corky things that I haven't wrapped my head around yet. Maybe the hardest is the multiple cores. It can really play tricks with your mind when reading through code.

    How can a person tell how many cogs a program will use. I think in order for me to make this work I will have to dedicate 1 or 2 cogs to communicating with the Prop Chip on the daughter board.

    Thanks
    Shawn
  • Mike GMike G Posts: 2,702
    edited 2011-10-10 20:28
    I'd be happy to help but can you clarify a few things?
    Shawna wrote:
    1. I need to have the capability of storing 500 to 1000 network variables in Ram so that I can display them on web pages. I do not want to store them on flash because some will be written to every second and that would destroy the Flash memory.
    2. I need a ModBus Master incorporated in the spinneret also.
    3. I need to display the points dynamicly without refreshing the whole web page.

    How large is a network variable?
    Is the ModBus over TCP, Serial...?
    Displaying 500 to 1000 nodes of dynamic data is pretty easy with AJAX
    Shawna wrote:
    I think I am going back to the prop and trying to get a ds1307 running. Then I can dump the rtc code from the spinneret. I will feed the time to the spinneret from my modbus master that is on the daughter board
    Why is a separate ModBus master needed? How large is the ModBus master?
    Shawna wrote:
    How can a person tell how many cogs a program will use. I think in order for me to make this work I will have to dedicate 1 or 2 cogs to communicating with the Prop Chip on the daughter board.
    Dunno, how much chatter do you expect over what protocol? FullDuplexSeial uses one COG.

    If you have the ModBus working, adding a Web server listening on a single socket with a minimal footprint is doable. The Web server would take 2 COGs. I would render the initial HTML page then update the page with an XML document every X seconds. It's very socket friendly. I recently built a project with a minimal web server for a project, you're welcome to it.
  • ShawnaShawna Posts: 508
    edited 2011-10-11 19:55
    Hey Mike
    Thanks for your follow up. I can answer most of the questions but it is late. I just got out of a continuing education class for my electrical license and my brain is fried. I'm going to spend some time with the fam and go to bed.

    Thanks
    Shawn
  • ShawnaShawna Posts: 508
    edited 2011-10-12 09:42
    Ok a few answers.

    Network Variables in my modbus network are word sized. All of them. With the prop if I get it working I may change them to 32 bit for 32 bit floating point. I can't remember if 16 bit floating point is acceptable.

    My ModBus Slaves run ModBus RTU protocol. Its simple and reliable, maybe some day I will venture into ModBus TCP IP but not now. Peer 2 Peer networks for what I do are to bloated in my opinion.

    The reason I think a second Prop will be needed is because of the code required to handle the ModBus Master Protocol. I have not actually written a ModBus Master program. But I have written ModBus Slave program for a PIC using PicBasic Pro and it required 2500 words of flash for just the basic program. The Pics have seperate Ram for the Variables so the 2500 words doesn't take account for all the variables.

    I'm not sure how much chatter should be expected over the network. I do know that the RS485 chip I use for the network can handle 32 or 64 device. At 9600K that is about 1ms for every byte that is received. I have kicked the network up to 115000kb and it functioned fine but I only had one slave on the network. I have a feeling that with multiple devices on the network my pic may not be able to keep up with network comunication and controller tasks. I am using interrupts but they are picbasic interrupts and not asm interrupts. This is why multiple cores look cool to me. I could have a core just for communication on the Modbus Network. I could have a core running through the main routine for the modbus master. And then I could have a core constantly dumbing variable to the spinneret. Also a core dumping data comeing from web pages(spinneret) back to my modbus master and then out to the modbus slaves.

    I have problems getting thoughts from my head to the forum pages sorry . Do you think I could fit all of this on the spinneret without a second prop for the Modbus Master. Maybe I still do not have enough info for ya.

    Thanks Mike
    Shawn
  • ShawnaShawna Posts: 508
    edited 2011-10-12 16:29
    Here is my current web page. I use it to play around with, i'm not much of a graphic designer. There are also some bugs to work out but it functions how I want it to. The pictures of the blower, evap. and heat exchanger change depending on the state of each one. The board in the lower left corner which is a terrible picture is my ModBus RTU Slave board.
    http://nsadesign.dyndns-at-work.com/user/ahumonitor/acstatus.htm
  • ShawnaShawna Posts: 508
    edited 2011-10-12 16:31
    Oh
    I did not write all of the HTML code, the server comes with a tool to build the page.
  • Mike GMike G Posts: 2,702
    edited 2011-10-12 18:52
    The prop has 32K of RAM so storing 1000 32 bit values is 4K which leaves 28K for your program. I'm pretty sure the Spinneret can handle the ModBus master and web server. The only way to know for sure is to build the ModBus master. The web server is already done.
  • ShawnaShawna Posts: 508
    edited 2011-10-12 20:55
    Ok maybe I should learn how to walk before I try running. The reason I did not think it would all fit in the Ram is because of one of your tutorial examples on your spinneret.When I load the code in the zip file below and compile it, the view info page says there is only 803 longs free in the stack. If I wrote the ModBus Master code in PicBasic I would bet that it would take at least 8K or 4000 words. Then add another 4K for my 1000 32 bit values(variables), that is way over the 803 longs that are free in the stack. I have not written much code in spin yet so maybe it would not take as much ram to write the modbus code but even the amount of variables I want would not fit. Unless I am missing something. I've looked through the objects in the zip file and played with the code a little. I do not really see where I could save on ram there. It looks like to me that all the objects are needed. I tossed around the idea of getting rid of the rtc object but that seems to be needed for the fat objects. Also I looked at getting rid of the PST but that maybe needed for debugging.
    But your right. The bottom line is that I need to write a modbus master program and see how much ram it takes. I don't know if I should even attempt this yet in Spin. I understand Modbus RTU protocol really well but the task is still challenging not being real familiar with spin. I could write the code in PicBasic and use the second usart on a Pic to talk to the spinneret. Ahhhh that is besides the point.
    I suppose it may not be that big of a task if I can use the FullDuplexSeial object to interface to my rs485 chip. I'll have to look at that object and try to sort through it.
  • Mike GMike G Posts: 2,702
    edited 2011-10-12 21:26
    Get the ModBus master working. I'm sure I can wire up a web server that will fit your space requirements. The HTTPServerBase is 2,484 longs.
  • ShawnaShawna Posts: 508
    edited 2011-10-13 10:24
    Hey Mike
    Thanks for the reply, I saw the HTTPServerBase before, and I've looked at it briefly. It didn't look like one could utilize the sd card though. Or am I missing something. I skipped over the HTTPServerBase because of that. The reason I didn't think the sd card could be used is because it is missing the fat driver and the fat wrapper which look like they take up allot of ram. I have to be able to store web pages on the sd card.
    Thanks
    Shawn A
  • ShawnaShawna Posts: 508
    edited 2011-10-15 09:11
    Mike,
    Thanks for replying to my threads. You have given me allot to think about. I think I am going to take a step back. I am going to go back to my ModBus Slave board and beat the Smile out of it and see how it holds up. If it holds up well I am going to write a ModBus Master program for a PIC. Once I have that working I will work at tying the Pic Modbus master and the spinneret together.
    If my ModBus Slave does not stand up then I will look into transferring everything over to a Prop. How long are you going to have your guide on the your spinneret online, it is very helpful.
    Thanks Again
    Shawn
  • Mike GMike G Posts: 2,702
    edited 2011-10-15 09:25
    The manual is published in the Google repository.
Sign In or Register to comment.