Shop OBEX P1 Docs P2 Docs Learn Events
Data Manipulation? — Parallax Forums

Data Manipulation?

Circuitbuilder9Circuitbuilder9 Posts: 85
edited 2012-03-10 06:27 in Propeller 1
Hey, all.
I was looking at all of your really awesome feats/projects, and a lot of them involve some type of upper or lower byte/data manipulation. Is there any tutorial or website where i can learn that? That's one skill that i still can't seem to comprehend for any projects.
So here's my questions, if you would like to answer them:
1. Why is data/byte manipulation important to your propeller projects?
2. How would you go about using it on a regular basis for your own project?
3. Is there a certain format for doing data/byte manipulation, as Hanno did?
4. How do you program and incorporate the values attained into the rest of the program?
5. How do you write the code in spin (or assembly) in order to do this? Is there a certain syntax for data/byte retrieval or manipulation?

If i am asking questions that bother you of my stupidity, please excuse me; freshman at high school here.

Comments

  • Mike GMike G Posts: 2,702
    edited 2012-03-09 18:53
    Serial data is sent one byte at a time. A byte can represent numeric values of 0 to 255 (0x00 to 0xFF) . What if you wanted to send a number larger than 255 like 1024? Well, you could split the number up into two bytes.

    1024 = 0x0400h

    A common method is to send the low byte followed by the high byte; little-endian. Check out the LONG, WORD, and BYTE data types in the Propeller manual.

    Get the low byte using a logical AND
    0400 & 00FF = 0000

    Get the high byte and shift the byte to the right 8 times
    0400 & FF00 = 0400 -> 04

    I think this is what you are asking. If not, please be more specific regarding data manipulation.
  • Circuitbuilder9Circuitbuilder9 Posts: 85
    edited 2012-03-09 20:37
    Sorry for being too broad.
    What i meant to say was: as an example using Hanno's way of data manipulation for values specifically inclined for the wheels of his DanceBot, what do you do to program (i.e. - what is the syntax of the code) and retrieve the data manipulation and its values and why is it significant in a project such as Hanno's?
  • Mike GMike G Posts: 2,702
    edited 2012-03-10 06:27
    Circuitbuilder9, your question is not specific enough. Every program contains data manipulation; convert a number the ASCII equivalent, scale a sensor value to a servo position, place data on a serial bus. The specifics are dependent on what you are trying to accomplish.

    Post the code you're having trouble understanding.
Sign In or Register to comment.