Stampworks manual version 1.2




















Certification Consultancy. Hong-Nam Kim. Neelakandan R. Sagar Panda. Sen Ming. Luis Garcia. Comenzi Eastbay. Franz Ortega. Bunga Teratai. Vladimir Arguirov.

More From Documento de Impresora Redirigido de Escritorio Remoto. Popular in Accounting And Audit. Problems - Audit of Prepayments and Intangible Assets. Romaine Salazar. Fadzilah Mohamad. Sarah Shehata. Reniel Eda. Mark Marasigan. Its purpose is to timeformat MMSS the seconds counter and update the current digit. Since the routine can only show one digit at a time, it must be called frequently, otherwise display strobing will occur.

This program will update the display while waiting for other things to happen. Clearing the current segments value keeps the display sharp. If this isnt done, the old segments value will cause ghosting in the display. The StampWorks display does not have the colon : normally found on a digital clock, so well enable the decimal point behind the second digit.

If the current digit is not a second, the decimal point illumination is skipped. The final steps are a short delay so the digit illuminates and the current digit variable is updated. The main loop of this program watches an incoming square-wave signal, produced by the StampWorks signal generator. When this low-to-high transition occurs, the seconds counter is updated. When the seconds counter is updated, the display is refreshed and then the program waits for the incoming signal to go low, updating the display during the wait.

If the program went right back to the top and the incoming signal was still high, the seconds counter would be prematurely updated, causing the clock to run fast. Once the incoming signal does go low, the program loops back to the top where it waits for the next low-to-high transition from the pulse generator.

Challenge If the decimal point illumination is modified as follows, what will happen? Modify and download the program to check your answer. Bit0 ' illuminate decimal point.

Using Character LCDs While LEDs and seven-segment displays make great output devices, there will be projects that require providing more complex information to the user. Of course, nothing beats the PC video display, but these are large, expensive and almost always impractical for microcontroller projects. Character LCD modules, on the other hand, fit the bill well.

Character LCD modules are available in a wide variety of configurations: one-line, two-line and fourline are very common. Screen width is also variable, but is usually 16 or 20 characters for each line. Datasheet is available for download from www. The header is keyed, preventing the header from being inserted upside-down. The projects in this document initialize the LCD in accordance with the specification for the Hitachi HD controller. The Hitachi controller is the most popular available and many controllers are compatible with it.

Modes Of Operation There are two essential modes of operation with character LCDs: sending a character and sending a command. When sending a character, the RS line is high and the data sent is interpreted as a character to be displayed at the current cursor position.

Several standard commands are available to manage and manipulate the LCD display. The connector is keyed so that it is always inserted correctly into the StampWorks lab. Simply align the connector key small bump with the slot in the LCD socket and press the connector into the socket until it is firmly seated.

Ex11 - LCD Demo. Essential LCD control ' Author There is a separate program for the BS2p. Experiment A Basic LCD Demonstration The basics of the initialization are appropriate for most applications: The display is on The cursor is off Display blinking is disabled The cursor is automatically incremented after each write The display does not shift. With the use of four data bits, two write cycles are necessary to send a byte to the LCD.

In this program, characters are written until a zero is encountered. With the message displayed, the cursor position is returned home first position of first line and turned on an underline cursor appears. The cursor is sent back and forth across the LCD using two techniques. The first uses the cursor-right command. Moving the cursor back is accomplished by manually positioning the cursor.

Manual cursor positioning is required by many LCD programs for tidy formatting of the information in the display. With the cursor back home, it is turned off and the blink attribute is enabled. Blink causes the current cursor position to alternate between the character and a solid black box. This can be useful as an attention getter. Another attention-getting technique is to flash the entire display.

This is accomplished by toggling the display enable bit. Using the display shift commands, the entire display is shifted off-screen to the right, then back. What this demonstrates is that the display is actually a window into the LCDs memory.

One method of using the additional memory is to write messages off-screen and shift to them. Building The Circuit Use the same circuit as in Experiment Ex12 - LCD Characters. With the display initialized, custom character data is downloaded to the LCD. The LCD has room for eight, user-definable customer characters. The data is stored for these characters in an area called CGRAM and must be downloaded to the LCD after power-up and initialization custom character definitions are lost when power is removed from the LCD.

Each custom character requires eight bytes of data. The standard LCD font is five bits wide by seven bits tall. You can create custom characters that are eight bits tall, but the eighth line is generally reserved for the underline cursor. Heres an example of a custom character definition:. The shape of the character is determined by the ones and zeros in the data bytes.

One in a given bit position will light a pixel; zero will extinguish it. Before the characters can be used, the display must be returned to normal mode. The usual method is to clear the display or home the cursor. Interestingly, the LCD retrieves the bit patterns from memory while refreshing the display. In advanced applications, the CGRam memory can be updated while the program is running to create unusual display effects.

This code grabs a character from the second message, then, for each character in that message, displays the animation sequence at the desired character location on the second line of the LCD. At the end of the sequence, the new character is revealed. Challenge Create your own custom character sequence.

Update the initialization and animation code to accommodate your custom characters. Ex13 - LCD Read. Read data from LCD ' Author Writing to the LCD was covered in the last two experiments. In most programs this line can be tied low to allow writing to the LCD. In programs that require less than eight custom characters the remaining bytes of CGRAM can be used as off-board memory. Reading data from the LCD is identical to writing: the address is set and the data is retrieved.

For this to take place, the LCD data lines must be reconfigured as inputs. Once again, HighNib and LowNib are used, this time to build a single byte from the two nibbles returned during the read operation.

When the retrieved data is ready, the address, output data and input data are written to the LCD for examination. The 8x10 font allows descended letters g, j, p, q and y to be displayed properly. RW to Vss. Magic 8-Ball simulation ' Author Ask a question, then press the. The program also demonstrates using a 2-Line display as a single-line display with the 5x10 font set.

Behind The Scenes The standard 5x7 LCD font suffers aesthetically when it comes to descended letters, those letters with tails g, j, p, q and y. The nature of the font map causes these letters to be squashed into the display. Many LCDs support a 5x10 character font and provide additional mapping for properly descended characters.

Using the 5x10 font is straightforward; it requires a single additional command in the initialization sequence. To display properly descended characters, however, is a bit trickier since these characters. After initialization, the screen is cleared and the user is prompted to think of a question. When a character is passed to Translate, it is compared to the list of known descended letters. If the character is in this list, it is converted to a value that will be used by the LOOKUP table to re-map the character to the descended version in the LCD font map.

If the character is not in the descended list, it will pass through Translate unaffected. The main loop of the program waits for you to press the button, creating a randomized answer by continuously calling the Shuffle subroutine.

Shuffle updates the answer variable and creates an animated bug. The animation is created with standard characters and updated every 15 cycles through the Shuffle subroutine. Challenge Create custom characters that use the 5x10 font mode.

Note: 16 bytes must be used for each character, even though only ten will be displayed. Moving Forward The first three sections of this manual dealt specifically with output devices, because the choice of output to the user is often critical to the success of a project. From this point forward we will present a variety of experiments -- some simple, others complex which will round your education as a BASIC Stamp programmer and give you the confidence you need to develop your own BASIC Stampcontrolled applications.

Remember, the key to success here is to complete each experiment and to take on each challenge. Then, go further by challenging yourself. Each time you modify a program you will learn something. Its okay if your experiments dont work as expected, because you will still be learning. With modification, any number of inputs from two to 16 can be debounced with this code.

Ex15 - Debounce. Multi-input button debouncing ' Author The ' input subroutine is easily adjusted to handle any number of inputs. To debounce two or more inputs, we need to create a bit of code.

As presented, it will accommodate four switch inputs. It can be modified for any number of inputs from two to Debounced inputs will be retuned in the variable, switches, with a valid input represented by a 1 in the switch position. The ones compliment operator will invert zero to one. One Anded with one is still one, so that switch remains valid. One is inverted to zero. Zero Anded with any number is zero and will cause the switch to remain invalid through the entire debounce cycle.

Challenge Modify the program to debounce and display eight switches. Experiment Counting Events This experiment demonstrates an events-based program delay.

Ex16 - Counter. Counts external events ' Author In an industrial setting, for example, a packaging system we might need to run a conveyor belt until boxes pass. When the line goes high, the counter is incremented and the program waits for the line to go low. When this happens, the code loops back for the next high input. When the target count is reached, the subroutine returns to the main program.

The time spent in the subroutine is determined by the rate of incoming events. Note that the subroutine expects a clean input. A noisy input could cause spurious counts, leading to early termination of the subroutine.

One method of dealing with a noisy input when the time between expected events is known is to add a PAUSE statement after the start of an event. Ex17 - FreqIn1. Frequency input ' Author Experiment Frequency Measurement Behind The Scenes In the previous experiment, several lines of code were used to count pulses on an input pin.

That method works when counting to a specific number. Other programs will want to count the number of pulses that arrive during a specified time period. The frequency of an oscillating signal is defined as the number of cycles per second and is expressed in Hertz. To create a frequency meter, the specified time window is set to milliseconds one second. What other adjustment has to be made?

How does this change affect the ability to measure very low frequency signals? Ex18 - FreqIn2. Frequency Input ' Author Behind The Scenes In the last experiment, you learned that the frequency of a signal is defined as the number of cycles per second. You created a simple frequency meter by counting the number of pulses cycles in one second.

This method works well, especially for low-frequency signals. There will be times, however, when project requirements will dictate a quicker response time for frequency measurement. Experiment Advanced Frequency Measurement The frequency of a signal can be calculated from its period, or the time for one complete cycle. By using PULSIN to measure the high and low portions of an incoming signal, its period can be calculated and the frequency can be determined.

Ex19 - Theremin. Simple Digital Theremin ' Author Experiment A Light-Controlled Theremin Behind The Scenes A Theremin is an interesting musical device used to create those weird, haunting sounds often heard in old horror movies. This version uses the light falling onto a photocell to create the output tone. The constant, Threshold, is used to control the cutoff point of the Theremin. When the photocell reading falls below this value, no sound is played. This value should be adjusted to the point where the Theremin stops playing when the photocell is not covered in ambient light.

Challenge Add a second RC circuit using a 10K pot instead of a photocell. Use this circuit to adjust the threshold value to varying light conditions. Ex20 - Sound FX. Stamp-generated sounds ' Author Its purpose is to play the dual-tones required. Instead of passing a tone or tones , the digit s to be dialed are passed as parameters. In actual dialing applications, the DTMF on-time and off-time can be specified to deal with telephone line quality. Constants for note frequency in the first octave and note timing simplify the operational code.

The musical quality can suffer a bit in the higher octaves because of rounding errors. Using the ideal values shown, the constants table can be expanded to create accurate musical notes. Keep in mind that each octave doubles the frequency of a note. Ex21 - AnalogIn. PULSIN is used to measure the ' high portion of the signal as it is controlled by the varialbe resistance.

Behind The Scenes In this experiment, the is configured as an oscillator. Analyzing the output, the width of the low portion of the output is controlled by the resistance of the photocell. By measuring the low portion of. Once the raw value is available, adding a portion of the raw value with a portion of the last filtered value digitally filters it. The ratio of raw-to-filtered readings in this equation will determine the responsiveness of the filter.

The larger the raw portion, the faster the filter. Challenge Create a final output value that is scaled so that its range is between zero and Note that this circuit requires 12V. Ex22 - Throb. Output a variable voltage with PWM ' Author The PWM function outputs a series of pulses which have a programmable on-time to off-time ratio duty cycle. The greater the duty cycle, the greater voltage output. A duty cycle of will charge the capacitor to five volts.

The opamp buffer prevents the capacitor from discharging too quickly under load. The LED brightness and dims because the changing voltage through its series resistor changes the current through the LED.

Notice that the LED seems to snap on and get brighter, then dim to a level and snap off. Using the digital multimeter, monitor Pin 1 of the LM Three lines are used to control eight LEDs with a 74x shift register.

Ex23 - 74HC Expanded outputs with 74HC ' Author For the most part, microcontroller applications will define pins as either inputs or outputs at initialization and the definitions will remain unchanged through the program. In this experiment, the 74x is used. The 74x converts a synchronous serial data stream to eight parallel outputs. Synchronous serial data actually has two components: the serial data and a serial clock.

With the 74x, the data must be latched to the outputs after the shift process. Latching is accomplished by briefly pulsing the Latch control line.

This prevents the outputs from rippling as new data is being shifted in. Being serial devices, shift registers can be cascaded. To connect cascaded 74xs, the clock and latch lines are all tied together and the SQ output from one stage connects to the serial input of the next stage.

Schematic on the next page Behind The Scenes The 75x has a Serial Output pin 9 that allows the cascading of multiple devices for more outputs. In this configuration, the Clock and Latch pins are shared to keep all devices synchronized.

When cascading multiple shift registers, you must send the data for the device that is furthest down the chain first.

Applying the latch pulse at that point causes the new data in all shift registers to appear at the outputs. The demo program illustrates this point by independently displaying a binary counter and a pingpong visual display using two 75x shift registers and eight LEDs for each. Note that the counter display is controlled by the 75x that is furthest from the BASIC Stamp, so its data is shifted out first. Ex23b - 74HC x 2. The data lines into the second 74HC is fed by the SQh output pin 9 of the first.

The clock and latch pins of the second 74HC are connected to the same pins on the first. Three lines are used to read an eight-position DIP-switch. Ex24 - 74HC Input expansion with 74HC ' Author Note that the DIP-switches are pulled-up to Vdd, so setting them to ON creates a logic low input to the shift register. Schematic on next page Behind The Scenes This program is very similar to 23b in that the Serial Output pin 9 from one shift register is fed into the Serial input pin 10 of the next device up the chain.

Note that the non-inverted output is used on the second 74x because the inverted output of the deice connected directly to the BASIC Stamp will take care of the inversion. Ex24b - 74HC x 2. The serial output pin 9 from one 74HC ' is fed into the serial input pin 10 of the second. Experiment Hobby Servo Control This experiment demonstrates the control of a standard hobby servo.

Hobby servos frequently are used in amateur robotics. Ex25 - Servo. Hobby Servo Control ' Author Behind The Scenes Hobby servos are specialized electromechanical devices used most frequently to position the control surfaces of model aircraft.

The position of the servo output shaft is determined by the width of an incoming control pulse. The control pulse is typically between one and two milliseconds wide.

The servo will center when the control signal is 1. In order to maintain its position, the servo must constantly be updated. The typical update frequency is about 50 times per second. This circuit and the project code can be used to determine the relative position of the potentiometer.

This value is added to the centering position of Negative numbers are stored in twos compliment format. The SDEC signed decimal modifier prints standard decimal with the appropriate sign. Experiment Hobby Servo Control Challenge Replace the potentiometer with two photocells and update the code to cause the servo to center at the brightest light source.

Experiment Stepper Motor Control This experiment demonstrates the control of a small volt unipolar stepper motor. Stepper motors are used as precision positioning devices in robotics and industrial control applications. Ex26 - Stepper. Stepper Motor Control ' Author The pot allows the. For a stepper motor to rotate, the power source must be continuously pulsed in specific patterns.

The step sequence pattern determines the direction of the steppers rotation. The time between sequence steps determines the rotational speed.

Each step causes the stepper motor to rotate a fixed angular increment. The stepper motor supplied with the StampWorks kit rotates 3. This means that one full rotation degrees of the stepper requires steps. The step sequences for the motor are stored in DATA statements.

The StepFwd subroutine will read the next sequence from the table to be applied to the coils. The StepRev subroutine is identical except that it will read the previous step. By adding the maximum value of the sequence to the current value and then applying the modulus operator, the sequence goes in reverse. This experiment reads both sides of the 10K potentiometer to determine its relative position.

The differential value between the two readings is kept positive by using the ABS function. The position is used to determine the rotational direction and the strength of the position is used to determine the rotational speed. Remember, the shorter the delay between steps, the faster the stepper will rotate. Challenge Rewrite the program to run the motor in half steps.

Experiment Voltage Measurement This experiment demonstrates the use of an analog-to-digital converter to read a variable voltage input. Ex27 - ADC Analog to Digital conversion ' Author This is a form of analog input, but isnt voltage measurement. The simplest way to measure a variable voltage is with an analog-to-digital converter.

The nature of the ADC requires nine bits to shift in the result. The eight-bit result will be from zero zero volts to five volts. Dividing five volts by , we find that each bit in the result is equal to For display purposes, the result is converted to millivolts by multiplying by Experiment Temperature Measurement This experiment demonstrates the use of a digital temperature sensor.

Temperature measurement is a necessary component of environmental control applications heating and air conditioning. Ex28 - DS Temperature measurement ' Author Experiment Temperature Measurement Behind The Scenes The largest organ of the human body is the skin and it is most readily affected by temperature.

Little wonder then that so much effort is put into environmental control systems heating and air conditioning. The DS is an intelligent device and, once programmed, is capable of stand-alone operation using the T com , T hi and T lo outputs.

The DS requires initialization before use. After the delay, the DS is instructed to start continuous conversions. Then the latest conversion value is read back. The data returned is nine bits wide. Bit8 indicates the sign of the temperature. If negative sign bit is 1 , the other eight bits hold the twos compliment value of the temperature.

Whether negative or positive, each bit of the temperature is equal to 0. The Celsius temperature is converted to whole degrees by dividing by two. Experiment Advanced 7-Segment Multiplexing This experiment demonstrates the use of seven-segment displays with an external multiplexing controller. Multi-digit seven-segment displays are frequently used on vending machines to display the amount of money entered.

Ex29 - Change Counter. Controlling 7-segment displays with MAX ' Author Bit0 deposit. Bit1 deposit. Bit2 deposit. Bit3 deposit. Bit4 Nib Byte Nib index. Bit0 ' current money count ' coins deposited ' bit values of deposit.

If you use less than eight digits, omit the highest digit numbers. For example, this experiment uses four digits, numbered 0 through 3, not 4 through 7. The MAX has a scan-limit feature than limits display scanning to digits 0 through n, where n is the highest digit number. S ignal. PDF CH Verdeyer - Laser Electronics - Prentice Hall - 3rd. Koch Johnson WW. Darr Sams, WW. Donahue WW. Lurie and Paul J. Thomas Holland.



0コメント

  • 1000 / 1000