12.07.2015 Views

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The <strong>se</strong>rvo motors in the head and the gripper modulesPositions the <strong>se</strong>rvo of the head in a certain position and the sweeps the <strong>se</strong>rvo from right to left.PIC16F887Demoprogram Flowcode PIC V4PROTDEM_FCPIC_SERVO.fcfDemoprogram Hitech C lite for PIC#include #include "PIC_PROTON_LIB.h"#define _XTAL_FREQ 19660800__CONFIG(0x2ff2); // <strong>se</strong>t HS Xtal etc__CONFIG(0x3fff);void DELAYSEC (void){for (char i = 0; i < 10 ; i++) __delay_ms(100);}void main(){// init AD & Option regANSEL = 0;ANSELH = 0;OPTION = 0xC0;// end of init__delay_ms(250);__delay_ms(250); //wait for stable power supplyI2C_INIT(); // initialize I2C - LCD03 is a I2C LCDvolatile unsigned char x = 128;I2C_SEND_MESSAGE(0xAA,0,1); // <strong>se</strong>rvo's head onI2C_SEND_MESSAGE(0xAA,1,80); // UP / DOWNDELAYSEC ();I2C_SEND_MESSAGE(0xAA,2,128); // LEFT / RIGHTDELAYSEC ();while (1){while (x < 255){I2C_SEND_MESSAGE(0xAA,2,x); // LEFT / RIGHTx++;__delay_ms(30);}while (x > 1){I2C_SEND_MESSAGE(0xAA,2,x); // LEFT / RIGHTx--;__delay_ms(30);ATMEGA32Demoprogram Flowcode AVR V4PROTDEM_FCAVR_SHARP.fcf_avrDemoprogram WinAVR C for AVR#include #define F_CPU 19660800UL#include #include "AVR_PROTON_LIB.h"#include "AVR_PROTON_LIB.c"void DELAYSEC (void){for (volatile char i = 0; i < 10 ; i++) _delay_ms(100);}int main ( void ){_delay_ms(250);_delay_ms(250); //wait for stable power supplyI2C_INIT(); // initialize I2C - LCD03 is a I2C LCDvolatile unsigned char x = 128;I2C_SEND_MESSAGE(0xAA,0,1); // <strong>se</strong>rvo's head onI2C_SEND_MESSAGE(0xAA,1,80); // UP / DOWNDELAYSEC ();I2C_SEND_MESSAGE(0xAA,2,128); // LEFT / RIGHTDELAYSEC ();while (1){while (x < 255){I2C_SEND_MESSAGE(0xAA,2,x); // LEFT / RIGHTx++;_delay_ms(30);}}while (x > 1){I2C_SEND_MESSAGE(0xAA,2,x); // LEFT / RIGHTx--;_delay_ms(30);}}}}}Bart Huyskens <strong>Manual</strong> <strong>Elektor</strong> <strong>Proton</strong> V1.0 3 April 2011 55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!