Shop OBEX P1 Docs P2 Docs Learn Events
Why do I get different answers from the same math process? — Parallax Forums

Why do I get different answers from the same math process?

krazyideaskrazyideas Posts: 119
edited 2009-08-23 02:44 in Propeller 1
Hello,

I have a program have been fighting with. I decided to run another propellor chip to double check it.
The one gives me an answer of 9000, while the other gives me an answer of 4500.
Besides one useing the TV·object to show me the result, and the other useing the FullDuplexSerialPlus to show me the result, they are twins. At least as far as I can see.
I have been fighting this for a couple hours and I am out of ideas.
Could the crystal be bad, or the chip? something.

Here they are

Any thoughts would be great.

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-22 21:59
    Check the pin assignment, in 1 case its pin := 21 in the other is pin := |<21
  • SRLMSRLM Posts: 5,045
    edited 2009-08-22 22:03
    There are two main differences.
    1). In the second program, you bitwise encode the pin number. This makes a completely different number (2^21) than just setting it equal to 21 (10101)
    2). In the second program, you delay by 50_000_000 less cycles.

    cnt += 150_000_000
    



    This line (in both programs) is in error. According to the Propeller Manual, cnt is a read only resource. It appears that the compiler doesn't check for this, but it's still wrong.

    As a side note, you should be able to use the same program for both setups, since TV_text and FDSP share some of the same methods (like str, dec, and tx). So, if you name both objects the same, and have both calls to their start, you can comment one out at a time, and easily switch when the need arises.
  • krazyideaskrazyideas Posts: 119
    edited 2009-08-22 22:06
    That wasn't it. It does not work at all with the pin assinment pin := |<21
    That was just a mistake I did when I was copy and pasteing into a smaller folder, so I could post it.
    Sorry bout that

    It still gives me to anwsers, one twice the size of the other. The crystals are the same and everything.
  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-22 22:32
    Have you fixed the cnt += problem? If not that could cause your problem, that probably causes a ~50 sec delay so you are seeing whatever is in rpm when the program starts in the 2nd case.
    I would fix the problems and post the code again. If you are not trying what you post can you try the test code that you post so we are not trying to debug something different from you are running, sometimes a bug elsewhere can affect other parts of your code.
  • krazyideaskrazyideas Posts: 119
    edited 2009-08-23 02:44
    Hey Guys I got it working. Thanks for the help. You were right there was a bug else where in my program. I was so focused on this one piece that I didn't see it.
    Thanks so much
  • krazyideaskrazyideas Posts: 119
    edited 2009-08-23 02:44
    Hey Guys I got it working. Thanks for the help. You were right there was a bug else where in my program. I was so focused on this one piece that I didn't see it.
    Thanks so much
Sign In or Register to comment.