Hi,
I am using the FOC4.4.2 firmware with the PAC5223.
I need to control the motors speed with a potentiometer connected to AIO6 pin.
Hi,
I am using the FOC4.4.2 firmware with the PAC5223.
I need to control the motors speed with a potentiometer connected to AIO6 pin.
Hi Anupthackar,
The FOC4.2.2 FW does not contain a function on how to use a potentiometer with AIO6. However, this code should be fairly easy to implement. Here are some steps that I recommend you follow:
Connect the potentiometer in series with a resistor such that the maximum voltage out of the potentiometer center tap is 2.5V. Tha PAC5223’s ADC can only see voltages as high as 2.5V. Your current configuration will saturate the ADC as the maximum output voltage is 3.3V.
Configure AIO6 as an analog input by configuring it as a Gain Amplifier (Gain Amplifier Mode 0b01), Gain = 1 (Gain = 0b001), and Multiplexer Selector of AB6 (0b000). This is done on the file board_ep5223lvmxxx.c.(the board file will depend on which board configuration you are employing.
pac5xxx_tile_register_write(ADDR_CFGAIO6, ((0b01<< 6) | (0b001 << 3) | (0b000 << 0))); // Gain Amp Mode
pac5xxx_adc_as1_sequence_config(2, ADCCTL_ADMUX_AD6, ASSEQ_MSPI_AFTER_SH, SIGMGR_MSPI(SIGMGR_AB6), ASSEQ_DELAY_0);
Once the ADC is converter you can add your own logic to extract speed command from the potentiometer analog voltage and then submit the Speed in Hz to the FOC algorithm. Hope the info helps!
Hi Jose,
Thank you for your elaborate explanation.
I had done these changes mentioned by you earlier, however observed the ADC value keeps fluctuating.
There is no definition for ADCCTL_ADMUX_AD6 in Pac5xxx_Adc.h file or in the Pac5223x user manual .
Is the AIO6 connected to ADCCTL_ADMUX_AD0 of the ADC Mux with the pre-mux in Cafe peripheral?
I connected the potentiometer to PC3 and it works as expected. I have revised the PCB files accordingly for now.
Hi Anupthakar, I must apologize as I made a mistake on my previous instructions. You would not use AD6 but AD0. Here is a diagram on how all the analog inputs are connected into the ADC input through the different multiplexers:
Yes, PC3 is also a good ADC input to use for potentiometers. Glad to hear you are up and running! Do let us know if there is anything else we can help you with.