Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 21, 2024, 05:07:24 17:07


Login with username, password and session length


Pages: [1]
Print
Author Topic: rc-switch for PIC microcontroller  (Read 4208 times)
0 Members and 1 Guest are viewing this topic.
iBnav
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 6
-Receive: 3


« on: February 19, 2022, 12:09:39 12:09 »

hello guys
as you know RC-switch is a good library for 355 and 433mhz Frequency. Before I saw it "RC-switch", I wrote simple code for 433mhz...
My code in Proteus was Ok. But in practice, it had many problems.
and my question is, no way to convert RC-switch for PIC microcontroller?


XC8 MPLBX

Code:
/*
 * File:   main.c
 * Author: iBnav
 *
 * Created on February 18, 2022 4:51 PM
 */


// PIC12F1822 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF      // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = OFF       // Internal/External Switchover (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)

// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = OFF        // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

#define _XTAL_FREQ 8000000


void PIN_MANAGER_Initialize(void) {

    LATA = 0x00;
    TRISA = 0b00000011;
    ANSELA = 0x00;
 

}

#define RF_DATA  PORTAbits.RA0
#define K_LEARN  PORTAbits.RA1
#define LED_REC  LATAbits.LATA2


char chekbit() {
    unsigned char i = 0;
    char b = 0;
    while (1) {
        if (i > 150) {
            if (RF_DATA) b = 1;
            break;
        }
        __delay_us(10);
        i++;
    }

    while (RF_DATA);
    return b;
}

void remote_code() {
    unsigned char inbits[24], shift;
    unsigned char i = 0;
    Rsw = Rcode[0] = Rcode[1] = Rcode[2] = 0;

    while (!((RF_DATA) && i >= 8)) {
        if (RF_DATA) i = 0;
        __delay_ms(1);
        i++;
    }

    i = 0;
    while (i < 24) {
        while (!(RF_DATA));
        inbits[i] = chekbit();
        i++;
    }

    shift = 3;
    for (i = 0; i < 4; i++) {
        Rcode[0] |= inbits[i] << shift;
        shift--;
    }
    shift = 7;
    for (i = 4; i < 12; i++) {
        Rcode[1] |= inbits[i] << shift;
        shift--;
    }
    shift = 7;
    for (i = 12; i < 20; i++) {
        Rcode[2] |= inbits[i] << shift;
        shift--;
    }
    shift = 3;
    for (i = 19; i < 24; i++) {
        Rsw |= inbits[i] << shift;
        shift--;
    }
}

Logged
sadman
Hero Member
*****
Offline Offline

Posts: 710

Thank You
-Given: 1839
-Receive: 2907


Sow The Seeds of Love


« Reply #1 on: February 19, 2022, 03:43:05 15:43 »

hi

Quote
no way to convert RC-switch for PIC microcontroller?

lot hobbyist have done this if I remember correctly such a design share here please search, there was a design publish in silicon chip magazine base on 12F508 chip  

sadman
Logged
iBnav
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 6
-Receive: 3


« Reply #2 on: February 19, 2022, 07:13:35 19:13 »

Thanks, Sadman.
I searched silicon magazine before. Silicon magazine is so amazing. but there are two problems with that... some projects in silicon magazine are too old and the second reason silicon code project usually is hex.
Logged
sadman
Hero Member
*****
Offline Offline

Posts: 710

Thank You
-Given: 1839
-Receive: 2907


Sow The Seeds of Love


« Reply #3 on: February 20, 2022, 04:51:37 04:51 »

Thanks, Sadman.
I searched silicon magazine before. Silicon magazine is so amazing. but there are two problems with that... some projects in silicon magazine are too old and the second reason silicon code project usually is hex.

here is some start

https://www.edaboard.com/threads/rf-tx-rx-interface-with-pic-microcontroller.334371/

https://www.edaboard.com/threads/ewn-manchester-encoding-decoding-rf-applications.390796/

https://www.ccsinfo.com/forum/viewtopic.php?t=51572

https://libstock.mikroe.com/projects/view/1609/pic-manchester-code-rf-remote

http://www.winpicprog.co.uk/pic_tutorial12.htm

sadman
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC