I have a doubt

llamaxt

New Member
Hello everyone.
My name is Alfonso And the reason for this post is that I have a question about programming a picaxe 28 board. I need a simple program for an application related to my work and it consists in activating two switches (one pulse of 0.5 seconds) one every 4 minutes and another every 15 minutes for an approximate time of 24 hours. (Both switches have to be started at the same time).
I have previously informed me, and I have only found solutions for visual basic. But I am not able to perform this program for the picaxe 28 board.
I'm not sure that this is the right place for these kinds of questions. If not, I apologize.
It would be of great help to me that someone would help me.
Thank you.
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

You have come to the right place to ask your questions and it seems a PICAXE would be well suited to what you want to do.

The first question would be; how accurate do you need your time periods to be ?

Also; have you got a 28-pin board or are you yet to purchase actual hardware ?
 

inglewoodpete

Senior Member
Welcome to the PICAXE forum.

If I understand your project correctly, it should be possible to do with a PICAXE. Will you be using a PICAXE 28X2 chip on the PICAXE 28 board? When you say "switch" do you mean "relay, like these"?

Peter
 

llamaxt

New Member
Hello Hippy

The accuracy of time that I need, I believe, does not have to be very demanding
To clarify doubts I briefly explain what the experiment consists of:
I need to measure the movement of a below over time, versus changes in temperature.
The system hardware consists of a electronical gauge to measure the movement and a data recorder temometer. I need the picaxe to order the caliber to make a measurement every 15 minutes and pass the result to an excel sheet. The thermometer is also independently programmed every 15 minutes and also downloads the data to an excel sheet.
So far so good. The problem comes because the gauge turns itself off after 5 minutes of inactivity. So I need a second switch every 4.30 minutes (approx) to turn the caliber off and on to reset the auto switch-off function. I have already programmed the first switch for the gauge and it works correctly but I do not know how to do the second one at the same time at the first one.

To respond to Inglewoodpete, when I say switch I mean to close a circuit. For example, the harward of the caliber to record data has a button to perform the measurement

Yes, I already have the PICAXE-28A SYSTEM working correctly

I hope the subject is understood. My English is not from Cambridge.
 

BESQUEUT

Senior Member
Hello Hippy

The accuracy of time that I need, I believe, does not have to be very demanding
To clarify doubts I briefly explain what the experiment consists of:
I need to measure the movement of a below over time, versus changes in temperature.
The system hardware consists of a electronical gauge to measure the movement and a data recorder temometer. I need the picaxe to order the caliber to make a measurement every 15 minutes and pass the result to an excel sheet. The thermometer is also independently programmed every 15 minutes and also downloads the data to an excel sheet.
So far so good. The problem comes because the gauge turns itself off after 5 minutes of inactivity. So I need a second switch every 4.30 minutes (approx) to turn the caliber off and on to reset the auto switch-off function. I have already programmed the first switch for the gauge and it works correctly but I do not know how to do the second one at the same time at the first one.

To respond to Inglewoodpete, when I say switch I mean to close a circuit. For example, the harward of the caliber to record data has a button to perform the measurement

Yes, I already have the PICAXE-28A SYSTEM working correctly

I hope the subject is understood. My English is not from Cambridge.
Maybe something like this :
Code:
[color=Blue]do
      
      for  [/color][color=Purple]b0[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]4 
            [/color][color=Blue]for [/color][color=Purple]b1[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]4 [/color][color=Black]: [/color][color=Blue]pause [/color][color=Navy]56250 [/color][color=Black]: [/color][color=Blue]next [/color][color=Purple]b1 [/color][color=Green]' 3,75 mn
            [/color][color=Blue]pulsout [/color][color=Navy]3[/color][color=Black],[/color][color=Navy]1000 [/color][color=Green]'reset gauge

      [/color][color=Blue]next [/color][color=Purple]b0
      [/color][color=Blue]pulsout [/color][color=Navy]4[/color][color=Black],[/color][color=Navy]1000    [/color][color=Green]' 15 mn interval[/color]
[color=Blue]loop[/color]
 
Last edited:

llamaxt

New Member
For the moment the only program I have is to activate a switch with a loop counter. Something like this:

main:

b1=0
for b1 = 1 to 15 ' 15 loops
pause 60000 ' 1 min
next b1



high 0 ' data
pause 500
low 0

goto main



On the other hand the solution that gives Besqueut (I have to prove it) I think have a problem. It's a smart solution to choose 3.75 minutes (3.75 * 4 = 15). But to reset the gauge does not serve a pulse, you have to press the switch once to turn off the gauge and then press again to turn it on.
In this way the internal counter that auto turns off the it, is set to zero. In the fourth reset, the gauge could not measure, since it would be at that moment resetting (Or at least that's what I think).
 

stan74

Senior Member
This code might do what you want Alfonso. It's in the manual.
Code:
[color=Navy]#picaxe [/color][color=Black]28x2[/color]
[color=Blue]setfreq m8 [/color][color=Green];default clock speed[/color]
[color=Blue]settimer t1s_8[/color][color=Green];timer at default clock speed[/color]
[color=Blue]gosub [/color][color=Black]Interrupt_Enable[/color]
[color=Green];switch 1 is c.0
;switch 2 is c.1[/color]
[color=Black]main:[/color]
[color=Blue]goto [/color][color=Black]main
 [/color]
[color=Blue]interrupt: [/color][color=Green];comes here every second[/color]
[color=Blue]inc [/color][color=Purple]w0[/color]
[color=Blue]inc [/color][color=Purple]w1[/color]
[color=Blue]if [/color][color=Purple]w0[/color][color=DarkCyan]=[/color][color=Navy]240 [/color][color=Blue]then [/color][color=Green];240 seconds=4 minutes
      [/color][color=Purple]w0[/color][color=DarkCyan]=[/color][color=Navy]0
      [/color][color=Blue]high c.0  [/color][color=Green];switch 1 on for
      [/color][color=Blue]pause [/color][color=Navy]500 [/color][color=Green];0.5 seconds
      [/color][color=Blue]low c.0
endif
if [/color][color=Purple]w1[/color][color=DarkCyan]=[/color][color=Navy]900 [/color][color=Blue]then[/color][color=Green];every 15 minutes or 900 seconds
      [/color][color=Purple]w1[/color][color=DarkCyan]=[/color][color=Navy]0
      [/color][color=Blue]high c.1  [/color][color=Green];switch 2 on for
      [/color][color=Blue]pause [/color][color=Navy]500 [/color][color=Green];0.5 seconds
      [/color][color=Blue]low c.0     
endif 
      [/color]
[color=Black]interrupt_Enable:
      [/color][color=Blue]setintflags [/color][color=Navy]%10000000[/color][color=Black], [/color][color=Navy]%10000000
      [/color][color=Purple]timer [/color][color=DarkCyan]= [/color][color=Navy]$FFFF
      [/color][color=Purple]toflag [/color][color=DarkCyan]= [/color][color=Navy]0
      [/color][color=Blue]return[/color]
 
Last edited:

BESQUEUT

Senior Member
But to reset the gauge does not serve a pulse, you have to press the switch once to turn off the gauge and then press again to turn it on.
In this way the internal counter that auto turns off the it, is set to zero. In the fourth reset, the gauge could not measure, since it would be at that moment resetting (Or at least that's what I think).
This was not said...
Here is a very simple state machine :
Code:
[color=Blue]do
      for  [/color][color=Purple]b0[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]15
            
            [/color][color=Blue]select  [/color][color=Purple]b0
            [/color][color=Blue]case [/color][color=Navy]1[/color][color=Black],[/color][color=Navy]5[/color][color=Black],[/color][color=Navy]9[/color][color=Black],[/color][color=Navy]13 [/color][color=Black]: [/color][color=Blue]pulsout [/color][color=Navy]3[/color][color=Black],[/color][color=Navy]1000 [/color][color=Green]'stop gauge
            [/color][color=Blue]case [/color][color=Navy]2[/color][color=Black],[/color][color=Navy]6[/color][color=Black],[/color][color=Navy]10[/color][color=Black],[/color][color=Navy]14 [/color][color=Black]: [/color][color=Blue]pulsout [/color][color=Navy]3[/color][color=Black],[/color][color=Navy]1000 [/color][color=Green]'restart gauge
            [/color][color=Blue]case [/color][color=Navy]15[/color][color=Black]:     [/color][color=Blue]pulsout [/color][color=Navy]2[/color][color=Black],[/color][color=Navy]1000 [/color][color=Green]' make measurement
            [/color][color=Blue]end select
                  
            pause [/color][color=Navy]59999 [/color][color=Green]' to be adjusted for 1 mn main loop
      [/color][color=Blue]next [/color][color=Purple]b0[/color]
[color=Blue]loop[/color]
 

llamaxt

New Member
Hi. The first thing I want to apologize for is taking so long to respond.
I have already tested the last two programs that had advised me and effectively both work perfectly.
I already have the measuring system in operation and I have done measurements in several bellows.
To finish I can only thank the members of this forum who have helped me.
Greetings from Spain and again thank you for everything.

Alfonso Llamazares.
 
Top