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

Quote from: kEhYo77 on February 09, 2014, 03:44:46 AM
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

Thank you kEhYo. I will take a look into your code too. I'm still waiting for the keypad (4x4 for Arduino) and for the lcd I use the nokia 5110. I found a simple library for the 5510 and works perfect. I also testing a voltmeter/ amp meter / watt meter / temperature / magnetic / fan controller / + pwm generator. When I will finish, I will share the code and schema.

@ Romero : I need to know the main frequency of your setup and DC. That will help me. My first version of the code works like a charm until 10Khz. I need to tweak it to go higher.

Au revoir,

Vincent

Romero

Quote from: Vincent on February 09, 2014, 03:13:14 PM
Quote from: kEhYo77 on February 09, 2014, 03:44:46 AM
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

Thank you kEhYo. I will take a look into your code too. I'm still waiting for the keypad (4x4 for Arduino) and for the lcd I use the nokia 5110. I found a simple library for the 5510 and works perfect. I also testing a voltmeter/ amp meter / watt meter / temperature / magnetic / fan controller / + pwm generator. When I will finish, I will share the code and schema.

@ Romero : I need to know the main frequency of your setup and DC. That will help me. My first version of the code works like a charm until 10Khz. I need to tweak it to go higher.

Au revoir,

Vincent
Hi Vincent,

I would need it to work from 25 to 35 kHz.
10kHz is a good start too.
Can you send me the code as is to have a quick look at it?
Below is the arduino keypad shield I am using.

Best regards,
Romero

Romero

#17
@Vincent
have a look at the link below, maybe that will help to get all code together.
There is the same keypad I am using. There is also a AD9850 board included. I have one of them too if required.
http://tobyrobb.com/wordpress/?p=577
I understand that copy/paste function in WordPress can lead to errors in the code.
I had numerous codes I tried and never worked and I had no idea why then when I compared I found differences.


Best regards,
Romero

Vincent

Quote from: Romero on February 10, 2014, 09:45:41 PM
@Vincent
have a look at the link below, maybe that will help to get all code together.
There is the same keypad I am using. There is also a AD9850 board included. I have one of them too if required.
http://tobyrobb.com/wordpress/?p=577
I understand that copy/paste function in WordPress can lead to errors in the code.
I had numerous codes I tried and never worked and I had no idea why then when I compared I found differences.


Best regards,
Romero

@ Thank you. That help me a lot. I have 1 AD9850. I will check the code and the setup. We can re-use part of it.

@

Hello,

My apologies for the delay of my answer and the code. I was working on this and I'm having one issue. Also I was working on kEhYo77 code and I found the same problem. Maybe I'm doing something wrong.

Case 1 - Shorting a Coil at 35khz

Frequency = 35Khz
Duty Cycle = 50%
Duty Cycle On =  15.2500 us

So if you want to short the coil at the peak (DC = ON )
Peak = 7.625 us.

You need a train pulse at least of 2 Mhz / DC 50 % / Duration 0.25 us.

8 shorting coil pulses * 0.50 s =  4 us.

Sounds Ok to short the coil more than 50 % of his Duty Cycle ?

I did use the full speed option on Arduino output :

#define fastWrite(_pin_, _state_) ( _pin_ < 8 ? (_state_ ?  PORTD |= 1 << _pin_ : PORTD &= ~(1 << _pin_ )) : (_state_ ?  PORTB |= 1 << (_pin_ -8) : PORTB &= ~(1 << (_pin_ -8)  )))
// the macro sets or clears the appropriate bit in port D if the pin is less than 8 or port B if between 8 and 13

and still not enough.

If you really want to short a coil running at 35 khz you need at least 4Mhz of train pulses and that changes everything.


When I was playing with my rotor and shorting coils at 4khz was easy. Again, sorry for my delay and I will keep thinking about a better solution. Romero, I will finish during the week the version until 10khz, maybe with the keyboard and lcd. I just want to share something that really can help on this kind of tests.

a+

Vincent



Romero

can do with 10khz too, I would have to make different coils but that is not a problem.
With a 10khz what is the max number of shorts we can have without getting into problems?
This same code can also be used for many other projects.
You can have a look at J L Naudin code here, that uses the same keypad and I have used that code in my experiments.
http://jlnlab-tools.googlecode.com/files/APMCv1b.zip
http://jnaudin.free.fr/dlenz/DLE26en.htm

I am planning to use similar schematic, controlling the mosfet via optocoupler.

Regards,
Romero

kEhYo77

From my experience with Arduino to do anything with the signal like shorting, the source has to be below 30kHz.

Vincent

Quote from: Romero on February 10, 2014, 10:24:20 PM
can do with 10khz too, I would have to make different coils but that is not a problem.
With a 10khz what is the max number of shorts we can have without getting into problems?
This same code can also be used for many other projects.
You can have a look at J L Naudin code here, that uses the same keypad and I have used that code in my experiments.
http://jlnlab-tools.googlecode.com/files/APMCv1b.zip
http://jnaudin.free.fr/dlenz/DLE26en.htm

I am planning to use similar schematic, controlling the mosfet via optocoupler.

Regards,
Romero


Hi Again,

Well, I did my research and I finished the first dummy. Before, I would share my thinking about shorting a coil. I'm writing this with humility and I'm open to any comments or improvements. This is not the truth revealed. I see the process of doing a short, also like a modulation. As you can see the 8 pulses are giving you a frequency of 380Khz over a carrier of 10 khz. Shorting is the modulation way, like you do with an AM or FM transmitter. The heterodyne effect is here.

Dummy 1 - Arduino UNO

This project is based on an Arduino UNO because can handle better processing speed than a Mega. Also the display maybe will be serial and a simple keypad with 4 buttons. But I will do a test with the keypad + parallel LCD too. As you can see at :

:: 10khz / DC 50%  = we have pulses of 1us.

This is the Max capabilities that this setup can handle. So if you go lower with the main frequency ( 8khz) you can do more shorting. Wen I did my tests, I found that going with more than 8-10 pulses of shorting, the result was the same. But I think this completely tide to the core and the coil that you are using and I think you have a lot of experience on that field than me. Just a thought. I forgot. This setup also is the DDS generator, so you don't need more than the arduino and the high driver for the Mosfet.

Dummy 2 - Arduino UNO / Mega Conditional to tests.

I did a few tests with the kEhYo77 code and I found it very cool. I like it. Well done. The only thing is I don't having any output at the csmPin. The plsPin reads the frequency with certains issues. Sometimes gave me 0. Also the int0Pin. i don't understand who is related to the setup. If you can help me with that, will be a pleasure to do the extra code for the keyboard and the LCD.

Dummy 3

Also if you reach the limit of the Arduino's capabilities, we can trigger external pulses from another processor or logic circuit. I did something like that years ago.

Brief, so Dummy1 or 2 can be done. I need to work on the maths if we chose Dummy1 for the keyboard and the interaction with the inputs or do the code for Dummy2 with a keyboard and the LCD.

Sorry if I look picky with this setup, but I think that having an accurate controller and good coils, can bring better results over the tests.

Cheers,

Vincent


Romero

Vincent you are the best. I am only a beginer in arduino, but this is a must now.
When you have time think of a code to detect bemf spikes and do a sort there

Vincent

I will need a little help from kEhYo77 with his code.
Au revoir

Vincent

Quote from: Romero on February 11, 2014, 10:12:07 PM
Vincent you are the best. I am only a beginer in arduino, but this is a must now.
When you have time think of a code to detect bemf spikes and do a sort there

Hi. I think the are 2 ways of measuring BEMF :

:: Voltage : used on motor's to do speed and torque monitoring.  Take a look here :
     http://scholar.lib.vt.edu/theses/available/etd-09152003-171904/unrestricted/T.pdf

or a simple filter , divider resistance, high voltage linear optocoupler. I don't like any of them.

  :: Measuring the magnetic field collapse with a hall sensor. I tested it and it works. I have like 10 Allegro 3144 on stock. It's not the best to do the job, but quite impressive the result on a test. A simple Gauss meter, linked to an Arduino. I started the research for a better hall sensor. There are a few candidates that can have the job done.

So the idea is :

:: Measurement the BEMF Peak with an oscilloscope and the data captured by the hall sensor once, just to know the delay between them.
:: So you know when the field collapse and the time frame...BANG !!! You start to short there.

Question. How do you do to measure the BEMF without destroying the oscilloscope  ? An HV probe ?

Cheers,

V

kEhYo77

Quote from: Vincent on February 11, 2014, 09:36:08 PM

I did a few tests with the kEhYo77 code and I found it very cool. I like it. Well done. The only thing is I don't having any output at the csmPin. The plsPin reads the frequency with certains issues. Sometimes gave me 0. Also the int0Pin. i don't understand who is related to the setup. If you can help me with that, will be a pleasure to do the extra code for the keyboard and the LCD.

Vincent

plsPin and int0Pin are triggered from the same input.
plsPin counts impulses (from a hall sensor for example)
init0Pin - when uC on this input detects rising edge then
void trigger() function is executed and it will give output only if potentiometer values are not zero.

hope it helps

Romero

@Vincent
I believe we ca do bemf shorting without any sensor or detector, should be done with timing adjustments knowing that the bemf occurs at the end of the initial pulse (opening coil) then we can initiate second pulse to trigger the shorting at specific time and specific duration. I hope you understand what I  mean

Romero

Vincent

Quote from: kEhYo77 on February 13, 2014, 09:47:58 AM
Quote from: Vincent on February 11, 2014, 09:36:08 PM

I did a few tests with the kEhYo77 code and I found it very cool. I like it. Well done. The only thing is I don't having any output at the csmPin. The plsPin reads the frequency with certains issues. Sometimes gave me 0. Also the int0Pin. i don't understand who is related to the setup. If you can help me with that, will be a pleasure to do the extra code for the keyboard and the LCD.

Vincent

plsPin and int0Pin are triggered from the same input.
plsPin counts impulses (from a hall sensor for example)
init0Pin - when uC on this input detects rising edge then
void trigger() function is executed and it will give output only if potentiometer values are not zero.

hope it helps

@ kEhYo77 : Thank you for your answer. All doubts are clear now.

Vincent

Quote from: Romero on February 13, 2014, 03:35:43 PM
@Vincent
I believe we ca do bemf shorting without any sensor or detector, should be done with timing adjustments knowing that the bemf occurs at the end of the initial pulse (opening coil) then we can initiate second pulse to trigger the shorting at specific time and specific duration. I hope you understand what I  mean

Romero

@ 100% Understood. I'll give you news soon. Working on the code and optimization.

Vincent

Hi,

The module is working. I will publish the code and details on Monday.

Cheers,

V