Преглед на файлове

Working software

iss17/08_feature_implementation_02
Wouter Horlings преди 5 години
родител
ревизия
70b8d999ee
променени са 9 файла, в които са добавени 95 реда и са изтрити 43 реда
  1. +1
    -0
      implementation/software/.gitignore
  2. +10
    -0
      implementation/software/Makefile
  3. +0
    -1
      implementation/software/design/design_spec.md
  4. +4
    -2
      implementation/software/include/sensor.h
  5. +0
    -1
      implementation/software/include/sensor_params.h
  6. +14
    -4
      implementation/software/include/stepper.h
  7. +32
    -33
      implementation/software/include/stepper_params.h
  8. +20
    -0
      implementation/software/main.c
  9. +14
    -2
      implementation/software/stepper.c

+ 1
- 0
implementation/software/.gitignore Целия файл

@@ -0,0 +1 @@
bin/*

+ 10
- 0
implementation/software/Makefile Целия файл

@@ -0,0 +1,10 @@
APPLICATION = stepper

BOARD ?= nucleo-f411re

RIOTBASE ?= /home/wouter/Development/RIOT/

USEMODULE += xtimer


include $(RIOTBASE)/Makefile.include

+ 0
- 1
implementation/software/design/design_spec.md Целия файл

@@ -76,7 +76,6 @@ or [gb_math.h](https://github.com/gingerBill/gb/blob/master/gb_math.h)


## Kinematics struct

* ArmLengthA float
* Motor motor1
* ArmLengthB float


+ 4
- 2
implementation/software/include/sensor.h Целия файл

@@ -1,9 +1,11 @@


#infdef SENSOR_H
#ifndef SENSOR_H
#define SENSOR_H

#include <stdint.h>
#include <limits.h>
#include "periph/adc.h"

#ifdef __cplusplus
extern "C" {
@@ -18,7 +20,7 @@ typedef struct {

typedef struct {
sensor_params_t p;
} sensor_t
} sensor_t;

/**
* @brief Initializes the sensor


+ 0
- 1
implementation/software/include/sensor_params.h Целия файл

@@ -6,7 +6,6 @@ extern "C" {
#endif

#include "board.h"
#include "adc.h"

#ifndef SENSOR_PARAMS
#define SENSOR_PARAMS \


+ 14
- 4
implementation/software/include/stepper.h Целия файл

@@ -1,14 +1,25 @@


#infdef STEPPER_H
#ifndef STEPPER_H
#define STEPPER_H

#include <stdint.h>
#include "periph/gpio.h"
#include "periph/uart.h"
#include "sensor.h"

#ifdef __cplusplus
extern "C" {
#endif

#define STEPPER_PARAM_VEL_MAX (25)
#define STEPPER_PARAM_ACC_MAX (200)
#define STEPPER_PARAM_VELOCITY_DEFAULT (0)
#define STEPPER_PARAM_MICROSTEP_DEFAULT (16)
#define STEPPER_PARAM_DIVISION_DEFAULT (200)
#define STEPPER_PARAM_ANGLE_DEFAULT (0)
#define STEPPER_PARAM_HOMING_ANGLE_DEFAULT (20)

/**
* @brief Status and error codes
*/
@@ -25,14 +36,13 @@ extern "C" {
STEPPER_REVERSE = 0x1,
} stepper_direction_t;


/**
* @brief Data structure holding the device parameters needed for initialization
*/
typedef struct {
gpio_t step_pin;
gpio_t dir_pin;
uint8_t addr;
uint8_t uart;
uint8_t vel_max;
uint8_t acc_max;
uint8_t microstep;
@@ -48,7 +58,7 @@ typedef struct {
*/
typedef struct {
stepper_params_t p;
} stepper_t
} stepper_t;

int stepper_init(stepper_t *dev, const stepper_params_t *params);



+ 32
- 33
implementation/software/include/stepper_params.h Целия файл

@@ -7,53 +7,52 @@ extern "C" {

#include "board.h"

#ifndef STEPPER_STEP_PIN
#define STEPPER_STEP_PIN GPIO_PIN(0, 0)
#ifndef STEPPER_PARAM_STEP_PIN
#define STEPPER_PARAM_STEP_PIN GPIO_PIN(0, 0)
#endif
#ifndef STEPPER_DIR_PIN
#define STEPPER_DIR_PIN GPIO_PIn(0, 1)
#ifndef STEPPER_PARAM_DIR_PIN
#define STEPPER_PARAM_DIR_PIN GPIO_PIN(0, 1)
#endif
#ifndef STEPPER_UART
#define STEPPER_UART UART(0)
#ifndef STEPPER_PARAM_UART
#define STEPPER_PARAM_UART UART_DEV(0)
#endif
#ifndef STEPPER_VEL_MAX
#define STEPPER_VEL_MAX STEPPER_VEL_MAX_DEFAULT
#ifndef STEPPER_PARAM_VEL_MAX
#define STEPPER_PARAM_VEL_MAX STEPPER_PARAM_VEL_MAX_DEFAULT
#endif
#ifndef STEPPER_ACC_MAX
#define STEPPER_ACC_MAX STEPPER_ACC_MAX_DEFAULT
#ifndef STEPPER_PARAM_ACC_MAX
#define STEPPER_PARAM_ACC_MAX STEPPER_PARAM_ACC_MAX_DEFAULT
#endif
#ifndef STEPPER_MICROSTEP
#define STEPPER_MICROSTEP STEPPER_MICROSTEP_DEFAULT
#ifndef STEPPER_PARAM_MICROSTEP
#define STEPPER_PARAM_MICROSTEP STEPPER_PARAM_MICROSTEP_DEFAULT
#endif
#ifndef STEPPER_DIVISION
#define STEPPER_DIVISION STEPPER_DIVISION_DEFAULT
#ifndef STEPPER_PARAM_DIVISION
#define STEPPER_PARAM_DIVISION STEPPER_PARAM_DIVISION_DEFAULT
#endif
#ifndef STEPPER_ANGLE
#define STEPPER_ANGLE STEPPER_ANGLE_DEFAULT
#ifndef STEPPER_PARAM_ANGLE
#define STEPPER_PARAM_ANGLE STEPPER_PARAM_ANGLE_DEFAULT
#endif
#ifndef STEPPER_VELOCITY
#define STEPPER_VELOCITY STEPPER_VELOCITY_DEFAULT
#ifndef STEPPER_PARAM_VELOCITY
#define STEPPER_PARAM_VELOCITY STEPPER_PARAM_VELOCITY_DEFAULT
#endif
#ifndef STEPPER_SENSOR
#define STEPPER_SENSOR STEPPER_SENSOR_DEFAULT
#ifndef STEPPER_PARAM_SENSOR
#define STEPPER_PARAM_SENSOR STEPPER_PARAM_SENSOR_DEFAULT
#endif
#ifndef STEPPER_HOMING_ANGLE
#define STEPPER_HOMING_ANGLE STEPPER_HOMING_ANGLE_DEFAULT
#ifndef STEPPER_PARAM_HOMING_ANGLE
#define STEPPER_PARAM_HOMING_ANGLE STEPPER_PARAM_HOMING_ANGLE_DEFAULT
#endif

#ifndef STEPPER_PARAMS
#define STEPPER_PARAMS \
{ .step_pin = stepper_param_step_pin, \
.dir_pin = stepper_param_dir_pin, \
.addr = stepper_param_addr, \
.vel_max = stepper_param_vel_max, \
.acc_max = stepper_param_acc_max, \
.microstep = stepper_param_microstep, \
.division = stepper_param_division, \
.angle = stepper_param_angle, \
.velocity = stepper_param_velocity, \
.sensor = stepper_param_sensor, \
.homing_angle = stepper_param_homing_angle, \
{ .step_pin = STEPPER_PARAM_STEP_PIN, \
.dir_pin = STEPPER_PARAM_DIR_PIN, \
.uart = STEPPER_PARAM_UART, \
.vel_max = STEPPER_PARAM_VEL_MAX, \
.acc_max = STEPPER_PARAM_ACC_MAX, \
.microstep = STEPPER_PARAM_MICROSTEP, \
.division = STEPPER_PARAM_DIVISION, \
.angle = STEPPER_PARAM_ANGLE, \
.velocity = STEPPER_PARAM_VELOCITY, \
.homing_angle = STEPPER_PARAM_HOMING_ANGLE, \
}
#endif



+ 20
- 0
implementation/software/main.c Целия файл

@@ -0,0 +1,20 @@
#include <stdlib.h>
#include <stdio.h>

#include "include/stepper.h"
#include "include/stepper_params.h"
#include "include/sensor.h"
#include "xtimer.h"

int main(void)
{
stepper_t dev;
stepper_init(&dev, &stepper_params[0]);
while (1) {
xtimer_usleep(100000);
stepper_step(&dev, STEPPER_FORWARD);
}

return 0;
}

implementation/software/src/stepper.c → implementation/software/stepper.c Целия файл

@@ -2,19 +2,26 @@
#include "periph/gpio.h"
#include "periph/uart.h"

#include "stepper.h"
#include "sensor.h"
#include "include/stepper.h"
#include "include/stepper_params.h"
#include "include/sensor.h"

#define ENABLE_DEBUG (0)
#include "debug.h"


#define STEP_PIN (dev->p.step_pin)
#define DIR_PIN (dev->p.dir_pin)

int stepper_init(stepper_t *dev, const stepper_params_t *params)
{
assert(dev && params);

dev->p = *params;

gpio_init(STEP_PIN, GPIO_OUT);


return STEPPER_OK;
}
@@ -22,6 +29,11 @@ int stepper_init(stepper_t *dev, const stepper_params_t *params)

int stepper_step(stepper_t *dev, stepper_direction_t *direction)
{
assert(direction);
gpio_toggle(STEP_PIN);

return STEPPER_OK;
}




Loading…
Отказ
Запис