ROBOTIS e-Manual v1.13.01
Learning ollo servo motor position reading
CM-530
OLLO servo motor
The controller can change input analog signals into digital form. This example converts the motor’s analog position signal.
Refer to controller’s port for port and pin number in 06 OLLO MOTOR ROTATE\APP\src\main.c


The ANALOG MUX (74HC4052D) blocks impedance and converts voltage from 5V to 3.3V.
The ADX MUX circuit combines signal from ADC_SELECT0, and ADC_SELECT1; SIG_ADC0 selects a signal from ADC1, ADC2, or ADC3 and feeds it into the microcontroller; SIG_ADC1 selects a signal from ADC4, ADC5, or ADC6 and feeds it into the microcontroller; then this signal gets converted into digital.
Refer to controller’s port for port and pin number in 07 OLLO MOTOR POSITION\APP\src\main.c
int main(void) { /* System Clocks Configuration */ RCC_Configuration(); /* NVIC configuration */ NVIC_Configuration(); /* GPIO configuration */ GPIO_Configuration(); SysTick_Configuration(); /* ADC configuration */ ADC_Configuration(); GPIO_ResetBits(PORT_SIG_MOT1P,PIN_SIG_MOT1P); GPIO_ResetBits(PORT_SIG_MOT1M,PIN_SIG_MOT1M); GPIO_ResetBits(PORT_SIG_MOT2P,PIN_SIG_MOT2P); GPIO_ResetBits(PORT_SIG_MOT2M,PIN_SIG_MOT2M); GPIO_ResetBits(PORT_SIG_MOT3P,PIN_SIG_MOT3P); GPIO_ResetBits(PORT_SIG_MOT3M,PIN_SIG_MOT3M); GPIO_ResetBits(PORT_SIG_MOT4P,PIN_SIG_MOT4P); GPIO_ResetBits(PORT_SIG_MOT4M,PIN_SIG_MOT4M); GPIO_ResetBits(PORT_SIG_MOT5P,PIN_SIG_MOT5P); GPIO_ResetBits(PORT_SIG_MOT5M,PIN_SIG_MOT5M); GPIO_ResetBits(PORT_SIG_MOT6P,PIN_SIG_MOT6P); GPIO_ResetBits(PORT_SIG_MOT6M,PIN_SIG_MOT6M); GPIO_ResetBits(PORT_LED_POWER, PIN_LED_POWER);
while(1) { GPIO_ResetBits(PORT_ADC_SELECT0,PIN_ADC_SELECT0); GPIO_ResetBits(PORT_ADC_SELECT1,PIN_ADC_SELECT1); mDelay(10); /* Start ADC1,ADC2 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); ADC_SoftwareStartConvCmd(ADC2, ENABLE); mDelay(10); POT_1 = (ADC_GetConversionValue(ADC1))>>2; POT_4 = (ADC_GetConversionValue(ADC2))>>2; GPIO_SetBits(PORT_ADC_SELECT0,PIN_ADC_SELECT0); GPIO_ResetBits(PORT_ADC_SELECT1,PIN_ADC_SELECT1); mDelay(10); /* Start ADC1,ADC2 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); ADC_SoftwareStartConvCmd(ADC2, ENABLE); mDelay(10); POT_2 = (ADC_GetConversionValue(ADC1))>>2; POT_5 = (ADC_GetConversionValue(ADC2))>>2; GPIO_ResetBits(PORT_ADC_SELECT0,PIN_ADC_SELECT0); GPIO_SetBits(PORT_ADC_SELECT1,PIN_ADC_SELECT1); mDelay(10); /* Start ADC1,ADC2 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); ADC_SoftwareStartConvCmd(ADC2, ENABLE); mDelay(10); POT_3 = (ADC_GetConversionValue(ADC1))>>2; POT_6 = (ADC_GetConversionValue(ADC2))>>2; TxDWord16(POT_1); TxDByte_PC(' '); TxDWord16(POT_2); TxDByte_PC(' '); TxDWord16(POT_3); TxDByte_PC(' '); TxDWord16(POT_4); TxDByte_PC(' '); TxDWord16(POT_5); TxDByte_PC(' '); TxDWord16(POT_6); TxDByte_PC(' '); TxDByte_PC('\r'); TxDByte_PC('\n'); } return 0; } |
From any port the controller can read the position value of the servo motor. The range is from 0 to 0x03FF. The following illustration is with a servo motor in port 3.
