Make PCB for fabric made

This commit is contained in:
eddyem
2018-01-24 12:48:36 +03:00
parent be520f32de
commit ff79aa36e3
12 changed files with 6416 additions and 2739 deletions

View File

@@ -77,20 +77,28 @@ Getters returning more than one field ends with `DATAEND` meaning that's all dat
All variables here are fields of `user_conf` struct.
* **R** - get *raw ADC* values, e.g.
* **R** - get *raw ADC* values:
* 0 - Steppers current
* 1 - Input voltage 12V
* 2 - EndSwitch2 of motor1
* 3 - EndSwitch1 of motor1
* 4 - inner temperature
* 5 - vref
E.g.:
```
ADC[0]=1991
ADC[1]=124
ADC[2]=1351
ADC[3]=1909
ADC[4]=0
ADC[5]=0
ADC[6]=1707
ADC[7]=1531
ADC[0]=4095
ADC[1]=2340
ADC[2]=4095
ADC[3]=4087
ADC[4]=1665
ADC[5]=1532
DATAEND
```
* **S** - get *motors' status*, e.g.
```
@@ -99,7 +107,8 @@ MOTOR0=STOP
POS0=-1
ESW00=ERR
ESW01=BTN
MOTOR1=STOPPOS1=-1
MOTOR1=STOP
POS1=-1
ESW10=HALL
ESW11=HALL
@@ -130,6 +139,7 @@ Change of any setter takes place in MCU RAM immediately. To store them permanent
* **E num** - set *numerator*
* **I num** - set *device ID*
* **M#num** - set maxsteps (*num* is 1..65535) for motor `#`
* **P num** - properties of internal pullup (0 - disabled, other or without `num` - enabled)
* **R#num** - set reverse for motor # (*num* == 0 turns reverse off, *num* == 1 turns it on)
* **S#num** - set *speed* (`motspd`) to *num* for motor #
* **T num** - set *end-switches threshold* (in ADU, near 0 for Hall switch, 2048 for user button

View File

@@ -45,6 +45,7 @@ user_conf the_conf = {
,.motspd = {10, 10} // max speed: 300 steps per second
,.maxsteps = {50000, 50000} // max steps from point to point
,.reverse = {0,0} // set DIR to this value when moving to '+'
,.intpullup = 1 // by default internal pullup @ Tx pin enabled
};
static int erase_flash();

View File

@@ -40,6 +40,7 @@ typedef struct{
uint16_t motspd[2]; // max motor speed ([3000 / motspd] steps per second)
uint16_t maxsteps[2]; // maximum amount of steps for each motor (0 - infinity)
uint8_t reverse[2]; // == 1 if positive direction when DIR is low
uint8_t intpullup; // internal pullup @ Tx
} user_conf;
extern user_conf the_conf;

View File

@@ -38,7 +38,7 @@ void sys_tick_handler(void){
* PA6 (Tim3Ch1) M2STEP
* PA5 - M2EN
* PA7 - M2DIR
* PB1 - 12V on/off
* PB1 - 12V current sensor on/off - set it to 1 to turn off MAX471
* PF0 - M1EN
* PF1 - M1DIR
*/

View File

@@ -267,7 +267,9 @@ static char *get_conf(){
put_uint((uint32_t) *curdesc->ptr);
SENDBUF();
}while((++curdesc)->fieldname);
write2trbuf("USARTSPD=");
write2trbuf("INTPULLUP=");
put2trbuf(the_conf.intpullup ? '1' : '0');
write2trbuf("\nUSARTSPD=");
put_uint(the_conf.usartspd);
SENDBUF();
write2trbuf("REVERSE0=");
@@ -338,6 +340,11 @@ static char *set_something(char *str){
case 'M': // set maxsteps
setmotvals('M', str);
break;
case 'P': // set pullup
omitwsp(str);
if(*str == '0') the_conf.intpullup = 0;
else the_conf.intpullup = 1;
break;
case 'R': // set reverse
setmotvals('R', str);
break;

View File

@@ -72,9 +72,8 @@ void USART1_config(){
| (1 << (1 * 4)) | (1 << (2 * 4)); /* (2) */
// Tx (PA9) in OD mode
GPIOA->OTYPER |= 1 << 9;
#ifdef EBUG
GPIOA->PUPDR = (GPIOA->PUPDR & ~GPIO_PUPDR_PUPDR9) | GPIO_PUPDR_PUPDR9_0; // set pullup for Tx
#endif
if(the_conf.intpullup)
GPIOA->PUPDR = (GPIOA->PUPDR & ~GPIO_PUPDR_PUPDR9) | GPIO_PUPDR_PUPDR9_0; // set pullup for Tx
/* Enable the peripheral clock USART1 */
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
/* Configure USART1 */