Go Down

Topic: Strange Behavior Regarding PWM/possible noise (Read 552 times) previous topic - next topic

deliand

Hello, I have been designing a circuit for a stationary bicycle accessory that we are building, meant to control a virtual bike in a virtual reality game. We are using an Arduino for sensing different aspects such as speed of pedaling, turning, braking, etc. We are also using the Arduino to give a PWM signal to modulate a retarding force on the bicycle's flywheel, done through the activation of an electromagnet. This is done through the changing of the PWM frequency on digital pin 3, which is set as an output.

However, we find that when the PWM frequency is anything but 0, slight jumps in the analogread values appear at the pins which sense turning, braking, and temperature. I am wondering whether this is noise, and what can be done about this, as it is very important that the values sensed are accurate and do not jump around even a little. Again, we don't have this issue when digital pin 3's PWM frequency is set to 0. Would it be beneficial to completely separate the PWM part of the circuit from the sensing part of the circuit?

A schematic of the circuit is attached, thank you for your help in advance!  :)

jremington

#1
Jun 18, 2018, 04:03 am Last Edit: Jun 18, 2018, 04:22 am by jremington
The schematic doesn't show the Arduino and more importantly, how it is powered.  Any variation in the Arduino Vcc will show up as noise in the ADC results, unless you are using a stable external ADC reference.

The schematic also does not show the required capacitors on the 7805 regulators. There is no need to use more than one 7805 to power the sensors.

Note that if the 24V supply drops significantly, so will the individual 7805 outputs (by up to 100 mV), and that also shows up as noise in the ADC. See the 7805 data sheet for the details. You would be better off not using the 24V supply for either the Arduino or the sensor power.

ChrisTenone

Do you really mean PWM frequency, or do you mean the duty cycle, as set by analogWrite()?
I'm not disparaging the differently abled. It's just that thirty years of community college has literally made me mentally retarded.

deliand

#3
Jun 18, 2018, 08:11 am Last Edit: Jun 18, 2018, 08:11 am by deliand
The schematic doesn't show the Arduino and more importantly, how it is powered.  Any variation in the Arduino Vcc will show up as noise in the ADC results, unless you are using a stable external ADC reference.

The schematic also does not show the required capacitors on the 7805 regulators. There is no need to use more than one 7805 to power the sensors.

Note that if the 24V supply drops significantly, so will the individual 7805 outputs (by up to 100 mV), and that also shows up as noise in the ADC. See the 7805 data sheet for the details. You would be better off not using the 24V supply for either the Arduino or the sensor power.

The Arduino is powered just through a power adaptor. I agree that I didn't need to use so many 7805s and realized that after building it. I'll use only one when i update it. I completely forgot about the capacitors required on the 7805. What you say about the noise makes sense. Would you recommend me just using the Arduino's 5V Vout for the sensor power and keeping the 24V power supply for the electromagnet? Or using a 7805 to power the sensors from the 24V power supply? Also, if they are separate, should the sensors and electromagnet share the same ground? Thanks so much!

Do you really mean PWM frequency, or do you mean the duty cycle, as set by analogWrite()?
Sorry, yes, I meant duty cycle.

ChrisTenone

The 7805 is gonna get hot taking 24V down to 5. Using a separate 5 volt supply for the logic circutry would be the least prone to issues, but bucking it down (with something like this) would be preferable to the linear device.
I'm not disparaging the differently abled. It's just that thirty years of community college has literally made me mentally retarded.

Wawa

A pot MUST be powered from Arduino's 5volt supply to keep it's ratiometric behaviour.
The voltage output of a TMP36 should NOT be measured with Arduino's potentially unstable default Aref.
A 47ohm gate resistor could cause dips in the Arduino supply (~ 75mA gate charge/discharge spikes).
Depending on the gate charge of the mosfet.
Leo..
 

deliand

Bump, can someone please advise me how I should connect the grounds? By separating the sensors' power from the electromagnet, I see that the readings are much more stable if only the sensors are connected, and I believe that the problem lies in how I connect the grounds of the two parts of the circuit.

A pot MUST be powered from Arduino's 5volt supply to keep it's ratiometric behaviour.
The voltage output of a TMP36 should NOT be measured with Arduino's potentially unstable default Aref.
A 47ohm gate resistor could cause dips in the Arduino supply (~ 75mA gate charge/discharge spikes).
Depending on the gate charge of the mosfet.
Leo..
 
What is an acceptable tolerance for a potentiometer (the ratiometric behavior you mention)?

jremington

#7
Jun 20, 2018, 01:17 am Last Edit: Jun 20, 2018, 01:17 am by jremington
I don't understand what you mean by "how to connect the grounds". They must be connected by wire, to establish a zero voltage reference.

If you are contemplating alternative circuits, post them so we understand the question.

MorganS

#8
Jun 20, 2018, 02:35 am Last Edit: Jun 20, 2018, 02:35 am by MorganS
Make sure that the high current to the electromagnet does not flow along the same wires as the sensor's grounds. This is usually called a 'star' grounding layout where each device is wired back to a common point - they don't share any length of wire.

"The problem is in the code you didn't post."

unforseen

I don't understand what you mean by "how to connect the grounds". They must be connected by wire, to establish a zero voltage reference.

If you are contemplating alternative circuits, post them so we understand the question.
I believe he is saying that the electromagnet and sensors are powered by 2 different power supplies. Should the negative rails for both supplies be connected and a single wire routed from that connection point to the ground pin on the Arduino? Or should a wire run from each negative rail to a separate ground pin on the Arduino?

unforseen

Make sure that the high current to the electromagnet does not flow along the same wires as the sensor's grounds. This is usually called a 'star' grounding layout where each device is wired back to a common point - they don't share any length of wire.


In order to achieve this, there has to be some some common point at which the ground wires connect so that one wire can be routed to the ground pin of the Arduino. Are you saying to do this as close to the ground pin as possible?

MorganS

Treat each supply and load as separate. Imagine changing the labels on that diagram so it says "Arduino" instead of "sensor1" and "power supply" instead of "sensor2". That doesn't change the wires going to the ground point.

It doesn't really matter how 'close' the supplies are. The power's really coming from a hydroelectric dam hundreds of km away, isn't it? What does matter is having a single point that every component can agree upon to measure "ground" from. One supply or one sensor may have a long wire going to that point.
"The problem is in the code you didn't post."

ChrisTenone

In order to achieve this, there has to be some some common point at which the ground wires connect so that one wire can be routed to the ground pin of the Arduino. Are you saying to do this as close to the ground pin as possible?
Yes
I'm not disparaging the differently abled. It's just that thirty years of community college has literally made me mentally retarded.

deliand

Make sure that the high current to the electromagnet does not flow along the same wires as the sensor's grounds. This is usually called a 'star' grounding layout where each device is wired back to a common point - they don't share any length of wire.


Thank you, this answered my question.

deliand

I changed the grounding and unfortunately I'm still getting noisy analog readings from the sensors when the PWM duty cycle is greater than 0. They start out consistent, but then they get noisier over time.

A pot MUST be powered from Arduino's 5volt supply to keep it's ratiometric behaviour.
The voltage output of a TMP36 should NOT be measured with Arduino's potentially unstable default Aref.
A 47ohm gate resistor could cause dips in the Arduino supply (~ 75mA gate charge/discharge spikes).
Depending on the gate charge of the mosfet.
Leo..
 
What would you recommend regarding the 47o resistor? Should I remove it entirely or replace it with another resistor with a different resistance value? Thanks!

Go Up