Shop OBEX P1 Docs P2 Docs Learn Events
Missed event detector with HM55 compass chip — Parallax Forums

Missed event detector with HM55 compass chip

Steve-0Steve-0 Posts: 5
edited 2007-08-08 23:24 in BASIC Stamp
I want to write a program for the BS2 using a hitachi HM55 compass chip. I want to monitor movement of a slowly spinning object by polling the compass chip every 30 seconds and noting it's bearing. If the bearing has not changed +/- 5 degrees from the last poll, I one of the I/O pins (say pin 1)to go high. At the same time this is being monitored, I need to monitor another input for change from low to high. When this occurs, I need the same output triggered by the compass (pin 1) to go high. Is this possible with the BS2? Also, once this cycle has completed, I need to reset the whole thing to start over. Any help would be greatly appreciated, I am admittedly new at this programming thing and pretty much self taught.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-08-08 16:52
    Hello,

    It seems possible although there is some missing information. For example, how long does the input stay HIGH for the BASIC Stamp to detect? What is the pulse width? Also, on output HIGH, how long does it stay HIGH before starting over again?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Steve-0Steve-0 Posts: 5
    edited 2007-08-08 16:56
    The input would go high for 250ms. The output before resetting would need to stay high for 30 seconds. Thanks for replying!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-08-08 20:03
    Sounds like it could work if the routine reading the compass doesn't take 250 ms.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Steve-0Steve-0 Posts: 5
    edited 2007-08-08 20:49
    let's just say, to get me started, using the sample code for the HM55 from your site. Could I just add an "UNTIL" to the "LOOP" at the end of the routine? I want it to repeat until the value on the debug screen is the same for 2 consecutive polls, and then move to the next part of the program. As long as the debug values are different every time, it should loop. How do I do this??
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-08-08 23:24
    Steve,

    It’s not as simple as adding a line of code…You never accounted for you input monitoring…I would break the code down to the minimum functional code needed to realize your goals. This code wasn’t written to do what you’re referring to so it may take more time then needed. I don’t even know which file you refer to, but it’s always a good practice to break things down into minimum code when timing is a potential issue.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.