Olimex Support Forum

Microcontrollers => PIC => Topic started by: ferzmontes on March 10, 2014, 07:14:58 pm

Title: pic web page not loads well
Post by: ferzmontes on March 10, 2014, 07:14:58 pm
using the pic-web and making moddification in the index.html page so it shows 7 leds with this code:

<span style="float:right;font-size:9px;font-weight:normal;padding-top:8px;text-indent:0px">(click to toggle)</span>
      <p>LEDos:<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>

it allows to see 7 leds that can be toggle, but i have two problems:

1 when i use MPFS promman to compile, the img file when i load it to the pic web it does not shows the 7 leds, but it does in in harddisc with the webpreview programm.

2 And the page showed in the picweb it loads but in a mode just text, not frames or images at all.

Any clues?
Title: Re: pic web page not loads well
Post by: ferzmontes on March 11, 2014, 08:30:54 am
Solved, just have to a compile with MPFS programm and generate the img but it has to be done inside the directory  TCPIP Demo App\WebPages2 and make modiffications inside the index.html and then it works.


Just another doubt:
I got the 7 leds showed in gray but immposible to toggle them, i think because have to connect diverse leds in the out put pin of each one, but this toggle buttons what GPIO turns on in the pic-web?
Title: Re: pic web page not loads well
Post by: Stanimir5F on March 11, 2014, 08:43:54 am
Hi ferzmontes!

I'm glad you solve your problem because when I tried what you said it worked fine.

As for your second question.

In order to make them toggle you must map them inside the file "Configs\HWP OLIMEX_PIC-WEB.h" line 145-163.
Also in all the places LEDs are controlled inside the CustomHTTPApp.c file. A fast search for let's say LED1_IO will show you where it is scanned/modified by the webpage. If somewhere is done only for him, make the same for the rest of the LEDs.
If you have further questions I will try to help.

Stan, Olimex
Title: Re: pic web page not loads well
Post by: ferzmontes on March 15, 2014, 03:09:47 am
Stanimir5F:

I looked at
https://www.olimex.com/forum/index.php?topic=2226.0

and i saw that it is needed to do some changes in the java script. But the questions is:

i change the
HWP OLIMEX_PIC-WEB.h

where is now:
   #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)

For this new code:

   #define LED2_TRIS         (TRISBbits.TRISB4)
   #define LED2_IO            (LATBbits.LATB4)

and the i compile with what?
should i open the project in the mplab and then compile?
or just using the jar file MPFS2?

Thanks for your help
Title: Re: pic web page not loads well
Post by: Stanimir5F on March 17, 2014, 08:16:53 am
"HWP OLIMEX_PIC-WEB.h" file is part of the project. So yes, you must rebuild the project after you make the changes in MPLAB/MPLABX.
"MPFS2.jar" file is a Microchip's tool which converts the webpage directory into a binary/c/asm file that contains the visible webpage.
Title: Re: pic web page not loads well
Post by: ferzmontes on March 17, 2014, 10:01:28 am
Well, has been a long day trying to make it up. Let me say:

working with the Ver 5.42 it just doesnt show like it should, because in compile option the mcc18 shows an erro 1109 with something about the write of uart.h Ok so i dont use the 5.42 any more, also when i use the pre loaded image that comes with the next
https://www.olimex.com/Products/PIC/Development/PIC-WEB/resources/PIC_WEB_MOD_WIFI_5_42.zip

does not shows the page with frames, just text. So just trow the 5.42. Half day with that.

So i went back to the 5.00 ver.
https://www.olimex.com/Products/PIC/Development/PIC-WEB/resources/PIC_WEB_5_00.zip

This one works fine. index.html with frames, the green &bull ok, so i can toggle it. The red leds turns on in the pic-web board.
I do changes in the index.html and erase the --> <--! arrows and then the 7 &bulls are show in the webpage.

next step also in the index.html : to change the bottom of the page with the notepad programm, to get this:
// 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';
   }
So, till here, it is not necessary to compile. So i load the files with "MPFS2.jar" file.
Next one:
In file leds.cgi i put ~led(0)~ ~led(1)~ ~led(2)~

Load again, to make test one by one.

Continue: Changes in CustomHTTPApp.c
row 1594 and from the leds 0 to 7  the only one with the !  mark is the number 1, so i put the mark to al the seven leds. and the same in row 1594.
Complile with c18 no problem, the i load with the jar program, everthing load nice no problem but the leds in http://theboardlanip/index.html they appear but not toggle, just in green. I go to the page form.html and
do some mods, the load the jar, they load good, the page form shows the leds that can be toggle, and then NOTHING changes, leds can not be toggled.

Uff : next move,i thought that the board needed to have the leds connected, so i connected two leds in pin 12 and 15 at the EXT port connected to 3.3 volts with a resistor of 470 ohms, and surprise, LEDS dont toggle  and not even turns on at all.

So, i have problems compiling 5.42 so i go to 5.00, but i cant make the leds works after all the mods.

ANY Clues?
Title: Re: pic web page not loads well
Post by: Stanimir5F on March 17, 2014, 11:03:22 am
Hi again, ferzmontes!

Which compiler exactly do you use?
If you have Microchip C Compiler for PIC18 3.44 you can download the latest version of the demo (it's still TCP/IP 5.42 but it is updated today). But I can't guarantee it will work with older versions of the compiler. As long as I remember the demo you have (old 5.42) was built with compiler 3.40. So the error you get may be caused by the compiler's version.

Anyway if you prefer to use the oldest version (5.00) it's your choice but I'm not very familiar with the this demo project. Still I guess it should be similar to the new one so I have an idea what the problem may be.
First don't change the leds.cgi file.
Before you generate with MPFS2.jar tool backup the files HTTPPrint.h and HTTPPrint.idx (you can also delete them but simple overwrite won't work if they are different) and check whether the new files are the same as the files before. Because if you add more dynamic variables (for example in status.xml file) they won't be the same and in this case you will have to rebuild the project with the new content of the files.

The changes you need to do are:
1) define the macros - LEDx_IO, LEDx_TRIS in "HWP OLIMEX_PIC_WEB.h"
2) add more leds in the status.xml
3) edit index.html so the dots are shown in the box on the top right side of the page
4) edit the javascript in index.html below
5) remove/backup old files HTTPPrint.h, HTTPPrint.idx; generate them and image using MPFS2.jar;
6) rebuild the project; and reprogram the board; upload the new page

If this doesn't help the only thing I can suggest you is to download and check the demo of the board PIC-MAXI-WEB: https://www.olimex.com/Products/PIC/Development/PIC-MAXI-WEB/resources/PIC-MAXI-WEB_5_42.zip
Of course it is a different board but it has multiple LEDs in its hardware (also relays and LCD background which are also controlled like simple LEDs) so you can see how it was done.

If you have further questions I will try to help but the list of ideas gets shorter. :(

Stan, Olimex
Title: Re: pic web page not loads well
Post by: ferzmontes on March 17, 2014, 06:46:40 pm
Ok i will do that, but one question?
in the next parte of hardwareprofile.h
in the part line 1663 there is :

#elif defined(OLIMEX_WEB) && !defined(HI_TECH_C)
// PICDEM.net 2 (PIC18F97J60 + ENC28J60)
   // We have an early revision sillicon for now - do we really need it?
   #define   ETH_18Fx7J60_ERRATA
   
   // 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))

   #define BUTTON0_TRIS      (TRISBbits.TRISB0)
   #define   BUTTON0_IO         (PORTBbits.RB0)
   #define BUTTON1_TRIS      (TRISBbits.TRISB0)
   #define   BUTTON1_IO         1
   #define BUTTON2_TRIS      (TRISBbits.TRISB0)
   #define   BUTTON2_IO         1
   #define BUTTON3_TRIS      (TRISBbits.TRISB0)
   #define   BUTTON3_IO         1

should i make some adds or mods to this part? cause it shows  that for led1 has some info and for the others  dont? for this version the "HWP OLIMEX_PIC_WEB.h" is the same that hardwareprofile.h isnt ?
By the way , im using mcc18 v 3,46.

other one:
For  "and reprogram the board" in your comment, youmean that i hace to use a programmer like pickit3 or something like that to up load a hex file or what?

Doing the compile whit 542 stack, aldo with the mod one, i get this error
(http://i59.tinypic.com/dg6rva.jpg)

i use both mcc18 v 3.46 and also ver 3.10 but same problem.
so icant get the hex file that  i need for continue the experiment.
any advice?
Title: Re: pic web page not loads well
Post by: Stanimir5F on March 18, 2014, 09:09:44 am
1. About "HardwareProfile.h" and "HWP OLIMEX_PIC_WEB.h"
In the new stack version the content of old "HardwareProfile.h" is distributed in many files "HWP <board>.h" so it is easier to modify. Before it was one HUGE file, now we have multiple smaller files (if you do download the original stack you will see inside the config directory around 50 HWP and TCPConfig files for a specific board, but I removed them because we don't need them). And in the new "HardwareProfile.h" itself, there is a big "#if .... #elif .... #elif ........... #endif" preprocessor clause where the specific HWP header is included. So basically the old "HardwareProfile.h" is the same as "HWP OLIMEX_PIC_WEB.h"

2. About modifications inside the HWP file.
Yes, you have to modify it with your hardware. This means you must "add more LEDs" by editing the LEDx_IO and LEDx_TRIS. Because this is how you actually manipulate the LEDs.

3. About "reprogram the board"
Yes, you have to use programmer because in this case the hex will be different and you must upload it to the board.

4. About the error
It seems exactly like a compiler problem. If it's possible try it with 3.44. Otherwise you will have to work with the old stack.
Title: Re: pic web page not loads well
Post by: ferzmontes on March 20, 2014, 08:34:22 am
having some good compiling with the 5.00 version, but i only get text in the index.htm when i load the files with the jar programm;. what could it be? is that the pic resist to act like a server or any clues why it does that?
Title: Re: pic web page not loads well
Post by: Stanimir5F on March 20, 2014, 09:00:15 am
This usually happens when you use firmware with one configuration of dynamic variables and in the external flash memory there is an image for the web page with another configuration of dynamic variables.

When you use the MPFS2.jar tool it generates 3 files. HTTPPrint.h (which is included in the project), HTTPPrint.idx and MPFS2.bin which has to be upload later.

So you have to rebuild and reprogram after you generate the files (but as I already mention before generate new files, rename/delete the old).

And after that when you run the program you must upload the new *.bin file. To do so append the text "/mpfsupload" at the end of the IP address and you will see the uploading page.


PS: If you use the old 5.00 version I think it's better to use MPFS.exe which is inside the old stack in Microchip/TCPIP/Utilities
Title: Re: pic web page not loads well
Post by: ferzmontes on March 24, 2014, 06:46:00 am
I Got  a few good lights.
Following Stanimir5F steps i got finally bow things, to have the olimex page working and two of the leds working in toggle.

I connected two extra leds to the rb5 and rb2 in the EXT connector. I have a now working with the toggle funtion in the web page, but only the rb5 working.

I made mods to the HWP OLIMEX_PIC_WEB in the PIC-WEB_AND_MOD-WIFI version. like:
// LEDs
#define LED0_TRIS         (PRODL)   // Ref D8
#define LED0_IO            (PRODL)
#define LED1_TRIS         (TRISBbits.TRISB4)   // Ref D7
#define LED1_IO            (LATBbits.LATB4)
#define LED2_TRIS         (TRISBbits.TRISB6)// Ref D6
#define LED2_IO            (LATBbits.LATB6)
#define LED3_TRIS         (TRISBbits.TRISB5)   // Ref D5
#define LED3_IO            (LATBbits.LATB5)
#define LED4_TRIS         (TRISBbits.TRISB3)// Ref D4
#define LED4_IO            (LATBbits.LATB3)
#define LED5_TRIS         (TRISBbits.TRISB2)   // Ref D3
#define LED5_IO            (LATBbits.LATB2)
#define LED6_TRIS         (TRISBbits.TRISB1)   // Ref D2
#define LED6_IO            (LATBbits.LATB1)
#define LED7_TRIS         (TRISBbits.TRISB7)   // Ref D1
#define LED7_IO            (LATBbits.LATB7)
#define LED_GET()         (LATB & 0x10)
#define LED_PUT(a)         (LATBbits.LATB4 = !!(a & 0x10))

Now its working the rb5 pin 15 of the EXTconnector, it shows for the TRISB5.

So now i dont know what else to do, so i could toggle the others leds?
Title: Re: pic web page not loads well
Post by: Stanimir5F on March 25, 2014, 12:10:42 pm
Sorry for the delay.
Just a question - did you added the dynamic variables inside status.xml file. If not - do it and then rebuild, reprogram, upload the image.
Otherwise I have no idea and I will need a little bit more details.

Also try to avoid using RB3 if you use the MOD-WIFI demo since it is used as an interrupt pin of the MOD. I don't think this is the problem but in future it may cause you troubles.
Title: Re: pic web page not loads well
Post by: ferzmontes on April 07, 2014, 04:38:29 pm
i got now two leds working well they toggle,  the original red one a another connected to the rb5 pin both turns on and off. Now the challenge it to turn others leds on. So i connected another led to the rb2 and got not good results. when i modified the customhttp and the also leds.cgi and status.xml, like:
void HTTPPrint_led(WORD num)
{
   // Determine which LED
   switch(num)
   {
      case 0:
         num = !LED0_IO;
         break;
      case 1:
         num = !LED1_IO;
         break;
      case 2:
         num = !LED2_IO;
         break;
      case 3:
         num = !LED3_IO;
         break;
      case 4:
         num = !LED4_IO;
         break;
      case 5:
         num = !LED5_IO;
         break;
      case 6:
         num = !LED6_IO;
         break;
      case 7:
         num = !LED7_IO;
         break;

      default:
         num = 0;
   }

   // Print the output
   TCPPut(sktHTTP, (num?'1':'0'));
   return;
}

void HTTPPrint_ledSelected(WORD num, WORD state)
{
   // Determine which LED to check
   switch(num)
   {
      case 0:
         num = !LED0_IO;
         break;
      case 1:
         num = !LED1_IO;
         break;
      case 2:
         num = !LED2_IO;
         break;
      case 3:
         num = !LED3_IO;
         break;
      case 4:
         num = !LED4_IO;
         break;
      case 5:
         num = !LED5_IO;
         break;
      case 6:
         num = !LED6_IO;
         break;
      case 7:
         num = !LED7_IO;
         break;

      default:
         num = 0;

but the rb2 led from ext port doesnt turns on.
Any help?
Title: Re: pic web page not loads well
Post by: Stanimir5F on April 08, 2014, 09:40:04 am
Don't modify the leds.cgi file (leave it as it is in the original demo) and check whether they (LEDs pins) were made to be outputs.
And once again to remind you - make sure when you generate the files (HTTPPrint.h, HTTPPrint.idx and *.bin file) to remove/backup/rename them but not overwrite them and then rebuild, reprogram, reupload.