2022-09-20 04:25 AM
Hello,
I am trying to get information from two analog sensore (FSRs) by using two seperated data lines (PB0 as IN15 and PA7 as IN12) through ADC1
(Not important note - I created unint32s for debuging and I am willing to transfer the data by using CANBUS as you can see in the main.c)
The problem:
I am getting the information from the sensors, but the data of one sensor gets corrupted by the other one. For example if I pinch the left FSR his data chanegs from 10 to 4095 but if I pinch the right sensor, the left sensor data still changes but from 10 to 800. The exact same thing happans both sides. What could be the problem? How can I make the data line seperated from eachothers?
I am attaching the main.c and the configurations.
In addition its on Circular Mode, Increment address is only Memory and with Data Width of a Word
Thank you,
Raam Kavod
Solved! Go to Solution.
2022-09-21 08:42 AM
I have figured it out!
There are S&H capacitors (Sample and Hold) in the ADC inputs and they are probably connected between the data lines, than there are parasitic noises(current that moves between the capacitors) between them and thats why I had this data corruptions.
The solution I chose is to add resistors in parallel between the GND and the Data line (in addition to the 10kOhm resistors), It harms the resolution but it pulls down the noises between the data lines.
I put 100Ohm resistors between each data line to its GND so the capacitors will discharge faster (tau=RC). It worked pretty good.
Important note: It worked for me because I put couple of FSRs in parallel and I had to pull down the noises as much as I can. It will probably work with more resistance aswell.
Thank for your help @raptorhal2 , @Simon.T
2022-09-20 06:02 AM
Hello @RKavod ,
I ran your main.c in my nucleo and I didn't see any issue with you code. The data weren't corrupted and were independent.
I might come from your sensor. Is it possible to check the voltage by a scope or to test them one by one,
2022-09-20 06:24 AM
Hello and thank you for your quick response.
The only connection between the two sensors is the GND and 5V lines through the board.
The sensors are simple resistors. so I cant see why they would affect each.
If I will check them with the scope I will see their affection becuase I believe it comes from the internal ADC.
Did you try my main.c with connected FSRs?
Thank you a lot for your help
2022-09-20 07:43 AM
I didn't try with FSRs sensor (I don't have it) just with wire connected to the ADC_INPUTs. However, I just checked your main and confirm at MCU level there is no issue.
Let's check with the scope or even with another ADC_INPUT. It should not come from the ADC as the channel are independents
2022-09-20 08:20 AM
I can see in the scope that there are changes in voltage, I think it happans becuase the sensors are connected to GND through an 10Kohm resistor and there is leakage of data to GND.
In addition I'm trying to write a code for stm32F303K8 which has two adc channels and to start and stop each adc after each sampling in two individual sub-routines, do you think it would solve the problem?
By the way I'm an amature, I'm sorry if I dont use the right terms and dont understand everything :)
Sincerely,
Raam Kavod
2022-09-20 02:57 PM
Try changing the 5V to something not greater than the L433 VDDA reference.
2022-09-21 03:28 AM
I've used 5V from external supplier, I tried 5V VDDA and I tried 3.3V external and internal too.
Unfortunatley it doesnt matter.
By the way I have used STM32F303K8 to try seperated ADCs (ADC1 & ADC2) without DMA and it still dependent somehow.
2022-09-21 08:42 AM
I have figured it out!
There are S&H capacitors (Sample and Hold) in the ADC inputs and they are probably connected between the data lines, than there are parasitic noises(current that moves between the capacitors) between them and thats why I had this data corruptions.
The solution I chose is to add resistors in parallel between the GND and the Data line (in addition to the 10kOhm resistors), It harms the resolution but it pulls down the noises between the data lines.
I put 100Ohm resistors between each data line to its GND so the capacitors will discharge faster (tau=RC). It worked pretty good.
Important note: It worked for me because I put couple of FSRs in parallel and I had to pull down the noises as much as I can. It will probably work with more resistance aswell.
Thank for your help @raptorhal2 , @Simon.T
2022-09-21 04:17 PM
There is one S&H cap for each ADC, a multiplexor switch connects one channel at a time to the S&H/ADC for conversion.
A hint - the 2cycles_5 sampling time is very short for a resistor network signal. ST has an application note on ADC Accuracy that explains it all.
2022-09-28 01:51 AM
Everything works.
Thank you for your help!