1 + 1 = 3???

Dave E

Senior Member
Delete A Post

How do you delete a post? I know where to edit one that I posted but how do I delete one?
 
Last edited:

Dave E

Senior Member
I got it now. I tried to delete my original post before anyone replied (the answer to my question poped into my head as soon as I hit the post button) but either did not see the delete button or it was not an option. Though, I can delete my 2nd post to this thread.

Thanks,
Dave
 

hippy

Technical Support
Staff member
Often it is the act of composing the question which reveals the answer through focusing the mind, the D'Oh! moment coinciding with the post going.

As embarassing as being confused can be ( I am intrigued by 1+1=3? ) it's often best to just let it stand, acknowledge the D'Oh! and put a brave face on it - It may be useful for someone else having a tough time with the same problem, and you're more likely to read responses along the lines of "what I did really stupid once was ..." rather than ridicule which is quite cheering. We're all human here ... well, mostly human :)
 

Dave E

Senior Member
OK, here goes the late night ramblings. Remember, you asked.

I was going to use bit0 as a flag bit when an 08M was sent a high or a low from another microcontroller. I wrote test code for both controllers and was using debug for the picaxe when I noticed the bit changing from 1 to 3. It should have been changing from 0 to 1 and back to 0. I happend to be looking at the debug register labeled "B0". Now by looking at the time stamp on my post you can tell that it was late so my brain was a bit weak at that time. There are at least 2 problems with what I was seeing/thinking. 1) a bit can ONLY contain a 0 or 1. 2) the debug screen only lables bytes and words, not bits. I was looking at the decimal equivalent of BYTE0 not BIT0. Another thing I noticed but didn't catch (and still don't quite understand) is when I looked at the binary display the bits (decimal equivelent of BITS 0 and 1) were changing from 1 to 3 back to 1 as the program did what it was told to do. Namely, keep adding 1 to BIT0 causing BIT0 to toggle between 0 and 1. It turns out that it was doing just that (changing between 1 and 3 causes BIT0 to toggle between 0 and 1) but I was looking at the BYTE and not the BIT. My code was just adding 1 to BIT0 everytime the flag needed to change but what I saw was adding 1 to 1 gave me 3. Hence 1 + 1 = 3.

Now that we are here, let me ask this part that I do not understand.
I was expecting BIT0 to be the only bit to be affected by my code. Why did the number carry over to BIT1 when I added 1 to BIT0 when BIT0 already contained a 1? This seems logical if I were adding 1 to a byte but I was only adding to a bit. I assumed that if I kept adding 1 to BIT0 it would overflow back to zero everytime 1 was added to 1. If that is the way the microcontroller does things then why didn't BYTE1 just keep adding up? BYTE0 would toggle between 1 and 3 as my code ran. And if I happen to be using BIT1 as another flag, would continuously adding 1 to BIT0 cause BIT1 to change independantly.

So, with all this running around in my head this morning, at around 1 a.m., I said to heck with it and set up a serial link between the 2 microcontrollers. This way the master just tells the 08M what to do and I didn't have to care if 1 + 1 = 3 or not and I could get to bed.

:eek: So there it is, my late night thoughts. Nothing we havn't all experenced in one form or another and unfortunately, it will not be the last time.

Hey! I think I just came up with a good tag line:

Easy? Where's the fun in that? ;)

It's been used before but it fits.

Dave
 
Last edited:
Top