October 12, 2024, 04:23:44 PM

PIC-WEB help Request

Started by Astra08, December 02, 2013, 07:55:53 PM

Previous topic - Next topic

Astra08

Hi ,
I am trying to learn how to work with PIC-Web Rev C.
I have a PIC-WEB server Rev C and a Pic-Kit 3.
I have downloaded and installed all the recommended and necessary files and software listed in the webpage for the Pic-Web Rev C . I have been able to use Putty.exe to configure IP address and I can access the factory installed pages on the pic-web . I have also been able to rebuild the example project in the Demo app using MPLAB and load the .hex file to the board using Pic Kit 3 . I also succeeded to restore the board to its Demo state by re-installing the demo files. The MPFS2 works fine and does the job.
My Problem is that when I make changes in pages like index.htm or forms.htm and I load them to the Pic-Web ,
I can see the changes but the changes have no effect on the inputs or output pins of EXT connector.
In other words I`d like to have more LEDs controlled from the EXT terminal like the Example page.
Which other files need to be modified?
I am sure there is something I am doing wrong.
I would truly appreciate some help and if there are any examples that I can look or try.

Many Thanks in advance.

Stanimir5F

Hi Astra08!

In order to have more LEDs controlled by the webpage you need to add the dynamic variables.
I don't know how many LEDs you want to add but you must add them in status.xml. Also you need to change the code inside the index.htm (and other files that makes pages to control them) for both status block:
<div id="status">
...
<p>LEDs:<br /><span class="leds">
<!-- <a id="led7" onclick="newAJAXCommand('leds.cgi?led=7');">&bull;</a>
<a id="led6" onclick="newAJAXCommand('leds.cgi?led=6');">&bull;</a>
<a id="led5" onclick="newAJAXCommand('leds.cgi?led=5');">&bull;</a>
<a id="led4" onclick="newAJAXCommand('leds.cgi?led=4');">&bull;</a>
<a id="led3" onclick="newAJAXCommand('leds.cgi?led=3');">&bull;</a>
<a id="led2" onclick="newAJAXCommand('leds.cgi?led=2');">&bull;</a> -->
<a id="led1" onclick="newAJAXCommand('leds.cgi?led=1');">&bull;</a>
<!-- <a id="led0">&bull;</a> -->
</span></p>
...
</div>)



and the javascript:
<script type="text/javascript">
...
// Loop over all the LEDs
//for(i = 0; i < 8; i++) {
// if(getXMLValue(xmlData, 'led'+i) == '1')
// document.getElementById('led' + i).style.color = '#ddd';
// else
// document.getElementById('led' + i).style.color = '#090';
//}
if(getXMLValue(xmlData, 'led'+1) == '1')
document.getElementById('led' + 1).style.color = '#ddd';
else
document.getElementById('led' + 1).style.color = '#090';
...
</script>

Since by default there is only 1 LED it is done for one so lower block is used but if you need more (like in your case) you need to use the upper block (the one which is commented).


Also in the MPLAB project you must add location of the LEDs inside the file "HWP OLIMEX_PIC-WEB.h", line 145-165:

// I/O pins
#define LED0_TRIS (PRODL) /* NC */
#define LED0_IO (PRODL) /* NC */
#define LED1_TRIS (TRISBbits.TRISB4)
#define LED1_IO (LATBbits.LATB4)

/* ignore rest of LEDs */
#define LED2_TRIS (PRODL)
#define LED2_IO (PRODL)
#define LED3_TRIS (PRODL)
#define LED3_IO (PRODL)
#define LED4_TRIS (PRODL)
#define LED4_IO (PRODL)
#define LED5_TRIS (PRODL)
#define LED5_IO (PRODL)
#define LED6_TRIS (PRODL)
#define LED6_IO (PRODL)
#define LED7_TRIS (PRODL)
#define LED7_IO (PRODL)
#define LED_GET() (LED1_IO)
#define LED_PUT(a) (LED1_IO = (a))

If you need more than 8 add new macros.

The same procedure you must do to the file CustomHTTPApp.c, line 1589-1666, functions HTTPPrint_led and HTTPPrint_ledSelected (and in case you want to send e-mail with their status check line 1291-1310). If you need more LEDs just add them the same way it is done for first 8.

Last but not least - if you have to change the status.xml file for more/less/different variables you MUST delete the old version of files HTTPPrint.h, HTTPPrint.idx, and *.bin before generating the new version with Microchip's tool MPFS2.jar. Otherwise if you overwrite the existing files it is very likely to cause your program malfunctioning. After you generate the new files you must rebuild the project (since HTTPPrint.h will be different), reprogram the board and at run-time to load the new webpage.
If you don't change status.xml this procedure isn't needed and all you have to do is to load the new *bin file into the PIC-WEB memory.

That's all I can do for you right now.

Stanimir, Olimex
May the Source be with You!

Astra08

Thank you I will try and post the results .

Astra08

I applied the changes , your answer was the exact solution and it worked perfectly. Once again Thank You ever so much for the info and instructions and wonderful support.

BT711

Stanimir,

Thanks for such a great answer and fantastic detail!

I have a question regarding your steps for adding another LED.

I have a new Pickit 3, and a new PIC-WEB rev C
I am using MPLABX newest version. My issue now is I cant get the 5.42 TCPIP demo to load.
It fails here: (file PIC_WEB_5_42\PIC-WEB_5_42\TCPIP\Demo App\TCPIPConfig.h)

#elif defined(OLIMEX)
   #ifdef OLIMEX_PIC_WEB
    #include "Configs/TCPIP OLIMEX_PIC-WEB.h"
   #endif
#else
   #error Missing project macro definition to select proper TCPIPConfig.h
#endif
#endif
------------------------------

Exact line MPLABX highlights:
#error Missing project macro definition to select proper TCPIPConfig.h

I can load ver 5.00 however the file mentioned above (HWP OLIMEX_PIC-WEB.h) does not exist in that version! :(

Any advice would be greatly appreciated. - Would like to use the latest version of TCPIP stack!

Thanks

JohnS

It may be that MPLABX is incompatible.

John

Stanimir5F

#6
Hi BT711!

If I understand you correct you are using the latest version of the Microchip Solutions library (which includes TCP/IP stack) and I suppose you are trying to apply the changes ON THE LATEST examples provided in the stack. I guess you made the changes on the files but did you edit project options. Because this error means the macro OLIMEX isn't defined(OLIMEX_PIC_WEB should also be defined). In the demo project these macros are defined as global for the whole project. Check the screenshot below:
http://i41.tinypic.com/308vfqq.png

But even if that works for you I can't guarantee you that it will work with the latest version. In many cases there is problem with the compatibility between the versions of the stack.
Anyway it's worth trying. :)

Best regards!
Stan, Olimex
May the Source be with You!

imran

I tried the above steps but unable to operate 16 outputs. when I clicked on the 11th-15th led. second led output triggers. I dont know why