Consultas sobre Picaxe en ESPAÑOL

inglewoodpete

Senior Member
I think the following code will do what you want.

Creo que el código se va a hacer lo que quieres.

The code assumes that you will use Pin C.0 as the button input. The input needs a pull down resistor to the 0v line. The button is connected between the input and the +5v and a press pulls the input high. I have used interrupts to capture the button press. The routine uses two bit variables to ensure that the button is released before the routine changes to the next flashing sequence.

El código se supone que va a utilizar Pin C.0 como entrada botón. La entrada tiene un desplegable resistencia a la línea de 0v. El botón está conectado entre la entrada y la 5 V y una prensa de tira de la alta de entrada. He utilizado las interrupciones para capturar la pulsación de botón. La rutina utiliza dos variables de bit para asegurar que el botón se libera antes de que los cambios de rutina a la siguiente secuencia de parpadeo.

Paste the following code into the Programming Editor. I do not have a PICAXE 18M2, so have not tested it fully. If you have questions on how the code work, please ask.

Pegue el código siguiente en el Editor de programación. No tengo un PICAXE 18M2, así que no lo he probado todo. Si tiene alguna pregunta sobre cómo el código funcione, por favor pregunte.
Code:
#PICAXE 18M2
#No_Data
'
'   Hardware Pins
Symbol iButton         = C.0        'Leg 17  C.0
'
'   Variables                       'Register b0 must not be used for other purposes
Symbol ButtonPressed         = bit0 'Button was pressed 
Symbol ButtonPressAndRelease = bit1 'Button was pressed and then released
Symbol bFlashProg            = b1   'Flash sequence
'
'   Constants
Symbol DelayBalA     = 80
Symbol DelayBalB     = 175
Symbol DelayBalC     = 80
Symbol DelayBalD     = 80
Symbol False         = 25
Symbol True          = 1
'
Init: SetInt %00000000,%00000001  'Interrupt when Pin C.0 is Low
'
Main: Select Case bFlashProg
      Case 1
         Goto bala
      Case 2
         Goto balb
      Case 3
         Goto balc
      Case 4
         Goto bald
      EndSelect   'Other values: do nothing
      GoTo Main
'
bala: For b10 = 1 To 4         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2
            pause DelayBalA 
            low 0,1,2
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
         '
         For b11 = 1 To 3      'Flash 3,4,5 - 3 times
            high 3,4,5
            pause DelayBalA
            low 3,4,5
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
      Next b10
      Goto Main               'Return to the main loop
'
balb: For b11 = 1 To 9        'Flash 0 Then 5 - 8 times
         high 0
         pause DelayBalB 
         low 0
         pause DelayBalB
         high 5
         pause DelayBalB 
         low 5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
      Next b11
      '
      For b11 = 1 To 9         'Flash 0,1 Then 4,5 - 8 times
         high 0,1
         pause DelayBalB 
         low 0,1
         pause DelayBalB
         high 4,5
         pause DelayBalB 
         low 4,5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
      Next b11
      '
      Goto Main                'Return to the main loop
'
balc: For b10 = 1 To 8         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2,4,5,6
            pause DelayBalC 
            low 0,1,2,4,5,6
            pause DelayBalC
            '
            If ButtonPressAndRelease = True Then
               ButtonPressAndRelease = False
               GoTo Main
            EndIf
         Next b11
         '
      Next b10
      Goto Main                'Return to the main loop
'
bald: For b10 = 1 To 5         'Repeat the whole sequence - 4 times
         For b11 = 1 To 6      'Flash 2,3 - 6 times
            high 2,3
            pause DelayBalD 
            low 2,3
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 0,5 - 6 times
            high 0,5
            pause DelayBalD 
            low 0,5
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            GoTo Main
         EndIf
      Next b10
      Goto Main                 'Return to the main loop
     
Interrupt:  If pinC.0 = 1 Then  'Button is currently pressed
               ButtonPressed = True
               ButtonPressAndRelease = False
               SetInt %00000000,%00000001  'Next interrupt when released
            Else                'Button is now released
               ButtonPressed = False
               ButtonPressAndRelease = True
               bFlashProg = bFlashProg + 1
               If bFlashProg = 5 Then
                  bFlashProg = 0           'Reset to 'off'
               EndIf
               SetInt %00000001,%00000001  'Next interrupt when pressed
            EndIf
            Return
 

afacuarius

New Member
Thanks for your time to develop this program is exactly what I want, use the simulation program worked well and without errors, but when making the connection to the push button does not work, I tried several times, I made several connections sometimes, so doubts, but does not work.

I remain amazed at your program, nothing to do with what I did, I lack a lot to learn, thanks to all these examples is how I'm learning to use the commands.

Thank you and I hope your comments

I attached a picture of the connections push button, use the output pin C.0 17
the picaxe 18m2

regards

Gracias por tu tiempo en elaborar este programa, es exactamente lo que quiero, utilice la simulacion del programa, funciono muy bien y sin errores, pero al realizar la conexion con el push boton, no funciona, lo intente varias veces, hice las conexiones varias veces, por eso de las dudas, pero no funciona.

me quede maravillado con tu programa, nada que ver con el que hice, me falta muchisimo por aprender, gracias a todos estos ejemplos es como estoy aprendiendo a usar los comandos.

Muchas Gracias y espero tus comentarios

te anexo una imagen de las conexiones del push boton, use la salida C.0 pin 17
del picaxe 18m2

saludos
push boton conection.jpg
 

inglewoodpete

Senior Member
You can test your hardware and wiring by writing a simple program to test the function.

Puede probar el hardware y el cableado al escribir un programa sencillo para probar la función.

Example: To test the input switch on PinC.0
Ejemplo: Para probar el interruptor de entrada en PinC.0
Code:
#PICAXE 18M2
#Terminal 4800
Do
   If pinC.0 = 1 Then    'If the button is pressed
      SerTxd("Pressed/Apretado", CR, LF)
      High B.0
      Low B.1
   Else                  'If the button is released
      SerTxd("Released/Liberado", CR, LF)
      High B.1
      Low B.0
   EndIf
Loop
 
Last edited:

afacuarius

New Member
I made the test with good results, to feed my circuit LED lights B.0, pressing the push button switches on and off the LED B.1, this I have done several times without any problem.

I am studying the code you sent me, is very well done, there are many new things for me, but only in so well into'll be learning

I attached a picture of my screen

regards


he realizado la prueba con buenos resultados, al alimentar mi circuito enciende el led B.0, al apretar el push boton se apaga y enciende el led B.1, esto lo he realizado varias veces sin ningun problema.

estoy estudiando el codigo que me enviaste, esta muy bien realizado, hay muchas cosas nuevas para mi, pero solo asi ya entrado en materia estare aprendiendo

te anexo una imagen de mi pantalla

saludos


prueba push boton.jpg
 

afacuarius

New Member
hello inglewoodpete
continued studying the program I did, I have not found the problem, check the push button several times, as well as running the program to verify, but all is well, I will continue testing with your code and you'll be commenting and

regards

hola inglewoodpete

continuo estudiando el programa que me hiciste, aun no encuentro el problema, revise varias veces el push boton, asi como corriendo el programa para verificarlo, pero todo se encuentra bien, seguire haciendo pruebas con tu codigo y ya te estare comentando

saludos
 

inglewoodpete

Senior Member
continuo estudiando el programa que me hiciste, aun no encuentro el problema, revise varias veces el push boton, asi como corriendo el programa para verificarlo, pero todo se encuentra bien, seguire haciendo pruebas con tu codigo y ya te estare comentando
Traducción/Translation #1: continued studying the program I did, I have not found the problem, check the push button several times, as well as running the program to verify, but all is well, I will continue testing with your code and you'll be commenting and

Traducción/Translation #2: He continued studying the program that you have made me, yet I don't see the problem, review several times the push button, as well as running the program to verify this, but all is well, I will keep doing tests with your code already and I'll be commenting on

It is not clear to me. Is there a problem with the program? Sometimes the internet translator gets confused. We should use short sentences.

No me queda claro. ¿Hay un problema con el programa? A veces internet traductor se confunde. Debemos utilizar frases cortas.

Peter
 

fernando_g

Senior Member
Oh yes! the beauty of Google translate. Such as: "the fountains of power have failed----las fuentes de poder han fallado"

IngPete: what he meant, properly translated is as follows:

I continue to study the program you made for me, I still have not found the problem, I have checked several times the push button, as well as running the program to verify it, but everything appears to be correct, I'll keep doing tests with your code, and I will be making (future) comments.
 

afacuarius

New Member
Traducción/Translation #1: continued studying the program I did, I have not found the problem, check the push button several times, as well as running the program to verify, but all is well, I will continue testing with your code and you'll be commenting and

Traducción/Translation #2: He continued studying the program that you have made me, yet I don't see the problem, review several times the push button, as well as running the program to verify this, but all is well, I will keep doing tests with your code already and I'll be commenting on


It is not clear to me. Is there a problem with the program? Sometimes the internet translator gets confused. We should use short sentences.

No me queda claro. ¿Hay un problema con el programa? A veces internet traductor se confunde. Debemos utilizar frases cortas.

Peter

Hello Peter

No program works by passing the picaxe 18m2

No funciona el programa al pasarlo al picaxe 18m2

Regards
 

afacuarius

New Member
Oh yes! the beauty of Google translate. Such as: "the fountains of power have failed----las fuentes de poder han fallado"

IngPete: what he meant, properly translated is as follows:

I continue to study the program you made for me, I still have not found the problem, I have checked several times the push button, as well as running the program to verify it, but everything appears to be correct, I'll keep doing tests with your code, and I will be making (future) comments.

Thanks fernando, that's exactly what I try to tell Peter, my English is very basic, I helped with the translator of google.

regards

Gracias fernando, eso es exactamente lo que trate de decirle a Peter, mi ingles es muy basico, me ayudo con el traductor de google.

Saludos
 

inglewoodpete

Senior Member
This is the same code. I have added some debugging commands to help find the problem.

Este es el mismo código. He añadido algunos comandos de depuración para ayudar a encontrar el problema.
Code:
#PICAXE 18M2
#Terminal 4800
#No_Data
'
'   Hardware Pins
Symbol iButton	      = pinC.0        'Leg 17  C.0
'
'   Variables                       'Register b0 must not be used for other purposes
Symbol ButtonPressed         = bit0 'Button was pressed 
Symbol ButtonPressAndRelease = bit1 'Button was pressed and then released
Symbol bFlashProg            = b1   'Flash sequence
'
'   Constants
Symbol DelayBalA     = 80
Symbol DelayBalB     = 175
Symbol DelayBalC     = 80
Symbol DelayBalD     = 80
Symbol False         = 25
Symbol True          = 1
'
Init: Pause 600
      SerTxd("Boot up", CR, LF)
		SetInt %00000000,%00000001  'Interrupt when Pin C.0 is Low
'
Main: Select Case bFlashProg
      Case 1
         Goto bala
      Case 2
         Goto balb
      Case 3
         Goto balc
      Case 4
         Goto bald
      EndSelect   'Other values: do nothing
      GoTo Main
'
bala: For b10 = 1 To 4         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2
            pause DelayBalA 
            low 0,1,2
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bala 1", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 3      'Flash 3,4,5 - 3 times
            high 3,4,5
            pause DelayBalA
            low 3,4,5
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bala 2", CR, LF)
            GoTo Main
         EndIf
      Next b10
      Goto Main               'Return to the main loop
'
balb: For b11 = 1 To 9        'Flash 0 Then 5 - 8 times
         high 0
         pause DelayBalB 
         low 0
         pause DelayBalB
         high 5
         pause DelayBalB 
         low 5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit balb 1", CR, LF)
            GoTo Main
         EndIf
      Next b11
      '
      For b11 = 1 To 9         'Flash 0,1 Then 4,5 - 8 times
         high 0,1
         pause DelayBalB 
         low 0,1
         pause DelayBalB
         high 4,5
         pause DelayBalB 
         low 4,5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit balb 2", CR, LF)
            GoTo Main
         EndIf
      Next b11
      '
      Goto Main                'Return to the main loop
'
balc: For b10 = 1 To 8         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2,4,5,6
            pause DelayBalC 
            low 0,1,2,4,5,6
            pause DelayBalC
            '
            If ButtonPressAndRelease = True Then
               ButtonPressAndRelease = False
            	SerTxd("Exit balc", CR, LF)
               GoTo Main
            EndIf
         Next b11
         '
      Next b10
      Goto Main                'Return to the main loop
'
bald: For b10 = 1 To 5         'Repeat the whole sequence - 4 times
         For b11 = 1 To 6      'Flash 2,3 - 6 times
            high 2,3
            pause DelayBalD 
            low 2,3
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 1", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 2", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 0,5 - 6 times
            high 0,5
            pause DelayBalD 
            low 0,5
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 3", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 4", CR, LF)
            GoTo Main
         EndIf
      Next b10
      Goto Main                 'Return to the main loop
     
Interrupt:  If iButton = 1 Then 'Button is currently pressed
               ButtonPressed = True
               ButtonPressAndRelease = False
            	SerTxd("Pressed", CR, LF)
               SetInt %00000000,%00000001  'Next interrupt when released
            Else                'Button is now released
                ButtonPressed = False
               ButtonPressAndRelease = True
               bFlashProg = bFlashProg + 1
               If bFlashProg = 5 Then
                  bFlashProg = 0           'Reset to 'off'
               EndIf
            	SerTxd("Released, Prog=", #bFlashProg, CR, LF)
               SetInt %00000001,%00000001  'Next interrupt when pressed
            EndIf
            Return
 

afacuarius

New Member
pantalla depuracion.jpgHello Sensei Peter :)

I Loaded debugging program, when I run the program, get a window on my monitor that says "pressed", comes running very fast, pressing the push button, it stays frozen, it does something else more. I keep pressing and running again very quickly.

I hope this is helpful

regards






Hola Sensei Peter :)

He Cargado el programa de depuracion, cuando corro el programa, sale una ventana en mi monitor que dice "pressed", aparece corriendo muy rapido, al presionar el push boton, se queda congelado, no hace alguna otra cosa mas. dejo de presionar y vuelve a correr muy rapido.

espero que esto te sea de ayuda

saludos
 

inglewoodpete

Senior Member
In this version I have changed the "SetInt" command...

En esta versión he cambiado el comando "SETINT" ...

Code:
#PICAXE 18M2
#Terminal 4800
#No_Data
'
'   Hardware Pins
Symbol iButton	      = pinC.0        'Leg 17  C.0  Normally held low, pulled high when button is pressed
'
'   Variables                       'Register b0 must not be used for other purposes
Symbol ButtonPressed         = bit0 'Button was pressed 
Symbol ButtonPressAndRelease = bit1 'Button was pressed and then released
Symbol bFlashProg            = b1   'Flash sequence
'
'   Constants
Symbol DelayBalA     = 80
Symbol DelayBalB     = 175
Symbol DelayBalC     = 80
Symbol DelayBalD     = 80
Symbol False         = 25
Symbol True          = 1
'
Init: Pause 600
      SerTxd("Boot up", CR, LF)
      'Set interrupt to wait until button is pressed
      SetInt %00000001,%00000001  'Initially, interrupt when Pin C.0 is High
'
Main: Select Case bFlashProg
      Case 1
         Goto bala
      Case 2
         Goto balb
      Case 3
         Goto balc
      Case 4
         Goto bald
      EndSelect   'Other values: do nothing
      GoTo Main
'
bala: For b10 = 1 To 4         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2
            pause DelayBalA 
            low 0,1,2
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bala 1", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 3      'Flash 3,4,5 - 3 times
            high 3,4,5
            pause DelayBalA
            low 3,4,5
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bala 2", CR, LF)
            GoTo Main
         EndIf
      Next b10
      Goto Main               'Return to the main loop
'
balb: For b11 = 1 To 9        'Flash 0 Then 5 - 8 times
         high 0
         pause DelayBalB 
         low 0
         pause DelayBalB
         high 5
         pause DelayBalB 
         low 5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit balb 1", CR, LF)
            GoTo Main
         EndIf
      Next b11
      '
      For b11 = 1 To 9         'Flash 0,1 Then 4,5 - 8 times
         high 0,1
         pause DelayBalB 
         low 0,1
         pause DelayBalB
         high 4,5
         pause DelayBalB 
         low 4,5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit balb 2", CR, LF)
            GoTo Main
         EndIf
      Next b11
      '
      Goto Main                'Return to the main loop
'
balc: For b10 = 1 To 8         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2,4,5,6
            pause DelayBalC 
            low 0,1,2,4,5,6
            pause DelayBalC
            '
            If ButtonPressAndRelease = True Then
               ButtonPressAndRelease = False
            	SerTxd("Exit balc", CR, LF)
               GoTo Main
            EndIf
         Next b11
         '
      Next b10
      Goto Main                'Return to the main loop
'
bald: For b10 = 1 To 5         'Repeat the whole sequence - 4 times
         For b11 = 1 To 6      'Flash 2,3 - 6 times
            high 2,3
            pause DelayBalD 
            low 2,3
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 1", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 2", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 0,5 - 6 times
            high 0,5
            pause DelayBalD 
            low 0,5
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 3", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 4", CR, LF)
            GoTo Main
         EndIf
      Next b10
      Goto Main                 'Return to the main loop
     
Interrupt:  If iButton = 1 Then 'Button is currently pressed
               ButtonPressed = True
               ButtonPressAndRelease = False
            	SerTxd("Pressed/Apretado", CR, LF)
               SetInt %00000000,%00000001  'Next interrupt when released (input will be low)
            Else                'Button is now released (input is low or 0)
                ButtonPressed = False
               ButtonPressAndRelease = True
               bFlashProg = bFlashProg + 1
               If bFlashProg = 5 Then
                  bFlashProg = 0           'Reset to 'off'
               EndIf
            	SerTxd("Released/Liberado, Prog=", #bFlashProg, CR, LF)
               SetInt %00000001,%00000001  'Next interrupt when pressed (input will be high)
            EndIf
            Return
 

afacuarius

New Member
Hello Sensei Peter, Good Day

Load the program setint, continue to experience difficulty, I captured the image of monitor.sin press, upon turning on the tablet appears on the serial terminal text boot up, pressing the push button, start running and appear in the screen text that says Presset/apretado, press down again and stops. not even any LED lights

I'm still learning a lot of basic

Greetings and I hope your comments




Hola Sensei Peter, Buen Dia

Cargue el programa setint, continua con problemas, te capturo la imagen del monitor.sin presionar, al momento de encender la tablilla, aparece en la terminal serial el texto de boot up, al presionar el push boton, empieza a correr y aparecer en la pantalla el texto que dice Presset/Apretado, vuelvo a presionar y se detiene. aun no enciende ningun led

Sigo aprendiendo bastante de basic

Saludos y Espero tus comentarios


version setint.jpg
 

sedeap

Senior Member
Solucion probada

Hola afacuarius:

Te cuento lo que yo hice hace un tiempo para una situación similar, donde necesitaba cambiar de secuencias al presionar un botón...
básicamente lo que hice fue poner el selector de secuencias al inicio del programa, entonces con una variable autoincremental, al iniciar el picaxe lee cual fué la ultima secuencia corrida , le suma uno, y ejecuta la siguiente...
O sea... cada vez que encendia el picaxe, arrancaba en la secuencia siguiente.
Puse un boton NC que al pulsar interrumpe, y asi cortaba la alimentacion del chip, o sea, lo reseteaba y reiniciaba nuevamente al soltarlo, cargando la siguiente secuencia.
Si bien no es muy delicada y elaborada la solucion... pero funciona.
Al interrumpir el suministro, no hace falta esperar a que termine la secuencia, ni hace falta chequear constantemente el boton, lo que ahorra mucho de programacion y espacio.

Espero te sirva el comentario.

Salu2
:cool:
 

inglewoodpete

Senior Member
It works! ¡Funciona!

Hola afacuarius,

I have an old PICAXE 18X, so I thought I'd try it on that chip. The code can run on an 18X or an 18M2! I found some problems, which I have fixed.

Tengo un viejo picaxe 18x, así que he pensado que podía probar en que chip. el código puede ejecutarse en una 18x o 18m2! He encontrado algunos problemas que he solucionado.

Pruebe este código, que trabaja para mí. (Try this code, it works for me:))

Code:
#PICAXE 18M2
#Terminal 4800
#No_Data
'
'   Hardware Pins
Symbol iButton       = pinC.0       'Leg 17  C.0  Normally held low, pulled high when button is pressed
'
'   Variables                       'Register b0 must not be used for other purposes
Symbol ButtonPressed         = bit0 'Button was pressed 
Symbol ButtonPressAndRelease = bit1 'Button was pressed and then released
Symbol bFlashProg            = b1   'Flash sequence
'
'   Constants
Symbol DelayBalA     = 80
Symbol DelayBalB     = 175
Symbol DelayBalC     = 80
Symbol DelayBalD     = 80
Symbol False         = 0            'Now Corrected!
Symbol True          = 1
'
Init: Pause 600
      'Set interrupt to wait until button is pressed
      SerTxd("Boot up button state is: ", #iButton, CR, LF)
      SetInt %00000001,%00000001    'Initially, interrupt when Pin C.0 is High
'
Main: Select Case bFlashProg
      Case 1
         Goto bala
      Case 2
         Goto balb
      Case 3
         Goto balc
      Case 4
         Goto bald
      EndSelect   'Other values: do nothing
      GoTo Main
'
bala: For b10 = 1 To 4         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2
            pause DelayBalA 
            low 0,1,2
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bala 1", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 3      'Flash 3,4,5 - 3 times
            high 3,4,5
            pause DelayBalA
            low 3,4,5
            pause DelayBalA
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bala 2", CR, LF)
            GoTo Main
         EndIf
      Next b10
      Goto Main               'Return to the main loop
'
balb: For b11 = 1 To 9        'Flash 0 Then 5 - 8 times
         high 0
         pause DelayBalB 
         low 0
         pause DelayBalB
         high 5
         pause DelayBalB 
         low 5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit balb 1", CR, LF)
            GoTo Main
         EndIf
      Next b11
      '
      For b11 = 1 To 9         'Flash 0,1 Then 4,5 - 8 times
         high 0,1
         pause DelayBalB 
         low 0,1
         pause DelayBalB
         high 4,5
         pause DelayBalB 
         low 4,5
         pause DelayBalB
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit balb 2", CR, LF)
            GoTo Main
         EndIf
      Next b11
      '
      Goto Main                'Return to the main loop
'
balc: For b10 = 1 To 8         'Repeat the whole sequence - 4 times
         For b11 = 1 To 3      'Flash 0,1,2 - 3 times
            high 0,1,2,4,5,6
            pause DelayBalC 
            low 0,1,2,4,5,6
            pause DelayBalC
            '
            If ButtonPressAndRelease = True Then
               ButtonPressAndRelease = False
               SerTxd("Exit balc", CR, LF)
               GoTo Main
            EndIf
         Next b11
         '
      Next b10
      Goto Main                'Return to the main loop
'
bald: For b10 = 1 To 5         'Repeat the whole sequence - 4 times
         For b11 = 1 To 6      'Flash 2,3 - 6 times
            high 2,3
            pause DelayBalD 
            low 2,3
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 1", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 2", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 0,5 - 6 times
            high 0,5
            pause DelayBalD 
            low 0,5
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 3", CR, LF)
            GoTo Main
         EndIf
         '
         For b11 = 1 To 6      'Flash 1,4 - 6 times
            high 1,4
            pause DelayBalD 
            low 1,4
            pause DelayBalD
         Next b11
         '
         If ButtonPressAndRelease = True Then
            ButtonPressAndRelease = False
            SerTxd("Exit bald 4", CR, LF)
            GoTo Main
         EndIf
      Next b10
      Goto Main                 'Return to the main loop
     
Interrupt:  If iButton = 1 And ButtonPressed = False Then 'Button is currently pressed
               ButtonPressed = True
               ButtonPressAndRelease = False
               SerTxd("Pressed/Apretado", CR, LF)
               SetInt %00000000,%00000001  'Next interrupt when released (input will be low)
            ElseIf ButtonPressed = True Then   'Button has now been released (input is low or 0)
               ButtonPressed = False
               ButtonPressAndRelease = True
               bFlashProg = bFlashProg + 1
               If bFlashProg = 5 Then
                  bFlashProg = 0           'Reset to 'off'
               EndIf
               SerTxd("Released/Liberado, Prog=", #bFlashProg, CR, LF)
               SetInt %00000001,%00000001  'Next interrupt when pressed (input will be high)
            Else
               SetInt %00000001,%00000001  'Next interrupt when pressed (input will be high)
            EndIf
            Return
 

sedeap

Senior Member
Wow...
Thats cool... this belongs to finished projects as soon we have some pics...
Good job Pete !!!

:)
 

afacuarius

New Member
Eureka !!!!!!

Hello Sensei Peter

It worked!!
I just loaded and this great, Many Thanks for the help,
addition to devote part of your time on this project, and I owe you one

I'll be checking to continue learning the syntax of the commands picaxe

in another moment I'll upload the video of this project.

Thank you!


Ya funciono !!!!!!
lo acabo de cargar y esta genial, Muchas Gracias por la ayuda,
ademas de dedicarme parte de tu tiempo en este proyecto, ya te debo una

Estare revisando la sintaxis para seguir aprendiendo de los comandos del picaxe

en un momento mas subire el video de este proyecto.

Gracias !!! ;) ;) ;) ;)
 

afacuarius

New Member
Hola afacuarius:

Te cuento lo que yo hice hace un tiempo para una situación similar, donde necesitaba cambiar de secuencias al presionar un botón...
básicamente lo que hice fue poner el selector de secuencias al inicio del programa, entonces con una variable autoincremental, al iniciar el picaxe lee cual fué la ultima secuencia corrida , le suma uno, y ejecuta la siguiente...
O sea... cada vez que encendia el picaxe, arrancaba en la secuencia siguiente.
Puse un boton NC que al pulsar interrumpe, y asi cortaba la alimentacion del chip, o sea, lo reseteaba y reiniciaba nuevamente al soltarlo, cargando la siguiente secuencia.
Si bien no es muy delicada y elaborada la solucion... pero funciona.
Al interrumpir el suministro, no hace falta esperar a que termine la secuencia, ni hace falta chequear constantemente el boton, lo que ahorra mucho de programacion y espacio.

Espero te sirva el comentario.

Salu2
:cool:

Hola Sedeap

El proyecto ya funciono con la completa ayuda de Peter, pondre en un momento mas el video, esta funcionando como era la idea.

Te agradesco tus comenatarios, si no es mucha molestia, podrias indicarme los comandos que dices ? ya que se muy poco de basic, con estos ejemplos es como estoy aprendiendo su uso y su aplicacion, ya que apenas estoy viendo el potencial del picaxe usandolo en proyectos pequeños.

Muchas Gracias y espero tus comentarios

Saludos


(the English translation yet using google)

Hello Sedeap

The project worked with the full support of Peter, I will put in another moment the video, it's working as was the idea.

I thanks your comenatarios, if not too much trouble, could you tell me the commands you say? and that very little basic, with these examples is how I'm learning its use and application, and I'm just seeing the potential of using it in small projects picaxe.

Thank you and I hope your comments

regards
 

afacuarius

New Member
Hola Sensei Peter

Esta es la finalizacion del Proyecto, Usando tu codigo, Muchas Gracias

[video=youtube_share;t3yxNxmexfs]http://youtu.be/t3yxNxmexfs[/video]

traigo en mente otro proyecto, me ayudas ??

bear in mind another project, help me?
 

inglewoodpete

Senior Member
As you can see, code does not always work first time for experts, either. I was able to quickly fix the problems when I tested the program on a PICAXE 18X, similar to the 18M2.

Como puede ver, el código no siempre funciona primera vez para los expertos, ya sea. Tuve la oportunidad de solucionar rápidamente los problemas cuando he probado el programa en un PICAXE 18X, similar a la 18M2.

I am sure your will be able to get help on the PICAXE forum. We have several fluent Spanish writers/speakers. I remember sedeap, fernando_g and marmitas have helped me at times. As you learn more of how to use the PICAXE, you will be able to help others too!

Estoy seguro de que su voluntad será capaz de obtener ayuda en el foro PICAXE. Tenemos varios escritores / dominan el español. Recuerdo sedeap, fernando_g marmitas y me han ayudado a veces. A medida que aprenda más sobre cómo usar el PICAXE, usted será capaz de ayudar a los demás también!
 

sedeap

Senior Member
Codigo usado

Hola Sedeap

El proyecto ya funciono con la completa ayuda de Peter, pondre en un momento mas el video, esta funcionando como era la idea.

Te agradesco tus comenatarios, si no es mucha molestia, podrias indicarme los comandos que dices ? ya que se muy poco de basic, con estos ejemplos es como estoy aprendiendo su uso y su aplicacion, ya que apenas estoy viendo el potencial del picaxe usandolo en proyectos pequeños.

Muchas Gracias y espero tus comentarios
Mira, aqui no tengo a mano el código usado en esa oportunidad, pero recuerdo la lógica de eso.
Iniciaba con un loop usando "if" (manual ingles, ó el manual español algo obsoleto)
cargaba una variable y la autoincrementaba ... b1=b1+1
controlaba que no fuera superior a la cantidad de secuencias que eran 4 segun recuerdo
if b1 > 4 then b1=0 else...
y corria el programa de secuencias en base al valor de la variable b1...
cargando cada secuencia por su numero con el comando CASE --> referencia manual

Así cada vez que daba alimentacion al picaxe, cargaba la variable y corria la siguiente secuencia programada...

Si encuentro algo de aquel codigo, lo posteo como referencia...

Salu2
:cool:
 

afacuarius

New Member
As you can see, code does not always work first time for experts, either. I was able to quickly fix the problems when I tested the program on a PICAXE 18X, similar to the 18M2.

Como puede ver, el código no siempre funciona primera vez para los expertos, ya sea. Tuve la oportunidad de solucionar rápidamente los problemas cuando he probado el programa en un PICAXE 18X, similar a la 18M2.

I am sure your will be able to get help on the PICAXE forum. We have several fluent Spanish writers/speakers. I remember sedeap, fernando_g and marmitas have helped me at times. As you learn more of how to use the PICAXE, you will be able to help others too!

Estoy seguro de que su voluntad será capaz de obtener ayuda en el foro PICAXE. Tenemos varios escritores / dominan el español. Recuerdo sedeap, fernando_g marmitas y me han ayudado a veces. A medida que aprenda más sobre cómo usar el PICAXE, usted será capaz de ayudar a los demás también!

Hola sensei Peter

Tu Programa a funcionado muy bien, me he detenido un poco en el proyecto ya que estoy estudiando los comandos que escribiste, la mayoria son nuevos para mi, estoy jugando con ellos con otras rutinas, estoy aprendiendo bastante.

Tal vez en la proxima semana inicie el proyecto que traigo en mente, puede ser un poco ambicioso pero ya se los comentare por que aun no lo inicio.

Saludos


Hi sensei Peter

Your Program to run fine, I stopped a bit on the project and I'm studying the commands you wrote, most are new to me, I'm playing with them with other routines, I'm learning a lot.

Maybe next week I bring start the project in mind, it may be a bit ambitious but I will comment that it's not even start.

regards
 

afacuarius

New Member
Mira, aqui no tengo a mano el código usado en esa oportunidad, pero recuerdo la lógica de eso.
Iniciaba con un loop usando "if" (manual ingles, ó el manual español algo obsoleto)
cargaba una variable y la autoincrementaba ... b1=b1+1
controlaba que no fuera superior a la cantidad de secuencias que eran 4 segun recuerdo
if b1 > 4 then b1=0 else...
y corria el programa de secuencias en base al valor de la variable b1...
cargando cada secuencia por su numero con el comando CASE --> referencia manual

Así cada vez que daba alimentacion al picaxe, cargaba la variable y corria la siguiente secuencia programada...

Si encuentro algo de aquel codigo, lo posteo como referencia...

Salu2
:cool:
Gracias por la informacion, apenas estoy conociendo el basic, desconosco aun los comandos y variables, lo que he aprendido a sido gracias a los tutoriales y los post que estan puestos aqui y en algunas paginas de internet, solo que en algunos casos son muy basicos, por eso me decidi meterme aqui a este foro, el nivel esta mas alto tanto de conocimientos asi como de aplicaciones. solo habia encontrado cosas muy basicas, pero aqui ya fue muy diferente, el picaxe tiene mucho potencial para muchas cosas, solo aprender a usarlos.

espero puedas encontrar tu codigo, para aprender mas, sobre todo eso de que al prenderlo y reiniciarlo avanza una secuencas, le encuentro muchas aplicaciones,

me detuve en este proyecto ya que estoy aprendiendo bastante del codigo que elaboro peter, espero la proxima semana iniciar con otro que traigo en mente.

saludos


Thanks for the info, I'm just knowing the basic, even desconosco commands and variables, what I've learned has been through the tutorials and posts that are made ​​here and some internet pages, only in some cases are very basic , so I decided to get me here to this forum, this higher level of knowledge as well as application. had only found very basic things, but here already very different, the picaxe has great potential for many things, just learn to use them.

I hope you can find your code, to learn more, especially that you turn it on and restart the advanced one secuencas, I find many applications,

I stopped by this project and I'm learning a lot of the code that I create peter, I hope next week start with another bear in mind.

regards
 

sedeap

Senior Member
Gracias por la informacion,
...
, el picaxe tiene mucho potencial para muchas cosas, solo aprender a usarlos.

espero puedas encontrar tu codigo, para aprender mas, sobre todo eso de que al prenderlo y reiniciarlo avanza una secuencas, le encuentro muchas aplicaciones,
Hola:

Mira, el programa final que use para descargar no lo encuentro, pero aqui tengo en papel, anotada la base sobre la que depuré luego el código final.
Para aprender debe servirte la idea, que es la de guardar una data y luego recuperarla para ejecutar la parte de código que quieres.
En cada etiqueta (sec1-4) deberías colocar la secuencia de los destellos de los LED que quieres ejecutar.
Cada vez que se enciende el picaxe, recupera el ultimo valor de b9 y lo incrementa, lo lee a b0 para luego usarlo de indice.
Siendo que en b9 está guardado un valor DATA que no se pierde al desconectar el chip, NO es lo mismo que una variable temporal de RAM
Como el valor 0 no se usa, si por error queda en b0 este valor, sec0 se ocupa de volver a empezar o a terminar el ciclo con END si tambien falla.

------------------------
inicial:
read b9,b0

main:

inc b0
if b0 > 4 then recicla
write b9,b0

branch b0,(sec0,sec1, sec2, sec3, sec4)
goto main

recicla:
let b0 = 0
write b9,b0
goto main

sec1:
---> (aqui va la secuencia de destellos LED)
goto sec1

sec2:

---> (aqui va la secuencia de destellos LED)
goto sec2

sec3:

---> (aqui va la secuencia de destellos LED)
goto sec3

sec4:
---> (aqui va la secuencia de destellos LED)
goto sec4

sec0:
goto inicial
end




*****************
(to admins and moderators, please do not convert this to a "code" tag, since isnt a operational code "as is")
Thanks
 

afacuarius

New Member
hola sensei peter,

anexo al foro unas imagenes del proyecto en el cual, me ayudaste a generar el codigo, posteriormente pondre el diagrama, una vez que termine de instalarlo en el barco, hare un video para ponerlo aqui o en la zona de audio/visual

saludos y gracias


hi peter sensei,

Annex to the forum some pictures of the project in which you helped me generate the code, then I will put the diagram, once you finish installing it on the boat, I will make a video to put it here or in the audio / visual

greetings and thanks

1.jpg2.jpg
 

afacuarius

New Member
una mas

lo unico que faltaria, es reducir mas la placa, pero ya sera posteriormente


the only thing that would fail, but the plate is reduced, but it will be later

3.jpg
 

tcvser

New Member
Hola estoy intentado hacer funcionar un picaxe 18m2+ con un adptador lcd 16x2 via SDA y SCL el cual tiene un pic pcf 8574 nesecito el codigo para que se comunique el picaxe con este adaptador agradecere cualquier ayuda Saludos
 

yv1hx

Member
Hola estoy intentado hacer funcionar un picaxe 18m2+ con un adptador lcd 16x2 via SDA y SCL el cual tiene un pic pcf 8574 nesecito el codigo para que se comunique el picaxe con este adaptador agradecere cualquier ayuda Saludos
Hola tcvser,

Te recomiendo que:

a) Abras un nuevo post con tu duda especifica, asi tendras mas posibilidades de respuesta.
b) El pcf 8574 no es un Pic, es un expansor de puertos de 8 bits. http://www.nxp.com/documents/data_sheet/PCF8574.pdf

Suerte.
 

inglewoodpete

Senior Member
Hola estoy intentado hacer funcionar un picaxe 18m2+ con un adptador lcd 16x2 via SDA y SCL el cual tiene un pic pcf 8574 nesecito el codigo para que se comunique el picaxe con este adaptador agradecere cualquier ayuda Saludos
"Hi I'm trying to run a 18m2 + picaxe with adapter the LCD 16x2 via SDA and SCL which has a pic pcf 8574. I need code for the picaxe communicate with this adapter appreciate any help Greetings"
 

gerysan

New Member
Hola tengo un problema con un 08m2+ hoy lo uso de forma normal con una conexion serial a la pc con el comando serin a 2400 pero necesito empesar a trabajarlo a 9600 como lo cambio.
inicio:
setfreq m4
let pins=%00000000
serin 1,n2400,("A"),b0,b1 ;aca le informo que la cadena de datos que mando desde la pc va en 2400 baudios y comienza con la letra "A" y los datos siguientes los verifico contra un IF para comprobar si son verdaderos ;sino son verdaderos los descarta, mi problema esta en que no logro ponerlo a 9600 y que funcione correctamente
 
Top