This week on First Spin we decide to talk about the Ping))) Ultrasonic Distance Sensor and we talk about the basics of what it does and hash out how the Ping Sensor actually works (because you know, Addie has to know those details):
It takes a little for Addie to understand it. We discuss good electronic habits and the subtleties needed to get the Ping Sensor to do its job.
The following blog post is the text explanation of what is discussed!
This week on First Spin, we talk about the modules and the code/objects involved again! We go specifically into accelerometers, what they do, what they are, and some of the subtleties involved in the data gained from them. We discuss the basics of how to interface accelerometers with gyroscopes or compass modules, and talk about the feasibility of basic projects to learn how to use these together.
We discuss different methods of figuring out how to measure wind speed by counting the number of rotations or overgineering it, Addie style. We talk about what a mems device is and then go into what First Spin will cover in the next few weeks. We also look at the altimeter module’s code. Less manual, more specific modules!!
This week on First Spin, we talk about the Parallax Expo and cover a lot of the cool projects that were seen in the booths. We had an amazing time talking to all of the different makers and watching the different projects. Thanks to Parallax for an awesome Expo! We will be sure to make it out to the next one!
Addie has been working on working with different peripherals and sensors sold by Parallax and recently, she’s been working on the GPS module, altimeter module, and gyroscope module. Whisker, Roy and Addie discuss the different approaches to these types of sensors and Addie discusses working with the gyroscope module. There’s also an Addie style explanation of I2C!
This week we continue talking about MANY binary operators and the assignment of results. We cover, analyze, and give examples for the following binary operators: +=, -=, *=, **=, /=, //=, #>, #>=, <#, <#=, ~>, ~>=, <<=, >>=, <-=, ->=, and ><=. Some show notes below!
Arithmetic Shift Right:
1010 ~> 1101
0101 ~> 0010
Bitwise Shift Left/Right – Add in a 0 depending on direction shifted, whereas arithmetic shift right adds in the signed bit of the value. So if the binary number’s signed bit is 1, it will add in a 1 and if a binary number’s signed bit is 0, it will add in a 0 (like the example above).
This week on First Spin, we finish up the Unary Operators by covering NOT, @, @@, and in doing so tackle the idea of boolean values with Addie. We also go over the small details involved in @ and @@ addressing.
We also start on the binary operators with =, :=, the distinction between := and ==, +, +=, and the subtleties involved!
This week we talk again about the Parallax Expo and we continue with Unary Operators! We continue with:
?: Random number (forward/reverse) – we discuss how it works and how someone could try to get as random a number as possible.
|<: Decode Value – Given a number from 0-31 it will give you the resultant value that is that bit turned on in the long. So if you give it 31, the 31st bit will be turned on and everything else not. Ex. Pin := |< 3 will set bit 3 of Pin ON and all other bits are off.
>|: Encode Long – This will give you the highest bit that is turned on in the long you are looking at and adds 1 to that value. Example below:
a := |< 16……will give you a long into a where bit number 16 is turned on and everything else is off
b := >| a……..b will equal 17. (It will be a binary number valued at 17)
!: BITWISE NOT – Whatever value you give it, it takes the bits in that value and switches them to the opposite. All of the 0′s become 1′s and the 1′s become 0′s. We get into binary nuttiness with this:
!1 == -2 —–> A 1 in binary is all 0′s except for the bottom bit which is 1. This (!) turns all of the 0′s into 1′s and then the bottom 1 into 0. This makes it equal a decimal value of -2 (whaaaaat?!). Cue the crazily confusing (but eventually elucidating) discussion on binary signage.
Assuming a 4-bit number: We start at 0, we count up, when we get to 7, that’s 0111. After 7, when we add 1 to it, instead of becoming 8, it wraps around and becomes 1000 which is -8. The top bit equals the sign and the max number. The rest of the bits determine how far away we are from the maximum negative number.
The top bit is a 1 which means it’s a negative number. If you have a 4 bit value: 0001, and do !0001, that would equal 1110. Assuming the top bit represents the sign of the value (+ or -). So the top “1″ makes it negative in value. Take the rest of the bits, figure out what that equals, and then subtract that from the maximum (of the side the sign is (in a 4bit number that’s either 7 for the positive side or -8 for the negative side).
Example. !0001 == 1110. The range is -8 to 7. 1 represents – and 110 = 6. So then -8 + 6 = -2.
Example. !001 == 110. The range is -4 to 3. 1 represents – and 10 = 2. So then -4 + 2 = -2.
So then any number that is all 1′s except for the last bit which is 0 will always equal -2.
This week on First Spin we remind everyone about the Parallax Expo (woohoo!) and then start on Unary Operators! Addie gets a bit confused by the subtle difference between pre and post increments/decrements – but our resident experts are patient and explain wonderfully! We also hash out sign-extensions!
We go through:
+ : Add
- : Subtract
- -X : Pre-decrement
X- – : Post-decrement
++X : Pre-increment
X++ : Post-increment
^^ : Square root
|| : Absolute Value
~ / ~~ : Sign Extension
(–) Example discussed:
a := X- – + 10 X = 2
a := X + 10 and X = X – 1
a := 2 + 10 and X = 2 – 1
a := 12 X = 1
VERSUS
a := – -X + 10 X = 2
a := (X-1) + 10 and X = 2-1
a := 1 + 10 and X = 1
a := 11 X = 1
(++) Example discussed:
a := X++ + 10 X = 2
a := 12 X = 3
VERSUS
a:= ++X + 10 X=2
a := 13 X = 3
Sign Extension Discussion:
If you set dira/ina to ~ this sets all bits in a 32 long to 0 (though 32 depends on the context).
For example, Outa[4..5]~ will only set bits 4 and 5 to 0
~~ = -1 so if you set dira/ina to ~~, this turns all of the bits ON in a 32 bit long
With 1, the first bit of the 32 bit is ON. With -1, all bits are ON.
If you put it (~ or ~~) in front of a variable (X) it sign-extends. So if you have a 8-bit value, positive or negative, then you use sign extension to sign extend it into a full 32 bit value.
So if you had just a BYTE (0-7) as a variable (vs WORD (8-16) or LONGs(17-32)). This lets you take a variable from a BYTE or WORD and ensures that the signed value (positive or negative) of the number is properly copied over to a LONG.
First Spin Episode 016 - Wrapping up Registers and Constants[ 32:01 | 43.96 MB ]Play Now | Play in Popup | Download (136)
This week on First Spin, we finish out the Registers by talking about VCFG, VSCL, PAR, and SPR with some examples of when these would be used. We then go into Constants – all of which have been previously covered – TRUE, FALSE, POSX, NEGX, and PI. And then we discuss Result and how it’s magically there even when not stated.
And before going into Unary Operators, we discuss Addie’s work on the Xbees and interfacing them with the Propeller. She talks about how she gets an xbee to control an rc servo and how to control her heart led project. Lots of learning experiences!