Shop OBEX P1 Docs P2 Docs Learn Events
Need help with my Propeller Project — Parallax Forums

Need help with my Propeller Project

http://www.titaniceng.altervista.org/DTMFLatch.zip
First of all here is the program. I noticed that its got massive delays, I know some are in the DTMF.spin, which I can easily adjust, but there seams to be more then that. Here is how it's supposed to run on my PPDB.
1)I/O 0..9 get looked at and place a word sized variable called ButtonState.
2)I/O 10-19 get looked at and placed into 10 Byte sized variables. Set1 to Set10
3)After these variables are done, I used Case to check the button state for this: %00000011_11111110 to %00000001_11111111. 10 diff binary combinations. Looking to see what button is pressed. The following info is sent to "Pri Button" with the following variables: Pin, LOoO, State. Pin being to represent what button has been pressed 0 to 9, LOoO aka Latch On or OFF? (used with Set1 - Set10 Variables. 0:= Momentary System & 1:= On or Off. I used the switches on the PPDB for this), State being the ButtonState Binary variable data. I used 2 PPDB's for the 10 buttons and 10 switches, just connected them togeather with the 5v & Gnd rails.
4) From there, the Word output variable called RelayState, I think, is updated %0000_00xx_xxxx_xxxx the x being each output, sent to 74hc595 shift register. I added waitpeq to wait till all the buttons had been released
4A) Momentary: Output on, plays 1 of 16 random DTMF tones, waits for all button(s) release then relay is turned off again.
4B) On or Off: Same as 4A but uses Case command to check if relay is currently On, if on then turns it out.
5)Repeats from 1

I know I got errors, but not sure where...

Joe

I saw on PRI Button in the Case area I had the buttonstate data in where I think 1 or 0 should been. Haven't tried the program. Already put everything away after being frustrated.... Lol

Comments

  • no one??

    Joe
  • jknightandkarr
    I'm thinking that you received no response is that No One knows what you are attempting
    to ask.
    It looks like you are asking about something using spin language.
    I am absolutely no expert here, but there are many people who chime in
    whenever they see that that they can help.
    The link you attached to the top of your post leads me to a site I'm hesitant to go to.
    ..
    I believe that if you think about how your questions are set up and reword them.
    Any of the forum guys that can contribute, will contribute.
    ..
    That's my 2 cents worth.
    I hope it helps you in some manner.
  • kwinnkwinn Posts: 8,697
    Please post the code you are using and a wiring diagram along with a clear explanation of what you are trying to do. perhaps a couple of examples of what should happen when a button is pressed or a switch closed.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2016-02-24 02:53
    The code is attached in in a ZIP file

    http://www.titaniceng.altervista.org/DTMFLatch.zip
  • kwinnkwinn Posts: 8,697
    edited 2016-02-24 18:08
    @jknightandkarr

    I downloaded your code and took a look at it along with the explanation in your first post, and am still a little unsure of what you are trying to do. It looks like the following to me:

    You have 10 momentary contact pushbuttons and 10 relays. When you press a button you want a random DTFM tone to play, and to turn the corresponding relay on if it is off, and off if it is on. That is button 1 toggles relay 1, button 2 relay 2, etc.

    Is this correct?

    PS- I am also guessing that you are using the 10 switches to emulate the relay contact being open or closed. Is that so?
  • Seems like you could simplify the program using longs as bit arrays. This idea includes a debounce routine for the buttons that also extracts new presses (0->1) between calls; the new press value is used when relay latching/unlatching is selected.
    pub main | modebits, btn, mask                                                      
                                                                     
      setup
    
      repeat
        scan_buttons                                                ' scan the buttons
        modebits := ina[MOD0..MOD1]                                 ' scan the mode inputs
    
        repeat btn from 0 to 9
          mask := 1 << btn                                          ' create mask for button
          ifnot (modebits & mask)                                   ' momentary mode?
            if (nbtns & mask)                                       ' button pressed?
              relays |= mask                                        '  relay on
            else                                                    ' else
              relays &= !mask                                       '  relay off
    
          else                                                      ' latch mode
            if (xbtns & mask)                                       '  new press?
              relays ^= mask                                        '   toggle relay
          
        ' set relays
        ' play random tone
    
    
    pub scan_buttons | t
    
      obtns := nbtns                                                ' save last
    
      nbtns := %11_11111111                                         ' arm all inputs
    
      t := cnt
      repeat 25                                                     ' 25ms debounce
        waitcnt(t += MS_001)                                        ' wait 1ms
        nbtns &= ina                                                ' (re)scan all inputs
    
      xbtns := nbtns ^ obtns & nbtns                                ' new presses (0 -> 1)
    
  • kwinnkwinn Posts: 8,697
    You can also try this. Should work for the buttons, switches, and relays part of it, but did not have the hardware to test the sound with me. Somewhat similar to what JonnyMac suggested but based on the code you posted.
  • kwinnkwinn Posts: 8,697
    Oops, file did not attach to previous post. And 3 copies attached here. Strange.

  • jknightandkarrjknightandkarr Posts: 234
    edited 2016-02-27 16:52
    garyg wrote: »
    The link you attached to the top of your post leads me to a site I'm hesitant to go to.
    ..
    That's my personal website for the business I am slowly trying to work on, as I am able. The only danger there is lack of content... Lol
    kwinn wrote: »
    You have 10 momentary contact pushbuttons and 10 relays. When you press a button you want a random DTFM tone to play, and to turn the corresponding relay on if it is off, and off if it is on. That is button 1 toggles relay 1, button 2 relay 2, etc.

    Is this correct?

    PS- I am also guessing that you are using the 10 switches to emulate the relay contact being open or closed. Is that so?
    Yes, 10 buttons, and 10 relays. The switches are supposed to be a settings.
    I/O: 0..9 := The 10 buttons. 'All momentary
    I/O 10..19 := 10 switches 'Output settings 1:= On or Off latching, 0:= Momentary
    -I/O 10 setting for button 0.. I/O 19 setting for button 9

    Here's the layout of what is supposed to happen:
    1) Read the button inputs and 10 setting switches, store in variables.
    2) If button is presses it plays a random, 1 of 16 possible DTMF tones for a moment then checks the corisponding setting variable and then turns on the relay. Otherwise loop at step 1 till a button is pressed.
    3) If setting for button being pressed is 0, then turn same relay back off. If setting is 1:= Then it's toggle the relay from Off to On or On to Off and hold state till button pressed again.
    4) Go back to step 1 and repeat endlessly.

    I originally was going to use 10 outputs, but when my original design wasn't going to work, I decided to save wires and use a shift out register to take the place of the 10 I/O pins. I got the tones, but there is a unwanted delay, and my shift register doesn't seam to be working, not sure if bad register or its the coding.

    JonnyMac, I will try your code and see if I can get it to work for me. I am also going to try another way of creating my sounds.

    kwinn, will try yours as well.

    Thanks for the help everyone.

    Joe
Sign In or Register to comment.