130-28176 Parallax Inc, 130-28176 Datasheet - Page 154

KIT PARTS PROCESS CONTROL

130-28176

Manufacturer Part Number
130-28176
Description
KIT PARTS PROCESS CONTROL
Manufacturer
Parallax Inc
Datasheets

Specifications of 130-28176

Accessory Type
Education Kit
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Board of Education Full Kit
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Example Program PwmTest.bs2
' -----[ Title ]-----------------------------------------------------------
' Process Control -
' Uses Pulse Width Modulation to control fan speed
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Declarations ]----------------------------------------------------
Opto_SW
Fan
Opto_Count
RPM
SP_Data
CyclesPerRev
Duty
Max_Count
Per_RPM
x
' -----[ Initialization ]--------------------------------------------------
PAUSE 500
' -----[ Main Routine ]----------------------------------------------------
GOSUB Calibrate
DO
LOOP
' -----[ Subroutines ]----------------------------------------------------
Apply_Drive:
FOR Duty = 100 TO 0 STEP 10
NEXT
DEBUG "!TEXT (PTIME),98A,0.8A,(BLACK),",DEC Duty,CR
GOSUB Apply_Drive
COUNT Opto_SW,100,opto_count
Per_RPM = Opto_Count * 100 / Max_Count
DEBUG DEC Duty,",",DEC Per_RPM ,CR
FOR x = 1 TO 15
IF duty > 0 THEN HIGH Fan
DEBUG IBIN OUT2,CR
PAUSE Duty
Attach the 4-cycles/revolution encoder to the fan (cut-outs can be found in
Appendix A.
Enter, save and run PwmTest.bs2, then close the Debug Terminal.
PIN
PIN
VAR
VAR
VAR
CON
VAR
VAR
VAR
VAR Byte
PwmTest.bs2
8
2
Word
Word
Word
4
Byte
Word
Word
' Opto-Reflector
' Fan drive pin
' Count from opto-reflective switch
' Calculated RPM
' Data returned from StampPlot
' Encoder used
' Duty cycle value 0-255
' Maximum count for calculating Per_RPM
' Percent of RPM 0-100
' General counting variable
' Connection stabilizing time
' Apply drive with a 100msc period
' Apply for 15 repetitions
' Check if any HIGH time
' Plot digital state of drive
' Apply for amount of high time
' Drive PWM from 100% to 0%
' Measure counts for 100mSec
' Calculate percent RPM
' Plot data
' Label plot

Related parts for 130-28176