04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

HPWM<br />

<strong>Syntax</strong><br />

hpwm pin,period,duty{,wait}<br />

• Pin - hardware capable PWM pin number. See the HPWM Capable Pins Table below.<br />

• Period - the time in clock cycles for a single pulse (high and low part).<br />

• Duty - the time in clock cycles for the high side of the pulse.<br />

Commands<br />

• Wait - an optional boolean (true or false) argument that will cause the command to wait until the<br />

current pulse has fi nished before setting the new period and duty. This eliminates the possibility<br />

of a glitch in the pulses.<br />

Supported<br />

• BA - Supported.<br />

• BAN - Supported.<br />

• BAP - Supported.<br />

• BAP40 - Supported.<br />

HPWM Capable Pins<br />

Processor Pins<br />

Nano 18 P3<br />

Nano 28 P9 / P10<br />

Nano 40 P9 / P10<br />

Atom 24m P9 / P10<br />

Atom 28m P9 / P10<br />

Atom 40m P9 / P10<br />

AtomPro One P4 / P5 / P6<br />

AtomPro 24m P10 / P11 / P12<br />

AtomPro 28m P10 / P11 / P12<br />

AtomPro 40m P9 / P10 / P11 / P13 / P14 / P15<br />

Description<br />

The HPWM command generates a pulse width modulated signal. HPWM is based on internal<br />

hardware and is processor independent. Meaning it will run in the background while your program<br />

performs additional tasks. HPWM has several uses, some of which include generating an analog<br />

voltage, DC motor control, servo control or generating a frequency.<br />

To create an analog voltage the pin is transitioned from high to low quickly. During the transitions<br />

leaving the pin high for a certain amount of time versus low and then averaging the output will cause<br />

a voltage change. If the pin was high (5V) 50% of the time and then low (0V) the other 50% of the<br />

time, the voltage output would be around 2.5V. By adjusting the ratio of how long the pin is high<br />

versus low we can control the output voltage with a simple RC circuit.<br />

116

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!