News:

New registrations to the forum only by request to admin@underservice.org

Main Menu

Arduino Square Wave Generator

Started by Vincent, January 11, 2014, 01:56:29 PM

Previous topic - Next topic

Vincent

Hello people.


Months ago I was tired of building oscillators and circuits with discrete components so I decided to move all my logic development to Arduino. Cheaper, simple and accurate. Also I can use the code with others ATMEL cpu's. This library wasn't wrote by me and all the credits are for the original developer.  I have more stuff to share and I will do it progressively. I highly recommend to use optocouplers for the high end section ( Mosfet Drivers, etc ).

Regards,

Vincent

Code

// Arduino UNO DDS

#include <PWM.h>

int32_t frequency_9 = 4000; //frequency (in Hz)
int32_t frequency_3 = 3000; //frequency (in Hz)


void setup()
{

InitTimersSafe();

SetPinFrequencySafe(9, frequency_9);
SetPinFrequencySafe(3, frequency_3);

}

void loop()
{

int dutyC =222; // Duty Cycle 0 (0%) - 1023(100%)
pwmWrite(9, dutyC / 4);
pwmWrite(3, dutyC / 4);
delay(30);

}



Arduino Square Wave Generator (UNO - Mega - Pro.Mini)

Frequency Range : 1Hz to 1Mhz
Duty Cycle : 2% - 98%
Pins Out : 3 - 9

Information

http://code.google.com/p/arduino-pwm-frequency-library/downloads/list
http://forum.arduino.cc/index.php/topic,117425.0.html

Recommended Mosfet driver : FOD3180
http://www.fairchildsemi.com/ds/FO/FOD3180.pdf

Romero

@Vincent

I need an Arduino code for coil shorting where I can chose the number or shortings per pulse also duration of the shorting pulse. Do you have  or know something like that?
I will prefer to use arduino mega board 2560 with display and keypad.

Best regards,
Romero

kEhYo77

Hi Romero.
I think I can help you with that type of code.
You just need to describe in detail what you want.
I own an ArduinoUno an 2-line and 4-line LCD displays.
Will you be using a pulse detection to trigger the shorting?

kEhYo

Romero

Quote from: kEhYo77 on February 07, 2014, 10:32:04 PM
Hi Romero.
I think I can help you with that type of code.
You just need to describe in detail what you want.
I own an ArduinoUno an 2-line and 4-line LCD displays.
Will you be using a pulse detection to trigger the shorting?

kEhYo
Hi kEhYo,

please have a look at the picture below and you will understand.

Regards,
Romero

Vincent

Quote from: Romero on February 07, 2014, 10:01:35 PM
@Vincent

I need an Arduino code for coil shorting where I can chose the number or shortings per pulse also duration of the shorting pulse. Do you have  or know something like that?
I will prefer to use arduino mega board 2560 with display and keypad.

Best regards,
Romero

Hi Romero,

You read my mind. I was working 1 month ago in that kind of code. I started from the scratch using a Zero Cross detector. Nothing fancy but it works. Originally was wrote for a dimmer and I need to finish the details about the items that are you asking.

Witch will be your trigger ? A truly clean sine-wave or a square waveform ?

@ kEhYo. Nice to meet you. Maybe the code that I started to work can help you too.

Regards, V.


Vincent

Quote from: Romero on February 07, 2014, 10:49:42 PM
Quote from: kEhYo77 on February 07, 2014, 10:32:04 PM
Hi Romero.
I think I can help you with that type of code.
You just need to describe in detail what you want.
I own an ArduinoUno an 2-line and 4-line LCD displays.
Will you be using a pulse detection to trigger the shorting?

kEhYo
Hi kEhYo,

please have a look at the picture below and you will understand.

Regards,
Romero

Sorry. I missed the pic. I understand what you want to do. The NE555 and the 4017 can be replaced by the arduino. Mixing CMOS and TTL can be done, but all most be at 5V, or a buffer to convert levels. Let me think about it.

Regads. V

kEhYo77

#6
Ok. I get it now.
I am working on coil shorting as well but things go slow on this. To many projects on my mind.
The arduino code for this setup shouldn't be difficult. I'll try to make some code for this soon.
I include my schematic for testing this.
Tell me what you think.

Romero

Quote from: kEhYo77 on February 08, 2014, 09:07:47 AM
Ok. I get it now.
I am working on coil shorting as well but things go slow on this. To many projects on my mind.
The arduino code for this setup shouldn't be difficult. I'll try to make some code for this soon.
I include my schematic for testing this.
Tell me what you think.
Hi,

I know your schematic for long time now but never tested it.
For now I would prefer to use my idea or instead of using cd4017 to replace it with arduino code too.
There is another idea that I must get arduino code for... shorting the bemf. people never understood the importance of this years back while I was playing with coil shorting.
I can do it with magnet motors but solid state will have many advantages.


Best regards,
Romero

kEhYo77

I got the feeling that Ismael Aviso is doing BEMF shorting :)

Vincent

Quote from: Romero on February 08, 2014, 12:26:12 PM
Quote from: kEhYo77 on February 08, 2014, 09:07:47 AM
Ok. I get it now.
I am working on coil shorting as well but things go slow on this. To many projects on my mind.
The arduino code for this setup shouldn't be difficult. I'll try to make some code for this soon.
I include my schematic for testing this.
Tell me what you think.
Hi,

I know your schematic for long time now but never tested it.
For now I would prefer to use my idea or instead of using cd4017 to replace it with arduino code too.
There is another idea that I must get arduino code for... shorting the bemf. people never understood the importance of this years back while I was playing with coil shorting.
I can do it with magnet motors but solid state will have many advantages.


Best regards,
Romero


Hi. Well the code is working. I'm just adjusting the last details. Maths are maths..

Romero

Quote from: Vincent on February 08, 2014, 10:57:07 PM
Quote from: Romero on February 08, 2014, 12:26:12 PM
Quote from: kEhYo77 on February 08, 2014, 09:07:47 AM
Ok. I get it now.
I am working on coil shorting as well but things go slow on this. To many projects on my mind.
The arduino code for this setup shouldn't be difficult. I'll try to make some code for this soon.
I include my schematic for testing this.
Tell me what you think.
Hi,

I know your schematic for long time now but never tested it.
For now I would prefer to use my idea or instead of using cd4017 to replace it with arduino code too.
There is another idea that I must get arduino code for... shorting the bemf. people never understood the importance of this years back while I was playing with coil shorting.
I can do it with magnet motors but solid state will have many advantages.


Best regards,
Romero


Hi. Well the code is working. I'm just adjusting the last details. Maths are maths..
Excellent,

can we do more than 2 shorts also reduce duration?

Regards,
Romero

Vincent

Quote from: Romero on February 08, 2014, 11:47:56 PM
Quote from: Vincent on February 08, 2014, 10:57:07 PM
Quote from: Romero on February 08, 2014, 12:26:12 PM
Quote from: kEhYo77 on February 08, 2014, 09:07:47 AM
Ok. I get it now.
I am working on coil shorting as well but things go slow on this. To many projects on my mind.
The arduino code for this setup shouldn't be difficult. I'll try to make some code for this soon.
I include my schematic for testing this.
Tell me what you think.
Hi,

I know your schematic for long time now but never tested it.
For now I would prefer to use my idea or instead of using cd4017 to replace it with arduino code too.
There is another idea that I must get arduino code for... shorting the bemf. people never understood the importance of this years back while I was playing with coil shorting.
I can do it with magnet motors but solid state will have many advantages.


Best regards,
Romero


Hi. Well the code is working. I'm just adjusting the last details. Maths are maths..
Excellent,

can we do more than 2 shorts also reduce duration?

Regards,
Romero

Off course all will be customizable 100%. Main frequency, duty cycle, number of shorting pulses, pulse shorting length and time between shorting pulses.

Regards. V.

Romero

@Vincent

that is good news. If you can implement the keypad and the display then we have even a super code.

Regards,
Romero

kEhYo77

@Vincent

Hi.

Wow, that was quick with code.
Good job!

kEhYo77

OK, for now I dug up some old code of mine for coil shorting.
I uses a trigger pulse to start the shorting.
Needs to be changed a bit but its a good base.
Hope it helps to build upon.
Feel free to modify it.

Ill try to adapt it for LCD and no trigger but Vincent might be faster with this :)

Cheers
kEhYo