Conversation
dzhang39
left a comment
There was a problem hiding this comment.
Lots of Comments that I would like clarification for in your code.
| bool ports_seen[num_ports] = {}; | ||
| GPIO_PIN pins_for_port[num_ports] = {}; | ||
|
|
||
| //iterate through all the ports we will use, set seen flag and |= the pins |
There was a problem hiding this comment.
Why are we iterating? Is it because each GPIO controlls a certain enable, counter clockwise, clockwise pins of the HBridge?
There was a problem hiding this comment.
iterating because we have to initiallze each gpio
| uint8_t max_speed; | ||
|
|
||
| uint8_t current_step; | ||
| uint8_t dir; |
|
|
||
| if (speed < 0){ | ||
| if (-1*speed > l298n->max_speed) return false; | ||
| l298n->dir = -1; |
There was a problem hiding this comment.
Internal Thought: Direction is counterclockwise?
| l298n->dir = 0; l298n->ticks_per_step = (1<<31); return true; | ||
| } | ||
|
|
||
| l298n->ticks_per_step = (uint32_t)( |
There was a problem hiding this comment.
Internal Thought: Main function which is non-bloking way for turning the stepper. Each tick takes 1 millionth of the current stepper timer period? Then setting the steps per revolution? Where did this come from? How would I know how to do this?
| HAL_GPIO_Init((GPIO_TypeDef*)((uint32_t)GPIOA + i*port_dist), &GPIO_InitStruct); | ||
|
|
||
|
|
||
| } |
There was a problem hiding this comment.
How is GPIO_InitStruct impacting the actual pin; how can a single GPIO pin have multiple parameters?
There was a problem hiding this comment.
its what the HAL library uses to initalize the pin, not sur ewhat you mean by the second question
|
|
||
| uint32_t max_time_ms; //max time | ||
| uint32_t current_time_running_ms;//how long its been running | ||
| uint32_t max_time_ms; //max time (currently not implemented) |
dzhang39
left a comment
There was a problem hiding this comment.
All Drivers and Debug not viewed
| #define PROJECT_CAN_ID_SCIENCE_DC_MOTOR_R 0x071U | ||
| #define PROJECT_CAN_ID_SCIENCE_SERVO_PCB_C 0x080U | ||
| #define PROJECT_CAN_ID_SCIENCE_SERVO_PCB_R 0x081U | ||
| #define PROJECT_CAN_ID_SCIENCE_STEPPER_PCB_C 0x090U |
There was a problem hiding this comment.
Internal_Thoughts: From an outside perspective, this is where you would type the 3 bit ID into Cangaroo?
| PROJECT_CAN_ID_SCIENCE_DC_MOTOR_R, | ||
| PROJECT_CAN_ID_SCIENCE_SERVO_PCB_C, | ||
| PROJECT_CAN_ID_SCIENCE_SERVO_PCB_R, | ||
| PROJECT_CAN_ID_SCIENCE_STEPPER_PCB_C, |
There was a problem hiding this comment.
Including Science Stepper Now
| @@ -0,0 +1,694 @@ | |||
| #include "dc_motor_system.h" | |||
There was a problem hiding this comment.
I am not reviewing this, Only Steppers at the momemnt
There was a problem hiding this comment.
Unless the steppers are using the DC_motor_system.c
There was a problem hiding this comment.
Unless the steppers are using the this system, I am ignoring this for now
There was a problem hiding this comment.
yeah that was an accident or smth just ignore
| l298n_stepper_driver_t drivers[NUM_STEPPERS] = { | ||
|
|
||
|
|
||
| // {GPIOA, GPIO_PIN_6, |
There was a problem hiding this comment.
Commented Out to prevent GPIO overlap. Still Confused as this seems like you don't need to configure these in the IOC file?
There was a problem hiding this comment.
they are nto supposed to be configured in the ioc, its just commented out because i was using it to test but didnt want to delete yet.
also it serves as an example
| #include "../../App/Inc/servo_system.h" | ||
| #include "../../App/Inc/dbc_examples_system.h" | ||
| #include "../../App/Inc/test_pwm_system.h" | ||
| #include "../../App/Inc/dc_motor_system.h" |
There was a problem hiding this comment.
Why is stepper not in here?
There was a problem hiding this comment.
it deosnt have to be until the pcb branch is written
| #include "l298n_stepper_system.h" | ||
|
|
||
|
|
||
| #define L298N_STEPPER_STATUS_UNDEFINED (uint8_t)0 |
There was a problem hiding this comment.
All Status Pins are from the DBC or CAN Protocol file?
There was a problem hiding this comment.
not pins, just statuses, they are defined in the protocol file
| GPIOA, GPIO_PIN_4, | ||
| GPIOC, GPIO_PIN_5, | ||
| GPIOA, GPIO_PIN_7, | ||
| l298n_stepper_driver_t drivers[NUM_STEPPERS] = { |
There was a problem hiding this comment.
its just the array of structs, user has to define this
|
|
||
| }; // needs to be defined in the .c | ||
| TIM_TypeDef* global_interrupt_clock = TIM2; | ||
| uint32_t l298n_stepper_timer_period_us = 100; |
There was a problem hiding this comment.
This is our stepper specific right? Don't need to change these?
There was a problem hiding this comment.
these parameters are stepper agnostic, the system will adjust behavior dependong on the stepper speciifc parameters to get the correct behavior, this is just which timer to trigger the interrupt, and how often you want to trigger the interrupt
it builds now