Component: HBRIDGE (CAL) (Peripheral CAL)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 2.1 (Release)
Category Peripheral CAL


Image HBRIDGE (CAL) component

CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the H-Bridge peripheral. Currently only supports compatible 8-bit PIC devices.


Detailed description

Half Bridge Application

A Half Bridge type output has two output signals A and B.

HB Schematic.jpg


Full Bridge Application

Full Bridge type output has four output signals A, B, C and D.

FB Schematic.jpg


Examples

A simple proof of concept example to drive a full bridge output with varying speed and direction.

FC6 Icon.png PIC16F1937 H-Bridge Example

FC6 Icon.png PIC16F18877 H-Bridge Example

Downloadable macro reference

Disable

Disable this PWM Channel

Parameters

This macro has no parameters


Return value

This call does not return a value


Enable

Enable this PWM Channel

Parameters

This macro has no parameters


Return value

This call does not return a value


SetSpeed

Sets the motor speed by varying the PWM duty.

Parameters

UINT duty
Duty value 0 - 1023


Return value

This call does not return a value


SetDirection

Set the motor direction.

Parameters

BYTE direction
0 = Forwards, 1 = Reverse


Return value

This call does not return a value


Simulation macro reference

GetValue

Returns Named property Value

Parameters

STRING Name


Return value

STRING


SetValue

Sets the Value of the property

PERIOD, PRESCALE or CHANNEL

(if CHANNEL also updates the PORT from FCD)

Parameters

STRING Name
STRING Value


Return value

This call does not return a value


GetList

Returns CHANNEL or PRESCALE list from the FCD

and updates the internal property

Parameters

STRING Name


Return value

STRING



Property reference

Channel

This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.

PWM Channel selector

Mode

This property is of type Fixed list of ints and can be referenced with the variable name Mode.

Selects between full bridge and half bridge output modes.

Some H-Bridge channels may only have one mode in which case the property selector will only show the available mode

Polarity

This property is of type Fixed list of ints and can be referenced with the variable name Polarity.

Selects the active output voltage.

Active high - Pins will be low when inactive and high when active.

Active Low- Pins will be high when inactive and low when active.

Timer

This property is of type Fixed list of ints and can be referenced with the variable name timer.

Timer associated with PWM to drive the output.

Warning - All PWM channels linked to the same timer will share the same period and prescaler settings.

Prescaler Divide

This property is of type Fixed list of ints and can be referenced with the variable name PRESCALE.

Prescaler Divider value

Period Register

This property is of type Signed integer and can be referenced with the variable name PERIOD.

PWM Period Register value

Rising Bits

This property is of type Unsigned integer and can be referenced with the variable name RisingBits.

Number of bits assigned to the rising edge dead band counter.

Auto populated based on selected target chip.

Falling Bits

This property is of type Unsigned integer and can be referenced with the variable name FallingBits.

Number of bits assigned to the falling edge dead band counter.

Auto populated based on selected target chip.

Rising Count

This property is of type Unsigned integer and can be referenced with the variable name RisingCount.

Number of cycles to wait after a falling edge and before a rising edge.

Falling Count

This property is of type Unsigned integer and can be referenced with the variable name FallingCount.

Number of cycles to wait after a rising edge and before a falling edge.

A Pin

This property is of type Single digital pin and can be referenced with the variable name A_Pin.

Output Pin A

B Pin

This property is of type Single digital pin and can be referenced with the variable name B_Pin.

Output Pin B

C Pin

This property is of type Single digital pin and can be referenced with the variable name C_Pin.

Output Pin C

D Pin

This property is of type Single digital pin and can be referenced with the variable name D_Pin.

Output Pin D

A Remap Pin

This property is of type Fixed list of ints and can be referenced with the variable name A_RemapPin.

Remap Pin A - Specifies the pin used for the A output.

Only available on devices supporting remappable hardware pins.

B Remap Pin

This property is of type Fixed list of ints and can be referenced with the variable name B_RemapPin.

Remap Pin B - Specifies the pin used for the B output.

Only available on devices supporting remappable hardware pins.

C Remap Pin

This property is of type Fixed list of ints and can be referenced with the variable name C_RemapPin.

Remap Pin C - Specifies the pin used for the C output.

Only available on devices supporting remappable hardware pins.

D Remap Pin

This property is of type Fixed list of ints and can be referenced with the variable name D_RemapPin.

Remap Pin D - Specifies the pin used for the D output. Only available on devices supporting remappable hardware pins.

Clock Speed

This property is of type Signed integer and can be referenced with the variable name CLK_SPEED.

Target Microcontroller Clock Speed.

Period (uS)

This property is of type Floating point and can be referenced with the variable name CALC_PERIOD.

Calculated length of PWM period in micro seconds.

Frequency (KHz)

This property is of type Floating point and can be referenced with the variable name CALC_FREQ.

Calculated PWM output frequency in KHz.

Frequency (Hz)

This property is of type Floating point and can be referenced with the variable name CALC_FREQ2.

Calculated PWM output frequency in Hz.