аврстудия стоит у кого тутошних?

Hello All!

на сях для атмега8 есть исходник там поменять чуток

Reply to
Sasha Shost
Loading thread data ...

Hello All!

сам оригинал скомпилил (там две неправильности были у автора теперь с полушагом тыркаюсь

SS> -- SS> у автора так:

SS> // для полушага SS> //unsigned char stepper_step_codes[8] = { SS> // 0b00100000, SS> // 0b00110000, SS> // 0b00010000, SS> // 0b00011000, SS> // 0b00001000, SS> // 0b00001100, SS> // 0b00000100, SS> // 0b00100100 SS> //};

SS> // для полношага SS> //unsigned char stepper_step_codes[4] = { 0b00100000, 0b00010000, SS> 0b00001000, // 0b00000100 };

SS> uint8_t stepper_step_codes[4][4] = { SS> { 1, 0, 0, 0 }, SS> { 0, 1, 0, 0 }, SS> { 0, 0, 1, 0 }, SS> { 0, 0, 0, 1 } SS> }; SS> unsigned char stepper_current_step;

SS> --

вот так если uint8_t stepper_step_codes[8][8] = { { 1, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 1 }, { 0, 0, 0, 1 }, { 1, 0, 0, 1 } }; unsigned char stepper_current_step; то оно не в половину, а в 5 раз меньше поворачивается

Sasha

formatting link
formatting link
[Team OS/2][Team EDSMO]

Reply to
Sasha Shost

Hello All!

SS> { 0, 1, 0, 0 }, SS> { 0, 1, 1, 0 }, все сделал, все гуд вышло

Reply to
Sasha Shost

Sasha,

You wrote to All:

SS> на сях для атмега8 есть исходник SS> там поменять чуток SS> -- SS> у автора так: SS>

SS> // для полушага SS> //unsigned char stepper_step_codes[8] = { SS> // 0b00100000, SS> // 0b00110000, SS> // 0b00010000, SS> // 0b00011000, SS> // 0b00001000, SS> // 0b00001100, SS> // 0b00000100, SS> // 0b00100100 SS> //}; SS>

SS> // для полношага SS> //unsigned char stepper_step_codes[4] = { 0b00100000, 0b00010000, SS> 0b00001000, SS> // 0b00000100 }; SS>

SS> uint8_t stepper_step_codes[4][4] = { SS> { 1, 0, 0, 0 }, SS> { 0, 1, 0, 0 }, SS> { 0, 0, 1, 0 }, SS> { 0, 0, 0, 1 } SS> }; SS> unsigned char stepper_current_step; SS>

SS> -- SS>

SS> записать вот так, как понимаю: SS>

SS> { 1, 0, 0, 0 }, SS> { 1, 1, 0, 0 }, SS> { 0, 1, 0, 0 }, SS> { 0, 1, 1, 0 }, SS> { 0, 0, 1, 0 }, SS> { 0, 0, 1, 1 }, SS> { 0, 0, 0, 1 }, SS> { 1, 0, 0, 1 } SS>

SS> тут исходный проект SS>

formatting link

=== Begin of motor.asm === ;* Motorsteuerung 2004-08-14 .include "tn11def.inc"

;************** Define global registers ************* .def temp = R16 .def temp1 = R17 .def temp2 = R18 .def zaehler = R20 ;*************** Define constants ******************* .equ c_value = 114 ;Value for Timer ;141cycles@1Mhz/8 = 1125us ;256-141=115 ;**************************************************** ;* ;* PROGRAM START - EXECUTION STARTS HERE ;* ;**************************************************** .cseg

;Initialize interrupt vectors ;Reset .org 0x00 rjmp main rjmp main rjmp main .org OVF0addr ;Init Timer interrupt vector rjmp OVF0_rout rjmp main

;******************************************** ;* ;* Timer Output interrupt routine ;* ;* DESCRIPTION ;* ; ; Z - point to next value ; ;* This interrupt routine load new step motor ;* value from the step motor table in FLASH. ;* The values in the table have two functions, ;* the lower nibble contains the value to output ;* to the step motor. ;* The upper nibble holds the address of the next ;* value. First the step value is output to the port, ;* next the address is moved to the ZL register. ; ; ;* Number of words : + return ;* Number of cycles : + return ; ;* registers used :5 (R0,temp1,temp,ZL,ZH) ;* set T=1 ;**************************************************** OVF0_rout: ldi temp1,c_value ;Load pre value out TCNT0,temp1 in temp,SREG lpm ;Load R0 with Z pointer value mov temp1,R0 andi temp1,0x0F ;Mask away upper nibble out PORTB,temp1 ;Output lower nibble to step motor mov temp1,R0 swap temp1 ;Swap upper and lower nibble andi temp1,0x0F ; Mask away upper nibble, address is ready andi ZL,0xF0 ; or ZL,temp1 out SREG,temp set ;for Counter reti

;**************************************************** ;* ;* Main Program ;* ;* This program initialize Timer 0 with a defined ; c_value constant. ;* The step motor lookup table is loaded from the flash. ;* ;******************************************************** main: cli ;Disable interrupt ldi temp,0 out PORTB,temp ;Write initial value to PORTB out SREG,temp out MCUCR,temp out GIMSK,temp out WDTCR,temp in temp,GIFR andi temp,1<<PCIF out GIFR,temp in temp,ACSR andi temp,1<<ACI out ACSR,temp ldi temp,0x0f ;Set PORTB pin3-0 as output out DDRB,temp ldi zaehler,3 ;add... wegen spaeter auf 1 ldi ZH,high(step0*2) ;Init Z pointer to step table in flash ldi ZL,low(step0*2) ldi temp,0b00000010 ; C(loc)K/8 - prescale for Timer out TCCR0,temp ; ldi temp,0b00000010 ;TOV0 cleare (0b00000010) out TIFR,temp ;Clear pending timer interrupt ldi temp,c_value ;Load value out TCNT0,temp ldi temp,0b00000010 ;Set TOIE0 (0b00000010) out TIMSK,temp ;Enable Timer interrupt sei rjmp main0 main1: cli ldi ZH,high(step1*2) ;Initialize Z pointer to FLASH location mov temp,ZL ldi ZL,low(step1*2) andi temp,0x0F ; andi ZL,0xF0 ;Keine "ueberraschungen" fuer Motor or ZL,temp sei rjmp loop1 main0: ldi temp2,0 bld temp2,0 ;Bit load from T to temp1(0) clt ;T=0 add zaehler,temp2 breq main1 rjmp main0

loop1: nop rjmp loop1 ;Do something else

;*** Step motor lookup table ***

.ORG FLASHEND - 0x0f

step0:

.DB 0b00011001, 0b00101001 .DB 0b00110001, 0b01000001 .DB 0b01010011, 0b01100011 .DB 0b01110010, 0b10000010 .DB 0b10010110, 0b10100110 .DB 0b10110100, 0b11000100 .DB 0b11011100, 0b11101100 .DB 0b11111000, 0b00001000

step1:

.DB 0b00010001, 0b00100001 .DB 0b00110000, 0b01000001 .DB 0b01010010, 0b01100010 .DB 0b01110000, 0b10000010 .DB 0b10010100, 0b10100100 .DB 0b10110000, 0b11000100 .DB 0b11011000, 0b11101000 .DB 0b11110000, 0b00001000

=== End of motor.asm =====

Зачем он нам нужен был, уже не помню. Hо работал...

Andrey

Reply to
Andrey Arnold

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.