Picaxe project request

Discussion in 'General Electronics Chat' started by happysoul, Jun 8, 2015.

  1. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    Hi all
    could anyone help me with a small picaxe project, i need to have a event input either hi or low that triggers and output flashing LED that flashers until a reset is given.
    thanks
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    What kind of help do you need? Do you need some help with the circuit or do you need help with the programming? Which specific picaxe are we talking about? Can you provide a link? What have you done so far?
     
  3. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    yeah programming , i need the code
     
  4. wayneh

    Expert

    Sep 9, 2010
    12,094
    3,033
    Is there a reason you wan to use the picaxe for this? I think it could be done with a simple circuit.
     
  5. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    yeah i thought i could use 2 * 555 or 556 one as a trigger and the other as the flasher but the picaxe would be smaller and easier
     
  6. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    Just the 8 pin picaxe version
     
  7. wayneh

    Expert

    Sep 9, 2010
    12,094
    3,033
    I think you could use just one 555, enabled or not. But I was just making sure you were aware and it sounds like you are.
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    So I'm confused. Do you need a complete code package or just a piece of it?
     
  9. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    Here is something to play with. You'll need a pull-down resistor on C.1 and C.2 to keep the inputs low when no signal is present.

    Did you build the 100 LED Push Button project?

    Code (Text):
    1. #picaxe 08m2                           ' Define PICAXE 08M2
    2. #no_data                               ' Ignore EEPROM data - loads program faster
    3.  
    4. '========================================================================
    5.  
    6. Initialize:                            ' Initialize Routine - initialize pins and set up variables
    7.     LET dirsC = %00001000              ' Make pin C.3 a output; rest as inputs
    8.     LET pinsC = %00000000              ' Turn off all outputs on port C
    9.     SYMBOL IN = C.1                    ' Define C.1 (pin 6) as IN to indicate input signal
    10.     SYMBOL RST = C.2                   ' Define C.2 (pin 5) as RST to indicate reset switch
    11.     SYMBOL LED = C.3                   ' Define C.3 (pin 4) as LED to indicate LED light
    12.     SYMBOL i = b0                      ' Data byte variable used with reset button command
    13.     LET i = 0                          ' Set i equal to 0
    14.     SYMBOL pulse_high = b1             ' Data byte variable used to set pulse high time
    15.     LET pulse_high = 500               ' Set pulse_num equal to 500 (milliseconds)
    16.     SYMBOL pulse_low = b2              ' Data byte variable used to set pulse low time
    17.     LET pulse_high = 500               ' Set pulse_num equal to 500 (milliseconds)
    18.  
    19. '========================================================================
    20.  
    21. Main:                                  ' Main Routine
    22.     IF IN = 1, THEN DoIt               ' If IN (input pin) is high, then go to DoIt routine
    23. GOTO Main                              ' Go to Main routine
    24.  
    25. '========================================================================
    26.  
    27. DoIt:                                  ' DoIt Routine
    28.     HIGH LED                           ' Turn on LED
    29.     PAUSE pulse_high                   ' Wait for pulse_high time
    30.     BUTTON RST,1,255,0,i,1,CLR         ' If reset button is pressed, go to CLR routine
    31.     LOW LED                            ' Turn off LED
    32.     PAUSE pulse_low                    ' Wait for pulse_low time
    33.     BUTTON RST,1,255,0,i,1,Main        ' If reset button is pressed, go to main routine
    34. GOTO DoIt                              ' Go to DoIt routine
    35.  
    36. '========================================================================
    37.  
    38. CLR:                                   ' CLR Routine
    39.     LOW LED                            ' Turn off LED
    40. GOTO Main                              ' Go to Main routine
    41.  
    42. '========================================================================
    43.  
    44. END                                    ' End program
     
    absf and Roderick Young like this.
  10. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    Hi elec mech thanks for the post, ill give it a try, with regards to the 100 led project we have had a few budget problems so i have everything but the switches, but i still want to build it, ill let you know as soon as i get the bean counters to come up with the money.
    thanks again
     
  11. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    Sorry to be a pain but im getting a syntax error on line 17.
     
  12. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    Sorry, change line 17 to:
    Code (Text):
    1. LET pulse_low = 500               ' Set pulse_low equal to 500 (milliseconds)
     
  13. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    now its 23 :) seems to be some issue with the LED symbol.
     
    Last edited: Jun 10, 2015
  14. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    Sorry, forgot C.3 can only be used as an input on the 08M2. Try this:

    Code (Text):
    1. #picaxe 08m2                           ' Define PICAXE 08M2
    2. #no_data                               ' Ignore EEPROM data - loads program faster
    3.  
    4. '========================================================================
    5.  
    6. Initialize:                            ' Initialize Routine - initialize pins and set up variables
    7.     LET dirsC = %00010000              ' Make pin C.3 a output; rest as inputs
    8.     LET pinsC = %00000000              ' Turn off all outputs on port C
    9.     SYMBOL IN = pinC.1                  ' Define C.1 (pin 6) as IN to indicate input signal
    10.     SYMBOL RST = C.2                   ' Define C.2 (pin 5) as RST to indicate reset switch
    11.     SYMBOL LED = C.4                   ' Define C.3 (pin 4) as LED to indicate LED light
    12.     SYMBOL i = b0                      ' Data byte variable used with reset button command
    13.     LET i = 0                          ' Set i equal to 0
    14.     SYMBOL pulse_high = b1             ' Data byte variable used to set pulse high time
    15.     LET pulse_high = 500               ' Set pulse_num equal to 500 (milliseconds)
    16.     SYMBOL pulse_low = b2              ' Data byte variable used to set pulse low time
    17.     LET pulse_high = 500               ' Set pulse_num equal to 500 (milliseconds)
    18.  
    19. '========================================================================
    20.  
    21. Main:                                  ' Main Routine
    22.     IF IN = 1 THEN DoIt                ' If IN (input pin) is high, then go to DoIt routine
    23. GOTO Main                              ' Go to Main routine
    24.  
    25. '========================================================================
    26.  
    27. DoIt:                                  ' DoIt Routine
    28.     HIGH LED                           ' Turn on LED
    29.     PAUSE pulse_high                   ' Wait for pulse_high time
    30.     BUTTON RST,1,255,0,i,1,CLR         ' If reset button is pressed, go to CLR routine
    31.     LOW LED                            ' Turn off LED
    32.     PAUSE pulse_low                    ' Wait for pulse_low time
    33.     BUTTON RST,1,255,0,i,1,Main        ' If reset button is pressed, go to main routine
    34. GOTO DoIt                              ' Go to DoIt routine
    35.  
    36. '========================================================================
    37.  
    38. CLR:                                   ' CLR Routine
    39.     LOW LED                            ' Turn off LED
    40. GOTO Main                              ' Go to Main routine
    41.  
    42. '========================================================================
    43.  
    44. END                                    ' End program
     
    happysoul likes this.
  15. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    Looks good, thank you for your time.
     
  16. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    could i reset with a 0
     
  17. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    Could you elaborate? I'm not sure what you are asking.
     
  18. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    sorry, at the moment the reset or clear is with a high 1 is it possible to reset with a low 0
     
  19. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    In both BUTTON commands, change the 1 after RST to 0 as shown below. I'm not 100% this is it - I need to see a schematic of your circuit, specifically the reset button (N.O. or N.C.) and whether you are using a pull-up or pull-down resistor on the PICAXE pin. Based on your description thus far, I assume a N.O. (normally open) switch and a pull-up resistor on the PICAXE pin and the other end of the switch connected to ground.

    Code (Text):
    1. BUTTON RST,0,255,0,i,1,Main        ' If reset button is pressed, go to main routine
     
  20. happysoul

    Thread Starter New Member

    Sep 9, 2014
    28
    0
    Thanks that did the trick, its for a warning indicator for a pump in a seller, i only have a three wire cable running up to the house so i needed the reset to be low and that way i could share the negative with the reset and the led.
     
Loading...