Skip to main content

Messages

This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.

Messages - megabug

31
Web platform / Control your remote outlets (433MHz) with the web platform
Hi,

After playing around with my  web platform I thought I can post some code that maybe help somebody. :)

My project with the web platform is to develop new features and implement them in my actual home automation. In my living room I can control some light (12V) with a couple of MosFETs on "old" 18f97j60 ethernet board. Controlling remote outlets currently is done quite dirty. (Bit banging an PT2262 remote IC)

I knew this could be done with only one pin and much cleaner!

You can see my code at the end of this posting.

Calling the function with: send_rf(0b10010011, 0b0100);

To be honest, you need to have at least a little bit understanding how to configure the function call, but I can help you with that. ;) It's quite easy.

RF is defined as an output pin. (of course!)

Works here at my home flawless! My test rig:


To see what exacly is being sent:


The blue capture is from my PIC and the yellow one is from an original remote control! (But different keys were pressed/sent) Just to see the timing ;).

I am using this transmitter module with much power: link but standard modules like this are fine, too. If your transmitter has a RF encoder chip on it, you have to cut the "RFout" wire from it and connect your PIC with the end of the wire that goes to the circuit.

I welcome questions and/or criticism on my code. The 8 bit variable is used so I can directly control it over uart! (on my PIC12F for example)

Oh, and everybody who doesn't know what I am talking about: these thingies are remote outlets

Code: [Select]
#define FOSC  80000000LL
#define FCY      (FOSC/2)  // MCU is running at FCY MIPS
#include "libpic30.h"

void send_rf(char conf1, char conf2)
{
  int i, j;
char conf1a, conf2a;
conf1a = conf1;
conf2a = conf2;
j = 0;
for (j=0; j<5; j++){ // repeat sending 5 times.
                                          //This is needed by the PT2272 receiver (at least 3 times iirc)
conf1 = conf1a; // store data to send
conf2 = conf2a;
for(i=0; i<8; i++){ // parse data from conf1 and send via RF (right to left)
           
            switch (conf1 & 0x01){   // one bit at a time!
                  case (0): {        // send as float
                        RF=1;
                        __delay_us(300);
                        RF=0;
                        __delay_us(900);
                        RF=1;
                        __delay_us(900);
                        RF=0;
                        __delay_us(300);
                  break;
                  }
                 
                  case (1): {        // send as 0
                        RF=1;
                        __delay_us(300);
                        RF=0;
                        __delay_us(900);
                        RF=1;
                        __delay_us(300);
                        RF=0;
                        __delay_us(900);
                  break;
                  }
            }
            conf1>>=1; // shift conf1 right to parse next bit
  }
  for(i=0; i<4; i++){ // parse data from conf2 and send via RF
                      // only the lower 4 bits are needed.

            switch (conf2 & 0x01){   // one bit at a time!
                  case (0): {        // send as float
                        RF=1;
                        __delay_us(300);
                        RF=0;
                        __delay_us(900);
                        RF=1;
                        __delay_us(900);
                        RF=0;
                        __delay_us(300);
                  break;
                  }

                  case (1): {        // send as 0
                        RF=1;
                        __delay_us(300);
                        RF=0;
                        __delay_us(900);
                        RF=1;
                        __delay_us(300);
                        RF=0;
                        __delay_us(900);
                  break;
                  }
            }
            conf2>>=1; // shift conf1 right to parse next bit
  } // done with data, now a sync is needed.
  RF=1;          // sync
  __delay_us(300);
  RF=0;
__delay_us(9690);  // weird time, I know...
  }
}

Have fun with it! Hope it helps.

PS: This is not an april fools. ;)

Best regards.
33
Web platform / Internet bootloader on Web Platform ?!
Hi,

I was wondering if anybody has tried an internet bootloader on the webplatform?! The one I found from microchip is for the 18f97j60 chip. I found some commercial bootloaders, but nothing free.

It would be very nice to automatically load a firmware every reboot if a new file is on a tftp or something.


thanks in advance.

PS: I just ordered my web platform and I am interested in testing it out. I was to lazy to make my own board, have already worked with 18f97j60 with internal ethernet. My own ethernet board currently controls my lights at home.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01292301512session_write_close ( )...(null):0
20.01332433128ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01332433904Database_MySQL->query( ).../DatabaseHandler.php:119
40.05622572664Database_MySQL->error( ).../Db-mysql.class.php:273