Example, Io_set_terminal_count( ) built-in function, Syntax – Echelon Neuron C User Manual

Page 125

Advertising
background image

Neuron C Reference Guide

105

Example

IO_0 output bit b0;
IO_0 input byte byte0;
int read_byte;

void f(void)
{
io_set_direction(b0,

IO_DIR_OUT);

io_out(b0,

0);

io_set_direction(byte0); // Defaults to IO_DIR_IN

read_byte = io_in(byte0);

}

io_set_terminal_count( )

Built-in Function

The io_set_terminal_count( ) built-in function allows the application to change

the terminal count for the stretched triac I/O object at runtime. This function

allows a device to:

• Have a single application for both 50 Hz and 60 Hz power domains
• Operate at a non-standard power line frequency
• Provide higher-than-typical tolerances to changes in frequency

The application can determine the current values for frequency at runtime, and
use this function to adjust the triac on-time as needed.
See the

I/O Model Reference

for more information about the stretched triac

model.

Syntax

void io_set_terminal_count (

io-object-name

,

terminal_count

);

io-object-name

The I/O object name that corresponds to

io-object-name

in

the I/O declaration. This built-in function is used only for

the stretchedtriac direct I/O object.

terminal_count

A value from 0 to 193 for triac devices running with 50 Hz
AC power, or a value from 0 to 160 for triac devices

running with 60 Hz AC power. This value represents the

amount of stretching for the triac trigger pulse within the
half-cycle. Specify this value to calibrate the triac device.

Example

IO_0 output stretchedtriac sync (IO_5) frequency(60)
ioTriac;

when (...) {
io_out(ioTriac, 160); // full on
}

when (...) {
io_out(ioTriac, 80); // half on

Advertising