logo elektroda
logo elektroda
X
logo elektroda
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[Atmega128][WINGCC] Serwomechanizm HSR 8498HB Serial Mode

albertas123 17 Lut 2010 13:18 1110 3
  • #1 7707807
    albertas123
    Poziom 10  
    Witam!

    Pracuję na serwie cyfrowym HSR 8498HB i próbuje dostać się do trybu Serial Mode. Ciekaw jestem czy ktoś z was miał z tym do czynienia.

    Zgodnie z instrukcją do serwa należy wysłać następujący szereg bajtów (przykładowo aby ustawić prędkość serwa i odczytać pozycję):

    Byte 1 = Header = 0x080
    Byte 2 = Command = 0xE9
    Byte 3 = Data 1 = Servo ID (0x00 to 0x7F) : use 0x00
    Byte 4 = Data 2 = Speed (0x00 to 0xFF)
    Byte 5 = Checksum = 256 – (Byte 1+ Byte2 +Byte3+Byte4)
    Byte 6 = Received Byte 1 = Position High
    Byte 7 = Received Byte 2 = Position Low

    Wszystko to z prędkością 19200 b/s. Tak wygląda poprawna ramka w przypadku wysłania nagłówka 0x080:
    [Atmega128][WINGCC] Serwomechanizm HSR 8498HB Serial Mode

    Cały pakiet ma składać się z: 7* (8+3) bitów = 4.03 ms.

    Wykonałem najprostszy z możliwych program na delayach, badam oscyloskopem sygnał wysyłany do serwa, ale niestety serwo a momencie wysyłania dwóch ostatnich 0x00 nic nie odpowiada. Nie potrafię dojść do tego co jest nie tak.

    Poniżej program:

    
    // SET MOTOR SPEED AND READ POSITION//
    
    		// HEADER //0x80// 1 1111 1110 00
    		PORTC = 0xFF;
    		_delay_us(8*52);
    		PORTC = 0x00;
    		_delay_us(3*52);
    		
    		// COMMAND // 0xE9 // 1 0110 1000 00
    		PORTC = 0xFF;
    		_delay_us(1*52);
    		PORTC = 0x00;
    		_delay_us(1*52);
    		PORTC = 0xFF;
    		_delay_us(2*52);
    		PORTC = 0x00;
    		_delay_us(1*52);
    		PORTC = 0xFF;
    		_delay_us(1*52);
    		PORTC = 0x00;
    		_delay_us(5*52);
    
    		// DATA 1 = SERVO ID // 1 1111 1111 00
    
    		PORTC = 0xFF;
    		_delay_us(9*52);
    		PORTC = 0x00;
    		_delay_us(2*52);
    
    		// DATA 2 = SPEED // 1 1111 1111 00
    
    		PORTC = 0xFF;
    		_delay_us(9*52);
    		PORTC = 0x00;
    		_delay_us(2*52);
    
    		// CHECKSUM = 1 0110 1001 00
    
    		PORTC = 0xFF;
    		_delay_us(1*52);
    		PORTC = 0x00;
    		_delay_us(1*52);
    		PORTC = 0xFF;
    		_delay_us(2*52);
    		PORTC = 0x00;
    		_delay_us(1*52);
    		PORTC = 0xFF;
    		_delay_us(1*52);
    		PORTC = 0x00;
    		_delay_us(2*52);
    		PORTC = 0xFF;
    		_delay_us(1*52);
    		PORTC = 0x00;
    		_delay_us(2*52);
    
    		// 00 // 1 1111 1111 00
    
    		PORTC = 0xFF;
    		_delay_us(9*52);
    		PORTC = 0x00;
    		DDRC = 0x00;
    		_delay_us(2*52);
    		DDRC = 0xFF;
    
    		// 00 // 1 1111 1111 00
    
    		PORTC = 0xFF;
    		_delay_us(9*52);
    		PORTC = 0x00;
    		DDRC = 0x00;
    		_delay_us(2*52);
    		DDRC = 0xFF;
    


    Help!
  • #2 7707904
    Konto nie istnieje
    Konto nie istnieje  
  • #3 7707938
    albertas123
    Poziom 10  
    Sumę kontrolną liczę następująco:

    1) Dodaję bajty 1-4.

    W tym wypadku 0x80+0xE9+0+0 = -0110 1001 = 0110 1001.

    2) Zamieniam na przeciwne: 1001 0110 i wysyłam od końca: 0110 1001.

    Czyli cała ramka ma postać 1 0110 1001 00...
  • Pomocny post
    #4 7707976
    Konto nie istnieje
    Konto nie istnieje  
REKLAMA