Hello folks,
I have a question about the ADC I use the TMS320F28055 controller. There is a POTI on the output pin. I can successfully do a conversion with the ADC. My trigger source is a timer, which means my ADC value is updated every millisecond. The converted ADC value is in the AdcResult.ADCRESULT0 register. I converted the digital value for my application in a state machine the value runs for example between 0-200 and is stored in a variable "A" and is sent to another controller. Now we come to the main problem, I only want to send the value stored in variable "A" when the ADC value changes. For this I created a struct with previous value and current value. I update the current value in my timer interrupt and constantly compare it in the state machine, if the values are not the same, "A" should be sent again. The problem is that it constantly jumps into the send function, although the debug mode shows that both values (previous and current) are the same. To test, I turned the potentiometer up all the way or set it to 0, but it doesn't work. Can someone tell me how I could solve it?
I suspect that it is due to the Adc Result.ADC RESULT 0 parameter.(because the parameter is always constantly changing)
I thank you for your help.
GLOBALS_statusMotorcontroller.frequenz_sollwert = is the value to be sent
freqsollwert.vorherigerSollwert = previous value
freqsollwert.aktuellerSollwert = this is the current value which is constantly updated in the timer interrupt
sendesollwert = this is a boolean variable to ensure that the value is only sent if it has changed.
faktor_frequenz = 4095 / diff; GLOBALS_statusMotorcontroller.frequenz_sollwert = offset + AdcResult.ADCRESULT0 / faktor_frequenz; if(freqsollwert.vorherigerSollwert != freqsollwert.aktuellerSollwert) { sendesollwert = false; } ////////////FREQUENZ-SOLLWERT auf Änderung senden///////////// if(sendesollwert == false) { //testcounter++; freqsollwert.vorherigerSollwert = freqsollwert.aktuellerSollwert; INTERFACE_MOTORCONTROLLER_addtokritischeQueue(Motorcontroller_Befehl_Write_BE_FREQUENZ_SOLLWERT, GLOBALS_statusMotorcontroller.frequenz_sollwert ); STATEMACHINE_SPI_MOTORCONTROLLER_kommunikation(); sendesollwert = true; }