An H-bridge is an electronic circuit which enables a voltage to be applied across a load in either direction. These circuits are often used in robotics snd other applications to allow DC motors to run forward and backwards. H-bridges are available as intergrated circuits, or can be built from discrete components.
H-bridge, sometimes called a full "full bridge" the H-bridge is so named because it has four switching elements at the "corners" of the H and the motor forms the cross bar. Here is a figure showing a basic gridge.
Structure of an H-bridge (highlighted in red)
An H-bridge is built with four switches (solid-state or mechanical). When the switches S1 and S4 are closed (and S2 and S3 are open) a positive voltage will be applied across the motor. By opening S1 and S4 switches and closing S2 and S3 switches, this voltage is reversed, allowing reverse operation of the motor.
The switches S1 and S2 should never be closed at the same time becayse this will cause a short circuit on the input voltage supply course. the same applies to the S3 and S4. This condition is known as shoot through.
Operation-
The H-Brifge arrangement is generally used to reverse the polarity of the motor, but can also be used to brake the motor, where the motor comes to a sudden stop, as the motors terminals are shortened, or to let the motor 'free run' to a stop, as the motor is effectively disconnected from the circuit. The following table summarises operation.
S1 S2 S3 S4 Result
1 0 0 1 Motor moves right
0 1 1 0 Motor moves left
0 0 0 0 Motor free runs
0 1 0 1 Motor brakes
1 0 1 0 Motor brakes
Thats all about H-bridges. Now hopefully I will be able to soon hack the RC car!!!
This post will explain all about transistor circuits; types of transistors, the current in them, different uses and the Darlington pair.
First, I'm going to look at some of basics of transistors.
Types of Transistors:
There are two types of standard transistors, NPN and PNP, with different circuit symbols. The letters refer to the layers of the semiconductor material used to make the transistor.
A Darlington pair is two transistors connected together to give a very high current gain.
Transistor currents:
The diagram shows the two current paths through a transistor. The small base current controls the larger collector current. When the switch is closed a small current flows into that base (B) of the transistor. It is just enough to make the LED B glow dimly. The transistor amplifies this small current to allow a larger current to flow through its collector (C) to its emitter (E). This collector current is large enough to make the LED C light brightly. When the switch is open no base current flows, so the transistor switches off the collector current. Both LEDs are off. A transistor amplifies current and can be used as a switch.
Functional model of an NPN transistor:
The base-emitter junction behaves like a diode.
A base current I.B flows only when the voltage V.BE across the base-emitter junction is 0.7V or more.
The small base current I.B controls the large collector current Ic.
Ic = h.FE * I.B (unless the transistor is full on and saturated) h.FE is the current gain (strictly the DC current gain), a typical value for h.FE is 100 (it has no units because it is a ratio).
The collector-emitter resistance R.CE is controlled by the base current I.B:
I.B = 0 R.CE = infinity transistor off
I.B small R.CE reduced transistor partly on
I.B increased R.CE = 0 transistor full on (saturated)
A resistor is often needed in series with the base connection to limit the base current I.B and prevent the transistor being damaged.
Transistors have a maximum collector current Ic rating.
A transistor that is full on (with R.CE = 0) is said to be saturated.
When a transistor is saturated the collector-emitter voltage V.CE is reduced to almost 0V.
The emitter current I.E = I.c + I.B, but I.c is much larger than I.B, so roughly I.E = I.c
Darlington Pair:
This is two transistors connected together so that the current amplified by the first is amplified further by the second transistor. The overall current gain is equal to the individual gains multiplied together: Darlington Pair current gain - h.FE = h.FE1 * h.FE2
(h.FE1 and h.FE2 are the gains of the individual transistors)
This gives the Darlington pair a very high current gain, such as 10000, so that only a tiny base current is required to make the pair switch on. A Darlington pair behaves like a single transistor with a very high current gain. It has three leads (B, C and E) which are equivalent to the leads of a standard individual transistor. To turn on there must be 0.7V across both the base-emitter junctions which are connected in series inside the Darlington pair, therefore it requires 1,4V to turn on. A Darlington pair is sufficiently sensitive to respond to the small current passed by your skin and it can be used to make a touch-switch as shown in the diagram. For this circuit which just lights a LED the two transistors can be any general purpose low power transistors. The 100k Ohm resistor protects the transistors if the contacts are linked with a piece of wire.
Using a transistor as a switch:
When a transistor is used as a switch it must be either OFF or fully ON. In the fully ON state the voltage V.CE across the transistor is almost zero and the transistor is said to be saturated because it cannot pass anymore collector current Ic. The output device switched by the transistor is usually called the 'load'.
The power development in a switching transistor is very small:
In the OFF state: power = Ic * V.CE, but Ic = 0, so the power is zero.
In the full ON state: power = Ic * V.CE, but V.CE = (almost), so the power is very small.
This means that the transistor should not become hot in use and you should not need to consider its maximum power rating.
Protection diode:
If the load is a motor, relay or solenoid (or any other device with a coil) a diode must be connected across the load to protect the transistor from the brief high voltage produced when the load is switched off.
The picture shows how a protection diode is connected 'backwards' across the load.
Important:
Current flowing through a coil creates a magnetic field which collapses suddenly when the current is switched off. The sudden collapse of the magnetic field induces a brief high voltage across the coil which is very likely to damage transistors or IC's. The protection diode allows the induced voltage to drive a grief current through the coil (and diode) so the magnetic field dies away quickly rather than instantly. This prevents the induced voltage becoming high enough to cause damage to transistors or IC's.
Advantages of relays:
Relays can switch AC and DC, transistors can only switch DC.
Relays can switch high voltages, transistors cannot.
Relays are a better choice for switching large currents (>5A).
Relay can switch many contacts at once.
Disadvantages of relays:
Relays are bulkier than transistors for switching small currents.
Relays cannot switch rapidly, transistors can switch many times per second.
Relays use more power due to the current flowing through the coil.
Relays require more current than many IC's can provide, so a low power transistor may be needed to switch the current for the relay's coil.
Connecting a transistor to the output from an IC:
Most ICs cannot supply large output currents so it may be neccessery to use a transistor to switch the larger current required for output devisec such as lamps, motors and relays. The 555 timer IC is unusual because it can supply a relatively large current of up to 200mA which is sufficient for some output devisec such as low current lamps, buzzers and many realy coils without needing to use a transistor.
A resistor R.B is required to limit the current flowing into the base of the transistor and prevent it being damaged. However, R.B must be sufficiently low to ensure that the transistor is thoroughly saturated to prevent it overheating. A safe rule is to make the base current I.B about five times larger than the value which should just saturate the transistor.
Choosing a suitable NPN transister:
The circuit diagram shows how to connect an NPN transister, this will switch on the load when the IC output is high.
This is how to choose a suitable switching transister:
The transistors maximum collector current Ic (max) must be greater than the load current Ic. load current Ic = supply voltage Vs / load resistance R.L
The transisters minimum current gain h.FE (min) must be atleat five times the load current Ic devided by the maximim output current from the IC. h.FE (min) > 5 * (load current Ic / max. IC current)
Choose a transistor which meets these requirements and make a note of its properties: Ic (max) and h.FE (min).
Calculate an appropiate value for the base resister: R.B = (V.c * h.FE) / 5 * Ic (where Vc = IC supply voltage).
Then choose the nearest standard value for the base resister.
Choosing a suitable PNP transister:
The circuit diagram shows how to connect a PNP transistor, this will switch on the load when the IC output is low.
A transistor inverter (NOT gate):
Inverters (NOT gate) are availabkle on logic ICs but if you only require one inverter it is usually better to use this circuit. The output (voltage) is the inverse of the input signal:
When the input is high the output is low.
When the input is low the output is high.
Thats all about transistor circuits I need to know to be able to soon hack into my RC car.
Heres the link were I found all the information on transistors -
http://www.kpsec.freeuk.com/trancirc.htm
While going through the "What's a Microcontroller" book, I was looking as some electronics junk and was soldering out some components that I knew that would would need for the future, for example, some small motors from a cd player and some LED's. However, it was quite difficult for me to take them out without having a device that would hold my circuit, while I was heating up the solder on the circuit and pulling out the actuall component out of the circuit on the other side. So instead of just buying a circuit holder, I decided to make one out of all the electronic things I have around me. So far I made the lamp that would make sure I have anouph light while I'm unsoldering or soldering components, and also a small compartement that would hold a wet sponge for me to cleen the soldering iron with.
I designed the circuit such way so that all the extra parts, such as the light and the sponge holder were detachable.
Side view of circuit holder, with a cup to show the scale.
Top view.
Top view. Light and sponge compartement detached.
Here is a vedeo that will explain everying and show you how it woks -
Storing and Retrieving sequence of Musical notes:
A good way of saving musical notes is to store them in the EEPROM. (Electrically Erasable Programmable Read-Only Memory). To do this use the DATA diractive.
Syntax for the DATA diractive -
Symbol} DATA {Word} DataItem {, {Word} DataItem,...}
Here is an example of how to use the DATA diractive to store the characters that corespond to musical notes:
Notes DATA "C","C","G","G","A","A","G"
You can use the READ command to acces these characters. The letter "C" is located at addreaa Notes + 0, and a second letter "C" is located at Notes + 1, and so on. For example, if you want to load the last letter "G" into a byte variable called noteLetter, use the cammand:
READ Notes + 6, noteLetter
You can also store lists of numbers using the DATA diractive. Frequency and duration values that the BASIC Stamp uses for musical notes need to be stored in word variables because they are usually greater than 225. This is how to do that with a DATA diractive.
Frequencies DATA Word 2093, Word 2093, Word 3136, Word 3136,
Word 3520, Word 3520, Word 3136
Because each of these values occupies two bytes, accesing them with the read command is different from accessing characters. The first 2093 is at Frequencies + 0, but the second 2093 is located at Frequencies + 2. The first 3136 is located at Frequencies + 4, and the second 3136 is locaded at Frequencies + 6.
Here is a FOR...NEXT loop that places the Notes DATA into a variable called noteLetter, then it plasec the Frequencies DATA into a variable named noteFreq -
FOR index = 0 to 6
READ Notes + index, noteLetter
READ Frequencies + (index * 2), Word noteFreq
DEBUG noteLetter, " ", DEC noteeq, CR
NEXT
Here's an example program that demonstrates how to use the DATA directive to store lists and how to use the READ command to access the valuin that list.
Coding:
Video of TwinklTwinkle:
A better system for storing and retrieving music:
By using Bytes, instead of Words, you can write programs that store twice as much music in the BASIC Stamp.
Here's an eample that introduces how to store musical information in a way that relates to the concepts of notes, durations and rests. Tempo is also introduced. Only the note characters are stored in the Notes DATA directive because LOOKUP and LOOKDOWN commands will be used to be match up letters to their corresponding friequencies.
Notes DATA "C","D","E","C","C","D","E","C","E","F","G","E","F","G","Q"
Durations DATA 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 2
WholeNote CON 2000
The first number in the Durations DATA directive tells the program how long the first note in the Notes Data directive should last. The second duration is for the second note, and so on.
Here's a list of what each duration means:
1 - whole note
2 - half note
4 - quarter note
8 - eighth note
16 - sixteenth note
32 - thirty-second note
Ater each value is read from the DurationsDATA diractive, it is devided into the WholeNote value to get the Duration used in the FREQOUT command.
The "Q" in the Notes DATA is for quit, and a DO WHILE...LOOP checks foe "Q" each time through the loop. You can insert a rest between notres by inserting a "P".
When you use the lower-case version of the note, it will play a flat note. For example, if you want to play B-flat, use "b" instead of "B".
Example Program - Frere Jacques.
Coding:
Video:
How does it all work:
The Notes and Durations DATA directives combined with the WholeNote constant are used to store all of the musical data used by the program.
Even though a FOR...NEXT loop is no longer used to access the data, there still has to be a variable (index) that keeps track of which DATA entry is being read in Notes and Durations. The offset variable is used in the LOOKDOWN and LOOKUP commands to select a particular value. The NoteLetter variable stores a character accessed by the READ command. LOOKUP and LOOKDOWN commands are used to convert this character into a friequency value. This value is stored in the NoteFreq variable and used as the FREQOUT command's Freq1 argument. The noteDuration variable is used in a READ command to recieve a value from the Durations DATA. It is also used to calculate the Duration used in the FREQOUT command.
The main loop keeps executing until the letter 'Q' is read from the Notes DATA.
A READ command gets a character from the Notes DATA, and stores it in the noteLetter variable. The noteLetter variable is then used in a LOOKDOWN command to set the value of the offset variable. Remeber that offset stores a 1 if "b" is detected and a 2 if "B" is detected and a 3 if "C: is detected and so on. The offset value is then used in a LOOKUP command to figure out what the value of the noteFreq variable should be. If offset is 1, noteFreq will be 1865, if offset is 2, noteFreq will be 1976 and so on.
The READ command uses the value of index to place a value from the Durations DATA into noteDuartion.
READ Durations + index, noteDuration
Then, noteDuration is set equal to the WholeNote constant devided by the noteDuration. If note duration starts out as 4 from a READ command, it becomes 2000 / 4 = 500. If noteDuration is 8, 1500 / 8 = 250.
noteDuration = WholeNote / noteDuration
Now that noteDuration and noteFreq are determined, the FREQOUT command plays the note.
FREQOUT 9, noteDuration, noteFreq
Each time through the main loop, the index value must be increased by one. When the main loop gets back to the beggining, the first thing the probram does is read the next note, using the index variable.
index = index + 1
LOOP
I had a few problems with that one - I didnt really understand it at first. But after reading it a couple times, I'm starting to understand it more and know whats going on.
Entering musical data is much easier when all you have to do is record notes and durations.
I editted the last program to play Beethoven's Fifth Symphony, just by replacing the notes and durations DATA diractives.
Adding Musical Features:
Cell phones that play musi to let you know that someone is calling have three features that were not supported by the previouse section:
The play "dotted" notes.
They determine the whole note duration from a value called tempo
They play notes from more than one octave.
The term "dotted" refers to a dot used in sheet music to indicate that a note should be played 1.5 times as long as its normal duration. In this example, a zero means there is no dot white a 1 means there is a dot:
Dots DATA 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0
Cell phones typically take the tempo for a song in beats per minute. This is the same as saying quarter notes per minute.
BeatsPerMinute CON 200
CELL PHONE RINGTONES:
One of the most widely used way of composing, recording and posting notes is one that features strings of text that describe each note in the song. Haere is an example of how the first few notes from Beethoven's 5th look like in RTTTL format:
Beethoven5:d=8,o=7,b=125:g,g,g2d#,p,f,f,f,2d
This format for storing musical data is called RTTTL, which stand for Ringing Tone Text Transfer Language.
RTTTL Ringtone Player Application Program
This application program is pretty long; in the book they said I can download it from the parralax site, but I couldnt find it so I had to write the whole thing.
Reveille Video:
Coding:
I changed the song in the coding by simply replacing the RTTTL_File DATA directive with different strings of coding.
JollyGoodFellow video:
OK thats done with Music, I have like two more chapters to post up.
Hope you enjoyed it!
To be honest, this was the hardest chapter so far and I think it would be a good idea to get back to it when I finish the book to the end. I think it was so hard because there were so many new commands and rules introduced.
So I'll start from the basics.
The rate of high/low signals sent to the speaker from the microcontroller is called the frequency - it determines the tone or pitch of the beep.
Each time a high/low repeats itself is called a cycle - Number of cycles per second (reffered to as Herts, Hz)
The Piezoelectric speaker:
In this activity I will be experimenting with sending some different signals to the Piezoelectric speaker.
Piezoelectric Speaker Schematic symbol and drawing.
First of all, I built this simple circuit -
How does the Piezo Speaker work?
When a guital string vibrates it causes change in air pressure, and these changes in air pressure are what your ear detects as a tone. The faster the change in air pressure the higher the pitch, and the slower the change, the lower the pitch.
When high/low signals are applied to the speakers positive terminal, the element inside the piezo speaker, called the piezoelectric element, it vibrates, and causes changes in air pressure.
Programming speaker control:
The FREQOUT command is a convenient way of sending high/low signals to a speaker to make sound.
FREQOUT command syntax -
FREQOUT Pin, Duration, Freq1 {, Freq2}
Pin - Value you can use to choose what I/O pin to use.
Duration - Value that tells the FREQOUT command how long the tone should play for (in milliseconds).
Freq1 - Argument is used to set the frequency of the tone, in Herts.
Freq2 - An optional Freq2 argument that can be used to mix frequencies.
This is the first test that I did on a Piezoelectric Speaker -
And the coding -
Here are a fiew ActionTones -
Coding -
Mixing Tones:
When you mix 2000 Hz with 20001 Hz, the tone will fade in and out once every second, at a frequency of 1 Hz. If you mix 2000 Hz with 2002 Hz, it will fade in and out twice a second, and so on.
Mixing Tones Video -
Coding for MixingTones -
I did some programming on that but whats coming up next is the real stuff so check it out -
Musical Notes and Songs:
This is basically an electronic piano. Rightmost piano keys and their frequencies.
With this, you can create any song, using the FREQOUT command.
Here's some music for you -
DoReMiFaSolLaTiDo:
Coding -
This is the part that gets pretty complicated, but its pretty cool -
Storing and Retrieving sequence of Musical notes:
A good way of saving musical notes is to store them in the EEPROM. (Electrically Erasable Programmable Read-Only Memory). To do this use the DATA diractive.
Syntax for the DATA diractive -
{Symbol} DATA {Word} DataItem {, {Word} DataItem,...}
Here is an example of how to use the DATA diractive to store the characters that corespond to musical notes:
Notes DATA "C","C","G","G","A","A","G"
This is what I put up so far today, I'll put up the rest later or another day.
Hi everyone!
Here I'm going to show you how I leared how to make a simple light meter with a 7-segment LED display, a photoresister, a capacitor and resistors.
On the way I learned some programming tricks that saves time and prevents typing error. I learned how to use subroutines. A DO...LOOP is usually called the main routine because all the main activity happens in it.
PBASIC has some commands that can be used to make the program jump out of the main routine, do a job, and then return right back to the same spot in the main routine. This will allow me to keep each segment of code that does a particular job somewhere other than the main routine. This process is called executing a subroutine.
Here's an example -
DO
GOSUB Subroutine_Name
DEBUG "Next command"
LOOP
Subroutine_Name:
DEBUG "This is a subroutine..."
PAUSE 3000
RETURN
The command GOSUB Subroutine_Name causes the program to jump to the Subroutine_Name: label. When the program gets to that label, it keeps running and exicuting commands untill it gets to a RETURN statement. Then the program goes back to the command that comes after the GOSUB command.
Now I'm going to show you how I programmed the light meter using subroutines.
Here is the programming text -
This is how it works -
Variable declaration:
I think its always best to declair variables (and constants) at the beggining of the program.
Initializing:
This is the section where things have to be done once at the beggining of the program.
Get_RC_Time:
This takes the RC time measurement on the photoresister circuit. This subroutine has a PAUSE command that charges up the capacitor and the time period to charge up the capacitor is very small. The RCTIME command sets the value of the time variable. This value is then used by the second subroutine.
Delay:
All this subroutine does is contain a PAUSE.
Update_Display:
The LOOKUP command in this subroutine contains a table with six bit patterns that are used to create the circular pattern on the display. By adding one to the index variable each time the subroutine is called, it causes the next bit patern in the sequence to get placed in OUTH.
I could change the speed of the light spinning by either changing the programmin or replacing the capacitor with a smaller one.
Hi everyone!
I just finished with the 'Measuring Light' chapter from my microcontroller book. This chapter was really great, I really enjoyed experimenting with the sensor and mostly liked building the Light Meter. Sounds cool right? But before I post up anything about the Light Meter, I'm going to show you some of the graphs that my Basic Plot Lite plotted for me when varying the light intensity on the photoresister. (Yes I finally got it all to work). So here are some graphs -
First of all, here's the coding I used to run and plot the data. (This gives me an idea - from now on instead of pasting the programming I'll print screen).
Here's a test graph - just messing around with the light.
I have gradually decreased the light intensity falling on the photoresister, meaning I'm increasing the resistance - increasing the RC-time. Then I'm slowly increasing the light intensity, and then quickly moving my hand on and off the photoresister (thats why I got those sharp peaks).
Here's another graph.
On the next post I'll post up all the other projects I did with the photoresister.
In the past couple of days, I have been having some problems with matching the COM (Communication Port) number on the Debug Terminal with the COM number on the Basic Plot Lite program. The Debug Terminal only gave me an option of COM 10, where Basic Plot Lite only gave me options of COM 1 to COM 4, therefore I could not get the program to plot my data that I have collected with a photoresister using a RC circuit.
So I upgraded the Basic Plot Lite program to see if the newer version gave me more COM options. Unfortunately, the new version only gave me option to COM 9.
After messing around with the settings in some hope that my options would be in a wider range, Mark (my brother) gave me this advice to simply change the USB port that I'm connecting the serial cable in. With exitement, after having to download all the programs on a different computer I finally managed to get COM 4, allowing me to now finally use the Basic Plot Lite program and visually see my data on a graph.
Hi, I took apart the old radio controlled car and the circuit does not look to complicated. It has one chip - TOSHIBA 8752U
T 8 1 4 0
M*SIA
Looks like it has loads of capacitors and tronsistors and some sort of a electromagnet. Im gonna check out, and try and get some information on the chip and see if it is programmable.
I completed the Digital Display chapter. I had so much fun in this chapter and I would like to share some of the projects that I did.
First i'll give you some information and facts about 7-segment LED displays.
A 7–segment display is a rectangular block of 7 lines of equal length that can be lit selectively to display digits and some letters.
Here are two pictures of how to work the display and the schematic for the 7-segment.
Pin numbers.
Schematic drawing for 7-segment LED display.
The Common Cathode means that all the cathodes (negative connection) are connected together (they share a common connection point).
Some interesting facts –
- The 7-segment LED display is called a parallel device because you have to use more than one I/O line at a time to send data to the device.
- The wires that transmit the HIGH/LOW signals from the BASIC Stamp to the 7-segment LED display are called a parallel bus.
I’m going to show you now how to display some digits:
- There are 8 different BASIC Stamp I/O pins that send high/low signals to the 7-segment LED display
REMINDER:
8 bits: A binary number that has 8 digits is said to have 8 bits. Each bit is a slot where you can store either a 1 or a 0.
A byte is a variable that contains 8 bits.
Special Variables: DIRH – A variable that controls the direction (input or output) of I/O pins P8 through P15. OUTH – Controls the high or low signals that each I/O pin sends.
Here is a program that displays the digits 0 through 9 on the display -
Schematic diagram for the 7-segment LED display.
The video –
How it works:
OUTH = 000000 initially turns off all the LED’s. (8 zero’s because there are 8 sets of I/O pins; P8 through P15)
DIRH = %11111111 sets all I/O pins P8 through P15 to outputs.
*The % is used to tell the BASIC Stamp Editor that the number is a binary number. Example: The binary number 001100 is the same as the decimal number 12.*
*All BASIC Stamp I/O pins start out as inputs.* - This is called a “default”. You have to tell a BASIC Stamp I/O pin to become an output before it starts sending a high or low signal.
I then spelt out A through F –
A through F video –
After I learned how to display numbers and letters and decided to experiment and spell something out of my own –
I spelt out ‘Richard is cool’. Here is the video –
Watch the video –
Notice I added a full stop at the end and did a blink at the O’s, I did those by my self.
I then learned how to make things easier with the LOOKUP command, that let’s you ‘look up’ elements in a list.
Example –
LOOKUP index, [ 7, 85, 19, 167, 28], value
2 variables – index and value.
If the index is 0, value stores the 7.
If index is 1, value stores 85, and so on.
I was then introduced to the LOOKDOWN command that gives you an index based on a number (the opposite to LOOKUP).
So in the previous programs instead of writing a whole huge list one by one what I want to spell out, I can just write a list of the numbers or letters that I’m going to be using, and then write in square brackets what I want to say, and the LOOKUP command will see in order what letter I want to spell, lets say A, so it goes and looks for the letter A in the list, reads the binary code and flashes it out. This saves time and prevents mistakes to be done in writing the binary code over and over. You will see this in the FISH CHIP And dIP example.
In this program I spelt out FISH CHIPS And dIP using the LOOKUP command. -
Here’s the Video –
Oh yeah, here’s a picture of my work station :). Notice the awesome Norway picture on the right guy’s! And I got a small shelf for my components, it’s under the speaker and it cost only £1.25 from the charity shop, it smells a bit like electricity ;) – I just have to put labels and start using it.
Hey Richard, Loved your last blog post - we're all looking forward to the videos! The easiest way to include a video in you blog post is to first upload it onto youtube (you know how to do that right - should be pretty simple...)
Then you go on the You tube page. Look in the area that the arrow in the image below is pointing at.
On the very bottom of that area there is the word "Embed" followed by a string of html code. Copy this code and paste it into the place in your blogg you want your video to go. Thats it! HEre look - I tried it with the video you sent us about the "sixth sense":
BTW really liked the video! Really glad to see you are watching TED lectures. Loads more can be found on the official website: www.ted.com (usually they are up on youtube as well). Hey, how about the next time you see a cool vid - find it on youtube and embed it here for all of us to comment on it (including your own comments as well)...!?
Hi, here are a few projects that I programmed using the BASIC Stamp Homework Board (PARALLAX).
The first couple projects are going to involve a Servo (Parallax Standard Servo). I’m going to show you how it works and how to program it.
A Servo is controlled by very brief high signals. They are sent every 20 ms.
The PULSOUT command can be used to send a pulse.
A command syntax for the PULSOUT command –
PULSOUT Pin, Duration.
- The Pin argument is a number that tells the BASIC Stamp which I/O the signal is sent out.
- The Duration argument is not in milliseconds. The Duration is a number of 2-millionth-of-a-second (µs) time durations that you want the high signal to last.
To make the servo rotate properly I had to convert from milliseconds to a Duration that I can use for the PULSOUT.
Duration = number of ms x 500
Duration of a mystery PULSOUT –
Number of ms = Duration / 500 ms
PULSOUT Duration – values between 500 and 1000
Number of pulses - values between 1 and 65534
I did some projects that involved entering the PULSOUT Duration value and the Number of pulses on the Debug Terminal, which read the values and sent pulses to the verto and moved it for a very brief moment like a pulse.
Because the verto has certain limits, it is important to give the PULSOUT Duration and the pulses in the given range or the verto can be damaged. So I added additional lines in my programming so that if a value was given outside its range, a message would show up on the Debug Terminal that the value is too high or too low. I thought this was pretty cool.
Here is the programming text to control the limits -
I wrote a program that would control how fast the servo in rotating.
You can use a FOR…NEXT loop to make a servo sweep through its range of motion like this:
FOR counter = 500 TO 1000
PULSOUT 14, counter
PAUSE 20
NEXT
FOR…NEXT loops have an option STEP argument. The STEP argument can be used to make the servo rotate faster. For example, you can use the STEP argument to add 8 to counter each time through the loop (instead of 1) by modifying the FOR statement like this:
FOR counter = 500 TO 1000 STEP 8
I made the servo rotate in the opposite direction by counting down. I made the StartValue argument smaller than the EndValue argument:
FOR counter = 1000 TO 500 STEP 8
I then made it rotate faster by increasing the STEP argument:
FOR counter = 500 TO 1000 STEP 20
After having fun with all of that I made the servo rotate using a potentiometer. It’s kind of like a wheel of a micro controlled car. When I rotated the variable resister clockwise, the verto turned clockwise and when I turned the variable resister anticlockwise the verto turned anticlockwise.
Programming for ControlServoWithPot:
This was pretty complicated. First of all I had to see what the smallest and largest value of the time variable was for my pot. I did this by connecting it with a capacitor and a resistor. As I turned the pot, the Debug Terminal told me what the time variable was when my pot was fully turned clockwise: (1)
and fully turned anticlockwise: (623)
Now that I got these values, I had to adjust them so they match to the values of 500 and 1000 that are needed to control the servo with the PULSOUT command. To do this I had to use multiplication and addition. I had to multiply the input values (1 and 623) by something to make the difference between the clockwise and anticlockwise values 500 instead of 622.
Here’s the math work for the multiplication (scaling):
Time (max) = 623 x (500/623) = 500
Time (min) = 1 x (500/623) = 0.803
After these values were scaled, I had to do the offset step:
Time (max) = 500 + 500 = 1000
Time (min) = 0.803 + 500 = 500
The */ operator is built into PBASIC for scaling by fractional values, like 0.803. Here are the steps for using */ applied to 0.803 –
1. Place the value or variable you want to multiply by a fractional value before the */ operator.
time = time */
2. Take the fractional value that you want to use and multiply it by 256 (I HAVE NO CLUE WHY THAT SPECIFIC NUMBER HAS TO BE MULTIPLIED BY THE FRACTION)
new fraction value = 0.803 x 256 = 205.568
3. Round off to get rid of anything to the right of the decimal point.
New fraction value = 205
4. Place that value after the */ operator.
time = time */ 205
Now that the scaling is done I just I just have to add the offset of 500.
time = time */ 205
time = time + 500
Now, time is ready to be recycled into the PULSOUT command’s Duration argument.
time = time */ 205
time = time + 500
PULSOUT 14, time
Video of ControleServoWithPot:
To make things more interesting I added the Bi-colour LED circuit to it. When I turned the pot (variable resister/ potentiometer) clockwise the LED shined red and green when the pot was turned the other way.