| Wheelchair Control MCU firmware

- Main Page
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Enumerations Groups Pages
Files | Data Structures | Macros | Enumerations
Wheelchair control MCU software.

## Files
file | MiscInits.c
file | MiscInits.h
file | SRF08.c
file | SRF08.h
file | UART.c
file | UART.h
file | WheelchairControlMain.c
file | WheelchairControlMain.h

## Data Structures
struct | t_ConfigStruct
struct | t_ISRsSharedStruct

## Macros
#define | GLOBAL_INTERRUPTS_ENABLE() asm("sei")
#define | GLOBAL_INTERRUPTS_DISABLE() asm("cli")
#define | WATCHDOG_RESET() asm("WDR")
#define | WATCHDOG_INITIALIZE() WATCHDOG_RESET(); WDTCR = ( (1<<WDE) | 0x05 )
#define | SRF08_RANGE (2500)
#define | SRF08_GAIN (0x03)
#define | SRF08_LOWEST_ADDR (0xE0)
#define | SRF08_HIGHEST_ADDR (0xE8)
#define | SCL_CLOCK (50000UL)
#define | RIGHT_WHEEL_DIR ( PIND & (1 << PD7) )
#define | LEFT_WHEEL_DIR ( PIND & (1 << PD6) )
#define | RIGHT_WHEEL_STEP ( PIND & (1 << PD3) )
#define | LEFT_WHEEL_STEP ( PIND & (1 << PD2) )
#define | UCHAR_TO_RC_SIGNAL (247)
#define | SPEED_OFFSET (128)
#define | REAR_CORRECTION_OFFSET (128)
#define | REG_OUTPUT_MAX (255)
#define | REG_OUTPUT_MIN (0)
#define | INTEGRATOR_MAX (2550)
#define | INTEGRATOR_MIN (-2550)
#define | F_CPU (16e6)
#define | STEERING_WHEEL_LEFT (FALSE)
#define | LED_IN (1 << PA1)
#define | LED_OUT (1 << PA2)
#define | BLINK_LEDS_MS(DURATION) PORTA |= (LED_IN | LED_OUT); DELAY_MS(DURATION); PORTA &= ~(LED_IN | LED_OUT); DELAY_MS(DURATION)
#define | DELAY_US(DURATION) _delay_us(DURATION)
#define | DELAY_MS(DURATION) _delay_ms(DURATION)
#define | PI_MRAD (3141)
#define | TWO_PI_MRAD (6283)
#define | WHEEL_INCREMENT_SCALE (10)
#define | REG_ANGLE_EPSILON (0.1)
#define | WTEMP_SCALE (10)
#define | OMEGA_SCALE (0.1)
#define | UART_WATCHDOG_TIMEOUT (20)
#define | TIMER_0_RESET() (TCNT0 = 0x00);
#define | TIMER_1_OFF() (TCCR1B = 0x18);
#define | TIMER2_OVF_INT_ENABLE() (TIMSK |= (1<<TOIE2))
#define | TIMER2_OVF_INT_DISABLE() (TIMSK &= ~(1<<TOIE2))
#define | ENCODER_INTERRUPT_ENABLE() (GICR |= (0xC0))
#define | ENCODER_INTERRUPT_DISABLE() (GICR &= ~(0xC0))
#define | SRF08_SAFETY_RANGE (10)
#define | FALSE (0)
#define | TRUE (!FALSE)

## Enumerations
enum | Timer2Intervals
enum | RxPacketByte
enum | TxPacketByte
enum | PacketHeaders

## Detailed Description

This group contains all source files for MCU of the wheelchair.

## Macro Definition Documentation

#define BLINK_LEDS_MS | ( |  | DURATION | ) | PORTA |= (LED_IN | LED_OUT); DELAY_MS(DURATION); PORTA &= ~(LED_IN | LED_OUT); DELAY_MS(DURATION)

Blink LEDs for a specified period.

Definition at line 61 of file Defines.h.

#define DELAY_MS | ( |  | DURATION | ) | _delay_ms(DURATION)

Delay in miliseconds.

Definition at line 66 of file Defines.h.

#define DELAY_US | ( |  | DURATION | ) | _delay_us(DURATION)

Delay in microseconds.

Definition at line 65 of file Defines.h.

#define ENCODER_INTERRUPT_DISABLE | ( |  | ) | (GICR &= ~(0xC0))

Disble encoders interrupt.

Definition at line 95 of file Defines.h.

#define ENCODER_INTERRUPT_ENABLE | ( |  | ) | (GICR |= (0xC0))

Enable encoders interrupt.

Definition at line 94 of file Defines.h.

#define F_CPU (16e6)

CPU freq. 16 MHz.

Definition at line 50 of file Defines.h.

#define FALSE (0)

True.

Definition at line 101 of file Defines.h.

#define GLOBAL_INTERRUPTS_DISABLE | ( |  | ) | asm("cli")

Disable global interrupts.

Definition at line 22 of file Defines.h.

#define GLOBAL_INTERRUPTS_ENABLE | ( |  | ) | asm("sei")

Enable global interrupts.

Definition at line 21 of file Defines.h.

#define INTEGRATOR_MAX (2550)

Maximal integrator value (10 * REG_OUTPUT_MAX).

Definition at line 45 of file Defines.h.

#define INTEGRATOR_MIN (-2550)

Minimal integrator value (-10 * REG_OUTPUT_MAX).

Definition at line 46 of file Defines.h.

#define LED_IN (1 << PA1)

UART in LED.

Definition at line 57 of file Defines.h.

#define LED_OUT (1 << PA2)

UART out LED.

Definition at line 58 of file Defines.h.

#define LEFT_WHEEL_DIR ( PIND & (1 << PD6) )

Direction signal of left wheel at PORTD.6.

Definition at line 35 of file Defines.h.

#define LEFT_WHEEL_STEP ( PIND & (1 << PD2) )

Light wheel STEP signal.

Definition at line 37 of file Defines.h.

#define OMEGA_SCALE (0.1)

Wall-following regulator omega scale to increase resolution.

Definition at line 80 of file Defines.h.

#define PI_MRAD (3141)

Pi in miliradians.

Definition at line 73 of file Defines.h.

#define REAR_CORRECTION_OFFSET (128)

Offset of SRF08 rear correction constant.

Definition at line 42 of file Defines.h.

#define REG_ANGLE_EPSILON (0.1)

Allowed angle regulation error.

Definition at line 78 of file Defines.h.

#define REG_OUTPUT_MAX (255)

Maximal possible output of the speed regulator.

Definition at line 43 of file Defines.h.

#define REG_OUTPUT_MIN (0)

Minimal possible output of the speed regulator.

Definition at line 44 of file Defines.h.

#define RIGHT_WHEEL_DIR ( PIND & (1 << PD7) )

Direction signal of right wheel at PORTD.7.

Definition at line 34 of file Defines.h.

#define RIGHT_WHEEL_STEP ( PIND & (1 << PD3) )

Right wheel STEP signal.

Definition at line 36 of file Defines.h.

#define SCL_CLOCK (50000UL)

I2C serial clock frequency.

Definition at line 31 of file Defines.h.

#define SPEED_OFFSET (128)

Zero speed offset.

Definition at line 41 of file Defines.h.

#define SRF08_GAIN (0x03)

SRF08 gain.

Definition at line 28 of file Defines.h.

#define SRF08_HIGHEST_ADDR (0xE8)

Highest possible address.

Definition at line 30 of file Defines.h.

#define SRF08_LOWEST_ADDR (0xE0)

Lowest possible address.

Definition at line 29 of file Defines.h.

#define SRF08_RANGE (2500)

SRF08 range in mm.

Definition at line 27 of file Defines.h.

#define SRF08_SAFETY_RANGE (10)

Safety range in cm.

Definition at line 98 of file Defines.h.

#define STEERING_WHEEL_LEFT (FALSE)

Determines whether steering wheel of car is situated on the right (UK) or left side (rest of Europe).

Definition at line 54 of file Defines.h.

#define TIMER2_OVF_INT_DISABLE | ( |  | ) | (TIMSK &= ~(1<<TOIE2))

Disable TIMER2 overflow interrupt.

Definition at line 91 of file Defines.h.

#define TIMER2_OVF_INT_ENABLE | ( |  | ) | (TIMSK |= (1<<TOIE2))

Enable TIMER2 overflow interrupt.

Definition at line 90 of file Defines.h.

#define TIMER_0_RESET | ( |  | ) | (TCNT0 = 0x00);

Reset RX timer.

Definition at line 86 of file Defines.h.

#define TIMER_1_OFF | ( |  | ) | (TCCR1B = 0x18);

Turn off R/C signal.

Definition at line 87 of file Defines.h.

#define TRUE (!FALSE)

False.

Definition at line 102 of file Defines.h.

#define TWO_PI_MRAD (6283)

2*pi in miliradians.

Definition at line 74 of file Defines.h.

#define UART_WATCHDOG_TIMEOUT (20)

Watchdog timeout in multiples of 50 ms.

Definition at line 83 of file Defines.h.

#define UCHAR_TO_RC_SIGNAL (247)

Offset to convert 0 - 255 values of unsigned char to 250 - 500 values of OCR1X of RC signal generator (128 + 247 = 375 -> stop motors).

Definition at line 40 of file Defines.h.

#define WATCHDOG_INITIALIZE | ( |  | ) | WATCHDOG_RESET(); WDTCR = ( (1<<WDE) | 0x05 )

Watchdog reset & initialize (reset interval appr. 0.5 s).

Definition at line 24 of file Defines.h.

#define WATCHDOG_RESET | ( |  | ) | asm("WDR")

Reset watchdog.

Definition at line 23 of file Defines.h.

#define WHEEL_INCREMENT_SCALE (10)

Wheel increment scale to improve resolution.

Definition at line 75 of file Defines.h.

#define WTEMP_SCALE (10)

Position regulator omega scale to increase resolution.

Definition at line 79 of file Defines.h.

## Enumeration Type Documentation

enum PacketHeaders

Communication packet identifier bytes enum.

Definition at line 143 of file Defines.h.

enum RxPacketByte

UART Rx packet bytes enum.

Definition at line 118 of file Defines.h.

enum Timer2Intervals

Timer 2 time intervals enum.

Definition at line 107 of file Defines.h.

enum TxPacketByte

UART Tx packet bytes enum.

Definition at line 132 of file Defines.h.