The post Buy DIY Programmable Drone Kit-Beginners Guide appeared first on BINARYUPDATES.COM.
]]>Back then I started reading and reaching out to professionals aka Drone Experts in the region. They were busy and many of them spent lots of cash on burning components and learning. In the end, I did the same. And, decided to document my hustle to help new learners.
Drone is an lucrative technology to add to your skill sets. Also worth investing in long term as a technologist. Along with it you’ll enjoy every bit of it
In future post, I will share about different drones I built with several leading flight controllers out there in the market. I’ll share experience with comparison and flying experience. There are several factors need to keep in mind before dive into drone or quadcopter. When it comes to buying spare parts, make sure you know what you’re buying and why? Because you should know basics to make sure they fulfil your objective. You may want to fly for fun or want to implement use case or even build applications. Whatever, the reason could be. I recommend beginners to buy DIY Programmable Drone Kit which saves time and make learning smooth. Especially, in case if you don’t have enough time.
Essential list of components or spare parts to build drone from scratch
According to Drone policy of India, drones are classified as
Now when you’re complete new then I recommend using programmable DIY Nano drones which are affordable quick and easy to fly. There are some really cool Nano Drones out there in a market like PlutoX and Crazflie2.1, both are great. I recommend PutoX for Indian users; it’s a programmable crash resistant drone with HD Camera. The reason is because it’s affordable at price point yet having freedom to code through its own Cygnus IDE. You can write API based C++ programs to implement your own ideas. Also there is support for expansion breakout board (X-Breakout Board), which lets us, add additional sensors. There are several features which lets, PlutoX best fit for implementing use cases. It’s not just a quadcopter/drone, its complete platform which includes flight controller, mobile App, Development IDE, API based programming Interface etc. You can easily find spare parts and buy online. Here is a link if in case you breakdown any part while experimenting.
For US & Europe, user’s maybe Crazflie2 will an option due to its availability. But it depends how you compare them including price, logistics, availability, government policy etc. I personally recommend PlutoX Drone Kit; my experience is so far great as a developer or tinkerer by myself. And I’ll be putting out lots of videos and blogs about it. I’ll even share some use cases built around PlutoX.
PlutoX | CrazyFlie | |
Flight time | 9 min. | 7 min. |
Payload | 15g | 15g |
SDK | API Based interface | Standard Developer interface |
Communication | WiFi (60m) | Proprietary (1km) |
Frame | Open Source & Modifiable | Standard Frame |
The following peripherals feature let’s PlutoX connect with your choice of sensors, actuators, motors etc with it. And don’t you think it’s awesome to build your own project around PlutoX Drone.
Installing Cygnus IDE for programming done using API based Interface
Final Thought!
When I started my journey I thought drone programming means all about writing flight control algorithm. But later I realized, algorithm is a fixed firmware you can tweak and play around as you develop expertise. But as a newbie, I think focus should be more on use cases. The real learning could be to fly stable flight and understanding flight-and-aerodynamics, later-on finally write an application programs to let your Quadcopter/drone do what you want it to do. This off-course needs programming knowledge. Stay tuned for my next post. And will learn more about every component of Drone including its types, uses & selection criteria. Thanks for reading.
The post Buy DIY Programmable Drone Kit-Beginners Guide appeared first on BINARYUPDATES.COM.
]]>The post Arduino Tutorials: Beginners and Advance appeared first on BINARYUPDATES.COM.
]]>1. How to Setup and Program Arduino
2. LED and Switches of Arduino Uno
3. Serial Communication in Arduino Uno
3. Timer Interrupt in Arduino Uno
5. brightness control of LED
6. Making sound tone using Arduino
7. Control Dimming of LED in Arduino
8. Interface 16×2 Character LCD with Arduino Uno
— 4-bit Mode
— 8-bit Mode
— Scrolling text
— Graphics on LCD Screen
9. Interface Servo Motor with Arduino Uno
10. I2C EEPROM with Arduino Uno
11. RTC DS1800 with Arduino Uno
12. ADC Analog to Digital Conversion using Arduino Uno (POT)
13. Interface LM35 with Arduino uno
14. Relay with Arduino Uno
1. Current Sensor ACS712 with Arduino Uno
2. DHT11 with Arduino Uno
3. LDR Photodiode with Arduino Uno
4. BMP180 with Arduino uno
5. IR Proximity Sensor with Arduino Uno
We believe learning microcontroller with Arduino is the best way to invest your time. On a personal note, I must say it’s never been easier without Arduino to learn programming microcontroller. I remember those old days when we used to buy expensive programmers and kits to learn microcontroller. Even with those expensive tools it’s challenging for non-technical candidates to learn microcontroller programming. But Arduino makes it so simple and easy for anybody to program their microcontroller and build some cool products. I hope you will enjoy reading these Arduino tutorials. If you have any suggestions or feedback feel free to leave a comment. Thanks.
The post Arduino Tutorials: Beginners and Advance appeared first on BINARYUPDATES.COM.
]]>The post Bitwise Operations in Embedded Programming appeared first on BINARYUPDATES.COM.
]]>Now let’s concentrate only on bitwise operations. We’ll learn how these bitwise operations allow’s us for Setting, Inverting, Toggling, Clearing, Extracting and Inserting bits in embedded programming. Here is a table which summarizes operations with 2-operands.
A | B | A | B | A & B | A ^ B |
0 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 | 0 |
Let’s take variable A and B. We’ll perform bitwise operation on these two variables. This example will help you understand their operation. Let’s first declare these two variables:
uint8_t A = 0x3B //00111011; uint8_t B = 0x96 //10010110; |
AND compares each bit and returns 1 if the two bits are 1 (TRUE) otherwise 0 (FALSE). So: C = A & B;
00111011………………..(A=0x3B) | |
& | 10010110………………..(B=0x96) |
00010010 |
The value of C will be 0x12 or in binary 00010010. That is where there is a 1 in each bit for both values.
OR (| in C)
OR will return a 1 if there is a 1 in either value at that bit. So: C = A | B;
00111011………………..(A=0x3B) | |
| | 10010110………………..(B=0x96) |
10111111 |
The value of C will be 0xBF or in binary 10111111
XOR will return a 1 if there is a 1 at that bit for either value but not both. For example, if bit position 5 for both values has a 1 then XOr returns a 0. But if only one has a 1 and the other has a 0 XOR returns a 1. So: C = A^B;
00111011………………..(A=0x3B) | |
^ | 10010110………………..(B=0x96) |
10101101 |
The value of C will be 0xAD or in binary 10101101.
This returns the compliment of a value. This mean where there was a 0 there will now be a 1 and vice versa. So: C = ~(A);
! | 00111011………………..(A=0x3B) |
11000100………………..(C=0xC4) |
The value of C will be 0xC4 or in binary 11000100
And then there are two shift operators – Left shift and Right shift. These operators shift the bits by the corresponding value, in other word’s move the bits. The sign << for left shift and >> for right shift. Here is an example:
C = A << 2; // left shift A by 2 |
The value of C becomes 0xEC or in binary 11101100 after shifting 2-bits to the left.
D = B >> 4; // right shift B by 4 |
The value of D becomes 0x03 or in binary 00001001 after shifting 4-bits to right.
Let’s say we have variable called bits and we have asked to set the bit-7. This can be achieved by writing this single line of code.
bits = bits | (1 << 7) ; /* sets bit 7 */
This would usually be written more succinctly as:
bits |= (1 << 7) ; /* sets bit 7 */
Inverting (toggling) is accomplished with bitwise-XOR. In following, example we’ll toggle bit-6.
bits ^= (1 << 6) ; /* toggle bit 6 */
Form a mask with 1 in the bit position of interest, in this case bit-6. Then bitwise AND the mask with the operand. The result is non-zero if and only if the bit of interest was 1:
if ((bits & 64) != 0) /* check to see if bit 6 is set */
Same as:
if (bits & 0x64) /* check to see if bit 6 is set */
Same as:
if (bits & (1 << 6)) /* check to see if bit 6 is set */
Let’s say if we want to clear bit-7. This can be accomplished using bitwise-AND operator
Mask must be as wide as the operand! if bits is a 32-bit data type, the assignment must be 32-bit:
bits &= ~(1L << 7) ; /* clears bit 7 */
Let’s say we have given a 32-bit number and we asked to extract bits from it. Assume that 32-bit number in hex is 0xD7448EAB. In binary= 1101 0111 0100 0100 1000 1110 1010 1011. Now we have asked to extract 16-bits from bit number 10 through 25.
To extract the bits first we have to use bitwise operator in combination with a bit mask to extract bits 10 through 25. The masking value will be 0x3FFFC00. Now we have two ways we can achieve result.
Method-I
unsigned int number = 0xD7448EAB; unsigned int value = (number & 0x3FFFC00) >> 10;
Method-II
unsigned int number = 0xD7448EAB; unsigned int value = (number >> 10) & 0xFFFF;
Now if we follow Method-I and after equating. We’ve got 0x3448C00 (In binary 11010001001000110000000000). When we shift 10 bits to right, we’ll get 0xD123 i.e. in binary 1101000100100011.
Monitoring specific bit in register is very important. In Embedded programming, very often we need to read status of flag bit in hardware register. These flag bit controls or indicate hardware feature. Also they are every useful while reading, writing data to and from microchip. So we continuously monitor these bits in register to carry out desired function by microchip. Let’s say if we want to monitor 4^{th} bit for any change, we’ll write function as below:
while( bits & (1<<4) ) // monitor for 4th bit changing from 0 to 1 { ....... ....... }
The 4^{th} bit of register bits is ‘1’ the result of (bits & (1<<4)) will always be zero. When 4^{th} bit is ‘1’ then (bits & (1<<4)) will be equal to (1<<4) which is greater than 0 and so this evaluates as TRUE condition and code inside while loop get executed.
Now let’s say if we want to monitor 4^{th} bit state from 1 to 0. In this case, we only need to negate the condition inside of while statement.
while( ~(bits & (1<<4)) ) // monitor for 4th bit changing from 1 to 0 { ....... ....... }
Bitwise operators save memory and it is fast. This all leads to improve performance. I hope now you know that why bitwise operations in embedded programming used such a widely. If you have any questions or suggestions then feel free to leave a comment.
The post Bitwise Operations in Embedded Programming appeared first on BINARYUPDATES.COM.
]]>The post Signed and Unsigned Numbers in Computer Programming appeared first on BINARYUPDATES.COM.
]]>In Number System we’ve assumed, we have as many bits as needed to represent numbers. But in computers, we have a fix number of bits to represent value. These bit sizes are typically 8-bit, 16-bit, 32-bit, 64-bit. These sizes are usually multiple of 8, because system memories are organized on an 8-bit byte basis. When a specific number of bits being used to represent a number. This number determines the range of possible values that can be represented. For example, there are 256 possible combinations of 8-bits, therefore an 8-bit number can represent 256 distinct numeric values and the range is typically considered to be 0-255 (we have provided table in later part of this tutorial). So we can’t represent numbers larger than 255 using 8-bit number. Similarly, 16 bits allows a range of 0-65535.
Until now we have only considered positive values for binary numbers. When a fixed binary number is used to hold positive values, it is considered as unsigned. In this case, the range of positive values that can be represented is from 0 – 2^{n}-1, where n is the number of bits being used. It is also possible to represent signed (negative as well as positive) numbers in binary. In this case, some part of the total range of values is used to represent positive values, and the remaining of the range is used to represent negative values.
There are several ways we can represent signed numbers in binary, but the most common representation used is called two’s complement method. The term two’s complement is somewhat ambiguous, in that it is used in two different ways. First, as a representation, two’s complement is a way of interpreting and assigning meaning to a bit pattern contained in a fixed precision binary quantity. Second, the term two’s complement is also used to refer to an operation that can be performed on the bits of a binary quantity. As an operation, the two’s complement of a number is formed by inverting all of the bits and adding 1 to it. In a binary number being interpreted using the two’s complement representation, the high order bit of the number indicates the sign. If the sign bit is 0, the number is positive, and if the sign bit is 1, the number is negative. For positive numbers, the rest of the bits hold the true magnitude of the number. For negative numbers, the lower order bits hold the magnitude of the number. It is important to note that two’s complement representation can only be applied to fixed precision quantities, that is, quantities where there are a set number of bits.
The 2’s complement method of representation is used because it reduces the complexity of the hardware in the ALU (arithmetic-logic unit) of a computer’s CPU. Using a 2’s complement method, all of the arithmetic operations can be performed by the same hardware whether the numbers are considered to be unsigned or signed. The bit operations performed are identical; the difference comes from the interpretation of the bits. The interpretation of the value will be different depending on whether the value is considered to be unsigned or signed.
The table below shows counting sequence for an 8-bit binary number using 2’s complement:
In above table, we’re counting up from 0. When 127 reached, the next binary pattern in the sequence corresponds to -128. The values from the largest positive number to the largest negative number, but that the sequence is as expected after that. Say for example, adding 1 to –128 gives –127. When the count has progressed to FFh (or the largest unsigned magnitude possible) the count wraps around to 0. Say for example adding 1 to –1 gives 0. This is it for Signed and Unsigned Numbers in computer programming. If you have any question, then feel free to leave a comment.
The post Signed and Unsigned Numbers in Computer Programming appeared first on BINARYUPDATES.COM.
]]>The post Number System in Embedded Programming appeared first on BINARYUPDATES.COM.
]]>Decimal numbering system uses digits from 0 to 9 i.e. (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9). The base of decimal number system is 10 because we use 10 digits to represent decimal number. When we write decimal numbers, we use a positional notation system. Each digit is multiplied by an appropriate power of 10 depending on its position in the number. Let’s take example: 5319
5319 | = 5 x 10^{3} + 3 x 10^{2} + 1 x 10^{1} + 9 x 10^{0} |
= 5 x 1000 + 3 x 100 + 1 x 10 + 9 x 1 | |
= 5000 + 300 + 10 + 9 |
For whole number, the rightmost digit is 1^{st} position (10^{0} = 1). The numeral in that position indicates how many ones are present in the number. The next position to the left is ten’s, then hundred’s, thousand’s, and goes on. Each digit position has a weight that is ten times the weight of the position to its right.
In the decimal number system, there are ten possible values that can appear in each digit position, and so there are ten numerals required to represent the quantity in each digit position. The decimal numerals are the familiar zero through nine (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9).
Binary Numbers uses only 0 and 1 digit. The base of binary number system is 2. The binary number system is also a positional notation numbering system. Each digit position in a binary number represents a power of two. So, when we write a binary number, each binary digit is multiplied by an appropriate power of 2 based on the position in the number. Example: Find decimal equivalent of binary number 10101
10101 | = 1 x 2^{4} + 0 x 2^{3} + 1 x 2^{2} + 0 x 2^{1} + 1 x 2^{0} |
= 1 x 16 + 0 x 8 + 1 x 4 + 0 x 2 + 1 x 1 | |
= 16 + 4 + 1 |
The decimal equivalent of 10101 is 21. Each digit in binary number carries specific multiplication factor. By default the bit on extreme right which is also called as LSB bit or 0^{th} bit and that on the extreme left is MSB or last bit. SO technically in computing first bit will be 0^{th} index and hence the right will have an order of 2^{0}, next bit will have an order of 2^{1} and 2^{2}, 2^{3} and so on. And when we start conversion we have to consider from LSB i.e. from RIGHT we multiply each bit with increasing power of 2 so Bit 0 will be multiplied with 2^{0}, Bit 1 will be multiplied with 2^{1} and so on.
Hexadecimal Number System uses 16 digits from 0 to 9 and A to F. The alphabets A to F represent decimal numbers from 10 to 15. The base of Hexadecimal uNmber system is 16. There are sixteen numerals required. Here are the hexadecimal numerals: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
The reason for the common use of hexadecimal numbers is the relationship between the numbers 2 and 16. Sixteen is a power of 2 (16 = 2^{4}). Because of this relationship, four digits in a binary number can be represented with a single hexadecimal digit. This makes conversion between binary and hexadecimal numbers very easy, and hexadecimal can be used to write large binary numbers with much fewer digits. When working with large digital systems, such as computers, it is common to find binary numbers with 8, 16 and even 32 digits. Writing a 16 or 32 bit binary number would be quite tedious and error prone. By using hexadecimal, the numbers can be written with fewer digits and much less likelihood of error. This makes programmer life easy while writing programs.
Example: Find Hexadecimal equivalent of 10110, where 10110 is binary number.
To convert any binary number into its equivalent hexadecimal number, we first need to group the bits each group will have 4-bits. In our example we have 5 binary digits, so we will group them into 0001–0110. After grouping bits directly replace group with its equivalent hexadecimal number. Make sure we always start grouping from RIGHT i.e. LSB bit to LEFT i.e. MSB bit. Hence the hex equivalent of 10110 is 16 or (0x16).
Equivalent Numbers in Decimal, Binary, Hexadecimal Notations,
Decimal | Binary | Hexadecimal |
0 | 00000000 | 00 |
1 | 00000001 | 01 |
2 | 00000010 | 02 |
3 | 00000011 | 03 |
4 | 00000100 | 04 |
5 | 00000101 | 05 |
6 | 00000110 | 06 |
7 | 00000111 | 07 |
8 | 00001000 | 08 |
9 | 00001001 | 09 |
10 | 00001010 | 0A |
11 | 00001011 | 0B |
12 | 00001100 | 0C |
13 | 00001101 | 0D |
14 | 00001110 | 0E |
15 | 00001111 | 0F |
16 | 00010000 | 10 |
17 | 00010001 | 11 |
31 | 00011111 | 1F |
32 | 00100000 | 20 |
63 | 00111111 | 3F |
64 | 01000000 | 40 |
65 | 01000001 | 41 |
127 | 01111111 | 7F |
128 | 10000000 | 80 |
129 | 10000001 | 81 |
255 | 11111111 | FF |
256 | 0000000100000000 | 0100 |
32767 | 0111111111111111 | 7FFF |
32768 | 1000000000000000 | 8000 |
65535 | 1111111111111111 | FFFF |
BCD is Binary Coded Decimal. In BCD system, numbers are represented in decimal form. However, each decimal digit is encoded using a 4-bit binary number. Here is an example. The decimal number 568 would be represented in BCD as follows:
568 | = 0101 0110 1000 |
= 5 6 8 |
Conversion of numbers between decimal and BCD is quite simple. To convert from decimal to BCD, simply write down the 4-bit binary pattern for each decimal digit. To convert from BCD to decimal, divide the number into groups of 4 bits and write down the corresponding decimal digit for each 4-bit group.
There are a couple of variations on the BCD representation, namely packed and unpacked. An unpacked BCD number has only a single decimal digit stored in each data byte. In this case, the decimal digit will be in the low four bits and the upper 4-bits of the byte will be 0. In the packed BCD representation, two decimal digits are placed in each byte. Generally, the high order bits of the data byte contain the more significant decimal digit.
BCD numbers is not as common as binary number system because it is not space efficient. In packed BCD format, only 10 of the 16 possible bit patterns in each 4-bit unit are used. In unpacked BCD, only 10 of the 256 possible bit patterns in each byte are used. A 16-bit quantity can represent the range 0-65535 in binary, 0-9999 in packed BCD and only 0-99 in unpacked BCD.
This is it for Number system in Embedded Programming. Now we hope you’ve understood the concept of Binary, BCD and Hexadecimal Number Systems with its inter-conversion. Please do write us if you have any suggestion/comments or come across any error on this page.
The post Number System in Embedded Programming appeared first on BINARYUPDATES.COM.
]]>