Shop OBEX P1 Docs P2 Docs Learn Events
Need help with Programming — Parallax Forums

Need help with Programming

pathikgohil85pathikgohil85 Posts: 21
edited 2011-11-01 17:08 in BASIC Stamp
I am working on my code where I have difficulties with combine different binary number and assign to one variable.

Ex : CONFIG VAR BYTE = 000111

according to my logic each bit will stored in different ram location from 0 to 5. Now I have to Check each and every digit from RAM and assign to variable CONFIG. It has to be bit wise operation.

Note : I am using SPSTR so my string will store each value in ram. I have to retrieve it and make single variable again.

can anybody explain me about it?

Thanks a lot. Have a good day.

Regards,
Pathik

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-28 15:23
    This is the same problem you have brought up before, just using a different number base. Previously, you wanted to convert a decimal digit stream of characters into a number. Now you have a binary digit stream of characters. In the examples shown in your thread and xanatos' thread, there was a factor of 10 used to multiply the previous value before adding in the next digit. For binary, you can use a factor of 2. You can also use a single bit shift which effectively multiplies by 2.

    You can do the same thing with hexadecimal values except that you have to handle the characters from "0" to "9" separately from the characters "A" to "F" which get converted into digits from 10 to 15 and the multiplication factor is 16.
  • pathikgohil85pathikgohil85 Posts: 21
    edited 2011-11-01 17:08
    Thanks a lot Mike. I figured out problem. I was sending all data through SEROUT in HEX which I did not aware about it. So i need to resolve that. Also I implement your logic too. Thanks again.

    I can make my Basic stamp work on 115.2 k with all the guidance provided by people on forum. Special thanks to all.

    Pathik Gohil
Sign In or Register to comment.