Compare commits
13 Commits
29611f6d43
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b1e1b862d4 | |||
| 0c65dc73ec | |||
| 640953b89c | |||
| eb13b0e14a | |||
| baee1b2e94 | |||
| 584d2b8951 | |||
| 60b3dced8a | |||
| c7d14cf1a4 | |||
| 324b69117a | |||
| 91d3966d88 | |||
| 0b87524719 | |||
| 27550dbfd4 | |||
| 5253648cfb |
6
Inc/address_selector.h
Normal file
6
Inc/address_selector.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void adress_selector_init_gpio();
|
||||||
|
uint8_t read_address();
|
||||||
|
|
||||||
|
extern uint8_t dmx_address;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "stm32g0b1xx.h"
|
#include "stm32g0b1xx.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GPIO_TypeDef* en_port;
|
GPIO_TypeDef* en_port;
|
||||||
@@ -11,12 +12,18 @@ typedef struct {
|
|||||||
uint8_t home_pin;
|
uint8_t home_pin;
|
||||||
uint8_t homed:1;
|
uint8_t homed:1;
|
||||||
uint8_t trigger_step:1;
|
uint8_t trigger_step:1;
|
||||||
int16_t pos;
|
int32_t home_position;
|
||||||
int16_t speed;
|
int32_t pos;
|
||||||
int16_t ramp_to_speed;
|
int32_t endless_rot_integrator;
|
||||||
|
int32_t speed;
|
||||||
|
int32_t ramp_to_speed;
|
||||||
uint32_t next_step;
|
uint32_t next_step;
|
||||||
} stepper_T;
|
} stepper_T;
|
||||||
|
|
||||||
|
#define STEPPER_MAX_SPEED 400
|
||||||
|
|
||||||
|
#define STEPPER_STEPS_PER_ROTATION 3200*4
|
||||||
|
|
||||||
void Timer1_Init(void);
|
void Timer1_Init(void);
|
||||||
void stepper_gpio_init();
|
void stepper_gpio_init();
|
||||||
void do_steps();
|
void do_steps();
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -22,7 +22,7 @@ TARGET = Parafraktor
|
|||||||
# debug build?
|
# debug build?
|
||||||
DEBUG = 1
|
DEBUG = 1
|
||||||
# optimization
|
# optimization
|
||||||
OPT = -Og
|
OPT = -O0
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
@@ -38,6 +38,7 @@ BUILD_DIR = build
|
|||||||
C_SOURCES = \
|
C_SOURCES = \
|
||||||
Src/main.c \
|
Src/main.c \
|
||||||
Src/uart_dmx.c \
|
Src/uart_dmx.c \
|
||||||
|
Src/address_selector.c \
|
||||||
Src/stepper.c \
|
Src/stepper.c \
|
||||||
Src/stm32g0xx_it.c \
|
Src/stm32g0xx_it.c \
|
||||||
Src/stm32g0xx_hal_msp.c \
|
Src/stm32g0xx_hal_msp.c \
|
||||||
@@ -114,7 +115,11 @@ AS_DEFS =
|
|||||||
# C defines
|
# C defines
|
||||||
C_DEFS = \
|
C_DEFS = \
|
||||||
-DUSE_HAL_DRIVER \
|
-DUSE_HAL_DRIVER \
|
||||||
-DSTM32G0B1xx
|
-DSTM32G0B1xx \
|
||||||
|
|
||||||
|
ifneq ($(DMX_ADDRESS),)
|
||||||
|
C_DEFS += -DDMX_ADDRESS=$(DMX_ADDRESS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
# AS includes
|
# AS includes
|
||||||
|
|||||||
92
README.md
92
README.md
@@ -1,25 +1,89 @@
|
|||||||
# Parrafraktor
|
# Parafraktor
|
||||||
|
## Hardware Connections
|
||||||
|
- Motor1: P30 (M1)
|
||||||
|
- Motor2: P53 (M2)
|
||||||
|
- Motor3: P46 (M3A)
|
||||||
|
- Motor4: P70 (M4)
|
||||||
|
- Motor5: P31 (M5)
|
||||||
|
- Motor6: P71 (M7)
|
||||||
|
- 24V: Power + -
|
||||||
|
- TTL-level DMX: FWS
|
||||||
|
- Limit switches: EXP2 (optional)
|
||||||
|
- Address selector: EXP1 (optional)
|
||||||
|
- VM/VBB(?) Jumper must be set on every motor driver
|
||||||
|
|
||||||

|
## DMX Registers
|
||||||
|
|
||||||
|
Control Motors 1 - 6
|
||||||
|
|
||||||
|
| Offset | Motor | Function | Values | |
|
||||||
|
| ------- | ----- | ------------ | --------- | ------------------------------ |
|
||||||
|
| 1 | 1 | Tilt | 000 - 255 | 8bit Position values can be combined to 16bit value |
|
||||||
|
| 2 | 1 | Tilt fine | 000 - 255 | |
|
||||||
|
| 3 | 1 | Endless Tilt | 000 - 004 | No function |
|
||||||
|
| | | | 005 - 121 | Forward Rotation fast -> slow |
|
||||||
|
| | | | 122 - 132 | Stop |
|
||||||
|
| | | | 133 - 250 | Backward Rotation slow -> fast |
|
||||||
|
| | | | 251 - 255 | No function |
|
||||||
|
| ... | ... | ... | ... | ... |
|
||||||
|
| 16 | 6 | Tilt | | |
|
||||||
|
| 17 | 6 | Tilt fine | | |
|
||||||
|
| 18 | 6 | Endless Tilt | | |
|
||||||
|
|
||||||
|
## Compile, Flash & Debug
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
- for compiling: arm-none-eabi-toolchain, gnu-make, git
|
||||||
|
- for flashing: SEGGER J-Link, JLinkGDBServer (other Debug Probes can be used, see Makefile)
|
||||||
|
|
||||||
|
run gdb-server<br />
|
||||||
|
`./gdb.sh`
|
||||||
|
|
||||||
|
build and flash firmware with static DMX-Address<br />
|
||||||
|
`make program DMX_ADDRESS=99`
|
||||||
|
|
||||||
|
build and flash firmware with address selector on EXP1<br />
|
||||||
|
`make program`
|
||||||
|
|
||||||
|
open serial RTT prints:<br />
|
||||||
|
`telnet localhost 9000`
|
||||||
|
|
||||||
|
open cgdb debugger:<br />
|
||||||
|
`./debug.sh`
|
||||||
|
|
||||||
|
## non-obvious PinOuts
|
||||||
|
|
||||||
|
### DMX/UART/FWS
|
||||||
|
| Pin # | connect to RS485 Transceiver
|
||||||
|
| - | ----------|
|
||||||
|
| 1 | NC |
|
||||||
|
| 2 | DATA-in |
|
||||||
|
| 3 | GND |
|
||||||
|
| 4 | 5V (only connect if not powered by other board) |
|
||||||
|
|
||||||
|
|
||||||
|
### Limit Switches/EXP2
|
||||||
|
|Pin #| Switch |Pin #| Switch |
|
||||||
|
| --- | ----------| --- | ----------|
|
||||||
|
| 1 | M1 (PB14) | 2 | M2 (PB13) |
|
||||||
|
| 3 | M3 (PF7) | 4 | M4 (PB12) |
|
||||||
|
| 5 | M5 (PE7) | 6 | M6 (PB11) |
|
||||||
|
| 7 | | 8 | |
|
||||||
|
| 9 | GND | 10 | |
|
||||||
|
|
||||||
| Channel | Function | Values | |
|
### Address Selector/EXP1
|
||||||
| ------- | ------------ | --------- | ------------------------------ |
|
|Pin #| Switch |Pin #| Switch |
|
||||||
| 1 + i | Tilt | | |
|
| --- | ----------| --- | ----------|
|
||||||
| 2 + i | Tilt fine | | |
|
| 1 | | 2 | |
|
||||||
| 3 + i | Endless Tilt | 000 - 005 | No function |
|
| 3 | | 4 | |
|
||||||
| | | 006 - 126 | Forward Rotation fast -> slow |
|
| 5 | | 6 | |
|
||||||
| | | 127 - 128 | Stop |
|
| 7 | | 8 | |
|
||||||
| | | 129 - 255 | Backward Rotation slow -> fast |
|
| 9 | GND | 10 | 5V |
|
||||||
| 31 | Auto Mode | 000 - 004 | No function |
|
|
||||||
| | | 005 - 010 | Go to Reference |
|
|
||||||
| | | 015 - 020 | Classic Mode |
|
|
||||||
|
|
||||||
|
|
||||||
## Hardware
|
## Hardware
|
||||||
|
|
||||||
- BIGTREETECH Manta M8P
|
- BIGTREETECH Manta M8P v1.1
|
||||||
- https://github.com/bigtreetech/Manta-M8P/tree/master/V1.0_V1.1/Hardware
|
- https://github.com/bigtreetech/Manta-M8P/tree/master/V1.0_V1.1/Hardware
|
||||||
- https://github.com/bigtreetech/Manta-M8P
|
- https://github.com/bigtreetech/Manta-M8P
|
||||||
- https://bttwiki.com/M8P.html#product-profile
|
- https://bttwiki.com/M8P.html#product-profile
|
||||||
53
Src/address_selector.c
Normal file
53
Src/address_selector.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include "stm32g0b1xx.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
uint8_t dmx_address;
|
||||||
|
|
||||||
|
void adress_selector_init_gpio(){
|
||||||
|
RCC->IOPENR |= RCC_IOPENR_GPIOEEN;
|
||||||
|
RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
||||||
|
|
||||||
|
GPIOE->MODER &= ~(0x3 << (9 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (10 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (11 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (12 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (13 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (14 * 2));
|
||||||
|
GPIOE->MODER &= ~(0x3 << (15 * 2));
|
||||||
|
GPIOB->MODER &= ~(0x3 << (10 * 2)); // B10
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (9 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (9 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (10 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (10 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (11 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (11 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (12 * 2));
|
||||||
|
GPIOE->PUPDR |= (0x1 << (12 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR |= (0x1 << (13 * 2));
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (13 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR |= (0x1 << (14 * 2));
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (14 * 2));
|
||||||
|
|
||||||
|
GPIOE->PUPDR |= (0x1 << (15 * 2));
|
||||||
|
GPIOE->PUPDR &= ~(0x3 << (15 * 2));
|
||||||
|
|
||||||
|
GPIOB->PUPDR &= ~(0x3 << (10 * 2)); // B10
|
||||||
|
GPIOB->PUPDR |= (0x1 << (10 * 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t read_address(){
|
||||||
|
#ifndef DMX_ADDRESS
|
||||||
|
uint16_t address = ((GPIOE->IDR >> 9)&0x7F) | (GPIOB->IDR & (1<<10))>>3;
|
||||||
|
printf("read address: %d = 0x%x\n", address, address);
|
||||||
|
#else
|
||||||
|
uint16_t address = DMX_ADDRESS;
|
||||||
|
printf("static address: %d\n", address);
|
||||||
|
#endif
|
||||||
|
return address;
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "uart_dmx.h"
|
#include "uart_dmx.h"
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
|
#include "address_selector.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@@ -56,6 +57,7 @@
|
|||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
static void MX_GPIO_Init(void);
|
static void MX_GPIO_Init(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
@@ -99,6 +101,9 @@ int main(void)
|
|||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
init_UART1_dma();
|
init_UART1_dma();
|
||||||
stepper_gpio_init();
|
stepper_gpio_init();
|
||||||
|
adress_selector_init_gpio();
|
||||||
|
dmx_address = read_address();
|
||||||
|
|
||||||
Timer1_Init();
|
Timer1_Init();
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
@@ -112,6 +117,7 @@ int main(void)
|
|||||||
// printf("0x%02X ", rxBuffer[i]);
|
// printf("0x%02X ", rxBuffer[i]);
|
||||||
//printf("\n");
|
//printf("\n");
|
||||||
SEGGER_SYSVIEW_OnIdle();
|
SEGGER_SYSVIEW_OnIdle();
|
||||||
|
//read_address();
|
||||||
//if(cnt++ >= 256-rxBuffer[1]){
|
//if(cnt++ >= 256-rxBuffer[1]){
|
||||||
// cnt = 0;
|
// cnt = 0;
|
||||||
// GPIOE->ODR ^= GPIO_ODR_OD2;
|
// GPIOE->ODR ^= GPIO_ODR_OD2;
|
||||||
|
|||||||
@@ -6,9 +6,16 @@
|
|||||||
|
|
||||||
#include "SEGGER_SYSVIEW.h"
|
#include "SEGGER_SYSVIEW.h"
|
||||||
#include "uart_dmx.h"
|
#include "uart_dmx.h"
|
||||||
|
#include "address_selector.h"
|
||||||
|
|
||||||
stepper_T steppers[] = {
|
stepper_T steppers[] = {
|
||||||
{.en_port=GPIOC, .en_pin=11, .dir_port=GPIOB, .dir_pin=4, .step_port=GPIOE, .step_pin=2, .home_port=GPIOF, .home_pin=3}
|
{.en_port=GPIOC, .en_pin=11, .dir_port=GPIOB, .dir_pin=4, .step_port=GPIOE, .step_pin=2, .home_port=GPIOB, .home_pin=14, .home_position=0, .homed = 0},
|
||||||
|
{.en_port=GPIOB, .en_pin=3, .dir_port=GPIOF, .dir_pin=11, .step_port=GPIOF, .step_pin=12, .home_port=GPIOB, .home_pin=13, .home_position=0, .homed = 0},
|
||||||
|
{.en_port=GPIOF, .en_pin=10, .dir_port=GPIOD, .dir_pin=6, .step_port=GPIOD, .step_pin=7, .home_port=GPIOF, .home_pin=7, .home_position=0, .homed = 0},
|
||||||
|
{.en_port=GPIOD, .en_pin=5, .dir_port=GPIOD, .dir_pin=2, .step_port=GPIOD, .step_pin=3, .home_port=GPIOB, .home_pin=12, .home_position=0, .homed = 0},
|
||||||
|
{.en_port=GPIOD, .en_pin=1, .dir_port=GPIOC, .dir_pin=8, .step_port=GPIOC, .step_pin=9, .home_port=GPIOE, .home_pin=7, .home_position=0, .homed = 0},
|
||||||
|
{.en_port=GPIOD, .en_pin=15, .dir_port=GPIOD, .dir_pin=9, .step_port=GPIOD, .step_pin=11, .home_port=GPIOB, .home_pin=11, .home_position=0, .homed = 0},
|
||||||
|
//{.en_port=GPIOA, .en_pin=15, .dir_port=GPIOA, .dir_pin=14, .step_port=GPIOA, .step_pin=10, .home_port=GPIOB, .home_pin=11, .home_position=0, .homed = 1},
|
||||||
};
|
};
|
||||||
|
|
||||||
void set_pins(stepper_T* stp){
|
void set_pins(stepper_T* stp){
|
||||||
@@ -28,14 +35,18 @@ void set_pins(stepper_T* stp){
|
|||||||
|
|
||||||
// home switch
|
// home switch
|
||||||
stp->home_port->MODER &= ~(0x3 << (stp->home_pin * 2));
|
stp->home_port->MODER &= ~(0x3 << (stp->home_pin * 2));
|
||||||
|
stp->home_port->PUPDR &= ~(0x3 << (stp->home_pin * 2));
|
||||||
|
stp->home_port->PUPDR |= (0x1 << (stp->home_pin * 2));
|
||||||
|
|
||||||
// make shure stepper is enabled (active low)
|
// make shure stepper is enabled (active low)
|
||||||
stp->en_port->BSRR |= (0x1 << (stp->en_pin + 16));
|
stp->en_port->BSRR |= (0x1 << (stp->en_pin + 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
void stepper_gpio_init(){
|
void stepper_gpio_init(){
|
||||||
|
RCC->IOPENR |= RCC_IOPENR_GPIOAEN;
|
||||||
RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
||||||
RCC->IOPENR |= RCC_IOPENR_GPIOCEN;
|
RCC->IOPENR |= RCC_IOPENR_GPIOCEN;
|
||||||
|
RCC->IOPENR |= RCC_IOPENR_GPIODEN;
|
||||||
RCC->IOPENR |= RCC_IOPENR_GPIOEEN;
|
RCC->IOPENR |= RCC_IOPENR_GPIOEEN;
|
||||||
RCC->IOPENR |= RCC_IOPENR_GPIOFEN;
|
RCC->IOPENR |= RCC_IOPENR_GPIOFEN;
|
||||||
|
|
||||||
@@ -74,6 +85,7 @@ void TIM1_BRK_UP_TRG_COM_IRQHandler(void) {
|
|||||||
|
|
||||||
void do_steps(){
|
void do_steps(){
|
||||||
static uint32_t timer = 0;
|
static uint32_t timer = 0;
|
||||||
|
int16_t rotation_speed = 0;
|
||||||
timer++;
|
timer++;
|
||||||
|
|
||||||
for(uint8_t i=0; i<(sizeof(steppers)/sizeof(stepper_T)); i++){
|
for(uint8_t i=0; i<(sizeof(steppers)/sizeof(stepper_T)); i++){
|
||||||
@@ -88,10 +100,10 @@ void do_steps(){
|
|||||||
steppers[i].speed--;
|
steppers[i].speed--;
|
||||||
|
|
||||||
/* limit max speed */
|
/* limit max speed */
|
||||||
if(steppers[i].speed >= 100)
|
if(steppers[i].speed >= STEPPER_MAX_SPEED)
|
||||||
steppers[i].speed=100;
|
steppers[i].speed=STEPPER_MAX_SPEED;
|
||||||
if(steppers[i].speed <= -100)
|
if(steppers[i].speed <= -STEPPER_MAX_SPEED)
|
||||||
steppers[i].speed=-100;
|
steppers[i].speed=-STEPPER_MAX_SPEED;
|
||||||
|
|
||||||
/* get direction from sign */
|
/* get direction from sign */
|
||||||
if(steppers[i].speed>0)
|
if(steppers[i].speed>0)
|
||||||
@@ -121,28 +133,92 @@ void do_steps(){
|
|||||||
steppers[i].next_step = timer + 1;
|
steppers[i].next_step = timer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("pos %d\tspeed %d\n", steppers[i].pos, steppers[i].speed);
|
//printf("motor[%d]: pos %ld\trot: %ld\tspeed %ld\n", i, steppers[i].pos, steppers[i].endless_rot_integrator, steppers[i].speed);
|
||||||
|
//printf("rotation speed: %d\n", rotation_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(steppers[i].homed){
|
if(steppers[i].homed){
|
||||||
static uint16_t old_ramp_to_speed;
|
static uint16_t old_ramp_to_speed;
|
||||||
old_ramp_to_speed = steppers[i].ramp_to_speed;
|
old_ramp_to_speed = steppers[i].ramp_to_speed;
|
||||||
steppers[i].ramp_to_speed = rxBuffer[1] - steppers[i].pos;
|
|
||||||
|
uint8_t raw_endless = rxBuffer[3*i + dmx_address + 2];
|
||||||
|
|
||||||
|
/* deadzone on top and bottom */
|
||||||
|
if(raw_endless >= 5 && raw_endless <= 250) {
|
||||||
|
rotation_speed = raw_endless - 127;
|
||||||
|
|
||||||
|
/* dead zone in the middle */
|
||||||
|
if(rotation_speed >= 5)
|
||||||
|
rotation_speed -= 5;
|
||||||
|
else if(rotation_speed <= -5)
|
||||||
|
rotation_speed += 5;
|
||||||
|
else
|
||||||
|
rotation_speed = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rotation_speed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(steppers[i].pos == STEPPER_STEPS_PER_ROTATION+1){
|
||||||
|
steppers[i].pos = 1;
|
||||||
|
}
|
||||||
|
if(steppers[i].pos == -1){
|
||||||
|
steppers[i].pos = STEPPER_STEPS_PER_ROTATION-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
///* handle endless rotation offset and wraparound */
|
||||||
|
//if(rotation_speed){
|
||||||
|
// steppers[i].endless_rot_integrator += rotation_speed;
|
||||||
|
// if(steppers[i].endless_rot_integrator >= STEPPER_STEPS_PER_ROTATION)
|
||||||
|
// {
|
||||||
|
// steppers[i].endless_rot_integrator -= STEPPER_STEPS_PER_ROTATION;
|
||||||
|
// steppers[i].pos -= STEPPER_STEPS_PER_ROTATION;
|
||||||
|
// }
|
||||||
|
// else if(steppers[i].endless_rot_integrator <= 0)
|
||||||
|
// {
|
||||||
|
// steppers[i].endless_rot_integrator += STEPPER_STEPS_PER_ROTATION;
|
||||||
|
// steppers[i].pos += STEPPER_STEPS_PER_ROTATION;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
// steppers[i].endless_rot_integrator = 0;
|
||||||
|
|
||||||
|
if(rotation_speed){
|
||||||
|
steppers[i].ramp_to_speed = rotation_speed;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
int32_t swapped_val = rxBuffer[3*i + dmx_address]<<8 | (rxBuffer[3*i+dmx_address+1]&0xFF);
|
||||||
|
//swapped_val += steppers[i].endless_rot_integrator;
|
||||||
|
int32_t scaled_steps = swapped_val * STEPPER_STEPS_PER_ROTATION / UINT16_MAX;
|
||||||
|
steppers[i].ramp_to_speed = scaled_steps - steppers[i].pos;
|
||||||
|
//static int cnt = 0;
|
||||||
|
//if(i==5 && ++cnt==10000){
|
||||||
|
// printf("swapped_val[%d]: %d\n", i, swapped_val);
|
||||||
|
// cnt=0;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
if(old_ramp_to_speed == 0 && steppers[i].ramp_to_speed != 0)
|
if(old_ramp_to_speed == 0 && steppers[i].ramp_to_speed != 0)
|
||||||
steppers[i].trigger_step = 1;
|
steppers[i].trigger_step = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(~(steppers[i].home_port->IDR) & (1 << steppers[i].home_pin)){
|
if(~(steppers[i].home_port->IDR) & (1 << steppers[i].home_pin)){
|
||||||
steppers[i].pos = 0;
|
steppers[i].pos = steppers[i].home_position;
|
||||||
steppers[i].homed = 1;
|
steppers[i].homed = 1;
|
||||||
steppers[i].speed = 0;
|
steppers[i].speed = 0;
|
||||||
steppers[i].ramp_to_speed = 0;
|
steppers[i].ramp_to_speed = 0;
|
||||||
printf("homed %d\n", i);
|
printf("homed %d\n", i);
|
||||||
}
|
}
|
||||||
|
else if(steppers[i].pos == 2*STEPPER_STEPS_PER_ROTATION){
|
||||||
|
steppers[i].pos = 0;
|
||||||
|
steppers[i].homed = 1;
|
||||||
|
steppers[i].speed = 0;
|
||||||
|
steppers[i].ramp_to_speed = 0;
|
||||||
|
printf("cant home %d, setting 0 now\n", i);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
if(steppers[i].ramp_to_speed == 0){
|
if(steppers[i].ramp_to_speed == 0){
|
||||||
steppers[i].ramp_to_speed=10;
|
steppers[i].ramp_to_speed=80;
|
||||||
steppers[i].trigger_step = 1; // trigger first step
|
steppers[i].trigger_step = 1; // trigger first step
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
-mthumb
|
-mthumb
|
||||||
-DUSE_HAL_DRIVER
|
-DUSE_HAL_DRIVER
|
||||||
-DSTM32G0B1xx
|
-DSTM32G0B1xx
|
||||||
|
-DDMX_ADDRESS=99
|
||||||
-IInc
|
-IInc
|
||||||
-IDrivers/STM32G0xx_HAL_Driver/Inc
|
-IDrivers/STM32G0xx_HAL_Driver/Inc
|
||||||
-IDrivers/STM32G0xx_HAL_Driver/Inc/Legacy
|
-IDrivers/STM32G0xx_HAL_Driver/Inc/Legacy
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
-IDrivers/SystemView/Config
|
-IDrivers/SystemView/Config
|
||||||
-IDrivers/SystemView/SEGGER
|
-IDrivers/SystemView/SEGGER
|
||||||
-IDrivers/SystemView/SYSVIEW
|
-IDrivers/SystemView/SYSVIEW
|
||||||
-Og
|
-O0
|
||||||
-Wall
|
-Wall
|
||||||
-fdata-sections
|
-fdata-sections
|
||||||
-ffunction-sections
|
-ffunction-sections
|
||||||
|
|||||||
Reference in New Issue
Block a user