Saturday, September 10, 2011
[Arduino] Light-detected Alarm
This is one of Arduino practice project from "Beginning Arduino, Michael McRoberts". In this exercise, I use an arduino uno board to control a light-detective alarm.
Monday, September 5, 2011
[C++] Storage duration, Scope, and Linkage
Quoted from "C++ Primer Plus, Fifth edition":
C++ uses three separate schemes for storing data, and the schemes differ in how long they preserve data in memory:
• Automatic storage duration—Variables declared inside a function definition—including
function parameters—have automatic storage duration. They are created when program
execution enters the function or block in which they are defined, and the memory
used for them is freed when execution leaves the function or block. C++ has two kinds
of automatic storage duration variables. (Automatic and register)
• Static storage duration—Variables defined outside a function definition or else by
using the keyword static have static storage duration. They persist for the entire time a
program is running. C++ has three kinds of static storage duration variables.
(external, internal, and no linkage)
• Dynamic storage duration—Memory allocated by the new operator persists until it is
freed with the delete operator or until the program ends, whichever comes first. This
memory has dynamic storage duration and sometimes is termed the free store.
C++ uses three separate schemes for storing data, and the schemes differ in how long they preserve data in memory:
• Automatic storage duration—Variables declared inside a function definition—including
function parameters—have automatic storage duration. They are created when program
execution enters the function or block in which they are defined, and the memory
used for them is freed when execution leaves the function or block. C++ has two kinds
of automatic storage duration variables. (Automatic and register)
• Static storage duration—Variables defined outside a function definition or else by
using the keyword static have static storage duration. They persist for the entire time a
program is running. C++ has three kinds of static storage duration variables.
(external, internal, and no linkage)
• Dynamic storage duration—Memory allocated by the new operator persists until it is
freed with the delete operator or until the program ends, whichever comes first. This
memory has dynamic storage duration and sometimes is termed the free store.
[C++] Declare a external (global) variable in header file
If you declare a global variable (in order to share within multifile program) in header file such as:
The right way is use extern keyword that let compile know it is a global variable:
int tom = 3; // declare in header fileIt would be wrong, because variable will redefine in multiple c files when you include header file in them.
The right way is use extern keyword that let compile know it is a global variable:
Sunday, September 4, 2011
[C++]Head file management #ifndef, #endif
quoted from "C++ Primer Plus, Fifth edition" about #ifndef, #endif:
You should include a header file just once in a file. There’s a standard C/C++ technique for
avoiding multiple inclusions of header files. It’s based on the preprocessor #ifndef (for if not
defined) directive. A code segment like
#ifndef COORDIN_H_
...
#endif
You should include a header file just once in a file. There’s a standard C/C++ technique for
avoiding multiple inclusions of header files. It’s based on the preprocessor #ifndef (for if not
defined) directive. A code segment like
#ifndef COORDIN_H_
...
#endif
Tuesday, August 30, 2011
Mechatronics - Stepper Motors Control
One of case studies at Mechatronics class at Columbia University taught by Dr. Fred R. Stolfi. The goal of this case study is get an understand of the issues and techniques for stepper motor control using an embedded microcomputer. Stepper motors are the preferred technology for position control system such as those in machine tools.
The main apparatus includes:
The main apparatus includes:
- A microcontroller, PIC16F74
- A Microchip microcomputer board
- Two permanent magnet stepper motors (unipolar and bipolar)
- Four optical interrupters (four sets of LED and Photo Transistor )
The film of stepper motors control:
Mechatronics - On/Off Temperature Control
One of case studies at Mechatronics class at Columbia University taught by Dr. Fred R. Stolfi. This case study is a dynamic system investigation of an important and a common mechatronic system: a thermal close-loop system.
The main apparatus includes:
- A microcontroller, PIC 16F74
- A resistive heater (SRMU 100202P)
- Two temperature sensor (AD590 and AD22100)
- A fan.
The film of On/Off temperature control:
Monday, August 22, 2011
Robotic eye Mechanism Design
Hi, Please visit my new blog for detail. Thank you for your visting!
Screenshot:
Screenshot:
Subscribe to:
Posts (Atom)