November 23, 2024, 05:30:36 AM

Relays on PIC-WEB

Started by 8art-5imson, May 20, 2014, 12:18:34 AM

Previous topic - Next topic

8art-5imson

About a year since I played with this, but have now decided to try once again. I want to be able to control relays using PIC-WEB. In a post last year I was told:
In order to achieve what you want you have to:
1. Define EXT pins
2. Add them to the source code of the web page
3. Recompile the source codes of the web page
4. Resend the new web page image to the PIC-WEB server

The good part is that this has already been done for LED1=0 and LED1=1 so you can use it as a starting point/template.
In HWP OLIMEX_PIC.h I have found these defines;
// LEDs
// I/O pins
#define LED0_TRIS         (PRODL)   /* NC */
#define LED0_IO            (PRODL)   /* NC */
#define LED1_TRIS         (TRISBbits.TRISB4)
#define LED1_IO            (LATBbits.LATB4)
#define LED2_TRIS         (PRODL)
#define LED2_IO            (PRODL)

        !                                  !
        V                                  V

#define LED_GET()         (LED1_IO)
#define LED_PUT(a)         (LED1_IO = (a))


Do I just change each pair of LED defines to (TRISBbits.TRISBx)\ (LATBbits.LATB4)
replacing x with the port number I want to switch? and add a #define LED_GET() / #define LED_PUT(a)for each LED (Relay I want to control.
What does (PRODL) mean? & is the (a) just a varable , do I need to use different letters for each LED?
as you have probably noticed I know very little 'C'
Any help would be appreciated
Many Thanks CHRIS



Stanimir5F

Hi Chris!
Check this thread and see if it is helpful for you:
https://www.olimex.com/forum/index.php?topic=2226.0

As for the PRODL this is more like an "empty value". When there is no such LED/button, but you want to add it in future you can define it this way. It's declared in: "p18f67j60.h" line 2010
extern          near unsigned char       PRODL;

LED_GET is a macro which reads the status of all the LEDs.
LED_PUT is a macro to set the state of all the LEDs.
But in the demo there is just one LED and that's why they are simplified to LED1_IO. If all the LEDs are on the same port you can replace define them like this:
#define LED_GET() (PORTx)
#define LED_PUT(a) (LATx = a)

Otherwise (if they are on different ports) my advice is don't use this macro, but the LEDx_IO macros.
May the Source be with You!