Page 1 of 1
make few sound with a motor dc
Posted: Fri Nov 02, 2018 9:06 am
by froussel
By ordering the output pwm and / or the high of the H-bridge which commands the motor dc I saw a long time ago how to produce some sounds.
But I forget that.
I want to identify with the start of the micro controller that everything is ok after the motor will be normaly commanded
A piece of code with IDE arduino would be appreciated or an URL
Re: make few sound with a motor dc
Posted: Fri Nov 02, 2018 2:23 pm
by rudi ;-)
froussel wrote:
A piece of code ...
did not played with this on esp32..
and
not from me, but think should be can transformed to the esp32 that work's
hope this helps you:
Code: Select all
void playSound(uint16_t freq, uint16_t duration_msec, uint8_t amplitude) {
uint32_t n,k,period_usec,duration_usec;
period_usec = 1000000L / freq;
duration_usec = 1000 * (uint32_t) duration_msec;
k = duration_usec / period_usec;
motorSpeed (amplitude, amplitude);
for (n = 0; n < k; n++) {
motorDirection (DIR_FORWARD, DIR_FORWARD);
delayMicroseconds(period_usec/2);
motorDirection (DIR_REVERSE, DIR_REVERSE);
delayMicroseconds(period_usec/2);
}
motorSpeed (0, 0);
}
for inspiration
best wishes
rudi
...or an ULR ...
sure ..
here you go
and ..
here
Re: make few sound with a motor dc (solved)
Posted: Tue Nov 13, 2018 12:33 pm
by froussel
Thanks!
Just must do it now
Re: make few sound with a motor dc
Posted: Wed Dec 12, 2018 10:03 pm
by froussel
I tried
void motorAv()
{ digitalWrite(inaPin, HIGH);
digitalWrite(inbPin, LOW); }
void motorAr()
{ digitalWrite(inaPin, LOW);
digitalWrite(inbPin, HIGH); }
void motorStop()
{ digitalWrite(inaPin, LOW);
digitalWrite(inbPin, LOW); }
void playSound(uint16_t freq, uint16_t duration_msec, uint8_t amplitude)
{ uint32_t n,k,period_usec,duration_usec;
period_usec = 1000000L / freq;
duration_usec = 1000 * (uint32_t) duration_msec;
k = duration_usec / period_usec;
pwm= amplitude; // pwm max driver motor = 100%
for (n = 0; n < k; n++)
{ motorAv();
delayMicroseconds(period_usec/2);
motorAr();
delayMicroseconds(period_usec/2); }
motorStop; }
uint16_t freq = 1000; // max 65535
uint16_t duration_msec = 400;
uint8_t amplitude=255;
for (int i =15000; i < 19000; i = i +100)
{ delay(100);
playSound(i, duration_msec, amplitude);
}
No sound
please why ?
Re: make few sound with a motor dc
Posted: Wed Dec 19, 2018 7:50 pm
by froussel
I'm alone ?
Re: make few sound with a motor dc
Posted: Fri Dec 21, 2018 8:12 am
by rudi ;-)
did you test, you can drive the motor normal?
is the motor working? how much sink it?
which motor you use?
how you drive the motor by hardware?
or do you use (later) motor drivers ics? ( example uln2003 )
and how
looks your hardware setup?
best wishes
rudi
Re: make few sound with a motor dc
Posted: Fri Dec 21, 2018 11:44 am
by froussel
rudi ;-) wrote: ↑Fri Dec 21, 2018 8:12 am
did you test, you can drive the motor normal?
Yes
is the motor working? how much sink it?
which motor you use?
Brushed DC motor
how you drive the motor by hardware?
or do you use (later) motor drivers ics? ( example uln2003 )
and how
looks your hardware setup?
Thing as
https://www.pololu.com/product/708
When reading this
http://esp8266.github.io/Arduino/versio ... log-output
I wonder if I have an error in the maximum of 255 for the pwm
Should not I put 1023 instead?
best wishes
rudi
Also
Re: make few sound with a motor dc
Posted: Tue Oct 15, 2019 8:27 am
by tancojoony
did you test, you can drive the motor normal?
is the motor working? how much sink it?
which motor you use?
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
My stepper motor website:skysmotor.com - Machinery Design - Stepper Moter Development
"Necessity is the mother of invention." - Author unknown.
as you type.