Hello, welcome to our forum.

It looks like you have registered but you have not yet posted and messages. Our requirements are that you must post at least two messages, to allow the moderators to review your registration, before you will be allowed access to the full range of forum areas.

Please make a couple of posts, until then you may see a notice that says you are banned from certain forum areas.


Thank you.

Remove Text Formatting
Loading...

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2016
    Posts
    1

    Default I need Help about PBP proyect, by PIC-18F45K20 and GSM module

    Hello everyone,
    I'm new to the forum, and a newbie to programming.
    You see, I need help for a small project I'm trying to do, it is a warning message by sending via GSM.
    The system is designed so that when someone opens a door, the system activates a relay,
    And the GSM module starts ringing, and then have a LED warning call it (LdRed) that are calling and when sag at the other end we turn on another led call it (LdGreen) advising that have off-hook, after about 8 seconds , enough to send a pre-recorded in the GSM module message time, the call was correctly sent back to the initial state, but we will no longer send anything but the door continues to be open, not to repeat the sending of the message, the cycle is not will repeat until the door is not closed and reopened again.
    I've done several routines, and have the simulation in Proteus, but no way to see if someone
    Sorry for my bad english
    Thank you very much
    '* MICROCONTROLADOR PIC 18F45K20 CLOCK 4 MHZ *
    '* *
    '************************************************* ****************************
    ;****************** PIC STANDARD CONFIGURATION BY EA3ABN *******************
    ;************************************************* ****************************
    ' DEFINICIÓN DE FUSES Y OSCILADOR
    '************************************************* ****************************
    define _INTRC_IO & _WDT_OFF & _PWRTE_ON & _MCLR_OFF & _LVP_OFF & _CP_OFF & _OSC_4
    DEFINE OSC 4

    ;********************* VARIABLES AND REGISTERS *******************************
    ;---------- OUTPUTS --------------
    RELCALL VAR portd.0 ; Variable guarda el valor de la salida portD.0
    BEACON VAR portd.1 ; Variable guarda el valor de la salida portD.1
    AMPLI VAR portd.2 ; Variable guarda el valor de la salida portD.2
    TESTLD VAR portd.3 ; Variable para led de test del sistema
    ;---------- DEFINE THE INPUT NAME --------------
    RSTSW var portb.5 ; Variable deteccion de RESET SWITCH
    TAMPER VAR portc.1 ; Variable de detección TAMPER SWITCH
    LDRED VAR portc.2 ; Variable deteccion de LED RED
    LDGREEN VAR portc.3 ; Variable deteccion de LED GREEN
    MAINT VAR portb.1 ; Variable deteccion de MAINTENANCE SWITCH
    ;---------- DEFINE PORT INPUTS ------------------------
    Input PORTb.5 ' Activamos B.5 como entrada de RESET switch.
    Input PORTb.1 ' Activamos B.1 como entrada de MAINTENANCE switch.
    Input PORTc.1 ' Activamos C.1 como entrada de TAMPER switch.
    input PORTc.2 ' Activamos C.2 como entrada de LED RED
    input PORTc.3 ' Activamos C.3 como entrada de LED GREEN
    ;---------- VARIABLES GENERAL USE ------------
    MEMOTamper VAR BIT ; Variable para guardar el estado TAMPER
    MEMORlay var bit ; Variable para guardar el estado RELAY Call
    MEMOLdRED var bit ; Variable para guardar el estado LedRED
    MEMOLdGreen var bit ; Variable para guardar el estado Green
    CondiCuelga var bit ; Variable para guardar el paso por colgar
    ;************************************************* ****************************
    ;------------------------ RESET INICIAL DE LA EEPROM ---------------------------
    EEPROM 0,[0] ;memoria 0 con el valor inicial 0 , sirve para
    ;indicar que nunca ha corrido este programa
    ;************************************************* ****************************
    ; vector de interrupcion
    RCON.7=1 ; Enable interrupt priorities 18f45k20 TESTING PP.
    IPR1.5=1 ; Set high interrupt priority TESTING PP
    ON INTERRUPT GOTO ARRANQUE ; EN CASO DE INTERRUPCION IR A .....
    ;------------- IMPORTANTE, ESTO HABILITA LA INTERRUPCION EN " PORTB.0
    INTCON=010000 ; HABILITA LA INTERRUPCION EN " PORTB.0 "
    ;Trisb=1
    ;Trisc=001010
    ;------------------------------------------------------------------------------

    ARRANQUE:
    high testld ;LED DE AVISO INICIO SISTEMA
    pause 100
    low testld
    pause 100
    high testld ;LED DE AVISO INICIO SISTEMA
    pause 100
    low testld
    pause 100
    high testld ;LED DE AVISO INICIO SISTEMA
    pause 100
    low testld
    pause 100
    PAUSE 100
    MEMOTamper=0 ;Inicializamos variable MEMOTamper
    MEMOLdRED=0 ;Inicializamos variable MEMOLdRED
    ;--------- HASTA QUE MAINT NO ESTE ABIERTO NO HACEMOS NADA ---------------------
    INICIO:
    CondiCuelga=0 ;
    IF MAINT=0 THEN TapaOpen ; Hasta que no está abierto Maint
    goto INICIO ; No seguimos con el resto.....
    ; Ojo esto solo sucede una vez
    ; Cuando estamos en modo normal, todo sigue
    ; su curso y nos vamos a ver si esta abierta
    ; la tapa TAMPER

    ;------- AQUI NOS QUEDAMOS DETECTANDO HASTA QUE SE ABRA LA PUERTA "TAMPER "-----

    TapaOpen:
    pause 100 ; Pausa
    high BEACON ; Activamos BALIZA DE LA CAJA
    pause 100
    LOW BEACON ; Activamos BALIZA DE LA CAJA
    'pause 10
    'if TAMPER=0 and LDRED =0 then ActAudio ; Miramos si esta la zona activada
    if TAMPER=0 then GOTO LLAMA1; Miramos si esta el tamper activado, y si
    ; lo esta, nos vamos a llamar, si no, seguimos
    ;mirando hasta que este abierta.
    goto TapaOpen ; bucle hasta tapa abierta, SI / N0

    ;----------- HASTA AQUI EL CODIGO BIEN ----------------------------------------
    ;------------------------------------------------------------------------------
    ;iniciamos la llamada poniendo el rele activo.
    llama1:
    PAUSE 10
    HIGH RELCALL
    memorlay=1
    IF TAMPER=0 and ldred=1 then llama1
    IF TAMPER=0 AND Ldred=0 THEN mirarverde ; si puerta abierta y led verde activo
    ;significa que estamos en transito de la llamada
    ; pero que ha sido cerrada la puerta
    RETURN
    ;----------------------------------------------------------------------------
    llama2:
    PAUSE 10
    HIGH RELCALL
    gosub contverde
    ;------------------------------------------------------------------------------
    ; Miramos si esta activo el rojo si no lo esta, seguimos mirando
    ; para asi verificar que está en transito la llamada.

    mirarVerde:
    if ldgreen=1 and tamper=0 then mirarVerde
    if ldgreen=0 and tamper=0 then llama2 ; tengo dudas aqui
    ContVerde:
    if ldgreen=1 and tamper=0 then CondiCuelga=1 ; aqui esta el problema
    if tamper=0 and CondiCuelga=1 then gosub cuelga
    cuelga:
    pause 10
    low relcall
    ;if condicuelga=0 and tamper=0 then goto cuelga
    ;if ldgreen=1 and tamper=0 then goto inicio

    end
    ;------------------------------------------------------------------------------

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,112

    Default Re: I need Help about PBP proyect, by PIC-18F45K20 and GSM module

    this is a SUBROUTINE

    llama1:
    PAUSE 10
    HIGH RELCALL
    memorlay=1
    IF TAMPER=0 and ldred=1 then llama1
    IF TAMPER=0 AND Ldred=0 THEN mirarverde ; si puerta abierta y led verde activo
    ;significa que estamos en transito de la llamada
    ; pero que ha sido cerrada la puerta
    RETURN
    You seem to be trying to CALL the SUBROUTINE with a GOTO
    if TAMPER=0 then GOTO LLAMA1; Miramos si esta el tamper activado, y si
    this is never going to be ok

    it needs to be like this
    if TAMPER=0 then GOSUB LLAMA1; Miramos si esta el tamper activado, y si
    I have not checked the rest of your code for other incidences of this error

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,194

    Default Re: I need Help about PBP proyect, by PIC-18F45K20 and GSM module

    If you gosub contverde, you must have a RETURN at the end to come back.

    Same with gosub cuelga.


    gosub contverde
    ;------------------------------------------------------------------------------
    ; Miramos si esta activo el rojo si no lo esta, seguimos mirando
    ; para asi verificar que está en transito la llamada.

    mirarVerde:
    if ldgreen=1 and tamper=0 then mirarVerde
    if ldgreen=0 and tamper=0 then llama2 ; tengo dudas aqui <=== this means GOTO LLAMA2
    ContVerde:
    if ldgreen=1 and tamper=0 then CondiCuelga=1 ; aqui esta el problema
    if tamper=0 and CondiCuelga=1 then gosub cuelga
    RETURN <=== are you sure you don't want a RETURN here?
    cuelga:
    pause 10
    low relcall
    ;if condicuelga=0 and tamper=0 then goto cuelga
    ;if ldgreen=1 and tamper=0 then goto inicio
    RETURN <=== are you sure you don't want a RETURN here?
    end
    Very important, if you GOSUB to a subroutine, do not GOTO out of it.

    You must stay within the subroutine and exit using RETURN.

    There are probably exceptions, but you can quickly get into trouble if you don't keep your logic clean.
    Last edited by Demon; - 8th April 2016 at 03:45.
    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Trying to build a PCB with onboard GSM Module
    By financecatalyst in forum GSM
    Replies: 1
    Last Post: - 13th August 2012, 15:50
  2. Using Gsm module in Data Mode
    By isaac in forum GSM
    Replies: 4
    Last Post: - 13th October 2011, 16:36
  3. sending string to module GSM with character ""
    By volcane in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd May 2010, 02:26
  4. Module GSM Telit GM862
    By volcane in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd November 2007, 10:51
  5. Using gsm module in data mode
    By isaac in forum GSM
    Replies: 0
    Last Post: - 25th September 2007, 15:21

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts