Go Down

Topic: Make or buy a RC circuit? (Read 325 times) previous topic - next topic

Spange

Oct 06, 2017, 05:30 pm Last Edit: Oct 06, 2017, 05:45 pm by Spange
Hello Arduino Forum.

I am experimenting with flatting out a PWM signal. I am thinking of using the PWM  library and setting the PWM frequency to 1kHz:

Code: [Select]

#include <PWM.h>
int32:t frequency = 1000; //Hz

// and then in the loop function:
pwmWrite(Pin, Val)


My problem is that I need to flatten out the signal or my Pizo might start to vibrate.
So my question is:
  • Should I but a resistor (R) and a Capasitor(C) and solder my own LP-filter?
  • Can I buy this as a neat small thing with input PWM and output smooth?


Thank you!

Also, side question: converting the PWM-signal to a smooth signal, is that what i DAC does, shoud I get one?

Grumpy_Mike

#1
Oct 06, 2017, 06:27 pm Last Edit: Oct 06, 2017, 06:31 pm by Grumpy_Mike
Quote
converting the PWM-signal to a smooth signal, is that what i DAC does,
No.

Quote
My problem is that I need to flatten out the signal or my Pizo might start to vibrate.
Do you mean smooth out the signal?

Quote
Should I but a resistor (R) and a Capasitor(C) and solder my own LP-filter?
Yes.

Quote
Can I buy this as a neat small thing with input PWM and output smooth?
Yes but you will need to know what cut off frequency you want. Indeed you will need to know what cut off frequency means. Along with the filter order. Low Pass filter

What frequency do you want this smoothed signal to change at?

Have you read this:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

MarkT

#2
Oct 06, 2017, 08:18 pm Last Edit: Oct 06, 2017, 08:18 pm by MarkT
A piezo transducer is already a capacitor by its nature - you may only need a series resistor
to get low-pass filtering.  Some experimentation needed of course.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Spange

What frequency do you want this smoothed signal to change at?

Have you read this:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html
I read your post, thx.

So, I need to move my piezo quickly, take a picture and then move again.
I'd like  a framrate of 200Hz. That means that after I take a picture, with a short short shutter speed, the piezo has less than 0,005s to move to a new position and become stationary.
The voltages I'd like to apply are 0,1,2,0,1V ...
So from the Arduino I write the voltages with PWM, and the piezo is connected in parallell with the capacitor. From your post I'd say I need a cut-off frequency of roughly 1kHz.

When it comes to the filter order i think 1st or 2nd should be adequate.
Could you provide a link to a online store? I have actually tried to google a lot.

A piezo transducer is already a capacitor by its nature - you may only need a series resistor
to get low-pass filtering.  Some experimentation needed of course.
I wasn't aware of this. So your saying i could hook up the piezo directly to the PWM-port and to GND (Possibly with a resistor in between). I'm reluctant to trying it, since I might destroy my piezo if it doesn't work. Do you have any theory supporting this?

Grumpy_Mike

Quote
So, I need to move my piezo quickly, take a picture and then move again.
I'd like  a framrate of 200Hz. That means that after I take a picture, with a short short shutter speed, the piezo has less than 0,005s to move to a new position and become stationary.
That is a whole new ball game and not at all what you asked in the first post. I also suspect that it is not going to happen.
What are you trying to do, this is coming across as a classic x-y problem.

So explain what you want to do and with what equipment and give a link to this piezo that looks like it has to move a camera. It doesn't sound like it is a project for an Arduino.

Spange

That is a whole new ball game and not at all what you asked in the first post. I also suspect that it is not going to happen.
What are you trying to do, this is coming across as a classic x-y problem.

So explain what you want to do and with what equipment and give a link to this piezo that looks like it has to move a camera. It doesn't sound like it is a project for an Arduino.
The piezo is not relevant for this post. (It does not move a camera, it moves a mirror which shift structured light)
I am searching for help on the design of a LP filter (or something else) that can smooth out a PWM-signal.
I'd like to send a constant 1V and 2V (seperately), sending a PWM square-wave does not work, I need the average value (duty cycle x 5V). I need the signal to converge in less than 5ms.

I thought of a RC circuit with t=RC=1ms, where R=100Ohm and C = 1uF.

Is it possible to buy this circuit?

Grumpy_Mike

Quote
Is it possible to buy this circuit?
Yes you buy the individual components.

Quote
I am searching for help on the design of a LP filter (or something else) that can smooth out a PWM-signal.
Yes but you do not have any specification to allow you to design it.
What is the acceptable ripple level?
How fast do you want the signal to move?
What PWM frequency do you want?

Quote
When it comes to the filter order i think 1st or 2nd should be adequate.
You have absolutely no foundation for saying this unless you plug in all the above numbers and see if that order of filter will do the job.


gdsports

Is it not possible to use an I2C DAC?

Or switch to a SAM/SAMD based board since they have built-in DACs? I have not personally used this feature so take this with a grain of sodium-free salt substitute.

https://www.arduino.cc/en/Reference/AnalogWriteResolution


Quote
The Zero has the following hardware capabilities:

10 pins which default to 8-bit PWM, like the AVR-based boards. These can be changed to 12-bit resolution.
1 pin with 10-bit DAC (Digital-to-Analog Converter).

By setting the write resolution to 10, you can use analogWrite() with values between 0 and 1023 to exploit the full DAC resolution

Spange

Is it not possible to use an I2C DAC?
Great Idea!
I just bought this:
https://www.adafruit.com/product/935

What fist bewilders me is which output channel from the Arduino I use as Input to the DAC.
I think the DAC want I2C (SLC/SDA) as input, but how do I provide/convert a given PWM (say 3V d=60%) to I2C.

A0 is the analog (flat/smoothed) output, right?

gdsports

#9
Oct 11, 2017, 10:49 am Last Edit: Oct 11, 2017, 12:18 pm by gdsports Reason: VOUT is voltage output
Run through the Adafruit tutorial for the board. You should be able to produce a triangle wave and sine wave at the DAC board VOUT pin. This ensures you have connected all the wires and soldered the pins correctly.

Read the datasheet and read the library source code to understand how it works.

I2C is a communications bus to the DAC chip.

Look at the source code for the triangle wave example.

Code: [Select]
dac.setVoltage(counter, false);

The setVoltage function sends a message over the I2C bus to the DAC chip. The DAC chip then changes the voltage output based on the first parameter. Stop thinking in duty cycle and start thinking in voltage output. The program changes the output voltage from min to max then max back to min. Scope the DAC board VOUT pin. If you do not know how to use a scope, you are in over your head.


Go Up